[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: du -D broken
From: |
Jim Meyering |
Subject: |
Re: du -D broken |
Date: |
Sun Oct 13 10:05:02 2002 |
User-agent: |
Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.3.50 (i686-pc-linux-gnu) |
Andreas Schwab <address@hidden> wrote:
> $ ln -s /boot A
> $ ln -s /bin B
> $ du -sD A B
> 4974 A
> du: `B': No such file or directory
>
> 2002-10-11 Andreas Schwab <address@hidden>
>
> * src/du.c (count_entry): Also save cwd when dereferencing
> arguments and we are at toplevel. Reported by Michal Svec
> <address@hidden>.
>
> --- src/du.c 2002/10/11 08:10:46 1.1
> +++ src/du.c 2002/10/11 08:11:09
> @@ -448,7 +448,8 @@ count_entry (const char *ent, int top, d
> to one of those. */
> if (strchr (ent, '/')
> || DOT_OR_DOTDOT (ent)
> - || (xstat == stat
> + || (((top && opt_dereference_arguments)
> + || xstat == stat)
> && lstat (ent, &e_buf) == 0
> && S_ISLNK (e_buf.st_mode)))
> {
>
Thank you both!
I've fixed it slightly differently:
Index: du.c
===================================================================
RCS file: /fetish/cu/src/du.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -p -u -r1.127 -r1.128
--- du.c 3 Oct 2002 09:31:33 -0000 1.127
+++ du.c 13 Oct 2002 13:59:25 -0000 1.128
@@ -401,10 +401,14 @@ count_entry (const char *ent, int top, d
{
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, d
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)))
{
- du -D broken, Andreas Schwab, 2002/10/11
- Re: du -D broken,
Jim Meyering <=