From: Jens Axboe Date: Wed, 26 Apr 2006 12:40:08 +0000 (+0200) Subject: [PATCH] splice: add ->splice_write support for /dev/null X-Git-Tag: v2.6.17-rc3~10^2 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ebd32fc54bd04de6b3944587f25513c0681f98e;p=linux-2.6 [PATCH] splice: add ->splice_write support for /dev/null Useful for testing. Signed-off-by: Jens Axboe --- diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 66719f9d29..1fa9fa157c 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -578,6 +579,18 @@ static ssize_t write_null(struct file * file, const char __user * buf, return count; } +static int pipe_to_null(struct pipe_inode_info *info, struct pipe_buffer *buf, + struct splice_desc *sd) +{ + return sd->len; +} + +static ssize_t splice_write_null(struct pipe_inode_info *pipe,struct file *out, + loff_t *ppos, size_t len, unsigned int flags) +{ + return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null); +} + #ifdef CONFIG_MMU /* * For fun, we are using the MMU for this. @@ -785,6 +798,7 @@ static struct file_operations null_fops = { .llseek = null_lseek, .read = read_null, .write = write_null, + .splice_write = splice_write_null, }; #if defined(CONFIG_ISA) || !defined(__mc68000__)