summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2002-10-13 13:59:25 +0000
committerJim Meyering <jim@meyering.net>2002-10-13 13:59:25 +0000
commite408ac408cd769543db22d82db7c1689972ee727 (patch)
treecb9b09851bd50237cefe559ed44504d3b82430c0
parent6dafd5b2fcb0fa381725ca565a7905176e2fca27 (diff)
downloadcoreutils-e408ac408cd769543db22d82db7c1689972ee727.tar.xz
(count_entry): Also save cwd when dereferencing (via --dereference-args, -D)
a command-line argument. Reported by Michal Svec. Based on a patch by Andreas Schwab.
-rw-r--r--src/du.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/du.c b/src/du.c
index a60ad6411..1da41411a 100644
--- a/src/du.c
+++ b/src/du.c
@@ -401,10 +401,14 @@ count_entry (const char *ent, int top, dev_t last_dev, int depth)
{
uintmax_t size;
struct stat stat_buf;
+ int (*tmp_stat) ();
- if (((top && opt_dereference_arguments)
- ? stat (ent, &stat_buf)
- : (*xstat) (ent, &stat_buf)) < 0)
+ if (top && opt_dereference_arguments)
+ tmp_stat = stat;
+ else
+ tmp_stat = xstat;
+
+ if ((*tmp_stat) (ent, &stat_buf) < 0)
{
error (0, errno, "%s", quote (path->text));
exit_status = 1;
@@ -448,7 +452,7 @@ count_entry (const char *ent, int top, dev_t last_dev, int depth)
to one of those. */
if (strchr (ent, '/')
|| DOT_OR_DOTDOT (ent)
- || (xstat == stat
+ || (tmp_stat == stat
&& lstat (ent, &e_buf) == 0
&& S_ISLNK (e_buf.st_mode)))
{