bin/137101: missing "rw" option in mount(8) -p output
Jimmy Olgeni
olgeni at FreeBSD.org
Fri Jul 24 20:10:07 UTC 2009
>Number: 137101
>Category: bin
>Synopsis: missing "rw" option in mount(8) -p output
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri Jul 24 20:10:06 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator: Jimmy Olgeni
>Release: FreeBSD 7.2-STABLE i386
>Organization:
>Environment:
System: FreeBSD olgeni 7.2-STABLE FreeBSD 7.2-STABLE #0: Fri Jul 3 15:50:27 CEST 2009 root at localhost:/usr/obj/usr/src/sys/RELENG_7.i386 i386
>Description:
The -p option in mount(8) enables fstab_style, which is supposed
to print mount information in fstab(5) format.
If a mounted file system does not have any options specified
(MNT_NOEXEC, MNT_NOSUID) then the default "rw" option is printed.
However, if any of the MNT_* flags is present (MNT_RDONLY aside)
the "rw" option is skipped. If the output is used in an actual fstab
file, output similar to the following will occur during mounts, and
the corresponding mounts would fail:
fstab: /etc/fstab:6: Inappropriate file type or format
fstab: /etc/fstab:6: Inappropriate file type or format
mount: /storage: unknown special file or file system
>How-To-Repeat:
# mount -p
/dev/ad0s1a / ufs noatime 1 1
/dev/ad0s1d /var ufs noatime 2 2
/dev/ad0s1e /usr ufs noatime 2 2
/dev/ad2s1f /storage ufs noatime 2 2
The problem may be repeated by temporarily removing "rw" from any
non essential filesystem and trying to umount/mount it.
>Fix:
The following patch to src/sbin/mount/mount.c 1.96.2.3 (RELENG_7)
changes flags2opts to consider "rw" the opposite of "ro", even if
other options are defined.
The original check for NULL options is removed, since flags2opts
now always adds at least "rw" or "ro" to the option string.
--- mount.c.orig 2009-07-24 21:28:50.000000000 +0200
+++ mount.c 2009-07-24 21:39:02.000000000 +0200
@@ -857,10 +857,6 @@
+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 +868,9 @@
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)))
@@ -902,7 +894,11 @@
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");
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list