remount issue on android 7.0

來源:互聯網
上載者:User

標籤:was   mem   amp   切換   ast   roi   nts   bool   can   

http://blog.chinaunix.net/uid-23141914-id-5754416.html

最近在新版本的android 7.0上,發現filesystem的remount老是報“ Device or resource busy”的錯誤。
最終發現,android 7.0上,從原來的toolbox切換到toybox。

  1. :/ $ ls -al /system/bin/mount
  2. lrwxr-xr-x 1 root shell 6 2016-09-02 16:23 /system/bin/mount -> toybox

然後仔細查看了一下toybox中關於mount的相關代碼,果然是一個坑。

  1. // For remount we need _last_ match (in case of overmounts), so traverse
  2.   // in reverse order. (Yes I‘m using remount as a boolean for a bit here,
  3.   // the double cast is to get gcc to shut up about it.)
  4.   remount = (void *)(long)comma_scan(opts, "remount", 1);
  5.   if (((toys.optflags & FLAG_a) && !access("/proc/mounts", R_OK)) || remount) {
  6.     mm = dlist_terminate(mtl = mtl2 = xgetmountlist(0));
  7.     if (remount) remount = mm;
  8.   }

關鍵就是這個comma_scan的最後一個參數clean

  1. // check all instances of opt and "no"opt in optlist, return true if opt
  2. // found and last instance wasn‘t no. If clean, remove each instance from list.
  3. int comma_scan(char *optlist, char *opt, int clean)
  4. {
  5.   int optlen = strlen(opt), len, no, got = 0;
  6.     
  7.   if (optlist) for (;;) {
  8.     char *s = comma_iterate(&optlist, &len);
  9.   
  10.     if (!s) break;
  11.     no = 2*(*s == ‘n‘ && s[1] == ‘o‘);
  12.     if (optlen == len-no && !strncmp(opt, s+no, optlen)) {
  13.       got = !no;
  14.       if (clean && optlist) memmove(s, optlist, strlen(optlist)+1);
  15.     }
  16.   }
  17.       
  18.   return got;
  19. }

如果remount不是-o的最後一個參數(_last_ match ),那麼就會被清除掉。最終調用syscall mount的時候,這個remount的flag就沒了。
把命令重新改為 mount -t vfat -o rw,remount /firmware 就好了。
關於remount的說明在help裡面根本沒有,真是坑!

remount issue on android 7.0

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.