vfs_vnops.c (4e27d36d38f4c3b12bcc1855c5d41527d08d1ce0) vfs_vnops.c (9696feebe2320c9976607df4090f91a34c6549c3)
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.

--- 55 unchanged lines hidden (view full) ---

64#include <sys/resourcevar.h>
65#include <sys/rwlock.h>
66#include <sys/sx.h>
67#include <sys/sysctl.h>
68#include <sys/ttycom.h>
69#include <sys/conf.h>
70#include <sys/syslog.h>
71#include <sys/unistd.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.

--- 55 unchanged lines hidden (view full) ---

64#include <sys/resourcevar.h>
65#include <sys/rwlock.h>
66#include <sys/sx.h>
67#include <sys/sysctl.h>
68#include <sys/ttycom.h>
69#include <sys/conf.h>
70#include <sys/syslog.h>
71#include <sys/unistd.h>
72#include <sys/user.h>
72
73#include <security/audit/audit.h>
74#include <security/mac/mac_framework.h>
75
76#include <vm/vm.h>
77#include <vm/vm_extern.h>
78#include <vm/pmap.h>
79#include <vm/vm_map.h>

--- 18 unchanged lines hidden (view full) ---

98 .fo_poll = vn_poll,
99 .fo_kqfilter = vn_kqfilter,
100 .fo_stat = vn_statfile,
101 .fo_close = vn_closefile,
102 .fo_chmod = vn_chmod,
103 .fo_chown = vn_chown,
104 .fo_sendfile = vn_sendfile,
105 .fo_seek = vn_seek,
73
74#include <security/audit/audit.h>
75#include <security/mac/mac_framework.h>
76
77#include <vm/vm.h>
78#include <vm/vm_extern.h>
79#include <vm/pmap.h>
80#include <vm/vm_map.h>

--- 18 unchanged lines hidden (view full) ---

99 .fo_poll = vn_poll,
100 .fo_kqfilter = vn_kqfilter,
101 .fo_stat = vn_statfile,
102 .fo_close = vn_closefile,
103 .fo_chmod = vn_chmod,
104 .fo_chown = vn_chown,
105 .fo_sendfile = vn_sendfile,
106 .fo_seek = vn_seek,
107 .fo_fill_kinfo = vn_fill_kinfo,
106 .fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE
107};
108
109static const int io_hold_cnt = 16;
110static int vn_io_fault_enable = 1;
111SYSCTL_INT(_debug, OID_AUTO, vn_io_fault_enable, CTLFLAG_RW,
112 &vn_io_fault_enable, 0, "Enable vn_io_fault lock avoidance");
113static u_long vn_io_faults_cnt;

--- 2130 unchanged lines hidden (view full) ---

2244 * A user having ACL_WRITE_DATA or ACL_WRITE_ATTRIBUTES
2245 * will be allowed to set the times [..] to the current
2246 * server time.
2247 */
2248 if (error != 0 && (vap->va_vaflags & VA_UTIMES_NULL) != 0)
2249 error = VOP_ACCESS(vp, VWRITE, cred, td);
2250 return (error);
2251}
108 .fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE
109};
110
111static const int io_hold_cnt = 16;
112static int vn_io_fault_enable = 1;
113SYSCTL_INT(_debug, OID_AUTO, vn_io_fault_enable, CTLFLAG_RW,
114 &vn_io_fault_enable, 0, "Enable vn_io_fault lock avoidance");
115static u_long vn_io_faults_cnt;

--- 2130 unchanged lines hidden (view full) ---

2246 * A user having ACL_WRITE_DATA or ACL_WRITE_ATTRIBUTES
2247 * will be allowed to set the times [..] to the current
2248 * server time.
2249 */
2250 if (error != 0 && (vap->va_vaflags & VA_UTIMES_NULL) != 0)
2251 error = VOP_ACCESS(vp, VWRITE, cred, td);
2252 return (error);
2253}
2254
2255int
2256vn_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
2257{
2258 struct vnode *vp;
2259 int error;
2260
2261 if (fp->f_type == DTYPE_FIFO)
2262 kif->kf_type = KF_TYPE_FIFO;
2263 else
2264 kif->kf_type = KF_TYPE_VNODE;
2265 vp = fp->f_vnode;
2266 vref(vp);
2267 FILEDESC_SUNLOCK(fdp);
2268 error = vn_fill_kinfo_vnode(vp, kif);
2269 vrele(vp);
2270 FILEDESC_SLOCK(fdp);
2271 return (error);
2272}
2273
2274int
2275vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif)
2276{
2277 struct vattr va;
2278 char *fullpath, *freepath;
2279 int error;
2280
2281 kif->kf_vnode_type = vntype_to_kinfo(vp->v_type);
2282 freepath = NULL;
2283 fullpath = "-";
2284 error = vn_fullpath(curthread, vp, &fullpath, &freepath);
2285 if (error == 0) {
2286 strlcpy(kif->kf_path, fullpath, sizeof(kif->kf_path));
2287 }
2288 if (freepath != NULL)
2289 free(freepath, M_TEMP);
2290
2291 /*
2292 * Retrieve vnode attributes.
2293 */
2294 va.va_fsid = VNOVAL;
2295 va.va_rdev = NODEV;
2296 vn_lock(vp, LK_SHARED | LK_RETRY);
2297 error = VOP_GETATTR(vp, &va, curthread->td_ucred);
2298 VOP_UNLOCK(vp, 0);
2299 if (error != 0)
2300 return (error);
2301 if (va.va_fsid != VNOVAL)
2302 kif->kf_un.kf_file.kf_file_fsid = va.va_fsid;
2303 else
2304 kif->kf_un.kf_file.kf_file_fsid =
2305 vp->v_mount->mnt_stat.f_fsid.val[0];
2306 kif->kf_un.kf_file.kf_file_fileid = va.va_fileid;
2307 kif->kf_un.kf_file.kf_file_mode = MAKEIMODE(va.va_type, va.va_mode);
2308 kif->kf_un.kf_file.kf_file_size = va.va_size;
2309 kif->kf_un.kf_file.kf_file_rdev = va.va_rdev;
2310 return (0);
2311}