Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_default.c
Show First 20 Lines • Show All 285 Lines • ▼ Show 20 Lines | dirent_exists(struct vnode *vp, const char *dirname, struct thread *td) | ||||
size_t dirbuflen, len; | size_t dirbuflen, len; | ||||
off_t off; | off_t off; | ||||
struct dirent *dp; | struct dirent *dp; | ||||
struct vattr va; | struct vattr va; | ||||
ASSERT_VOP_LOCKED(vp, "vnode not locked"); | ASSERT_VOP_LOCKED(vp, "vnode not locked"); | ||||
KASSERT(vp->v_type == VDIR, ("vp %p is not a directory", vp)); | KASSERT(vp->v_type == VDIR, ("vp %p is not a directory", vp)); | ||||
error = VOP_GETATTR(vp, &va, td->td_ucred); | error = VOP_GETATTR(vp, 0, &va, td->td_ucred); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
dirbuflen = MAX(DEV_BSIZE, GENERIC_MAXDIRSIZ); | dirbuflen = MAX(DEV_BSIZE, GENERIC_MAXDIRSIZ); | ||||
if (dirbuflen < va.va_blocksize) | if (dirbuflen < va.va_blocksize) | ||||
dirbuflen = va.va_blocksize; | dirbuflen = va.va_blocksize; | ||||
dirbuf = malloc(dirbuflen, M_TEMP, M_WAITOK); | dirbuf = malloc(dirbuflen, M_TEMP, M_WAITOK); | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | vop_stdadvlock(struct vop_advlock_args *ap) | ||||
if (ap->a_fl->l_whence == SEEK_END) { | if (ap->a_fl->l_whence == SEEK_END) { | ||||
/* | /* | ||||
* The NFSv4 server must avoid doing a vn_lock() here, since it | * The NFSv4 server must avoid doing a vn_lock() here, since it | ||||
* can deadlock the nfsd threads, due to a LOR. Fortunately | * can deadlock the nfsd threads, due to a LOR. Fortunately | ||||
* the NFSv4 server always uses SEEK_SET and this code is | * the NFSv4 server always uses SEEK_SET and this code is | ||||
* only required for the SEEK_END case. | * only required for the SEEK_END case. | ||||
*/ | */ | ||||
vn_lock(vp, LK_SHARED | LK_RETRY); | vn_lock(vp, LK_SHARED | LK_RETRY); | ||||
error = VOP_GETATTR(vp, &vattr, curthread->td_ucred); | error = VOP_GETATTR(vp, 0, &vattr, curthread->td_ucred); | ||||
VOP_UNLOCK(vp); | VOP_UNLOCK(vp); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
} else | } else | ||||
vattr.va_size = 0; | vattr.va_size = 0; | ||||
return (lf_advlock(ap, &(vp->v_lockf), vattr.va_size)); | return (lf_advlock(ap, &(vp->v_lockf), vattr.va_size)); | ||||
} | } | ||||
int | int | ||||
vop_stdadvlockasync(struct vop_advlockasync_args *ap) | vop_stdadvlockasync(struct vop_advlockasync_args *ap) | ||||
{ | { | ||||
struct vnode *vp; | struct vnode *vp; | ||||
struct vattr vattr; | struct vattr vattr; | ||||
int error; | int error; | ||||
vp = ap->a_vp; | vp = ap->a_vp; | ||||
if (ap->a_fl->l_whence == SEEK_END) { | if (ap->a_fl->l_whence == SEEK_END) { | ||||
/* The size argument is only needed for SEEK_END. */ | /* The size argument is only needed for SEEK_END. */ | ||||
vn_lock(vp, LK_SHARED | LK_RETRY); | vn_lock(vp, LK_SHARED | LK_RETRY); | ||||
error = VOP_GETATTR(vp, &vattr, curthread->td_ucred); | error = VOP_GETATTR(vp, 0, &vattr, curthread->td_ucred); | ||||
VOP_UNLOCK(vp); | VOP_UNLOCK(vp); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
} else | } else | ||||
vattr.va_size = 0; | vattr.va_size = 0; | ||||
return (lf_advlockasync(ap, &(vp->v_lockf), vattr.va_size)); | return (lf_advlockasync(ap, &(vp->v_lockf), vattr.va_size)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 274 Lines • ▼ Show 20 Lines | vop_stdvptocnp(struct vop_vptocnp_args *ap) | ||||
struct thread *const td = curthread; | struct thread *const td = curthread; | ||||
struct ucred *const cred = td->td_ucred; | struct ucred *const cred = td->td_ucred; | ||||
struct dirent *dp; | struct dirent *dp; | ||||
struct vnode *mvp; | struct vnode *mvp; | ||||
if (vp->v_type != VDIR) | if (vp->v_type != VDIR) | ||||
return (ENOENT); | return (ENOENT); | ||||
error = VOP_GETATTR(vp, &va, cred); | error = VOP_GETATTR(vp, 0, &va, cred); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
VREF(vp); | VREF(vp); | ||||
locked = VOP_ISLOCKED(vp); | locked = VOP_ISLOCKED(vp); | ||||
VOP_UNLOCK(vp); | VOP_UNLOCK(vp); | ||||
NDINIT_ATVP(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF, UIO_SYSSPACE, | NDINIT_ATVP(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF, UIO_SYSSPACE, | ||||
"..", vp); | "..", vp); | ||||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | #endif | ||||
buf = NULL; | buf = NULL; | ||||
error = 0; | error = 0; | ||||
td = curthread; | td = curthread; | ||||
vap = &vattr; | vap = &vattr; | ||||
vp = ap->a_vp; | vp = ap->a_vp; | ||||
len = *ap->a_len; | len = *ap->a_len; | ||||
offset = *ap->a_offset; | offset = *ap->a_offset; | ||||
error = VOP_GETATTR(vp, vap, ap->a_cred); | error = VOP_GETATTR(vp, 0, vap, ap->a_cred); | ||||
if (error != 0) | if (error != 0) | ||||
goto out; | goto out; | ||||
fsize = vap->va_size; | fsize = vap->va_size; | ||||
iosize = vap->va_blocksize; | iosize = vap->va_blocksize; | ||||
if (iosize == 0) | if (iosize == 0) | ||||
iosize = BLKDEV_IOSIZE; | iosize = BLKDEV_IOSIZE; | ||||
if (iosize > maxphys) | if (iosize > maxphys) | ||||
iosize = maxphys; | iosize = maxphys; | ||||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | vop_stddeallocate(struct vop_deallocate_args *ap) | ||||
int error; | int error; | ||||
struct vattr va; | struct vattr va; | ||||
off_t noff, xfersize, rem; | off_t noff, xfersize, rem; | ||||
vp = ap->a_vp; | vp = ap->a_vp; | ||||
offset = *ap->a_offset; | offset = *ap->a_offset; | ||||
cred = ap->a_cred; | cred = ap->a_cred; | ||||
error = VOP_GETATTR(vp, &va, cred); | error = VOP_GETATTR(vp, 0, &va, cred); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
len = omin((off_t)va.va_size - offset, *ap->a_len); | len = omin((off_t)va.va_size - offset, *ap->a_len); | ||||
while (len > 0) { | while (len > 0) { | ||||
noff = offset; | noff = offset; | ||||
error = vn_bmap_seekhole_locked(vp, FIOSEEKDATA, &noff, cred); | error = vn_bmap_seekhole_locked(vp, FIOSEEKDATA, &noff, cred); | ||||
if (error) { | if (error) { | ||||
▲ Show 20 Lines • Show All 298 Lines • ▼ Show 20 Lines | vop_stdioctl(struct vop_ioctl_args *ap) | ||||
switch (ap->a_command) { | switch (ap->a_command) { | ||||
case FIOSEEKDATA: | case FIOSEEKDATA: | ||||
case FIOSEEKHOLE: | case FIOSEEKHOLE: | ||||
vp = ap->a_vp; | vp = ap->a_vp; | ||||
error = vn_lock(vp, LK_SHARED); | error = vn_lock(vp, LK_SHARED); | ||||
if (error != 0) | if (error != 0) | ||||
return (EBADF); | return (EBADF); | ||||
if (vp->v_type == VREG) | if (vp->v_type == VREG) | ||||
error = VOP_GETATTR(vp, &va, ap->a_cred); | error = VOP_GETATTR(vp, 0, &va, ap->a_cred); | ||||
else | else | ||||
error = ENOTTY; | error = ENOTTY; | ||||
if (error == 0) { | if (error == 0) { | ||||
offp = ap->a_data; | offp = ap->a_data; | ||||
if (*offp < 0 || *offp >= va.va_size) | if (*offp < 0 || *offp >= va.va_size) | ||||
error = ENXIO; | error = ENXIO; | ||||
else if (ap->a_command == FIOSEEKHOLE) | else if (ap->a_command == FIOSEEKHOLE) | ||||
*offp = va.va_size; | *offp = va.va_size; | ||||
▲ Show 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | vop_stdstat(struct vop_stat_args *a) | ||||
* about them. | * about them. | ||||
*/ | */ | ||||
vap->va_birthtime.tv_sec = -1; | vap->va_birthtime.tv_sec = -1; | ||||
vap->va_birthtime.tv_nsec = 0; | vap->va_birthtime.tv_nsec = 0; | ||||
vap->va_fsid = VNOVAL; | vap->va_fsid = VNOVAL; | ||||
vap->va_gen = 0; | vap->va_gen = 0; | ||||
vap->va_rdev = NODEV; | vap->va_rdev = NODEV; | ||||
error = VOP_GETATTR(vp, vap, a->a_active_cred); | error = VOP_GETATTR(vp, a->a_flags, vap, a->a_active_cred); | ||||
if (error) | if (error) | ||||
goto out; | goto out; | ||||
/* | /* | ||||
* Zero the spare stat fields | * Zero the spare stat fields | ||||
*/ | */ | ||||
bzero(sb, sizeof *sb); | bzero(sb, sizeof *sb); | ||||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |