Currently if a mount point is not accessible by the calling user,
invalid information will be printed if the -t flag is specified. $ df -t ufs Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad0s1a 495726 139944 316124 31% / /dev/ad0s1e 253678 6438 226946 3% /tmp /dev/ad0s1f 56206340 13594248 38115586 26% /usr /dev/ad0s1d 694126 19812 618784 3% /var /dev/ad0s1d 694126 19812 618784 3% /var $ Note that the mount point which is not accessible shows up as the previous file system that was printed. The reason for this is that df -t will call statfs(2) on the pathname supplied by getfsstat(2). This is done to refresh the file system statistics in the event that a previous file system had a long delay in providing its stats. This change affects the df utility in the following ways: o Teach df has to deal with statfs(2) failing. If statfs(2) fails, fall back on the possibly stale stats provided by the initial call to getfsstat(2). o Print a warning that the fs stats could possibly be stale o Modify the man page and document this new behavior as a bug. Approved by: bmilekic (mentor) PR: 68165
This commit is contained in:
+3
-1
@@ -149,7 +149,9 @@ is set, the block counts will be displayed in units of that size block.
|
||||
.Sh BUGS
|
||||
The
|
||||
.Fl n
|
||||
flag is ignored if a file or file system is specified.
|
||||
flag is ignored if a file or file system is specified. Also, if a mount
|
||||
point is not accessible by the user, it is possible that the file system
|
||||
information could be stale.
|
||||
.Sh SEE ALSO
|
||||
.Xr lsvfs 1 ,
|
||||
.Xr quota 1 ,
|
||||
|
||||
+15
-5
@@ -298,7 +298,7 @@ getmntpt(const char *name)
|
||||
static size_t
|
||||
regetmntinfo(struct statfs **mntbufp, long mntsize, const char **vfslist)
|
||||
{
|
||||
int i, j;
|
||||
int error, i, j;
|
||||
struct statfs *mntbuf;
|
||||
|
||||
if (vfslist == NULL)
|
||||
@@ -308,10 +308,20 @@ regetmntinfo(struct statfs **mntbufp, long mntsize, const char **vfslist)
|
||||
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];
|
||||
/*
|
||||
* XXX statfs(2) can fail for various reasons. It may be
|
||||
* possible that the user does not have access to the
|
||||
* pathname, if this happens, we will fall back on
|
||||
* "stale" filesystem statistics.
|
||||
*/
|
||||
error = statfs(mntbuf[i].f_mntonname, &mntbuf[j]);
|
||||
if (nflag || error < 0)
|
||||
if (i != j) {
|
||||
if (error < 0)
|
||||
warnx("%s stats possibly stale",
|
||||
mntbuf[i].f_mntonname);
|
||||
mntbuf[j] = mntbuf[i];
|
||||
}
|
||||
j++;
|
||||
}
|
||||
return (j);
|
||||
|
||||
Reference in New Issue
Block a user