From owner-freebsd-hackers Thu Mar 14 04:32:59 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id EAA02758 for hackers-outgoing; Thu, 14 Mar 1996 04:32:59 -0800 (PST) Received: from yokogawa.co.jp (yhqfm.yokogawa.co.jp [202.33.29.34]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id EAA02752 for ; Thu, 14 Mar 1996 04:32:48 -0800 (PST) Received: from sjc.yokogawa.co.jp ([133.140.4.100]) by yokogawa.co.jp (8.6.9+2.4Wb3/3.3Wb4-firewall:08/09/94) with ESMTP id VAA27523 for ; Thu, 14 Mar 1996 21:32:15 +0900 Received: from leia.pa.yokogawa.co.jp by sjc.yokogawa.co.jp (8.7.1+2.6Wbeta4/6.4J.6-YOKOGAWA-R/GW) id VAA01459; Thu, 14 Mar 1996 21:32:14 +0900 (JST) Received: from cabbage by leia.pa.yokogawa.co.jp (16.8/6.4J.6-YOKOGAWA/pa) id AA29128; Thu, 14 Mar 96 21:32:13 +0900 Received: by cabbage.pa.yokogawa.co.jp (16.6/3.3Wb) id AA20013; Thu, 14 Mar 96 21:33:15 +0900 Date: Thu, 14 Mar 96 21:33:15 +0900 From: Mihoko Tanaka Message-Id: <9603141233.AA20013@cabbage.pa.yokogawa.co.jp> To: freebsd-hackers@freebsd.org Subject: PANIC ( remove a file on the read-only FS) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Hello all, I'm using FreeBSD-2.1.0R on my PC. When I removed a file which is on a read-only NFS by accident, panic occured ! In kern/vfs_lookup.c:lookup() ------------------------------ /* * We now have a segment name to search for, and a directory to search. */ unionlookup: ndp->ni_dvp = dp; error = VOP_LOOKUP(dp, &ndp->ni_vp, cnp); if (error) { #ifdef DIAGNOSTIC if (ndp->ni_vp != NULL) panic("leaf should be empty"); #endif ------------------------------ The function 'VOP_LOOKUP()' calls xxx_lookup() (xxx : file system name). When I remove a file which is on a read-only file system, VOP_LOOKUP() returns a error(EROFS) and ndp->ni_vp isn't NULL because it exist. So if I compile my kernel with 'DIAGNOSTIC', panic occurs . If without 'DIAGNOSTIC', the system conflicts somewhere and gets into panic. I made some patch for this trouble. Is it correct? Does anyone have another good idea? -----------------(cut here)------------------------------------------ --- vfs_lookup.c Wed Oct 25 18:17:15 1995 +++ vfs_lookup.c.new Thu Mar 14 20:23:05 1996 @@ -399,6 +399,9 @@ error = VOP_LOOKUP(dp, &ndp->ni_vp, cnp); if (error) { #ifdef DIAGNOSTIC + if (error == EROFS) + goto bad; + if (ndp->ni_vp != NULL) panic("leaf should be empty"); #endif @@ -422,7 +425,7 @@ * If creating and at end of pathname, then can consider * allowing file to be created. */ - if (rdonly) { + if (rdonly || (dp->v_mount->mnt_flag & MNT_RDONLY)) { error = EROFS; goto bad; } -----------------(cut here)------------------------------------------ -- Mihoko Tanaka