summaryrefslogtreecommitdiffstats
path: root/sbin/mount
diff options
context:
space:
mode:
authorrodrigc <rodrigc@FreeBSD.org>2006-02-25 05:09:47 +0000
committerrodrigc <rodrigc@FreeBSD.org>2006-02-25 05:09:47 +0000
commitc8955355a02aa63f0ebd72c62440a93dec70fb91 (patch)
treebeaf208ef7dd3ae9ed901cb35a7473e4daa830db /sbin/mount
parent8a3d42569d0d408904949119bc454be2f044272e (diff)
downloadFreeBSD-src-c8955355a02aa63f0ebd72c62440a93dec70fb91.zip
FreeBSD-src-c8955355a02aa63f0ebd72c62440a93dec70fb91.tar.gz
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.
Diffstat (limited to 'sbin/mount')
-rw-r--r--sbin/mount/mount.c18
1 files changed, 7 insertions, 11 deletions
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");
OpenPOWER on IntegriCloud