vfs_vnops.c (94861) | vfs_vnops.c (96616) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94 | 1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94 |
39 * $FreeBSD: head/sys/kern/vfs_vnops.c 94861 2002-04-16 17:11:34Z jhb $ | 39 * $FreeBSD: head/sys/kern/vfs_vnops.c 96616 2002-05-14 21:59:49Z jeff $ |
40 */ 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/fcntl.h> 45#include <sys/file.h> 46#include <sys/stat.h> 47#include <sys/proc.h> --- 53 unchanged lines hidden (view full) --- 101 struct ucred *cred; 102{ 103 struct vnode *vp; 104 struct mount *mp; 105 struct thread *td = ndp->ni_cnd.cn_thread; 106 struct vattr vat; 107 struct vattr *vap = &vat; 108 int mode, fmode, error; | 40 */ 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/fcntl.h> 45#include <sys/file.h> 46#include <sys/stat.h> 47#include <sys/proc.h> --- 53 unchanged lines hidden (view full) --- 101 struct ucred *cred; 102{ 103 struct vnode *vp; 104 struct mount *mp; 105 struct thread *td = ndp->ni_cnd.cn_thread; 106 struct vattr vat; 107 struct vattr *vap = &vat; 108 int mode, fmode, error; |
109#ifndef LOOKUP_EXCLUSIVE | 109#ifdef LOOKUP_SHARED |
110 int exclusive; /* The current intended lock state */ 111 112 exclusive = 0; 113#endif 114 115restart: 116 fmode = *flagp; 117 if (fmode & O_CREAT) { --- 26 unchanged lines hidden (view full) --- 144 if (error) { 145 NDFREE(ndp, NDF_ONLY_PNBUF); 146 return (error); 147 } 148 ASSERT_VOP_UNLOCKED(ndp->ni_dvp, "create"); 149 ASSERT_VOP_LOCKED(ndp->ni_vp, "create"); 150 fmode &= ~O_TRUNC; 151 vp = ndp->ni_vp; | 110 int exclusive; /* The current intended lock state */ 111 112 exclusive = 0; 113#endif 114 115restart: 116 fmode = *flagp; 117 if (fmode & O_CREAT) { --- 26 unchanged lines hidden (view full) --- 144 if (error) { 145 NDFREE(ndp, NDF_ONLY_PNBUF); 146 return (error); 147 } 148 ASSERT_VOP_UNLOCKED(ndp->ni_dvp, "create"); 149 ASSERT_VOP_LOCKED(ndp->ni_vp, "create"); 150 fmode &= ~O_TRUNC; 151 vp = ndp->ni_vp; |
152#ifndef LOOKUP_EXCLUSIVE | 152#ifdef LOOKUP_SHARED |
153 exclusive = 1; 154#endif 155 } else { 156 if (ndp->ni_dvp == ndp->ni_vp) 157 vrele(ndp->ni_dvp); 158 else 159 vput(ndp->ni_dvp); 160 ndp->ni_dvp = NULL; 161 vp = ndp->ni_vp; 162 if (fmode & O_EXCL) { 163 error = EEXIST; 164 goto bad; 165 } 166 fmode &= ~O_CREAT; 167 } 168 } else { 169 ndp->ni_cnd.cn_nameiop = LOOKUP; | 153 exclusive = 1; 154#endif 155 } else { 156 if (ndp->ni_dvp == ndp->ni_vp) 157 vrele(ndp->ni_dvp); 158 else 159 vput(ndp->ni_dvp); 160 ndp->ni_dvp = NULL; 161 vp = ndp->ni_vp; 162 if (fmode & O_EXCL) { 163 error = EEXIST; 164 goto bad; 165 } 166 fmode &= ~O_CREAT; 167 } 168 } else { 169 ndp->ni_cnd.cn_nameiop = LOOKUP; |
170#ifndef LOOKUP_EXCLUSIVE | 170#ifdef LOOKUP_SHARED |
171 ndp->ni_cnd.cn_flags = 172 ((fmode & O_NOFOLLOW) ? NOFOLLOW : FOLLOW) | 173 LOCKSHARED | LOCKLEAF; 174#else 175 ndp->ni_cnd.cn_flags = 176 ((fmode & O_NOFOLLOW) ? NOFOLLOW : FOLLOW) | LOCKLEAF; 177#endif 178 if ((error = namei(ndp)) != 0) --- 29 unchanged lines hidden (view full) --- 208 } 209 } 210 if ((error = VOP_OPEN(vp, fmode, cred, td)) != 0) 211 goto bad; 212 /* 213 * Make sure that a VM object is created for VMIO support. 214 */ 215 if (vn_canvmio(vp) == TRUE) { | 171 ndp->ni_cnd.cn_flags = 172 ((fmode & O_NOFOLLOW) ? NOFOLLOW : FOLLOW) | 173 LOCKSHARED | LOCKLEAF; 174#else 175 ndp->ni_cnd.cn_flags = 176 ((fmode & O_NOFOLLOW) ? NOFOLLOW : FOLLOW) | LOCKLEAF; 177#endif 178 if ((error = namei(ndp)) != 0) --- 29 unchanged lines hidden (view full) --- 208 } 209 } 210 if ((error = VOP_OPEN(vp, fmode, cred, td)) != 0) 211 goto bad; 212 /* 213 * Make sure that a VM object is created for VMIO support. 214 */ 215 if (vn_canvmio(vp) == TRUE) { |
216#ifndef LOOKUP_EXCLUSIVE | 216#ifdef LOOKUP_SHARED |
217 int flock; 218 219 if (!exclusive && VOP_GETVOBJECT(vp, NULL) != 0) 220 VOP_LOCK(vp, LK_UPGRADE, td); 221 /* 222 * In cases where the object is marked as dead object_create 223 * will unlock and relock exclusive. It is safe to call in 224 * here with a shared lock because we only examine fields that --- 6 unchanged lines hidden (view full) --- 231 if ((error = vfs_object_create(vp, td, cred)) != 0) { 232 VOP_UNLOCK(vp, 0, td); 233 VOP_CLOSE(vp, fmode, cred, td); 234 NDFREE(ndp, NDF_ONLY_PNBUF); 235 vrele(vp); 236 *flagp = fmode; 237 return (error); 238 } | 217 int flock; 218 219 if (!exclusive && VOP_GETVOBJECT(vp, NULL) != 0) 220 VOP_LOCK(vp, LK_UPGRADE, td); 221 /* 222 * In cases where the object is marked as dead object_create 223 * will unlock and relock exclusive. It is safe to call in 224 * here with a shared lock because we only examine fields that --- 6 unchanged lines hidden (view full) --- 231 if ((error = vfs_object_create(vp, td, cred)) != 0) { 232 VOP_UNLOCK(vp, 0, td); 233 VOP_CLOSE(vp, fmode, cred, td); 234 NDFREE(ndp, NDF_ONLY_PNBUF); 235 vrele(vp); 236 *flagp = fmode; 237 return (error); 238 } |
239#ifndef LOOKUP_EXCLUSIVE | 239#ifdef LOOKUP_SHARED |
240 flock = VOP_ISLOCKED(vp, td); 241 if (!exclusive && flock == LK_EXCLUSIVE) 242 VOP_LOCK(vp, LK_DOWNGRADE, td); 243#endif 244 } 245 246 if (fmode & FWRITE) 247 vp->v_writecount++; --- 804 unchanged lines hidden --- | 240 flock = VOP_ISLOCKED(vp, td); 241 if (!exclusive && flock == LK_EXCLUSIVE) 242 VOP_LOCK(vp, LK_DOWNGRADE, td); 243#endif 244 } 245 246 if (fmode & FWRITE) 247 vp->v_writecount++; --- 804 unchanged lines hidden --- |