GNU bug report logs - #7823
Rm -f fails on non-existant file

Previous Next

Package: coreutils;

Reported by: "Nadav Har'El" <nyh <at> math.technion.ac.il>

Date: Tue, 11 Jan 2011 13:28:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: "Nadav Har'El" <nyh <at> math.technion.ac.il>
Subject: bug#7823: closed (Re: bug#7823: Rm -f fails on non-existant file)
Date: Wed, 12 Jan 2011 05:28:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#7823: Rm -f fails on non-existant file

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 7823 <at> debbugs.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)]
From: Jim Meyering <jim <at> meyering.net>
To: Eric Blake <eblake <at> redhat.com>
Cc: ramic <at> il.ibm.com, Nadav Har'El <nyh <at> math.technion.ac.il>,
	7823-done <at> debbugs.gnu.org
Subject: Re: bug#7823: Rm -f fails on non-existant file
Date: Wed, 12 Jan 2011 06:34:54 +0100
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.

[Message part 3 (message/rfc822, inline)]
From: "Nadav Har'El" <nyh <at> math.technion.ac.il>
To: bug-coreutils <at> gnu.org
Cc: ramic <at> il.ibm.com
Subject: Rm -f fails on non-existant file
Date: Tue, 11 Jan 2011 14:58:43 +0200
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.



This bug report was last modified 14 years and 135 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.