forgot to remove some debugging noise
[oweals/busybox.git] / mount.c
diff --git a/mount.c b/mount.c
index 97b60abbd732542d70c9c4519c0d22ab1f180c02..7b0bf3e214e85fea245ffd7520a73a3bab0aa336 100644 (file)
--- a/mount.c
+++ b/mount.c
@@ -43,7 +43,6 @@
  *     
  */
 
-#include "busybox.h"
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
 #if defined BB_FEATURE_USE_DEVPS_PATCH
 #include <linux/devmtab.h> /* For Erik's nifty devmtab device driver */
 #endif
+#include "busybox.h"
 
-
-#define MS_MGC_VAL             0xc0ed0000 /* Magic number indicatng "new" flags */
-#define MS_RDONLY        1      /* Mount read-only */
-#define MS_NOSUID        2      /* Ignore suid and sgid bits */
-#define MS_NODEV         4      /* Disallow access to device special files */
-#define MS_NOEXEC        8      /* Disallow program execution */
-#define MS_SYNCHRONOUS  16      /* Writes are synced at once */
-#define MS_REMOUNT      32      /* Alter flags of a mounted FS */
-#define MS_MANDLOCK     64      /* Allow mandatory locks on an FS */
-#define S_QUOTA         128     /* Quota initialized for file/directory/symlink */
-#define S_APPEND        256     /* Append-only file */
-#define S_IMMUTABLE     512     /* Immutable file */
-#define MS_NOATIME      1024    /* Do not update access times. */
-#define MS_NODIRATIME   2048    /* Do not update directory access times */
-
+enum {
+       MS_MGC_VAL = 0xc0ed0000, /* Magic number indicatng "new" flags */
+       MS_RDONLY = 1,      /* Mount read-only */
+       MS_NOSUID = 2,      /* Ignore suid and sgid bits */
+       MS_NODEV = 4,      /* Disallow access to device special files */
+       MS_NOEXEC = 8,      /* Disallow program execution */
+       MS_SYNCHRONOUS = 16,      /* Writes are synced at once */
+       MS_REMOUNT = 32,      /* Alter flags of a mounted FS */
+       MS_MANDLOCK = 64,      /* Allow mandatory locks on an FS */
+       S_QUOTA = 128,     /* Quota initialized for file/directory/symlink */
+       S_APPEND = 256,     /* Append-only file */
+       S_IMMUTABLE = 512,     /* Immutable file */
+       MS_NOATIME = 1024,    /* Do not update access times. */
+       MS_NODIRATIME = 2048,    /* Do not update directory access times */
+};
 
 
 #if defined BB_FEATURE_MOUNT_LOOP
@@ -132,20 +132,20 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
 
                        specialfile = find_unused_loop_device();
                        if (specialfile == NULL) {
-                               error_msg_and_die("Could not find a spare loop device\n");
+                               error_msg_and_die("Could not find a spare loop device");
                        }
                        if (set_loop(specialfile, lofile, 0, &loro)) {
-                               error_msg_and_die("Could not setup loop device\n");
+                               error_msg_and_die("Could not setup loop device");
                        }
                        if (!(flags & MS_RDONLY) && loro) {     /* loop is ro, but wanted rw */
-                               error_msg("WARNING: loop device is read-only\n");
+                               error_msg("WARNING: loop device is read-only");
                                flags &= ~MS_RDONLY;
                        }
                }
 #endif
                status = mount(specialfile, dir, filesystemtype, flags, string_flags);
                if (errno == EROFS) {
-                       error_msg("%s is write-protected, mounting read-only\n", specialfile);
+                       error_msg("%s is write-protected, mounting read-only", specialfile);
                        status = mount(specialfile, dir, filesystemtype, flags |= MS_RDONLY, string_flags);
                }
        }
@@ -171,7 +171,7 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
 #endif
 
        if (errno == EPERM) {
-               error_msg_and_die("permission denied. Are you root?\n");
+               error_msg_and_die("permission denied. Are you root?");
        }
 
        return (FALSE);
@@ -232,13 +232,9 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
 {
        int status = 0;
 
-#if defined BB_FEATURE_USE_PROCFS
        char buf[255];
        if (strcmp(filesystemType, "auto") == 0) {
-               FILE *f = fopen("/proc/filesystems", "r");
-
-               if (f == NULL)
-                       return (FALSE);
+               FILE *f = xfopen("/proc/filesystems", "r");
 
                while (fgets(buf, sizeof(buf), f) != NULL) {
                        filesystemType = buf;
@@ -261,7 +257,6 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
                }
                fclose(f);
        } else
-#endif
 #if defined BB_FEATURE_USE_DEVPS_PATCH
        if (strcmp(filesystemType, "auto") == 0) {
                int fd, i, numfilesystems;
@@ -353,7 +348,7 @@ extern int mount_main(int argc, char **argv)
                        perror_msg_and_die( "\nDEVMTAB_GET_MOUNTS");
 
                for( i = 0 ; i < numfilesystems ; i++) {
-                       fprintf( stdout, "%s %s %s %s %d %d\n", mntentlist[i].mnt_fsname,
+                       printf( "%s %s %s %s %d %d\n", mntentlist[i].mnt_fsname,
                                        mntentlist[i].mnt_dir, mntentlist[i].mnt_type, 
                                        mntentlist[i].mnt_opts, mntentlist[i].mnt_freq, 
                                        mntentlist[i].mnt_passno);
@@ -510,5 +505,5 @@ singlemount:
        goto singlemount;
        
 goodbye:
-       usage(mount_usage);
+       show_usage();
 }