{"id":47,"date":"2024-04-16T13:46:59","date_gmt":"2024-04-16T05:46:59","guid":{"rendered":"https:\/\/www.addsv.com\/?p=47"},"modified":"2024-04-16T13:46:59","modified_gmt":"2024-04-16T05:46:59","slug":"%e4%bb%a5rmmod%e4%b8%ba%e4%be%8b%ef%bc%8c%e5%9c%a8init-rc%e4%b8%ad%e6%b7%bb%e5%8a%a0%e5%91%bd%e4%bb%a4%e6%94%af%e6%8c%81","status":"publish","type":"post","link":"http:\/\/www.addsv.com\/index.php\/2024\/04\/16\/47\/eason\/","title":{"rendered":"\u4ee5rmmod\u4e3a\u4f8b\uff0c\u5728init.rc\u4e2d\u6dfb\u52a0\u547d\u4ee4\u652f\u6301"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>diff --git a\/system\/core\/init\/builtins.cpp b\/system\/core\/init\/builtins.cpp\nindex 01db4f5dabd..72cc41612ba 100644\n--- a\/system\/core\/init\/builtins.cpp\n+++ b\/system\/core\/init\/builtins.cpp\n@@ -364,6 +364,17 @@ static Result&lt;void> do_insmod(const BuiltinArguments&amp; args) {\n     return {};\n }\n \n+static Result&lt;void> do_rmmod(const BuiltinArguments&amp; args) {\n+    auto it = args.begin() + 1;\n+\n+    std::string filename = *it;\n+\n+    int rc = syscall(__NR_delete_module, filename.c_str(), O_NONBLOCK | O_EXCL);\n+    if (rc == -1) return ErrnoError() &lt;&lt; \"delete_module for \" &lt;&lt; filename &lt;&lt; \" failed\";\n+\n+    return {};\n+}\n+\n static Result&lt;void> do_interface_restart(const BuiltinArguments&amp; args) {\n     Service* svc = ServiceList::GetInstance().FindInterface(args&#91;1]);\n     if (!svc) return Error() &lt;&lt; \"interface \" &lt;&lt; args&#91;1] &lt;&lt; \" not found\";\n@@ -1398,6 +1409,7 @@ const BuiltinFunctionMap&amp; GetBuiltinFunctionMap() {\n         {\"ifup\",                    {1,     1,    {true,   do_ifup}}},\n         {\"init_user0\",              {0,     0,    {false,  do_init_user0}}},\n         {\"insmod\",                  {1,     kMax, {true,   do_insmod}}},\n+        {\"rmmod\",                   {1,     1,    {true,   do_rmmod}}},\n         {\"installkey\",              {1,     1,    {false,  do_installkey}}},\n         {\"interface_restart\",       {1,     1,    {false,  do_interface_restart}}},\n         {\"interface_start\",         {1,     1,    {false,  do_interface_start}}},\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-47","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.addsv.com\/index.php\/wp-json\/wp\/v2\/posts\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.addsv.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.addsv.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.addsv.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.addsv.com\/index.php\/wp-json\/wp\/v2\/comments?post=47"}],"version-history":[{"count":1,"href":"http:\/\/www.addsv.com\/index.php\/wp-json\/wp\/v2\/posts\/47\/revisions"}],"predecessor-version":[{"id":48,"href":"http:\/\/www.addsv.com\/index.php\/wp-json\/wp\/v2\/posts\/47\/revisions\/48"}],"wp:attachment":[{"href":"http:\/\/www.addsv.com\/index.php\/wp-json\/wp\/v2\/media?parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.addsv.com\/index.php\/wp-json\/wp\/v2\/categories?post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.addsv.com\/index.php\/wp-json\/wp\/v2\/tags?post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}