NetBSD Problem Report #3474

Received: (qmail-queue invoked from smtpd); 11 Apr 1997 01:27:47 -0000
Message-Id: <199704110134.SAA00426@epsilon.teraflop.com>
Date: Thu, 10 Apr 1997 18:34:53 -0700 (PDT)
From: Ross Harvey <ross@teraflop.com>
Reply-To: ross@teraflop.com
To: gnats-bugs@gnats.netbsd.org
Subject: df(1) gets stacked FS data wrong, sometimes
X-Send-Pr-Version: 3.95

>Number:         3474
>Category:       bin
>Synopsis:       df(1) gets stacked FS data wrong, sometimes. Have fix.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 10 18:35:01 +0000 1997
>Closed-Date:    Tue Jul 27 12:14:40 +0000 1999
>Last-Modified:  Tue Jul 27 12:15:10 +0000 1999
>Originator:     Ross Harvey
>Release:        all
>Organization:
Avalon Computer Systems, Inc.
>Environment:
System: NetBSD epsilon.teraflop.com 1.2D NetBSD 1.2D (e) #15: Wed Apr 9 21:12:42 PDT 1997 ross@epsilon.ghs.com:/bsd/ross/e alpha


>Description:
	If df is given a restricting arg -l or -t, it will get all
	the data and the mount from-point wrong on FS stacks,
	incorrectly repeating the data for the top file system in
	the stack.
>How-To-Repeat:
	% cd /tmp
	% mkdir a b c a/a b/b c/c
	% mount_null b/b a/a
	% mount_null c/c a/a
	% df
		[ correct output ]
	% df -l
		[ incorrect ]
	% df -t null
		[ incorrect ]

	[ in these examples, only the name is wrong but the data
	is all "correct" because it is all the same. If you go to
	the trouble of stacking directories from different file
	systems, you will see all the other data be incorrectly
	repeated as well ]

>Fix:
	patch -d /usr/src/bin/df

--- /bsd/base-src/bin/df/df.c	Wed Dec 11 04:06:07 1996
+++ ./df.c	Thu Apr 10 18:31:50 1997
@@ -285,8 +285,17 @@
 			continue;
 		if (nflag)
 			mntbuf[j] = mntbuf[i];
-		else
+		else {
+			struct statfs layerbuf = mntbuf[i];
 			(void)statfs(mntbuf[i].f_mntonname, &mntbuf[j]);
+			/*
+			 * If the FS name changed, then new data is for
+			 * a different layer and we don't want it.
+			 */
+			if(memcmp(layerbuf.f_mntfromname,
+				 mntbuf[j].f_mntfromname, MNAMELEN))
+				 mntbuf[j] = layerbuf;
+		}
 		j++;
 	}
 	return (j);
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: sommerfeld 
State-Changed-When: Tue Jul 27 05:14:40 PDT 1999 
State-Changed-Why:  
Fix from PR tested and committed. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.