vfs_vnops.c (184118) | vfs_vnops.c (184413) |
---|---|
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. --- 21 unchanged lines hidden (view full) --- 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94 35 */ 36 37#include <sys/cdefs.h> | 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. --- 21 unchanged lines hidden (view full) --- 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94 35 */ 36 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: head/sys/kern/vfs_vnops.c 184118 2008-10-21 09:55:49Z kib $"); | 38__FBSDID("$FreeBSD: head/sys/kern/vfs_vnops.c 184413 2008-10-28 13:44:11Z trasz $"); |
39 40#include "opt_mac.h" 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/fcntl.h> 45#include <sys/file.h> 46#include <sys/kdb.h> --- 63 unchanged lines hidden (view full) --- 110 struct ucred *cred; 111 struct file *fp; 112{ 113 struct vnode *vp; 114 struct mount *mp; 115 struct thread *td = ndp->ni_cnd.cn_thread; 116 struct vattr vat; 117 struct vattr *vap = &vat; | 39 40#include "opt_mac.h" 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/fcntl.h> 45#include <sys/file.h> 46#include <sys/kdb.h> --- 63 unchanged lines hidden (view full) --- 110 struct ucred *cred; 111 struct file *fp; 112{ 113 struct vnode *vp; 114 struct mount *mp; 115 struct thread *td = ndp->ni_cnd.cn_thread; 116 struct vattr vat; 117 struct vattr *vap = &vat; |
118 int mode, fmode, error; | 118 int fmode, error; 119 accmode_t accmode; |
119 int vfslocked, mpsafe; 120 121 mpsafe = ndp->ni_cnd.cn_flags & MPSAFE; 122restart: 123 vfslocked = 0; 124 fmode = *flagp; 125 if (fmode & O_CREAT) { 126 ndp->ni_cnd.cn_nameiop = CREATE; --- 70 unchanged lines hidden (view full) --- 197 if (vp->v_type == VLNK) { 198 error = EMLINK; 199 goto bad; 200 } 201 if (vp->v_type == VSOCK) { 202 error = EOPNOTSUPP; 203 goto bad; 204 } | 120 int vfslocked, mpsafe; 121 122 mpsafe = ndp->ni_cnd.cn_flags & MPSAFE; 123restart: 124 vfslocked = 0; 125 fmode = *flagp; 126 if (fmode & O_CREAT) { 127 ndp->ni_cnd.cn_nameiop = CREATE; --- 70 unchanged lines hidden (view full) --- 198 if (vp->v_type == VLNK) { 199 error = EMLINK; 200 goto bad; 201 } 202 if (vp->v_type == VSOCK) { 203 error = EOPNOTSUPP; 204 goto bad; 205 } |
205 mode = 0; | 206 accmode = 0; |
206 if (fmode & (FWRITE | O_TRUNC)) { 207 if (vp->v_type == VDIR) { 208 error = EISDIR; 209 goto bad; 210 } | 207 if (fmode & (FWRITE | O_TRUNC)) { 208 if (vp->v_type == VDIR) { 209 error = EISDIR; 210 goto bad; 211 } |
211 mode |= VWRITE; | 212 accmode |= VWRITE; |
212 } 213 if (fmode & FREAD) | 213 } 214 if (fmode & FREAD) |
214 mode |= VREAD; | 215 accmode |= VREAD; |
215 if (fmode & FEXEC) | 216 if (fmode & FEXEC) |
216 mode |= VEXEC; | 217 accmode |= VEXEC; |
217 if (fmode & O_APPEND) | 218 if (fmode & O_APPEND) |
218 mode |= VAPPEND; | 219 accmode |= VAPPEND; |
219#ifdef MAC | 220#ifdef MAC |
220 error = mac_vnode_check_open(cred, vp, mode); | 221 error = mac_vnode_check_open(cred, vp, accmode); |
221 if (error) 222 goto bad; 223#endif 224 if ((fmode & O_CREAT) == 0) { | 222 if (error) 223 goto bad; 224#endif 225 if ((fmode & O_CREAT) == 0) { |
225 if (mode & VWRITE) { | 226 if (accmode & VWRITE) { |
226 error = vn_writechk(vp); 227 if (error) 228 goto bad; 229 } | 227 error = vn_writechk(vp); 228 if (error) 229 goto bad; 230 } |
230 if (mode) { 231 error = VOP_ACCESS(vp, mode, cred, td); | 231 if (accmode) { 232 error = VOP_ACCESS(vp, accmode, cred, td); |
232 if (error) 233 goto bad; 234 } 235 } 236 if ((error = VOP_OPEN(vp, fmode, cred, td, fp)) != 0) 237 goto bad; 238 239 if (fmode & FWRITE) --- 1039 unchanged lines hidden --- | 233 if (error) 234 goto bad; 235 } 236 } 237 if ((error = VOP_OPEN(vp, fmode, cred, td, fp)) != 0) 238 goto bad; 239 240 if (fmode & FWRITE) --- 1039 unchanged lines hidden --- |