GNU bug report logs -
#7823
Rm -f fails on non-existant file
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Wed, 12 Jan 2011 06:34:54 +0100
with message-id <87vd1uit1d.fsf <at> meyering.net>
and subject line Re: bug#7823: Rm -f fails on non-existant file
has caused the GNU bug report #7823,
regarding Rm -f fails on non-existant file
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
7823: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7823
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
Hi,
"rm -f" is supposed to succeed (and not print an error message) when the
given file name does not exist.
Unfortunately, I found a rare case where this is not happening.
It appears that when mounting a Windows filesystem using Samba, if I try
running:
command
#!/bin/sh
mkdir emptydir
rm -f emptydir/*
The shell leaves this "*" unchanged, and rm gives this name to unlink(2),
which oddly enough returns EINVAL (invalid argument) instead of the expected
ENOENT (no such file or directory!).
I'm guessing the smbfs people chose to give this as a special error when
"invalid" characters are used in the file name (this is a concept that doesn't
exist in Unix), but I'm not sure why it was so important to them to not
just return ENOENT in this case... But still, I think "rm" should behave
well in this case.
So currently, in the above example "rm -f emptydir/*", instead of just doing
nothing silently, prints an error message (Invalid Argument) and does exit(1).
This, for example, causes problems in Makefiles which run "rm -f" assuming it
won't fail (yes, I know, make has the "-" modifier - unfortunately some
makefiles don't use it...).
Anyway, in remove.c, you have
static inline bool
nonexistent_file_errno (int errnum)
{
switch (errnum)
{
case ENOENT:
case ENOTDIR:
return true;
default:
return false;
}
}
And I wonder whether EINVAL shouldn't also be added to it.
Thanks,
Nadav Har'El.
--
Nadav Har'El | Tuesday, Jan 11 2011, 6 Shevat 5771
nyh <at> math.technion.ac.il |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |Share your knowledge. It's a way to
http://nadav.harel.org.il |achieve immortality.
[Message part 3 (message/rfc822, inline)]
Eric Blake wrote:
...
> Actually, this is a bug fix, so I'm also squashing this NEWS blurb in,
> then pushing:
>
> diff --git i/NEWS w/NEWS
...
> + rm -f no longer fails for EINVAL or EILSEQ on file systems that
> + reject file names invalid for that file system.
Thanks to both of you.
This bug report was last modified 14 years and 134 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.