Ok maybe I have been smoking crack for a long time but the following used to work on <=6.95 ( (date; find . -maxdepth 1 -print | xargs du -s | sort -nr ; date) > dsk &) This would give you a list of files for du to traverse.. usually I have a '-type d' in there also.. (both are broke) Now what happens is du: ./.RealNetworks_RealShared_00: No such file or directory du: ./.RealNetworks_RealPlayer_60: No such file or directory du: ./.RealNetworks_RealMediaSDK_60: No such file or directory du: ./Install_Material: No such file or directory du: ./.lynx_cookies: No such file or directory du: ./.signature-news: No such file or directory du: ./list_of_wants: No such file or directory du: ./.#bum_equiptment: No such file or directory du: ./.Xresources: No such file or directory du: ./ack.html: No such file or directory du: ./.mozilla: No such file or directory du: ./Games: No such file or directory du: ./boys.jpg: No such file or directory du: ./mcs20000601.gif: No such file or directory du: ./ent_eng.PDF: No such file or directory du: ./ark: No such file or directory du: ./XtraStuf.mac: No such file or directory du: ./.fetchmail.pid: No such file or directory du: ./core: No such file or directory du: ./.gtkrc: No such file or directory du: ./.sawfish: No such file or directory du: ./mmm: No such file or directory du: ./.bashrc~: No such file or directory du: ./.fetchmailrc~: No such file or directory du: ./DTD: No such file or directory du: ./smooge_back.tgz: No such file or directory du: ./HOMESEARCH: No such file or directory du: ./mozilla-M17-2.i386.rpm: No such file or directory du: ./mozilla-devel-M17-2.i386.rpm: No such file or directory du: ./wml-2.0.2.tar.gz: No such file or directory du: ./gfont-1.0.3.tar.gz: No such file or directory du: ./sdf-2.001.tar.gz: No such file or directory 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
Please try this patch. -- H.J. Lu (hjl) -- 2000-08-14 H.J. Lu <hjl> * 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)))
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 +# 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 /null || fail=1
Resolved in fileutils-4.0x-2.