X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=mount.c;h=72734ae62380a73714eac98b488d7ef8cf8d52af;hb=9b2297a34e35be143155769a470331af2f2b9330;hp=bde55d155f99ab6cecb68edee7679131e5bab197;hpb=7ab9c7ee52db8759d457819f5480378fa3aa97cc;p=oweals%2Fbusybox.git diff --git a/mount.c b/mount.c index bde55d155..72734ae62 100644 --- a/mount.c +++ b/mount.c @@ -43,25 +43,41 @@ #include #include #include -#include #include #if defined BB_FEATURE_USE_DEVPS_PATCH #include #endif -#ifndef MS_RDONLY -#include -#endif + + +#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 */ + #if defined BB_FEATURE_MOUNT_LOOP #include #include -#include - - static int use_loop = FALSE; #endif +extern int mount (__const char *__special_file, __const char *__dir, + __const char *__fstype, unsigned long int __rwflag, + __const void *__data); +extern int umount (__const char *__special_file); +extern int umount2 (__const char *__special_file, int __flags); + + extern const char mtab_file[]; /* Defined in utility.c */ static const char mount_usage[] = @@ -154,8 +170,7 @@ do_mount(char *specialfile, char *dir, char *filesystemtype, } } #endif - status = - mount(specialfile, dir, filesystemtype, flags, string_flags); + status = mount(specialfile, dir, filesystemtype, flags, string_flags); } @@ -176,6 +191,11 @@ do_mount(char *specialfile, char *dir, char *filesystemtype, del_loop(specialfile); } #endif + + if (errno == EPERM) { + fatalError("mount: permission denied. Are you root?\n"); + } + return (FALSE); } @@ -307,7 +327,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, fakeIt, mtab_opts); } - if (status == FALSE && whineOnErrors == TRUE) { + if (status == FALSE) { if (whineOnErrors == TRUE) { fprintf(stderr, "Mounting %s on %s failed: %s\n", blockDevice, directory, strerror(errno)); @@ -458,24 +478,19 @@ extern int mount_main(int argc, char **argv) // If the filesystem isn't noauto, // and isn't swap or nfs, then mount it if ((!strstr(m->mnt_opts, "noauto")) && - (!strstr(m->mnt_type, "swap")) && - (!strstr(m->mnt_type, "nfs"))) { + (!strstr(m->mnt_type, "swap")) && + (!strstr(m->mnt_type, "nfs"))) { flags = 0; *string_flags = '\0'; parse_mount_options(m->mnt_opts, &flags, string_flags); - /* If the directory is /, try to remount - * with the options specified in fstab */ - if (m->mnt_dir[0] == '/' && m->mnt_dir[1] == '\0') { - flags |= MS_REMOUNT; - } if (mount_one(m->mnt_fsname, m->mnt_dir, m->mnt_type, - flags, string_flags, useMtab, fakeIt, - extra_opts, FALSE)) + flags, string_flags, useMtab, fakeIt, + extra_opts, FALSE)==FALSE) { /* Try again, but this time try a remount */ mount_one(m->mnt_fsname, m->mnt_dir, m->mnt_type, - flags|MS_REMOUNT, string_flags, useMtab, fakeIt, - extra_opts, TRUE); + flags|MS_REMOUNT, string_flags, useMtab, fakeIt, + extra_opts, TRUE); } } } @@ -483,11 +498,14 @@ extern int mount_main(int argc, char **argv) } else { if (device && directory) { #ifdef BB_NFSMOUNT + if (strchr(device, ':') != NULL) + filesystemType = "nfs"; if (strcmp(filesystemType, "nfs") == 0) { - if (nfsmount - (device, directory, &flags, &extra_opts, &string_flags, - 1) != 0) - exit(FALSE); + int ret; + ret = nfsmount (device, directory, &flags, + &extra_opts, &string_flags, 1); + if (ret != 0) + fatalError("nfsmount failed: %s\n", strerror(errno)); } #endif exit(mount_one(device, directory, filesystemType,