summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_pipe.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2008-01-07 20:05:19 +0000
committerjhb <jhb@FreeBSD.org>2008-01-07 20:05:19 +0000
commitf8a246b9791d1450cf4945cc7b38f651a3a456ee (patch)
tree4cf9280569e048ce55d457d60918586c5cf023e5 /sys/kern/sys_pipe.c
parent1b130ab3271ae64d5c2979889a661e27bbe422d9 (diff)
downloadFreeBSD-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/kern/sys_pipe.c')
-rw-r--r--sys/kern/sys_pipe.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 27ecf80..457f30b 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -140,6 +140,7 @@ __FBSDID("$FreeBSD$");
*/
static fo_rdwr_t pipe_read;
static fo_rdwr_t pipe_write;
+static fo_truncate_t pipe_truncate;
static fo_ioctl_t pipe_ioctl;
static fo_poll_t pipe_poll;
static fo_kqfilter_t pipe_kqfilter;
@@ -149,6 +150,7 @@ static fo_close_t pipe_close;
static struct fileops pipeops = {
.fo_read = pipe_read,
.fo_write = pipe_write,
+ .fo_truncate = pipe_truncate,
.fo_ioctl = pipe_ioctl,
.fo_poll = pipe_poll,
.fo_kqfilter = pipe_kqfilter,
@@ -1230,6 +1232,18 @@ pipe_write(fp, uio, active_cred, flags, td)
return (error);
}
+/* ARGSUSED */
+static int
+pipe_truncate(fp, length, active_cred, td)
+ struct file *fp;
+ off_t length;
+ struct ucred *active_cred;
+ struct thread *td;
+{
+
+ return (EINVAL);
+}
+
/*
* we implement a very minimal set of ioctls for compatibility with sockets.
*/
OpenPOWER on IntegriCloud