summaryrefslogtreecommitdiff
path: root/src/du.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-08-15 13:05:03 +0000
committerJim Meyering <jim@meyering.net>2000-08-15 13:05:03 +0000
commitf0a4b95c5819d1c61f41eff2bc1dcb76c3ecce1f (patch)
tree45e68dff2a57dd3d3082ffe0516104732b49374c /src/du.c
parentd5d043c57a710d445bb2aea86ad3cdd6e17519fc (diff)
downloadcoreutils-f0a4b95c5819d1c61f41eff2bc1dcb76c3ecce1f.tar.xz
(count_entry): Remember the current directory also for `.'
and `..'. Reported by Stephen Smoogen, based on a patch from H.J. Lu.
Diffstat (limited to 'src/du.c')
-rw-r--r--src/du.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/du.c b/src/du.c
index ec64bb32d..97d6257de 100644
--- a/src/du.c
+++ b/src/du.c
@@ -529,8 +529,12 @@ count_entry (const char *ent, int top, dev_t last_dev, int depth)
/* If we're traversing more than one level, or if we're
dereferencing symlinks and we're about to chdir through a
symlink, remember the current directory so we can return to
- it later. In other cases, chdir ("..") works fine. */
+ it later. In other cases, chdir ("..") works fine.
+ Treat `.' and `..' like multi-level paths, since `chdir ("..")'
+ wont't restore the current working directory after a `chdir'
+ to one of those. */
if (strchr (ent, '/')
+ || DOT_OR_DOTDOT (ent)
|| (xstat == stat
&& lstat (ent, &e_buf) == 0
&& S_ISLNK (e_buf.st_mode)))