From babolo@links.ru  Tue Mar 12 22:23:13 2002
Return-Path: <babolo@links.ru>
Received: from aaz.links.ru (aaz.links.ru [193.125.152.37])
	by hub.freebsd.org (Postfix) with ESMTP id 0FE1137B402
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 12 Mar 2002 22:23:12 -0800 (PST)
Received: (from babolo@localhost)
	by aaz.links.ru (8.9.3/8.9.3) id JAA24905;
	Wed, 13 Mar 2002 09:31:04 +0300 (MSK)
Message-Id: <200203130631.JAA24905@aaz.links.ru>
Date: Wed, 13 Mar 2002 09:31:04 +0300 (MSK)
From: .@babolo.ru
Reply-To: .@babolo.ru
To: FreeBSD-gnats-submit@freebsd.org
Subject: rm -rf fails to delete nonexistent file [patch]
X-Send-Pr-Version: 3.2

>Number:         35842
>Category:       bin
>Synopsis:       rm -f nonexistent file successful but rm -fr is not in some conditions
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 12 22:30:01 PST 2002
>Closed-Date:    Thu Jan 01 02:28:31 PST 2004
>Last-Modified:  Thu Jan 01 02:28:31 PST 2004
>Originator:     Aleksandr A. Babaylov
>Release:        FreeBSD 4.5-STABLE i386
>Organization:
home
>Environment:

uname -a
FreeBSD cicuta.babolo.ru 4.5-STABLE FreeBSD 4.5-STABLE #7: Thu Feb 28 06:47:27 MSK 2002     babolo@cicuta.babolo.ru:/tmp/babolo/usr/src/sys/cicuta  i386

>Description:

choose nonexistant file in ro mount filesystem:

0cicuta~(53)>mount | grep mnt
/dev/ad4s1h on /mnt (ufs, local, read-only)

0cicuta~(54)>stat /mnt/a/e
Can't lstat /mnt/a/e

2cicuta~(55)>rm -f /mnt/a/e  

0cicuta~(56)>rm -fr /mnt/a/e 
rm: /mnt/a/e: Read-only file system

1cicuta~(57)>

This affects, for example buildworld on ro mount
sources.
(another thing - I do non understand contrib/libgmp/mp[zfq] 
existanse)

>How-To-Repeat:

See Description

>Fix:
	
--- bin/rm/rm.c	Wed Aug  1 09:15:56 2001
+++ bin/rm/rm.c	Wed Mar 13 08:54:54 2002
@@ -268,6 +268,14 @@
 				}
 				break;
 
+			case FTS_NS:
+				/*
+				 * FTS_NS: assume that if can't stat the file, it
+				 * can't be unlinked.
+				 */
+				if (fflag)
+					continue;
+				/* breakthrough */
 			default:
 				if (Pflag)
 					rm_overwrite(p->fts_accpath, NULL);

>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: <.@babolo.ru>
Cc: <FreeBSD-gnats-submit@FreeBSD.ORG>
Subject: Re: bin/35842: rm -rf fails to delete nonexistent file [patch]
Date: Fri, 15 Mar 2002 14:23:44 +1100 (EST)

 On Wed, 13 Mar 2002 .@babolo.ru wrote:
 
 > >Description:
 >
 > choose nonexistant file in ro mount filesystem:
 >
 > 0cicuta~(53)>mount | grep mnt
 > /dev/ad4s1h on /mnt (ufs, local, read-only)
 >
 > 0cicuta~(54)>stat /mnt/a/e
 > Can't lstat /mnt/a/e
 >
 > 2cicuta~(55)>rm -f /mnt/a/e
 >
 > 0cicuta~(56)>rm -fr /mnt/a/e
 > rm: /mnt/a/e: Read-only file system
 
 I think this is the same bug as in PR 16815.  If so, then it is a kernel
 bug in nfs.
 
 Bruce
 

From: "."@babolo.ru
To: bde@zeta.org.au (Bruce Evans)
Cc: FreeBSD-gnats-submit@FreeBSD.ORG, freebsd-bugs@FreeBSD.ORG
Subject: Re: bin/35842: rm -rf fails to delete nonexistent file [patch]
Date: Fri, 15 Mar 2002 08:00:22 +0300 (MSK)

 Bruce Evans writes:
 > On Wed, 13 Mar 2002 .@babolo.ru wrote:
 > > >Description:
 > >
 > > choose nonexistant file in ro mount filesystem:
 > >
 > > 0cicuta~(53)>mount | grep mnt
 > > /dev/ad4s1h on /mnt (ufs, local, read-only)
 > >
 > > 0cicuta~(54)>stat /mnt/a/e
 > > Can't lstat /mnt/a/e
 > >
 > > 2cicuta~(55)>rm -f /mnt/a/e
 > >
 > > 0cicuta~(56)>rm -fr /mnt/a/e
 > > rm: /mnt/a/e: Read-only file system
 > 
 > I think this is the same bug as in PR 16815.  If so, then it is a kernel
 > bug in nfs.
 No nfs involved in test - only ro ufs.
 IMHO no kernel bug - see at rm source and my patch
 
 -- 
 @BABOLO      http://links.ru/
State-Changed-From-To: open->closed 
State-Changed-By: kuriyama 
State-Changed-When: Thu Jan 1 02:27:26 PST 2004 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=35842 
>Unformatted:
