bin/123021: mount(8): mount -p shows incorrect mount options
[regression]
Jaakko Heinonen
jh at saunalahti.fi
Thu May 22 19:50:03 UTC 2008
The following reply was made to PR bin/123021; it has been noted by GNATS.
From: Jaakko Heinonen <jh at saunalahti.fi>
To: bug-followup at FreeBSD.org, citrin at citrin.ru
Cc:
Subject: Re: bin/123021: mount(8): mount -p shows incorrect mount options
[regression]
Date: Thu, 22 May 2008 22:41:57 +0300
The bug was introduced in mount.c revision 1.82. There was an attempt to
fix the bug in revision 1.83 but the fix is incomplete.
I first thought this patch but it might break something since
flags2opts() was changed in r1.82 specifically not to return "rw".
Index: mount.c
===================================================================
RCS file: /home/ncvs/src/sbin/mount/mount.c,v
retrieving revision 1.98
diff -p -u -r1.98 mount.c
--- mount.c 4 Feb 2008 07:37:56 -0000 1.98
+++ mount.c 14 May 2008 15:12:13 -0000
@@ -819,10 +819,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" : "",
@@ -834,13 +830,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)))
@@ -864,7 +856,10 @@ flags2opts(int flags)
res = NULL;
- if (flags & MNT_RDONLY) res = catopt(res, "ro");
+ if (flags & MNT_RDONLY)
+ res = catopt(res, "ro");
+ else
+ res = catopt(res, "rw");
if (flags & MNT_SYNCHRONOUS) res = catopt(res, "sync");
if (flags & MNT_NOEXEC) res = catopt(res, "noexec");
if (flags & MNT_NOSUID) res = catopt(res, "nosuid");
This patch possibly avoids breaking things but it feels more hacky:
Index: mount.c
===================================================================
RCS file: /home/ncvs/src/sbin/mount/mount.c,v
retrieving revision 1.98
diff -p -u -r1.98 mount.c
--- mount.c 4 Feb 2008 07:37:56 -0000 1.98
+++ mount.c 22 May 2008 19:02:12 -0000
@@ -838,6 +838,10 @@ putfsent(struct statfs *ent)
printf("%s\t", "rw");
} else {
l = strlen(opts);
+ if (!(ent->f_flags & MNT_RDONLY)) {
+ printf("rw,");
+ l += 3;
+ }
printf("%s%s", opts,
l < 8 ? "\t" : " ");
}
More information about the freebsd-bugs
mailing list