Subject: bin/3474: df(1) gets stacked FS data wrong, sometimes
To: None <gnats-bugs@gnats.netbsd.org>
From: Ross Harvey <ross@teraflop.com>
List: netbsd-bugs
Date: 04/10/1997 18:34:53
>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 (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Apr 10 18:35:01 1997
>Last-Modified:
>Originator: Ross Harvey
>Organization:
Avalon Computer Systems, Inc.
>Release: all
>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);
>Audit-Trail:
>Unformatted: