From owner-freebsd-bugs@FreeBSD.ORG Fri Jul 24 20:10:07 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1F6251065678 for ; Fri, 24 Jul 2009 20:10:07 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id EB25D8FC23 for ; Fri, 24 Jul 2009 20:10:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n6OKA66A089025 for ; Fri, 24 Jul 2009 20:10:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n6OKA6Ut089018; Fri, 24 Jul 2009 20:10:06 GMT (envelope-from gnats) Resent-Date: Fri, 24 Jul 2009 20:10:06 GMT Resent-Message-Id: <200907242010.n6OKA6Ut089018@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jimmy Olgeni Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7AD9C106566B for ; Fri, 24 Jul 2009 20:07:28 +0000 (UTC) (envelope-from olgeni@colby.it) Received: from jack.mail.tiscali.it (jack.mail.tiscali.it [213.205.33.53]) by mx1.freebsd.org (Postfix) with ESMTP id 06C3D8FC1A for ; Fri, 24 Jul 2009 20:07:27 +0000 (UTC) (envelope-from olgeni@colby.it) Received: from olgeni.olgeni (94.36.172.211) by jack.mail.tiscali.it (8.0.022) id 499F036C053D1CC4 for FreeBSD-gnats-submit@freebsd.org; Fri, 24 Jul 2009 21:56:12 +0200 Received: from olgeni.olgeni (localhost [127.0.0.1]) by olgeni.olgeni (8.14.3/8.14.3) with ESMTP id n6OJuBIv002332 for ; Fri, 24 Jul 2009 21:56:11 +0200 (CEST) (envelope-from olgeni@olgeni.olgeni) Received: (from olgeni@localhost) by olgeni.olgeni (8.14.3/8.14.3/Submit) id n6OJuBxO002331; Fri, 24 Jul 2009 21:56:11 +0200 (CEST) (envelope-from olgeni) Message-Id: <200907241956.n6OJuBxO002331@olgeni.olgeni> Date: Fri, 24 Jul 2009 21:56:11 +0200 (CEST) From: Jimmy Olgeni To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/137101: missing "rw" option in mount(8) -p output X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jul 2009 20:10:07 -0000 >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@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: