1. 程式人生 > >remount issue on android 7.0

remount issue on android 7.0

n) 重新 tar 版本 all vfat art memmove html

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. if (optlist) for (;;) {
  7. char *s = comma_iterate(&optlist, &len);
  8. if (!s) break;
  9. no = 2*(*s == ‘n‘ && s[1] == ‘o‘);
  10. if (optlen == len-no && !strncmp(opt, s+no, optlen)) {
  11. got = !no;
  12. if (clean && optlist) memmove(s, optlist, strlen(optlist)+1);
  13. }
  14. }
  15. return got;
  16. }

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

remount issue on android 7.0