diff options
author | jhb <jhb@FreeBSD.org> | 2008-01-07 20:05:19 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2008-01-07 20:05:19 +0000 |
commit | f8a246b9791d1450cf4945cc7b38f651a3a456ee (patch) | |
tree | 4cf9280569e048ce55d457d60918586c5cf023e5 /sys/sys/file.h | |
parent | 1b130ab3271ae64d5c2979889a661e27bbe422d9 (diff) | |
download | FreeBSD-src-f8a246b9791d1450cf4945cc7b38f651a3a456ee.zip FreeBSD-src-f8a246b9791d1450cf4945cc7b38f651a3a456ee.tar.gz |
Make ftruncate a 'struct file' operation rather than a vnode operation.
This makes it possible to support ftruncate() on non-vnode file types in
the future.
- 'struct fileops' grows a 'fo_truncate' method to handle an ftruncate() on
a given file descriptor.
- ftruncate() moves to kern/sys_generic.c and now just fetches a file
object and invokes fo_truncate().
- The vnode-specific portions of ftruncate() move to vn_truncate() in
vfs_vnops.c which implements fo_truncate() for vnode file types.
- Non-vnode file types return EINVAL in their fo_truncate() method.
Submitted by: rwatson
Diffstat (limited to 'sys/sys/file.h')
-rw-r--r-- | sys/sys/file.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/sys/file.h b/sys/sys/file.h index c5f4afb..757c884 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -69,6 +69,8 @@ typedef int fo_rdwr_t(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td); #define FOF_OFFSET 1 /* Use the offset in uio argument */ +typedef int fo_truncate_t(struct file *fp, off_t length, + struct ucred *active_cred, struct thread *td); typedef int fo_ioctl_t(struct file *fp, u_long com, void *data, struct ucred *active_cred, struct thread *td); typedef int fo_poll_t(struct file *fp, int events, @@ -82,6 +84,7 @@ typedef int fo_flags_t; struct fileops { fo_rdwr_t *fo_read; fo_rdwr_t *fo_write; + fo_truncate_t *fo_truncate; fo_ioctl_t *fo_ioctl; fo_poll_t *fo_poll; fo_kqfilter_t *fo_kqfilter; @@ -175,6 +178,7 @@ int _fdrop(struct file *fp, struct thread *td); */ fo_rdwr_t soo_read; fo_rdwr_t soo_write; +fo_truncate_t soo_truncate; fo_ioctl_t soo_ioctl; fo_poll_t soo_poll; fo_kqfilter_t soo_kqfilter; @@ -195,6 +199,7 @@ void fputsock(struct socket *sp); static __inline fo_rdwr_t fo_read; static __inline fo_rdwr_t fo_write; +static __inline fo_truncate_t fo_truncate; static __inline fo_ioctl_t fo_ioctl; static __inline fo_poll_t fo_poll; static __inline fo_kqfilter_t fo_kqfilter; @@ -226,6 +231,17 @@ fo_write(fp, uio, active_cred, flags, td) } static __inline int +fo_truncate(fp, length, active_cred, td) + struct file *fp; + off_t length; + struct ucred *active_cred; + struct thread *td; +{ + + return ((*fp->f_ops->fo_truncate)(fp, length, active_cred, td)); +} + +static __inline int fo_ioctl(fp, com, data, active_cred, td) struct file *fp; u_long com; |