From bernd@heitec.net  Fri Jul  7 18:38:46 2000
Return-Path: <bernd@heitec.net>
Received: from heitec.net (paladin.heitec.net [212.204.92.251])
	by hub.freebsd.org (Postfix) with ESMTP id 8884E37B519
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  7 Jul 2000 18:38:44 -0700 (PDT)
	(envelope-from bernd@heitec.net)
Received: (from root@localhost)
	by  heitec.net (8.9.3/8.9.3) id DAA38919;
	Sat, 8 Jul 2000 03:38:50 +0200 (CEST)
	(envelope-from bernd)
Message-Id: <200007080138.DAA38919@ heitec.net>
Date: Sat, 8 Jul 2000 03:38:50 +0200 (CEST)
From: bdluevel@heitec.net
Sender: bernd@heitec.net
Reply-To: bdluevel@heitec.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: df output wrong for union-mounts
X-Send-Pr-Version: 3.2

>Number:         19772
>Category:       bin
>Synopsis:       [unionfs] df(1) output wrong for union-mounts
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 07 18:40:01 PDT 2000
>Closed-Date:    
>Last-Modified:  Mon Nov 21 22:36:51 UTC 2011
>Originator:     Bernd Luevelsmeyer
>Release:        FreeBSD 4.0-STABLE i386
>Organization:
Heitec AG
>Environment:

	FreeBSD 4.0-STABLE #1: Tue Jul  4 05:48:30 CEST 2000

>Description:

	'df -t nonfs' lists, if two partitions are mounted
	to the same mountpoint with 'union', one of them
	twice and omits the other. 'df' by itself lists both,
	as expected.
	This also affects the "daily" report to root,
	/etc/periodic/daily/400.status-disks

>How-To-Repeat:

	$ mount -p | grep ftproot
	/dev/ad1s1e     /ftproot        ufs rw,noatime  2 2
	/dev/ad2s1e     /ftproot/pub/stuff     ufs rw,noatime  2 2
	/dev/ad3s1e     /ftproot/pub/stuff     ufs rw,union,noatime    2 2
	$ df | grep ftproot
	/dev/ad1s1e     17255046 10381956  5492688    65%    /ftproot
	/dev/ad2s1e     48443416 43861994   705950    98%    /ftproot/pub/stuff
	/dev/ad3s1e     38779472  7757158 27919958    22%    /ftproot/pub/stuff
	$ df -t nonfs | grep ftproot
	/dev/ad1s1e   17255046 10381956  5492688    65%    /ftproot
	/dev/ad3s1e   38779472  7757158 27919958    22%    /ftproot/pub/stuff
	/dev/ad3s1e   38779472  7757158 27919958    22%    /ftproot/pub/stuff

>Fix:



>Release-Note:
>Audit-Trail:

From: Robert Drehmel <robd@gmx.net>
To: freebsd-gnats-submit@FreeBSD.org
Cc: bdluevel@heitec.net
Subject: Re: bin/19772: df output wrong for union-mounts
Date: Sun, 09 Jul 2000 12:54:32 +0200

 This is a multi-part message in MIME format.
 --------------F4ADB7FBFEE0C8F7415DC772
 Content-Type: text/plain; charset=iso-8859-1
 Content-Transfer-Encoding: 8bit
 
 > 'df -t nonfs' lists, if two partitions are mounted
 > to the same mountpoint with 'union', one of them
 > twice and omits the other. 'df' by itself lists both,
 > as expected.
 > This also affects the "daily" report to root,
 > /etc/periodic/daily/400.status-disks
 
 Use df -n or take this patch.
 
 I'm not quite sure for what the statfs(2) call down in regetmntinfo()
 is. statfs(2) takes the path and a ``struct statfs buffer as
 arguments; it can not distinguish between two identical paths (who
 can? :-), so the information about the last filesystem mounted on that
 path is written into the buffer.
 
 Or am I wrong ? Anyway, the patch works for me...
 
 -- 
 Robert S. F. Drehmel <robd@gmx.net>
 
 linux.de: "Forget Ctrl-Alt-Del, use Linux"
 Right, their productivity seems to be the same.
 --------------F4ADB7FBFEE0C8F7415DC772
 Content-Type: text/plain; charset=us-ascii; name="df.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline; filename="df.diff"
 
 *** ../df.c	Sun Jul  9 12:11:07 2000
 --- df.c	Sun Jul  9 12:09:23 2000
 ***************
 *** 296,304 ****
   	for (j = 0, i = 0; i < mntsize; i++) {
   		if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
   			continue;
 ! 		if (!nflag)
 ! 			(void)statfs(mntbuf[i].f_mntonname,&mntbuf[j]);
 ! 		else if (i != j)
   			mntbuf[j] = mntbuf[i];
   		j++;
   	}
 --- 296,302 ----
   	for (j = 0, i = 0; i < mntsize; i++) {
   		if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
   			continue;
 ! 		if (i != j)
   			mntbuf[j] = mntbuf[i];
   		j++;
   	}
 
 --------------F4ADB7FBFEE0C8F7415DC772--
 
 
State-Changed-From-To: open->feedback 
State-Changed-By: iedowse 
State-Changed-When: Fri Aug 9 16:38:57 PDT 2002 
State-Changed-Why:  

This doesn't seem to be easy to fix, as to get non-cached information 
requires using either fstatfs() or getmntinfo(, MNT_WAIT). The 
former cannot distinguish between filesystems with identical 
mountpoints and the latter will hang if an NFS server is down. Is 
the "-n" flag an acceptible workaround for you? 

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

From: Bernd Luevelsmeyer <bdluevel@heitec.net>
To: Ian Dowse <iedowse@FreeBSD.org>
Cc: freebsd-bugs@FreeBSD.org, freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/19772: df output wrong for union-mounts
Date: Sat, 10 Aug 2002 10:27:51 +0200

 Ian Dowse wrote:
 > 
 > Synopsis: df output wrong for union-mounts
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: iedowse
 > State-Changed-When: Fri Aug 9 16:38:57 PDT 2002
 > State-Changed-Why:
 > 
 > This doesn't seem to be easy to fix, as to get non-cached information
 > requires using either fstatfs() or getmntinfo(, MNT_WAIT). The
 > former cannot distinguish between filesystems with identical
 > mountpoints and the latter will hang if an NFS server is down. Is
 > the "-n" flag an acceptible workaround for you?
 > 
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=19772
 
 As a workaround, it's fine. But in the long run, the output of "df -t
 nonfs" should either include all the requested mountpoints or fail with
 an error. Currently the information is wrong without an error message.
 
 I'd rather have it risk the hang (with a timeout); after all, the user
 asked for non-cached information without -n, and the man-page explicitly
 warns about the long delay.
State-Changed-From-To: feedback->open 
State-Changed-By: ceri 
State-Changed-When: Sun Jun 8 10:57:03 PDT 2003 
State-Changed-Why:  
Feedback has been requested and received; throw this PR back open. 

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