diff options
author | jmallett <jmallett@FreeBSD.org> | 2006-06-10 01:37:00 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2006-06-10 01:37:00 +0000 |
commit | e7ad0cfada9c038071326d9479b71de09b3c1c1a (patch) | |
tree | af594050a30b4ee0063d187ee6ffe93bafa29f4b /sbin/mount | |
parent | 4d313a147087c9153f8828ad447da9161a6e60b1 (diff) | |
download | FreeBSD-src-e7ad0cfada9c038071326d9479b71de09b3c1c1a.zip FreeBSD-src-e7ad0cfada9c038071326d9479b71de09b3c1c1a.tar.gz |
Rather than using specified_ro to parse the options list an extra time, and
keeping a flag to check whether we actually wanted to mount the filesystem
readonly, setup the options list so that we start off by assuming rw is what's
desired and let later flags change that.
Diffstat (limited to 'sbin/mount')
-rw-r--r-- | sbin/mount/mount.c | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c index e1c4e8a..254d4e8 100644 --- a/sbin/mount/mount.c +++ b/sbin/mount/mount.c @@ -184,26 +184,6 @@ exec_mountprog(const char *name, const char *execname, return (0); } -static -int specified_ro(const char *arg) -{ - char *optbuf, *opt; - int ret = 0; - - optbuf = strdup(arg); - if (optbuf == NULL) - err(1, NULL); - - for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) { - if (strcmp(opt, "ro") == 0) { - ret = 1; - break; - } - } - free(optbuf); - return (ret); -} - int main(int argc, char *argv[]) { @@ -212,12 +192,14 @@ main(int argc, char *argv[]) struct statfs *mntbuf; FILE *mountdfp; pid_t pid; - int all, ch, i, init_flags, mntsize, rval, have_fstab, ro; + int all, ch, i, init_flags, mntsize, rval, have_fstab; char *cp, *ep, *options; + options = strdup("noro"); + if (options == NULL) + errx(1, "malloc failed"); + all = init_flags = 0; - ro = 0; - options = NULL; vfslist = NULL; vfstype = "ufs"; while ((ch = getopt(argc, argv, "adF:fo:prwt:uv")) != -1) @@ -235,11 +217,7 @@ main(int argc, char *argv[]) init_flags |= MNT_FORCE; break; case 'o': - if (*optarg) { - options = catopt(options, optarg); - if (specified_ro(optarg)) - ro = 1; - } + options = catopt(options, optarg); break; case 'p': fstab_style = 1; @@ -247,7 +225,6 @@ main(int argc, char *argv[]) break; case 'r': options = catopt(options, "ro"); - ro = 1; break; case 't': if (vfslist != NULL) @@ -276,9 +253,6 @@ main(int argc, char *argv[]) (strcmp(type, FSTAB_RO) && \ strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ)) - if ((init_flags & MNT_UPDATE) && (ro == 0)) - options = catopt(options, "noro"); - rval = 0; switch (argc) { case 0: |