diff options
| author | Christian S.J. Peron <csjp@FreeBSD.org> | 2004-07-20 18:24:47 +0000 |
|---|---|---|
| committer | Christian S.J. Peron <csjp@FreeBSD.org> | 2004-07-20 18:24:47 +0000 |
| commit | 239c9e601ae8d10d636d9cc4830266886e3c61e4 (patch) | |
| tree | 420e461d75773b4d8c0bce6d9802d6f07acc18b0 /bin | |
| parent | be4252b3678cb9f12ac9cbc4b9d827b06d073799 (diff) | |
Notes
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/df/df.1 | 4 | ||||
| -rw-r--r-- | bin/df/df.c | 20 |
2 files changed, 18 insertions, 6 deletions
diff --git a/bin/df/df.1 b/bin/df/df.1 index 76d3a02a473e..8deaefc15bc2 100644 --- a/bin/df/df.1 +++ b/bin/df/df.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 , diff --git a/bin/df/df.c b/bin/df/df.c index ddeb58182c70..dfff6aef4265 100644 --- a/bin/df/df.c +++ b/bin/df/df.c @@ -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); |
