From c8955355a02aa63f0ebd72c62440a93dec70fb91 Mon Sep 17 00:00:00 2001 From: rodrigc Date: Sat, 25 Feb 2006 05:09:47 +0000 Subject: If we specify: mount -u (update), without specifying an additional -r (read-only) flag or or -w (read-write) flag, then assume we want, mount -u -w. When doing a mount update, this will implicitly pass a "noro" mount option down to the VFS layer. vfs_mergeopts() in vfs_mount.c will then remove the "ro" mount option if it exists in the mount options for a mounted file system. This means that "mount -u" works the same as "mount -u -w" and will convert a read-only mount to read-write. --- sbin/mount/mount.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'sbin/mount') diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c index e1a36c0..655ef48 100644 --- a/sbin/mount/mount.c +++ b/sbin/mount/mount.c @@ -189,10 +189,11 @@ main(int argc, char *argv[]) struct statfs *mntbuf; FILE *mountdfp; pid_t pid; - int all, ch, i, init_flags, mntsize, rval, have_fstab; + int all, ch, i, init_flags, mntsize, rval, have_fstab, ro; char *cp, *ep, *options; all = init_flags = 0; + ro = 0; options = NULL; vfslist = NULL; vfstype = "ufs"; @@ -220,6 +221,7 @@ main(int argc, char *argv[]) break; case 'r': options = catopt(options, "ro"); + ro = 1; break; case 't': if (vfslist != NULL) @@ -248,6 +250,9 @@ 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: @@ -462,14 +467,6 @@ mountfs(const char *vfstype, const char *spec, const char *name, int flags, if (mntopts == NULL) mntopts = ""; - if (options == NULL) { - if (*mntopts == '\0') { - options = "rw"; - } else { - options = mntopts; - mntopts = ""; - } - } optbuf = catopt(strdup(mntopts), options); if (strcmp(name, "/") == 0) @@ -783,8 +780,7 @@ flags2opts(flags) res = NULL; - res = catopt(res, (flags & MNT_RDONLY) ? "ro" : "rw"); - + if (flags & MNT_RDONLY) res = catopt(res, "ro"); if (flags & MNT_SYNCHRONOUS) res = catopt(res, "sync"); if (flags & MNT_NOEXEC) res = catopt(res, "noexec"); if (flags & MNT_NOSUID) res = catopt(res, "nosuid"); -- cgit v1.1