From citrin@mx15.rambler.ru  Wed Apr 23 16:22:18 2008
Return-Path: <citrin@mx15.rambler.ru>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6484F106567E
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 23 Apr 2008 16:22:18 +0000 (UTC)
	(envelope-from citrin@mx15.rambler.ru)
Received: from mx-carp-ext.rambler.ru (mx-carp-ext.rambler.ru [81.19.66.237])
	by mx1.freebsd.org (Postfix) with ESMTP id D0B5A8FC16
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 23 Apr 2008 16:22:17 +0000 (UTC)
	(envelope-from citrin@mx15.rambler.ru)
Received: by mx15.rambler.ru (Postfix, from userid 1072)
	id 56138FA7CB7; Wed, 23 Apr 2008 20:05:16 +0400 (MSD)
Message-Id: <20080423160516.56138FA7CB7@mx15.rambler.ru>
Date: Wed, 23 Apr 2008 20:05:16 +0400 (MSD)
From: Anton Yuzhaninov <citrin@citrin.ru>
Reply-To: Anton Yuzhaninov <citrin@citrin.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [regression] mount -p show incorrect mount options
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         123021
>Category:       bin
>Synopsis:       [patch] mount(8): mount -p shows incorrect mount options [regression]
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 23 16:30:00 UTC 2008
>Closed-Date:    Mon Oct 18 15:04:39 UTC 2010
>Last-Modified:  Mon Oct 18 15:04:39 UTC 2010
>Originator:     Anton Yuzhaninov
>Release:        FreeBSD 7.0-RELEASE amd64
>Organization:
>Environment:
System: FreeBSD mx15.rambler.ru 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Sun Feb 24 10:35:36 UTC 2008 root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
>Description:
mount -p should show mount information in fstab(5) format, but when fs
mounted with options rw,nosuid,noatime it don't show rw option.
>How-To-Repeat:

Mount some filesystem with -o rw,nosuid,noatime

$ mount -p
...
/dev/mirror/gm0s1g      /spool                  ufs     nosuid,noatime  2 2

In the FreeBSD6 mount -p show rw option:
$ mount -p
/dev/mirror/gm0s1g      /spool  ufs rw,nosuid,noatime   2 2

>Fix:
No known yet.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: matteo 
State-Changed-When: Dom 11 Mag 2008 16:30:06 UTC 
State-Changed-Why:  
I cannot reproduce this. Do you still experience this issue? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123021 

From: Anton Yuzhaninov <citrin@citrin.ru>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/123021: mount(8): mount -p shows incorrect mount options
 [regression]
Date: Wed, 14 May 2008 14:26:13 +0400

 Bug still here on fresh current:
 
 # uname -a
 FreeBSD citrin.park.rambler.ru 8.0-CURRENT FreeBSD 8.0-CURRENT #14: Mon May 12 01:23:53 MSD 2008 
 root@citrin.park.rambler.ru:/usr/obj/usr/src/sys/NK  amd64
 
 # dd if=/dev/zero of=test.img count=1 bs=1m                                                                        [0]
 1+0 records in
 1+0 records out
 1048576 bytes transferred in 0.018834 secs (55674294 bytes/sec)
 # mdconfig -a -f test.img
 md1
 # newfs -U /dev/md1
 /dev/md1: 1.0MB (2048 sectors) block size 16384, fragment size 2048
          using 2 cylinder groups of 0.50MB, 32 blks, 64 inodes.
          with soft updates
 super-block backups (for fsck -b #) at:
   160, 1184
 # mount -o noatime,nosuid /dev/md1 /mnt/
 # mount
 /dev/ad4s1a on / (ufs, local, noatime)
 devfs on /dev (devfs, local)
 /dev/ad4s1g on /home (ufs, local, noatime, nosuid, soft-updates)
 /dev/ad4s1d on /tmp (ufs, local, noatime, soft-updates)
 /dev/ad4s1f on /usr (ufs, local, noatime, soft-updates)
 /dev/ad4s1e on /var (ufs, local, noatime, soft-updates)
 /dev/md0 on /var/clamav (ufs, asynchronous, local, noexec, nosuid, nosymfollow)
 spool on /spool (zfs, local, noatime, nosuid)
 spool/mail-chaos on /spool/mail-chaos (zfs, local, noatime, nosuid)
 spool/pt on /spool/pt (zfs, local, noatime, nosuid)
 /dev/md1 on /mnt (ufs, local, noatime, nosuid, soft-updates)
 # mount -p
 /dev/ad4s1a             /                       ufs     noatime         1 1
 devfs                   /dev                    devfs   rw              0 0
 /dev/ad4s1g             /home                   ufs     nosuid,noatime  2 2
 /dev/ad4s1d             /tmp                    ufs     noatime         2 2
 /dev/ad4s1f             /usr                    ufs     noatime         2 2
 /dev/ad4s1e             /var                    ufs     noatime         2 2
 /dev/md0                /var/clamav             ufs     noexec,nosuid,async,nosymfollow         0 0
 spool                   /spool                  zfs     nosuid,noatime  0 0
 spool/mail-chaos        /spool/mail-chaos       zfs     nosuid,noatime  0 0
 spool/pt                /spool/pt               zfs     nosuid,noatime  0 0
 /dev/md1                /mnt                    ufs     nosuid,noatime  0 0
 
 But should be
 /dev/md1                /mnt                    ufs     rw,nosuid,noatime  0 0
 
 Even if rw specified in mount command, mount -p don't show rw
 
 # umount /mnt/
 # mount -o rw,noatime,nosuid /dev/md1 /mnt/
 # mount -p
 ...
 /dev/md1                /mnt                    ufs     nosuid,noatime  0 0

From: Jaakko Heinonen <jh@saunalahti.fi>
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" : " ");
  	}
 
State-Changed-From-To: feedback->open 
State-Changed-By: linimon 
State-Changed-When: Thu May 22 23:53:43 UTC 2008 
State-Changed-Why:  
Feedback received, and now we have a patch. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123021 
State-Changed-From-To: open->analyzed 
State-Changed-By: vwe 
State-Changed-When: Fri May 23 10:11:31 UTC 2008 
State-Changed-Why:  

...and finally, we don't just have a patch, it's clearly understood ;) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123021 
Responsible-Changed-From-To: freebsd-bugs->jh 
Responsible-Changed-By: jh 
Responsible-Changed-When: Mon Sep 27 18:00:31 UTC 2010 
Responsible-Changed-Why:  
Take. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123021 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/123021: commit references a PR
Date: Thu, 30 Sep 2010 13:31:41 +0000 (UTC)

 Author: jh
 Date: Thu Sep 30 13:31:35 2010
 New Revision: 213298
 URL: http://svn.freebsd.org/changeset/base/213298
 
 Log:
   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
   Reviewed by:	keramida, rodrigc
   MFC after:	2 weeks
 
 Modified:
   head/sbin/mount/mount.c
 
 Modified: head/sbin/mount/mount.c
 ==============================================================================
 --- head/sbin/mount/mount.c	Thu Sep 30 12:59:56 2010	(r213297)
 +++ head/sbin/mount/mount.c	Thu Sep 30 13:31:35 2010	(r213298)
 @@ -850,10 +850,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) {
 @@ -861,10 +869,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" : "",
 @@ -876,13 +880,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)))
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: analyzed->patched 
State-Changed-By: jh 
State-Changed-When: Thu Sep 30 15:11:07 UTC 2010 
State-Changed-Why:  
Patched in head (r213298). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123021 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/123021: commit references a PR
Date: Sun, 17 Oct 2010 14:48:59 +0000 (UTC)

 Author: jh
 Date: Sun Oct 17 14:48:53 2010
 New Revision: 213978
 URL: http://svn.freebsd.org/changeset/base/213978
 
 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/8/sbin/mount/mount.c
 Directory Properties:
   stable/8/sbin/mount/   (props changed)
 
 Modified: stable/8/sbin/mount/mount.c
 ==============================================================================
 --- stable/8/sbin/mount/mount.c	Sun Oct 17 14:25:55 2010	(r213977)
 +++ stable/8/sbin/mount/mount.c	Sun Oct 17 14:48:53 2010	(r213978)
 @@ -850,10 +850,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) {
 @@ -861,10 +869,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" : "",
 @@ -876,13 +880,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)))
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/123021: commit references a PR
Date: Mon, 18 Oct 2010 14:40:54 +0000 (UTC)

 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)))
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: jh 
State-Changed-When: Mon Oct 18 15:04:38 UTC 2010 
State-Changed-Why:  
Fixed in head, stable/8 and stable/7. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123021 
>Unformatted:
