Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_syscalls.c
Show First 20 Lines • Show All 3,348 Lines • ▼ Show 20 Lines | freebsd6_ftruncate(struct thread *td, struct freebsd6_ftruncate_args *uap) | ||||
struct ftruncate_args ouap; | struct ftruncate_args ouap; | ||||
ouap.fd = uap->fd; | ouap.fd = uap->fd; | ||||
ouap.length = uap->length; | ouap.length = uap->length; | ||||
return (sys_ftruncate(td, &ouap)); | return (sys_ftruncate(td, &ouap)); | ||||
} | } | ||||
#endif | #endif | ||||
/* | static int | ||||
* Sync an open file. | kern_fsync(struct thread *td, int fd, bool datasync) | ||||
*/ | |||||
#ifndef _SYS_SYSPROTO_H_ | |||||
struct fsync_args { | |||||
int fd; | |||||
}; | |||||
#endif | |||||
int | |||||
sys_fsync(td, uap) | |||||
struct thread *td; | |||||
struct fsync_args /* { | |||||
int fd; | |||||
} */ *uap; | |||||
{ | { | ||||
struct vnode *vp; | struct vnode *vp; | ||||
struct mount *mp; | struct mount *mp; | ||||
struct file *fp; | struct file *fp; | ||||
cap_rights_t rights; | cap_rights_t rights; | ||||
int error, lock_flags; | int error, lock_flags; | ||||
AUDIT_ARG_FD(uap->fd); | AUDIT_ARG_FD(fd); | ||||
error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_FSYNC), &fp); | error = getvnode(td, fd, cap_rights_init(&rights, CAP_FSYNC), &fp); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
vp = fp->f_vnode; | vp = fp->f_vnode; | ||||
#if 0 | |||||
if (datasync) | |||||
/* XXXKIB: compete outstanding aio writes */; | |||||
#endif | |||||
error = vn_start_write(vp, &mp, V_WAIT | PCATCH); | error = vn_start_write(vp, &mp, V_WAIT | PCATCH); | ||||
if (error != 0) | if (error != 0) | ||||
goto drop; | goto drop; | ||||
if (MNT_SHARED_WRITES(mp) || | if (MNT_SHARED_WRITES(mp) || | ||||
((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount))) { | ((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount))) { | ||||
lock_flags = LK_SHARED; | lock_flags = LK_SHARED; | ||||
} else { | } else { | ||||
lock_flags = LK_EXCLUSIVE; | lock_flags = LK_EXCLUSIVE; | ||||
} | } | ||||
vn_lock(vp, lock_flags | LK_RETRY); | vn_lock(vp, lock_flags | LK_RETRY); | ||||
AUDIT_ARG_VNODE1(vp); | AUDIT_ARG_VNODE1(vp); | ||||
if (vp->v_object != NULL) { | if (vp->v_object != NULL) { | ||||
VM_OBJECT_WLOCK(vp->v_object); | VM_OBJECT_WLOCK(vp->v_object); | ||||
vm_object_page_clean(vp->v_object, 0, 0, 0); | vm_object_page_clean(vp->v_object, 0, 0, 0); | ||||
VM_OBJECT_WUNLOCK(vp->v_object); | VM_OBJECT_WUNLOCK(vp->v_object); | ||||
} | } | ||||
error = VOP_FSYNC(vp, MNT_WAIT, td); | error = datasync ? VOP_FDATASYNC(vp, td) : VOP_FSYNC(vp, MNT_WAIT, td); | ||||
VOP_UNLOCK(vp, 0); | VOP_UNLOCK(vp, 0); | ||||
vn_finished_write(mp); | vn_finished_write(mp); | ||||
drop: | drop: | ||||
fdrop(fp, td); | fdrop(fp, td); | ||||
return (error); | return (error); | ||||
} | |||||
/* | |||||
* Sync an open file. | |||||
*/ | |||||
#ifndef _SYS_SYSPROTO_H_ | |||||
struct fsync_args { | |||||
int fd; | |||||
}; | |||||
#endif | |||||
int | |||||
sys_fsync(struct thread *td, struct fsync_args *uap) | |||||
{ | |||||
return (kern_fsync(td, uap->fd, false)); | |||||
} | |||||
int | |||||
sys_fdatasync(struct thread *td, struct fdatasync_args *uap) | |||||
{ | |||||
return (kern_fsync(td, uap->fd, true)); | |||||
} | } | ||||
/* | /* | ||||
* Rename files. Source and destination must either both be directories, or | * Rename files. Source and destination must either both be directories, or | ||||
* both not be directories. If target is a directory, it must be empty. | * both not be directories. If target is a directory, it must be empty. | ||||
*/ | */ | ||||
#ifndef _SYS_SYSPROTO_H_ | #ifndef _SYS_SYSPROTO_H_ | ||||
struct rename_args { | struct rename_args { | ||||
▲ Show 20 Lines • Show All 1,254 Lines • Show Last 20 Lines |