From nobody@FreeBSD.org  Fri Feb 18 19:11:05 2000
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21])
	by hub.freebsd.org (Postfix) with ESMTP id 2BEC437BB6C
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 18 Feb 2000 19:11:05 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.9.3/8.9.2) id TAA47092;
	Fri, 18 Feb 2000 19:11:04 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Message-Id: <200002190311.TAA47092@freefall.freebsd.org>
Date: Fri, 18 Feb 2000 19:11:04 -0800 (PST)
From: kuriyama@FreeBSD.org
Sender: nobody@FreeBSD.org
To: freebsd-gnats-submit@FreeBSD.org
Subject: Cannot "rm -rf" for not-existed file on read-only nfs
X-Send-Pr-Version: www-1.0

>Number:         16815
>Category:       kern
>Synopsis:       Cannot "rm -rf" for not-existed file on read-only nfs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 18 19:20:01 PST 2000
>Closed-Date:    Thu Jan 01 02:29:12 PST 2004
>Last-Modified:  Thu Jan 01 02:29:12 PST 2004
>Originator:     Jun Kuriyama
>Release:        4.0-CURRENT
>Organization:
FreeBSD Project
>Environment:
FreeBSD leda.sky.rim.or.jp 4.0-CURRENT FreeBSD 4.0-CURRENT #181: Sat Feb 19 11:03:55 JST 2000     junk@leda.sky.rim.or.jp:/home/junk/ncvs/src/sys/compile/NM  i386
>Description:
On nfs read-only mounted filesystem, you cannot "rm -rf" for not-existed file (or directory).
Kernel should not return EROFS at that case.
>How-To-Repeat:
% rm /usr/bin/a
rm: /usr/bin/a: No such file or directory
% rm -f /usr/bin/a
% rm -rf /usr/bin/a
% rm /usr/src/a
rm: /usr/src/a: No such file or directory
% rm -f /usr/src/a
% rm -rf /usr/src/a
rm: /usr/src/a: Read-only file system
%

>Fix:
Sorry, this may be broken because copy/paste space/tab issue.

Index: nfs_vnops.c
===================================================================
RCS file: /home/ncvs/src/sys/nfs/nfs_vnops.c,v
retrieving revision 1.150
diff -u -r1.150 nfs_vnops.c
--- nfs_vnops.c	2000/01/05 00:32:18	1.150
+++ nfs_vnops.c	2000/02/15 15:49:39
@@ -820,9 +820,6 @@
 	struct proc *p = cnp->cn_proc;
 
 	*vpp = NULLVP;
-	if ((flags & ISLASTCN) && (dvp->v_mount->mnt_flag & MNT_RDONLY) &&
-	    (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME))
-		return (EROFS);
 	if (dvp->v_type != VDIR)
 		return (ENOTDIR);
 	lockparent = flags & LOCKPARENT;
@@ -833,6 +830,11 @@
 		struct vattr vattr;
 		int vpid;
 
+		if ((flags & ISLASTCN) &&
+		    (dvp->v_mount->mnt_flag & MNT_RDONLY) &&
+		    (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME))
+			return (EROFS);
+
 		if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, p)) != 0) {
 			*vpp = NULLVP;
 			return (error);
@@ -894,6 +896,10 @@
 		goto nfsmout;
 	}
 	nfsm_getfh(fhp, fhsize, v3);
+
+	if ((flags & ISLASTCN) && (dvp->v_mount->mnt_flag & MNT_RDONLY) &&
+	    (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME))
+		return (EROFS);
 
 	/*
 	 * Handle RENAME case...


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->dillon 
Responsible-Changed-By: kuriyama 
Responsible-Changed-When: Tue Mar 14 06:58:17 PST 2000 
Responsible-Changed-Why:  
Pass this PR to dillon. 
Responsible-Changed-From-To: dillon->freebsd-bugs 
Responsible-Changed-By: keramida 
Responsible-Changed-When: Sat Feb 22 18:14:28 PST 2003 
Responsible-Changed-Why:  
Back to the free pool. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=16815 

From: "."@babolo.ru
To: Giorgos Keramidas <keramida@FreeBSD.ORG>
Cc: freebsd-bugs@FreeBSD.ORG, FreeBSD-gnats-submit@FreeBSD.ORG,
	dillon@FreeBSD.ORG
Subject: Re: kern/16815: Cannot "rm -rf" for not-existed file on read-only nfs
Date: Mon, 24 Feb 2003 01:54:01 +0300 (MSK)

 > Synopsis: Cannot "rm -rf" for not-existed file on read-only nfs
 > 
 > Responsible-Changed-From-To: dillon->freebsd-bugs
 > Responsible-Changed-By: keramida
 > Responsible-Changed-When: Sat Feb 22 18:14:28 PST 2003
 > Responsible-Changed-Why: 
 > Back to the free pool.
 Look at bin/35842 with patch
 

From: Bruce Evans <bde@zeta.org.au>
To: "."@babolo.ru
Cc: Giorgos Keramidas <keramida@FreeBSD.ORG>,
	<freebsd-bugs@FreeBSD.ORG>, <FreeBSD-gnats-submit@FreeBSD.ORG>,
	<dillon@FreeBSD.ORG>
Subject: Re: kern/16815: Cannot "rm -rf" for not-existed file on read-only
 nfs
Date: Mon, 24 Feb 2003 14:12:29 +1100 (EST)

 On Mon, 24 Feb 2003 .@babolo.ru wrote:
 
 > > Synopsis: Cannot "rm -rf" for not-existed file on read-only nfs
 > >
 > > Responsible-Changed-From-To: dillon->freebsd-bugs
 > > Responsible-Changed-By: keramida
 > > Responsible-Changed-When: Sat Feb 22 18:14:28 PST 2003
 > > Responsible-Changed-Why:
 > > Back to the free pool.
 > Look at bin/35842 with patch
 
 Yes; this seems to be simpler than I first though.  rm -f works so there
 is no problem in the kernel.
 
 Bruce
 

From: "."@babolo.ru
To: Bruce Evans <bde@zeta.org.au>
Cc: "."@babolo.ru, Giorgos Keramidas <keramida@FreeBSD.ORG>,
	freebsd-bugs@FreeBSD.ORG, FreeBSD-gnats-submit@FreeBSD.ORG,
	dillon@FreeBSD.ORG
Subject: Re: kern/16815: Cannot "rm -rf" for not-existed file on read-only nfs
Date: Mon, 24 Feb 2003 19:28:31 +0300 (MSK)

 > On Mon, 24 Feb 2003 .@babolo.ru wrote:
 > 
 > > > Synopsis: Cannot "rm -rf" for not-existed file on read-only nfs
 > > >
 > > > Responsible-Changed-From-To: dillon->freebsd-bugs
 > > > Responsible-Changed-By: keramida
 > > > Responsible-Changed-When: Sat Feb 22 18:14:28 PST 2003
 > > > Responsible-Changed-Why:
 > > > Back to the free pool.
 > > Look at bin/35842 with patch
 > Yes; this seems to be simpler than I first though.  rm -f works so there
 > is no problem in the kernel.
 I glad to see this.
 Is there chance for patch to be commited?
 
 
State-Changed-From-To: open->closed 
State-Changed-By: kuriyama 
State-Changed-When: Thu Jan 1 02:28:49 PST 2004 
State-Changed-Why:  
bin/35842 should fix this. 

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