|
|
下面是一个卸载u盘的程序(在此之前u 盘已经挂起了,并且是已root身份登陆系统的):
- #include <linux/mount.h>
- #include <errno.h>
- void main()
- {
- /* target 指定卸载的路径,/dev/sdb1 是 usb device 的器件号,在 /etc/fstab 中有定义*/
- char *target="/dev/sdb1";
-
- printf("device %s is going to be umounted\n",target);
-
- /*卸载失败则返回 -1*/
- if(umount(target)==-1)
- printf("error: %s \n",strerror(errno));
-
- return 0;
- }
复制代码
程序运行后,出错信息是:no such file or directory
但是在命令行下输入“umount /dev/sdb1" 是可以成功卸载器件的。原因我想不出来啊 ,为什么用 umount 命令就可以,但是用 umount 函数却不行?
大家帮忙看看是什么地方的问题,谢谢啦! |
|