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/fs/fifofs | |
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/fs/fifofs')
-rw-r--r-- | sys/fs/fifofs/fifo_vnops.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c index 78718db..9b0ad1e 100644 --- a/sys/fs/fifofs/fifo_vnops.c +++ b/sys/fs/fifofs/fifo_vnops.c @@ -61,10 +61,12 @@ static fo_poll_t fifo_poll_f; static fo_kqfilter_t fifo_kqfilter_f; static fo_stat_t fifo_stat_f; static fo_close_t fifo_close_f; +static fo_truncate_t fifo_truncate_f; struct fileops fifo_ops_f = { .fo_read = fifo_read_f, .fo_write = fifo_write_f, + .fo_truncate = fifo_truncate_f, .fo_ioctl = fifo_ioctl_f, .fo_poll = fifo_poll_f, .fo_kqfilter = fifo_kqfilter_f, @@ -724,6 +726,13 @@ fifo_stat_f(struct file *fp, struct stat *sb, struct ucred *cred, struct thread } static int +fifo_truncate_f(struct file *fp, off_t length, struct ucred *cred, struct thread *td) +{ + + return (vnops.fo_truncate(fp, length, cred, td)); +} + +static int fifo_write_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *td) { struct fifoinfo *fip; |