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里面根本没有,真是坑!

    相关文章:

    • 2021-08-24
    • 2021-05-30
    • 2021-11-15
    • 2022-12-23
    • 2021-09-26
    • 2021-11-26
    • 2021-06-24
    • 2021-10-11
    猜你喜欢
    • 2021-07-30
    • 2022-12-23
    • 2021-04-07
    • 2021-08-17
    • 2022-12-23
    • 2021-07-13
    • 2022-12-23
    相关资源
    相似解决方案