how to umount a usb disk by native application

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

how to umount a usb disk by native application

641件の閲覧回数
thony
Contributor II

I usb i.mx6 board with android 4.2.2. it's usb disk auto mount to /mnt/udisk dir. I find a a trick question,  

this is code in native app

int main(void)

{

  int a = 0;

  FILE * fd = fopen("/data/test/out.txt", "a+");

  fprintf(fd,  "uid = %d, gid = %d, euid = %d, egid = %d\n", getuid(), getgid(), geteuid(), getegid());

  a = umount("/mnt/udisk");

  if(a != 0)

  fprintf(fd,"%s\n",strerror(errno));

  fprintf(fd,"umount = %d\n", a);

  fclose(fd);

  //sleep(60);

  return 0;

}

this is the java app

ProcessBuilder process = new ProcessBuilder("su", "-c", "/data/test/testumount");

              Process p = process.start();

              p.waitFor();

I got a out.txt from native app.

uid = 0, gid = 0, euid = 0, egid = 0

umount = 0

You see the umount return 0, but /mnt/udisk not umount. So , why? the native app's uid = 0, it is root.

ラベル(3)
タグ(2)
0 件の賞賛
返信
0 返答(返信)