From f8a246b9791d1450cf4945cc7b38f651a3a456ee Mon Sep 17 00:00:00 2001 From: jhb Date: Mon, 7 Jan 2008 20:05:19 +0000 Subject: 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 --- sys/kern/kern_descrip.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sys/kern/kern_descrip.c') diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index d68854e..24438dd 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -2760,6 +2760,13 @@ badfo_readwrite(struct file *fp, struct uio *uio, struct ucred *active_cred, int } static int +badfo_truncate(struct file *fp, off_t length, struct ucred *active_cred, struct thread *td) +{ + + return (EINVAL); +} + +static int badfo_ioctl(struct file *fp, u_long com, void *data, struct ucred *active_cred, struct thread *td) { @@ -2797,6 +2804,7 @@ badfo_close(struct file *fp, struct thread *td) struct fileops badfileops = { .fo_read = badfo_readwrite, .fo_write = badfo_readwrite, + .fo_truncate = badfo_truncate, .fo_ioctl = badfo_ioctl, .fo_poll = badfo_poll, .fo_kqfilter = badfo_kqfilter, -- cgit v1.1