- check if the compiler supports -fwhole-program -- 4.0 does not
[oweals/busybox.git] / util-linux / umount.c
index 1a6b14ccc8878b99f8c178fce070900bf0a9da82..4ea15d91b94cc9dde9c04f6a0e5a8ab0faa549bd 100644 (file)
@@ -5,10 +5,7 @@
  * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
  * Copyright (C) 2005 by Rob Landley <rob@landley.net>
  *
- * This program is licensed under the GNU General Public license (GPL)
- * version 2 or later, see http://www.fsf.org/licensing/licenses/gpl.html
- * or the file "LICENSE" in the busybox source tarball for the full text.
- *
+ * Licensed under GPL version 2, see file LICENSE in this tarball for details.
  */
 
 #include "busybox.h"
@@ -23,6 +20,7 @@
 #define OPT_REMOUNT                    16
 #define OPT_ALL                                (ENABLE_FEATURE_UMOUNT_ALL ? 32 : 0)
 
+int umount_main(int argc, char **argv);
 int umount_main(int argc, char **argv)
 {
        int doForce;
@@ -30,7 +28,7 @@ int umount_main(int argc, char **argv)
        struct mntent me;
        FILE *fp;
        int status = EXIT_SUCCESS;
-       unsigned long opt;
+       unsigned opt;
        struct mtab_list {
                char *dir;
                char *device;
@@ -39,7 +37,7 @@ int umount_main(int argc, char **argv)
 
        /* Parse any options */
 
-       opt = bb_getopt_ulflags(argc, argv, OPTION_STRING);
+       opt = getopt32(argc, argv, OPTION_STRING);
 
        argc -= optind;
        argv += optind;
@@ -57,11 +55,12 @@ int umount_main(int argc, char **argv)
        /* If we're umounting all, then m points to the start of the list and
         * the argument list should be empty (which will match all). */
 
-       if (!(fp = setmntent(bb_path_mtab_file, "r"))) {
+       fp = setmntent(bb_path_mtab_file, "r");
+       if (!fp) {
                if (opt & OPT_ALL)
                        bb_error_msg_and_die("cannot open %s", bb_path_mtab_file);
        } else {
-               while (getmntent_r(fp,&me,path,sizeof(path))) {
+               while (getmntent_r(fp, &me, path, sizeof(path))) {
                        m = xmalloc(sizeof(struct mtab_list));
                        m->next = mtl;
                        m->device = xstrdup(me.mnt_fsname);
@@ -71,12 +70,12 @@ int umount_main(int argc, char **argv)
                endmntent(fp);
        }
 
-       /* If we're not mounting all, we need at least one argument. */
+       /* If we're not umounting all, we need at least one argument. */
        if (!(opt & OPT_ALL)) {
                m = 0;
                if (!argc) bb_show_usage();
        }
-       
+
        // Loop through everything we're supposed to umount, and do so.
        for (;;) {
                int curstat;
@@ -107,7 +106,7 @@ int umount_main(int argc, char **argv)
                if (curstat && doForce) {
                        curstat = umount2(zapit, doForce);
                        if (curstat)
-                               bb_error_msg_and_die("forced umount of %s failed!", zapit);
+                               bb_error_msg("forced umount of %s failed!", zapit);
                }
 
                // If still can't umount, maybe remount read-only?
@@ -133,7 +132,7 @@ int umount_main(int argc, char **argv)
                // Note this means that "umount /dev/blah" will unmount all instances
                // of /dev/blah, not just the most recent.
                while (m && (m = m->next))
-                       if ((opt & OPT_ALL) || !strcmp(path,m->device))
+                       if ((opt & OPT_ALL) || !strcmp(path, m->device))
                                break;
        }