Add errno.h
[oweals/busybox.git] / umount.c
index e76e0521f261bbe6067ccc6ae1ff5dd8125b9c9f..2e2d95de449562333e230816848ea68ca8d0dee8 100644 (file)
--- a/umount.c
+++ b/umount.c
 #include <errno.h>
 
 
-#define MNT_FORCE              1
-#define MS_MGC_VAL             0xc0ed0000 /* Magic number indicatng "new" flags */
-#define MS_REMOUNT             32      /* Alter flags of a mounted FS.  */
-#define MS_RDONLY              1       /* Mount read-only.  */
+static const int MNT_FORCE = 1;
+static const int MS_MGC_VAL = 0xc0ed0000; /* Magic number indicatng "new" flags */
+static const int MS_REMOUNT = 32;      /* Alter flags of a mounted FS.  */
+static const int MS_RDONLY = 1;        /* Mount read-only.  */
 
 extern int mount (__const char *__special_file, __const char *__dir,
                        __const char *__fstype, unsigned long int __rwflag,
@@ -212,18 +212,18 @@ static int umount_all(int useMtab)
                /* Never umount /proc on a umount -a */
                if (strstr(mountpt, "proc")!= NULL)
                        continue;
-               status = do_umount(mountpt, useMtab);
-               if (status != 0) {
+               if (!do_umount(mountpt, useMtab)) {
                        /* Don't bother retrying the umount on busy devices */
                        if (errno == EBUSY) {
-                               perror(mountpt);
+                               perror_msg("%s", mountpt);
+                               status = FALSE;
                                continue;
                        }
-                       status = do_umount(mountpt, useMtab);
-                       if (status != 0) {
+                       if (!do_umount(mountpt, useMtab)) {
                                printf("Couldn't umount %s on %s: %s\n",
                                           mountpt, mtab_getinfo(mountpt, MTAB_GETDEVICE),
                                           strerror(errno));
+                               status = FALSE;
                        }
                }
        }
@@ -280,7 +280,6 @@ extern int umount_main(int argc, char **argv)
        }
        if (do_umount(*argv, useMtab) == TRUE)
                return EXIT_SUCCESS;
-       perror("umount");
-       return EXIT_FAILURE;
+       perror_msg_and_die("%s", *argv);
 }