summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-12-03 20:38:20 +0000
committerJim Meyering <jim@meyering.net>1994-12-03 20:38:20 +0000
commit1d6dc36be9696230119410e42e2fb163f8791aa7 (patch)
treeca86d4ed672ad8eaf6ea558db43df7f46c180b7c
parent9f715b2bdb8fa3b4803af025c1a709403ed7fd7d (diff)
downloadcoreutils-1d6dc36be9696230119410e42e2fb163f8791aa7.tar.xz
(du_files): Handle very low-probability fchdir failure (when errno != 0
&& errno != EINVAL).
-rw-r--r--src/du.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/du.c b/src/du.c
index 3cbaeb092..53711537a 100644
--- a/src/du.c
+++ b/src/du.c
@@ -325,12 +325,19 @@ du_files (files)
if (starting_desc < 0)
error (1, errno, "cannot open current directory");
- /* On SunOS, fchdir returns EINVAL if accounting is enabled,
+ /* On SunOS 4, fchdir returns EINVAL if accounting is enabled,
so we have to fall back to chdir. */
- if (fchdir (starting_desc) && errno == EINVAL)
+ if (fchdir (starting_desc))
{
- close (starting_desc);
- starting_desc = -1;
+ if (errno == EINVAL)
+ {
+ close (starting_desc);
+ starting_desc = -1;
+ }
+ else
+ {
+ error (1, errno, "current directory");
+ }
}
if (starting_desc == -1)
#endif