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.
This commit is contained in:
Craig Rodrigues 2006-02-25 05:09:47 +00:00
parent 69084095dc
commit 88e2c33564
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=155997

View File

@ -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");