URL:
<http://savannah.gnu.org/bugs/?25538>
Summary: excluded files are still stat()ed
Project: GNU Core Utilities
Submitted by: devkev
Submitted on: Tue 10 Feb 2009 04:24:35 AM GMT
Category: None
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
My problem is that files I have excluded from du using -X or --exclude still
have stat() run on them. In particular, this is a problem when trying to
exclude some fuse filesystems on Linux, eg. sshfs and encfs, which deny all
access to other users (including root).
For example:
r...@bebique:~# du -axk /home/kev/mnt/sf
du: cannot access `/home/kev/mnt/sf/home': Permission denied
4 /home/kev/mnt/sf
r...@bebique:~# du -axk --exclude=/home/kev/mnt/sf/home /home/kev/mnt/sf
du: cannot access `/home/kev/mnt/sf/home': Permission denied
4 /home/kev/mnt/sf
r...@bebique:~# echo $?
1
r...@bebique:~#
The non-zero exit status is particularly troubling, since it means I cannot
chain other commands after du using '&&' whenever it's operating on a tree
that has these sorts of fuse fs's in it.
The only workaround at the moment is to exclude the parent directory, eg.
--exclude=~kev/mnt/sf in the example above. This unfortunately means that
everything else in that directory is also excluded.
r...@bebique:~# du -axk --exclude=/home/kev/mnt/sf /home/kev/mnt/sf
r...@bebique:~# echo $?
0
r...@bebique:~#
Having looked at the code, I'm not sure how this would best be fixed. The
list of excluded files is only used in process_file(), which is too late. I
presume that the stat() is happening inside fts_read(), which populates
end->fts_statp with the results of the stat() call. I suppose that extending
fts_read() to also respect the exclusion list would be fairly invasive.
Alternatively, the EPERM could persist during the fts_read(), but then be
somehow "forgotten about" later for excluded files, allowing the exit status
to return to being 0 (assuming no other genuine errors).
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?25538>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils