Thanks for the report and patch!
Here's the change I've made (relative to fileutils-4.0x):
* src/du.c (count_entry): Remember the current directory also for `.'
and `..'. Reported by Stephen Smoogen, based on a patch from H.J. Lu.
* tests/du/two-args: Add a test for this.
Index: src/du.c
===================================================================
RCS file: /fetish/fileutils/src/du.c,v
retrieving revision 1.108
diff -u -p -r1.108 du.c
--- src/du.c 2000/07/30 16:28:25 1.108
+++ src/du.c 2000/08/15 12:59:47
@@ -529,8 +529,12 @@ count_entry (const char *ent, int top, d
/* 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)))
Index: tests/du/two-args
===================================================================
RCS file: /fetish/fileutils/tests/du/two-args,v
retrieving revision 1.3
diff -u -p -r1.3 two-args
--- tests/du/two-args 2000/04/27 12:15:23 1.3
+++ tests/du/two-args 2000/08/15 13:00:29
@@ -16,4 +16,9 @@ mkdir -p $tmp/1 $tmp/2
test -d $tmp || fail=1
du $tmp/1 $tmp/2 > /dev/null || fail=1
+# Make sure `du . $tmp' and `du .. $tmp' work.
+# These would fail prior to fileutils-4.0y.
+du . $tmp > /dev/null || fail=1
+du .. $tmp > /dev/null || fail=1
+
exit $fail
"H . J . Lu" <[EMAIL PROTECTED]> writes:
| On Mon, Aug 14, 2000 at 06:38:35PM -0400, Stephen Smoogen wrote:
| >
| > Ok in 6.2 the following has always worked fine:
| >
| > ( (date; find . -maxdepth 1 -print | xargs du -s | sort -nr ; date) > dsk &)
| >
| >
| > To give me a list of dsk hogs. On pinstripe and RC1 I get a long list of
| > file not founds.
| >
| > du: ./mozilla-psm-1.1-1.i386.rpm: No such file or directory
| > du: ./.m: No such file or directory
| > du: ./dsk: No such file or directory
| > du: ./#pico01080#: No such file or directory
| >
| > If I find do the files by hand they show up
| >
| > smooge:{smooge}$ du -s ./.m
| > 328 ./.m
| >
| > Sorry for not finding this sooner.
| >
| >
| >
|
| Please try this patch.
|
|
| --
| H.J. Lu ([EMAIL PROTECTED])
| --
| 2000-08-14 H.J. Lu <[EMAIL PROTECTED]>
|
| * src/du.c (count_entry): Save the cwd when traversing relative
| path.
|
| --- fileutils-4.0x/src/du.c.relpath Mon Aug 14 17:53:09 2000
| +++ fileutils-4.0x/src/du.c Mon Aug 14 18:07:14 2000
| @@ -525,11 +525,11 @@ count_entry (const char *ent, int top, d
| #ifndef S_ISLNK
| # define S_ISLNK(s) 0
| #endif
| - /* 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
| + /* If we're traversing more than one level, relative path, 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. */
| - if (strchr (ent, '/')
| + if (strchr (ent, '/') || *ent == '.'
| || (xstat == stat
| && lstat (ent, &e_buf) == 0
| && S_ISLNK (e_buf.st_mode)))