svn commit: r214024 - stable/7/sbin/mount

Jaakko Heinonen jh at FreeBSD.org
Mon Oct 18 14:40:49 UTC 2010


Author: jh
Date: Mon Oct 18 14:40:48 2010
New Revision: 214024
URL: http://svn.freebsd.org/changeset/base/214024

Log:
  MFC r213298:
  
  Fix printing of the "rw" mount option in fstab(5) format (-p option).
  fstab(5) format requires that one of "rw", "rq" or "ro" is always
  specified.
  
  PR:		bin/123021

Modified:
  stable/7/sbin/mount/mount.c
Directory Properties:
  stable/7/sbin/mount/   (props changed)

Modified: stable/7/sbin/mount/mount.c
==============================================================================
--- stable/7/sbin/mount/mount.c	Mon Oct 18 14:36:51 2010	(r214023)
+++ stable/7/sbin/mount/mount.c	Mon Oct 18 14:40:48 2010	(r214024)
@@ -846,10 +846,18 @@ void
 putfsent(struct statfs *ent)
 {
 	struct fstab *fst;
-	char *opts;
+	char *opts, *rw;
 	int l;
 
+	opts = NULL;
+	/* flags2opts() doesn't return the "rw" option. */
+	if ((ent->f_flags & MNT_RDONLY) != 0)
+		rw = NULL;
+	else
+		rw = catopt(NULL, "rw");
+
 	opts = flags2opts(ent->f_flags);
+	opts = catopt(rw, opts);
 
 	if (strncmp(ent->f_mntfromname, "<below>", 7) == 0 ||
 	    strncmp(ent->f_mntfromname, "<above>", 7) == 0) {
@@ -857,10 +865,6 @@ putfsent(struct statfs *ent)
 		    +1));
 	}
 
-	/*
-	 * "rw" is not a real mount option; this is why we print NULL as "rw"
-	 * if opts is still NULL here.
-	 */
 	l = strlen(ent->f_mntfromname);
 	printf("%s%s%s%s", ent->f_mntfromname,
 	    l < 8 ? "\t" : "",
@@ -872,13 +876,9 @@ putfsent(struct statfs *ent)
 	    l < 16 ? "\t" : "",
 	    l < 24 ? "\t" : " ");
 	printf("%s\t", ent->f_fstypename);
-	if (opts == NULL) {
-		printf("%s\t", "rw");
-	} else {
-		l = strlen(opts);
-		printf("%s%s", opts,
-		    l < 8 ? "\t" : " ");
-	}
+	l = strlen(opts);
+	printf("%s%s", opts,
+	    l < 8 ? "\t" : " ");
 	free(opts);
 
 	if ((fst = getfsspec(ent->f_mntfromname)))


More information about the svn-src-all mailing list