vfs_syscalls.c (237032) | vfs_syscalls.c (237033) |
---|---|
1/*- 2 * Copyright (c) 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_syscalls.c 8.13 (Berkeley) 4/15/94 35 */ 36 37#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 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_syscalls.c 8.13 (Berkeley) 4/15/94 35 */ 36 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: head/sys/kern/vfs_syscalls.c 237032 2012-06-13 21:22:35Z pjd $"); | 38__FBSDID("$FreeBSD: head/sys/kern/vfs_syscalls.c 237033 2012-06-13 21:32:35Z pjd $"); |
39 40#include "opt_capsicum.h" 41#include "opt_compat.h" 42#include "opt_kdtrace.h" 43#include "opt_ktrace.h" 44 45#include <sys/param.h> 46#include <sys/systm.h> --- 1041 unchanged lines hidden (view full) --- 1088kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg, 1089 int flags, int mode) 1090{ 1091 struct proc *p = td->td_proc; 1092 struct filedesc *fdp = p->p_fd; 1093 struct file *fp; 1094 struct vnode *vp; 1095 int cmode; | 39 40#include "opt_capsicum.h" 41#include "opt_compat.h" 42#include "opt_kdtrace.h" 43#include "opt_ktrace.h" 44 45#include <sys/param.h> 46#include <sys/systm.h> --- 1041 unchanged lines hidden (view full) --- 1088kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg, 1089 int flags, int mode) 1090{ 1091 struct proc *p = td->td_proc; 1092 struct filedesc *fdp = p->p_fd; 1093 struct file *fp; 1094 struct vnode *vp; 1095 int cmode; |
1096 int type, indx = -1, error, error_open; | 1096 int type, indx = -1, error; |
1097 struct flock lf; 1098 struct nameidata nd; 1099 int vfslocked; 1100 cap_rights_t rights_needed = CAP_LOOKUP; 1101 1102 AUDIT_ARG_FFLAGS(flags); 1103 AUDIT_ARG_MODE(mode); 1104 /* XXX: audit dirfd */ --- 33 unchanged lines hidden (view full) --- 1138 * If the vn_open replaced the method vector, something 1139 * wonderous happened deep below and we just pass it up 1140 * pretending we know what we do. 1141 */ 1142 if (error == ENXIO && fp->f_ops != &badfileops) 1143 goto success; 1144 1145 /* | 1097 struct flock lf; 1098 struct nameidata nd; 1099 int vfslocked; 1100 cap_rights_t rights_needed = CAP_LOOKUP; 1101 1102 AUDIT_ARG_FFLAGS(flags); 1103 AUDIT_ARG_MODE(mode); 1104 /* XXX: audit dirfd */ --- 33 unchanged lines hidden (view full) --- 1138 * If the vn_open replaced the method vector, something 1139 * wonderous happened deep below and we just pass it up 1140 * pretending we know what we do. 1141 */ 1142 if (error == ENXIO && fp->f_ops != &badfileops) 1143 goto success; 1144 1145 /* |
1146 * Handle special fdopen() case. bleh. dupfdopen() is 1147 * responsible for dropping the old contents of ofiles[indx] 1148 * if it succeeds. | 1146 * Handle special fdopen() case. bleh. |
1149 * 1150 * Don't do this for relative (capability) lookups; we don't 1151 * understand exactly what would happen, and we don't think 1152 * that it ever should. 1153 */ 1154 if (nd.ni_strictrelative == 0 && 1155 (error == ENODEV || error == ENXIO) && 1156 td->td_dupfd >= 0) { | 1147 * 1148 * Don't do this for relative (capability) lookups; we don't 1149 * understand exactly what would happen, and we don't think 1150 * that it ever should. 1151 */ 1152 if (nd.ni_strictrelative == 0 && 1153 (error == ENODEV || error == ENXIO) && 1154 td->td_dupfd >= 0) { |
1157 /* XXX from fdopen */ 1158 error_open = error; 1159 if ((error = finstall(td, fp, &indx, flags)) != 0) 1160 goto bad_unlocked; 1161 if ((error = dupfdopen(td, fdp, indx, td->td_dupfd, 1162 flags, error_open)) == 0) | 1155 error = dupfdopen(td, fdp, td->td_dupfd, flags, error, 1156 &indx); 1157 if (error == 0) |
1163 goto success; 1164 } | 1158 goto success; 1159 } |
1160 |
|
1165 if (error == ERESTART) 1166 error = EINTR; 1167 goto bad_unlocked; 1168 } 1169 td->td_dupfd = 0; 1170 vfslocked = NDHASGIANT(&nd); 1171 NDFREE(&nd, NDF_ONLY_PNBUF); 1172 vp = nd.ni_vp; --- 3336 unchanged lines hidden (view full) --- 4509 } 4510 4511 error = falloc_noinstall(td, &fp); 4512 if (error) { 4513 vput(vp); 4514 VFS_UNLOCK_GIANT(vfslocked); 4515 return (error); 4516 } | 1161 if (error == ERESTART) 1162 error = EINTR; 1163 goto bad_unlocked; 1164 } 1165 td->td_dupfd = 0; 1166 vfslocked = NDHASGIANT(&nd); 1167 NDFREE(&nd, NDF_ONLY_PNBUF); 1168 vp = nd.ni_vp; --- 3336 unchanged lines hidden (view full) --- 4505 } 4506 4507 error = falloc_noinstall(td, &fp); 4508 if (error) { 4509 vput(vp); 4510 VFS_UNLOCK_GIANT(vfslocked); 4511 return (error); 4512 } |
4517 | |
4518 /* 4519 * An extra reference on `fp' has been held for us by 4520 * falloc_noinstall(). 4521 */ | 4513 /* 4514 * An extra reference on `fp' has been held for us by 4515 * falloc_noinstall(). 4516 */ |
4517 |
|
4522#ifdef INVARIANTS 4523 td->td_dupfd = -1; 4524#endif 4525 error = vn_open_vnode(vp, fmode, td->td_ucred, td, fp); 4526 if (error) { 4527 KASSERT(fp->f_ops == &badfileops, 4528 ("VOP_OPEN in fhopen() set f_ops")); 4529 KASSERT(td->td_dupfd < 0, --- 406 unchanged lines hidden --- | 4518#ifdef INVARIANTS 4519 td->td_dupfd = -1; 4520#endif 4521 error = vn_open_vnode(vp, fmode, td->td_ucred, td, fp); 4522 if (error) { 4523 KASSERT(fp->f_ops == &badfileops, 4524 ("VOP_OPEN in fhopen() set f_ops")); 4525 KASSERT(td->td_dupfd < 0, --- 406 unchanged lines hidden --- |