NetBSD Problem Report #9643
Received: (qmail 29162 invoked from network); 20 Mar 2000 10:06:57 -0000
Message-Id: <200003201006.CAA15988@slipstream.wofme.com>
Date: Mon, 20 Mar 2000 02:06:07 -0800 (PST)
From: William O Ferry <woferry@warp.wofme.com>
Reply-To: woferry@warp.wofme.com
To: gnats-bugs@gnats.netbsd.org
Subject: Unexpected behavior from rm -rf
X-Send-Pr-Version: 3.95
>Number: 9643
>Category: bin
>Synopsis: Unexpected behavior from rm -rf
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Mar 20 02:09:01 +0000 2000
>Closed-Date: Wed Apr 17 12:28:39 +0000 2002
>Last-Modified: Wed Apr 17 12:28:39 +0000 2002
>Originator: William O Ferry
>Release: 20000316
>Organization:
>Environment:
System: NetBSD slipstream 1.4U NetBSD 1.4U (kernel) #22: Fri Mar 17 00:03:32 PST 2000 root@slipstream.wofme.com:/usr/obj.i386/kernel i386
>Description:
Attempting to remove a nonexistant file from a read-only directory
with "rm -rf" causes the "Read-only file system" error to be displayed, rather
than no error at all. "man rm" says that with the -f flag "If the file does
not exist, do not display a diagnostic message or modify the exist status to
reflect an error.", yet rm returns an error if the file does not exist but is
in a read-only filesystem.
>How-To-Repeat:
Mount a filesystem as read-only.
Attempt to "rm -rf" a non-existant file in that mountpoint.
Ran across this one doing a "make clean" in an already cleaned, read-only
(using obj dirs) /usr/src.
>Fix:
Not sure exactly which piece of code should be corrected here. In rm
the "problem" begins with line 194. If the -r and -f flags were set we end
up at this clause, and needstat is false. So we fall out of the switch
statement and enter the second one, which ends up in the default case.
unlink() sets errno to EROFS, which does not count as true for the
NONEXISTENT() macro, so we end up at the warn() and print the error message
for EROFS. I suspect this code path could be adjusted to prevent this from
happening, I'm not sure where the best place to modify things would be.
The other possible problem is that unlink() returns EROFS in this
case. Should unlink() return ENOENT if the file doesn't exist whether the
directory is writable or not, or is EROFS the right error response?
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: mycroft
State-Changed-When: Wed Apr 17 05:27:25 PDT 2002
State-Changed-Why:
Fixed in rm.c 1.28 on 2001/11/22.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.