From owner-freebsd-bugs Fri Feb 18 19:20: 5 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 95ED137BB3B for ; Fri, 18 Feb 2000 19:20:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id TAA48835; Fri, 18 Feb 2000 19:20:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 2BEC437BB6C for ; 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 To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: kern/16815: Cannot "rm -rf" for not-existed file on read-only nfs Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Feb 18 19:20:01 PST 2000 >Closed-Date: >Last-Modified: >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: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message