diff --git a/system/core/init/builtins.cpp b/system/core/init/builtins.cpp
index 01db4f5dabd..72cc41612ba 100644
--- a/system/core/init/builtins.cpp
+++ b/system/core/init/builtins.cpp
@@ -364,6 +364,17 @@ static Result<void> do_insmod(const BuiltinArguments& args) {
return {};
}
+static Result<void> do_rmmod(const BuiltinArguments& args) {
+ auto it = args.begin() + 1;
+
+ std::string filename = *it;
+
+ int rc = syscall(__NR_delete_module, filename.c_str(), O_NONBLOCK | O_EXCL);
+ if (rc == -1) return ErrnoError() << "delete_module for " << filename << " failed";
+
+ return {};
+}
+
static Result<void> do_interface_restart(const BuiltinArguments& args) {
Service* svc = ServiceList::GetInstance().FindInterface(args[1]);
if (!svc) return Error() << "interface " << args[1] << " not found";
@@ -1398,6 +1409,7 @@ const BuiltinFunctionMap& GetBuiltinFunctionMap() {
{"ifup", {1, 1, {true, do_ifup}}},
{"init_user0", {0, 0, {false, do_init_user0}}},
{"insmod", {1, kMax, {true, do_insmod}}},
+ {"rmmod", {1, 1, {true, do_rmmod}}},
{"installkey", {1, 1, {false, do_installkey}}},
{"interface_restart", {1, 1, {false, do_interface_restart}}},
{"interface_start", {1, 1, {false, do_interface_start}}},
发表评论