From owner-freebsd-bugs@FreeBSD.ORG Thu May 22 19:50:03 2008 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 01E251065674 for ; Thu, 22 May 2008 19:50:03 +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 E163C8FC22 for ; Thu, 22 May 2008 19:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m4MJo232023193 for ; Thu, 22 May 2008 19:50:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m4MJo2YI023192; Thu, 22 May 2008 19:50:02 GMT (envelope-from gnats) Date: Thu, 22 May 2008 19:50:02 GMT Message-Id: <200805221950.m4MJo2YI023192@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Jaakko Heinonen Cc: Subject: Re: bin/123021: mount(8): mount -p shows incorrect mount options [regression] X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jaakko Heinonen List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 May 2008 19:50:03 -0000 The following reply was made to PR bin/123021; it has been noted by GNATS. From: Jaakko Heinonen To: bug-followup@FreeBSD.org, citrin@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" : " "); }