Bug 16201
Summary: | find or du broken in RC1/Pinstripe | ||
---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | Stephen John Smoogen <smooge> |
Component: | findutils | Assignee: | Preston Brown <pbrown> |
Status: | CLOSED RAWHIDE | QA Contact: | |
Severity: | medium | Docs Contact: | |
Priority: | high | ||
Version: | 7.1 | ||
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | i386 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2000-08-15 15:03:14 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Stephen John Smoogen
2000-08-14 22:34:33 UTC
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. |