summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-07-13 22:12:18 -0700
committerJeff Brown <jeffbrown@google.com>2011-07-14 13:43:57 -0700
commitbaf6b6bdebd6e91c401f64e8013fed49697ed2cc (patch)
treed55867253951a285af3221ba0e0557890af323be
parente877ad7ae3ea3c1a631652c86887a627ef9feb3f (diff)
downloadsystem_core-baf6b6bdebd6e91c401f64e8013fed49697ed2cc.zip
system_core-baf6b6bdebd6e91c401f64e8013fed49697ed2cc.tar.gz
system_core-baf6b6bdebd6e91c401f64e8013fed49697ed2cc.tar.bz2
Show why umount failed.
Change-Id: Id2b3fbc46b8dfbe2f05637fb35c298915cd5f524
-rw-r--r--toolbox/umount.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/toolbox/umount.c b/toolbox/umount.c
index 6eb8b92..890e870 100644
--- a/toolbox/umount.c
+++ b/toolbox/umount.c
@@ -6,6 +6,7 @@
#include <string.h>
#include <unistd.h>
#include <linux/loop.h>
+#include <errno.h>
#define LOOPDEV_MAXLEN 64
#define LOOP_MAJOR 7
@@ -36,7 +37,7 @@ static int is_loop_mount(const char* path, char *loopdev)
f = fopen("/proc/mounts", "r");
if (!f) {
- fprintf(stdout, "could not open /proc/mounts\n");
+ fprintf(stdout, "could not open /proc/mounts: %s\n", strerror(errno));
return -1;
}
@@ -66,8 +67,8 @@ int umount_main(int argc, char *argv[])
}
loop = is_loop_mount(argv[1], loopdev);
- if(umount(argv[1])){
- fprintf(stderr,"failed.\n");
+ if (umount(argv[1])) {
+ fprintf(stderr, "failed: %s\n", strerror(errno));
return 1;
}
@@ -75,11 +76,11 @@ int umount_main(int argc, char *argv[])
// free the loop device
loop_fd = open(loopdev, O_RDONLY);
if (loop_fd < 0) {
- perror("open loop device failed");
+ fprintf(stderr, "open loop device failed: %s\n", strerror(errno));
return 1;
}
if (ioctl(loop_fd, LOOP_CLR_FD, 0) < 0) {
- perror("ioctl LOOP_CLR_FD failed");
+ fprintf(stderr, "ioctl LOOP_CLR_FD failed: %s\n", strerror(errno));
return 1;
}