標籤: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。
- :/ $ ls -al /system/bin/mount
- lrwxr-xr-x 1 root shell 6 2016-09-02 16:23 /system/bin/mount -> toybox
然後仔細查看了一下toybox中關於mount的相關代碼,果然是一個坑。
- // For remount we need _last_ match (in case of overmounts), so traverse
- // in reverse order. (Yes I‘m using remount as a boolean for a bit here,
- // the double cast is to get gcc to shut up about it.)
- remount = (void *)(long)comma_scan(opts, "remount", 1);
- if (((toys.optflags & FLAG_a) && !access("/proc/mounts", R_OK)) || remount) {
- mm = dlist_terminate(mtl = mtl2 = xgetmountlist(0));
- if (remount) remount = mm;
- }
關鍵就是這個comma_scan的最後一個參數clean
- // check all instances of opt and "no"opt in optlist, return true if opt
- // found and last instance wasn‘t no. If clean, remove each instance from list.
- int comma_scan(char *optlist, char *opt, int clean)
- {
- int optlen = strlen(opt), len, no, got = 0;
-
- if (optlist) for (;;) {
- char *s = comma_iterate(&optlist, &len);
-
- if (!s) break;
- no = 2*(*s == ‘n‘ && s[1] == ‘o‘);
- if (optlen == len-no && !strncmp(opt, s+no, optlen)) {
- got = !no;
- if (clean && optlist) memmove(s, optlist, strlen(optlist)+1);
- }
- }
-
- return got;
- }
如果remount不是-o的最後一個參數(_last_ match ),那麼就會被清除掉。最終調用syscall mount的時候,這個remount的flag就沒了。
把命令重新改為 mount -t vfat -o rw,remount /firmware 就好了。
關於remount的說明在help裡面根本沒有,真是坑!
remount issue on android 7.0