Fix func prototype
[oweals/busybox.git] / umount.c
index 0867118c0afd91339cd881f95ab9aeb029ea6ce1..2868a1bc379ea64b8564f4fc02cb319e49fff5cd 100644 (file)
--- a/umount.c
+++ b/umount.c
@@ -3,7 +3,7 @@
  * Mini umount implementation for busybox
  *
  *
- * Copyright (C) 1999,2000 by Lineo, inc.
+ * Copyright (C) 1999,2000,2001 by Lineo, inc.
  * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
  *
  * This program is free software; you can redistribute it and/or modify
  *
  */
 
-#include "busybox.h"
 #include <stdio.h>
 #include <mntent.h>
 #include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include "busybox.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,
@@ -79,7 +81,7 @@ void mtab_read(void)
                return;
 
        if ((fp = setmntent(mtab_file, "r")) == NULL) {
-               error_msg("Cannot open %s\n", mtab_file);
+               error_msg("Cannot open %s", mtab_file);
                return;
        }
        while ((e = getmntent(fp))) {
@@ -179,7 +181,7 @@ static int do_umount(const char *name, int useMtab)
        if (status != 0 && doForce == TRUE) {
                status = umount2(blockDevice, MNT_FORCE);
                if (status != 0) {
-                       error_msg_and_die("forced umount of %s failed!\n", blockDevice);
+                       error_msg_and_die("forced umount of %s failed!", blockDevice);
                }
        }
 #endif
@@ -187,9 +189,9 @@ static int do_umount(const char *name, int useMtab)
                status = mount(blockDevice, name, NULL,
                                           MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL);
                if (status == 0) {
-                       error_msg("%s busy - remounted read-only\n", blockDevice);
+                       error_msg("%s busy - remounted read-only", blockDevice);
                } else {
-                       error_msg("Cannot remount %s read-only\n", blockDevice);
+                       error_msg("Cannot remount %s read-only", blockDevice);
                }
        }
        if (status == 0) {
@@ -212,18 +214,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_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;
                        }
                }
        }
@@ -233,7 +235,7 @@ static int umount_all(int useMtab)
 extern int umount_main(int argc, char **argv)
 {
        if (argc < 2) {
-               usage(umount_usage);
+               show_usage();
        }
 #ifdef BB_FEATURE_CLEAN_UP
        atexit(mtab_free);
@@ -267,7 +269,7 @@ extern int umount_main(int argc, char **argv)
                        case 'v':
                                break; /* ignore -v */
                        default:
-                               usage(umount_usage);
+                               show_usage();
                        }
        }