Chinaunix首页 | 论坛 | 博客
  • 博客访问: 735489
  • 博文数量: 79
  • 博客积分: 2671
  • 博客等级: 少校
  • 技术积分: 1247
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-02 15:26
个人简介

宅男

文章分类

全部博文(79)

文章存档

2017年(11)

2016年(12)

2015年(6)

2012年(10)

2011年(33)

2010年(7)

分类: Android平台

2016-11-02 16:54:56

最近在新版本的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里面根本没有,真是坑!



阅读(2086) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~