X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=util-linux%2Fmount.c;h=6e95cdc793317f2fca9176440ff44931c7046091;hb=807f0fd637ecc25e60c81e41ad969c177c7df327;hp=72734ae62380a73714eac98b488d7ef8cf8d52af;hpb=a57ba4db64d5b2e8d9f7e9ab15ac32d1c1abdea5;p=oweals%2Fbusybox.git diff --git a/util-linux/mount.c b/util-linux/mount.c index 72734ae62..6e95cdc79 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -45,7 +45,7 @@ #include #include #if defined BB_FEATURE_USE_DEVPS_PATCH -#include +#include /* For Erik's nifty devmtab device driver */ #endif @@ -80,38 +80,6 @@ extern int umount2 (__const char *__special_file, int __flags); extern const char mtab_file[]; /* Defined in utility.c */ -static const char mount_usage[] = - "mount [flags] device directory [-o options,more-options]\n" -#ifndef BB_FEATURE_TRIVIAL_HELP - "\nMount a filesystem\n\n" - "Flags:\n" - "\t-a:\t\tMount all filesystems in fstab.\n" -#ifdef BB_MTAB - "\t-f:\t\t\"Fake\" mount. Add entry to mount table but don't mount it.\n" - "\t-n:\t\tDon't write a mount table entry.\n" -#endif - "\t-o option:\tOne of many filesystem options, listed below.\n" - "\t-r:\t\tMount the filesystem read-only.\n" - "\t-t fs-type:\tSpecify the filesystem type.\n" - "\t-w:\t\tMount for reading and writing (default).\n" - "\n" - "Options for use with the \"-o\" flag:\n" - "\tasync/sync:\tWrites are asynchronous / synchronous.\n" - "\tatime/noatime:\tEnable / disable updates to inode access times.\n" - "\tdev/nodev:\tAllow use of special device files / disallow them.\n" - "\texec/noexec:\tAllow use of executable files / disallow them.\n" -#if defined BB_FEATURE_MOUNT_LOOP - "\tloop:\t\tMounts a file via loop device.\n" -#endif - "\tsuid/nosuid:\tAllow set-user-id-root programs / disallow them.\n" - "\tremount:\tRe-mount a currently-mounted filesystem, changing its flags.\n" - "\tro/rw:\t\tMount for read-only / read-write.\n" - "\nThere are EVEN MORE flags that are specific to each filesystem.\n" - "You'll have to see the written documentation for those.\n" -#endif - ; - - struct mount_options { const char *name; unsigned long and; @@ -157,15 +125,15 @@ do_mount(char *specialfile, char *dir, char *filesystemtype, specialfile = find_unused_loop_device(); if (specialfile == NULL) { - fprintf(stderr, "Could not find a spare loop device\n"); + errorMsg("Could not find a spare loop device\n"); return (FALSE); } if (set_loop(specialfile, lofile, 0, &loro)) { - fprintf(stderr, "Could not setup loop device\n"); + errorMsg("Could not setup loop device\n"); return (FALSE); } if (!(flags & MS_RDONLY) && loro) { /* loop is ro, but wanted rw */ - fprintf(stderr, "WARNING: loop device is read-only\n"); + errorMsg("WARNING: loop device is read-only\n"); flags &= ~MS_RDONLY; } } @@ -193,7 +161,7 @@ do_mount(char *specialfile, char *dir, char *filesystemtype, #endif if (errno == EPERM) { - fatalError("mount: permission denied. Are you root?\n"); + fatalError("permission denied. Are you root?\n"); } return (FALSE); @@ -203,7 +171,7 @@ do_mount(char *specialfile, char *dir, char *filesystemtype, /* Seperate standard mount options from the nonstandard string options */ static void -parse_mount_options(char *options, unsigned long *flags, char *strflags) +parse_mount_options(char *options, int *flags, char *strflags) { while (options) { int gotone = FALSE; @@ -329,7 +297,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, if (status == FALSE) { if (whineOnErrors == TRUE) { - fprintf(stderr, "Mounting %s on %s failed: %s\n", + errorMsg("Mounting %s on %s failed: %s\n", blockDevice, directory, strerror(errno)); } return (FALSE); @@ -342,7 +310,7 @@ extern int mount_main(int argc, char **argv) char string_flags_buf[1024] = ""; char *string_flags = string_flags_buf; char *extra_opts = string_flags_buf; - unsigned long flags = 0; + int flags = 0; char *filesystemType = "auto"; char *device = NULL; char *directory = NULL; @@ -379,9 +347,9 @@ extern int mount_main(int argc, char **argv) mntentlist[i].mnt_opts, mntentlist[i].mnt_freq, mntentlist[i].mnt_passno); } +#ifdef BB_FEATURE_CLEAN_UP /* Don't bother to close files or free memory. Exit * does that automagically, so we can save a few bytes */ -#if 0 free( mntentlist); close(fd); #endif