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/opencrypto/cryptodev.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sys/opencrypto') diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index c9fc6d2..fe7372b 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -86,6 +86,8 @@ struct fcrypt { static int cryptof_rw(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *); +static int cryptof_truncate(struct file *, off_t, struct ucred *, + struct thread *); static int cryptof_ioctl(struct file *, u_long, void *, struct ucred *, struct thread *); static int cryptof_poll(struct file *, int, struct ucred *, struct thread *); @@ -97,6 +99,7 @@ static int cryptof_close(struct file *, struct thread *); static struct fileops cryptofops = { .fo_read = cryptof_rw, .fo_write = cryptof_rw, + .fo_truncate = cryptof_truncate, .fo_ioctl = cryptof_ioctl, .fo_poll = cryptof_poll, .fo_kqfilter = cryptof_kqfilter, @@ -129,6 +132,17 @@ cryptof_rw( return (EIO); } +static int +cryptof_truncate( + struct file *fp, + off_t length, + struct ucred *active_cred, + struct thread *td) +{ + + return (EINVAL); +} + /* * Check a crypto identifier to see if it requested * a software device/driver. This can be done either -- cgit v1.1