splice: allow direct splicing with chardevs
PATCH RESEND 1/1 splice: allow direct splicing with chardevs
The original direct splicing mechanism from Jens required the input to be a regular file because it was avoiding the special socket case. It also recognized blkdevs as being close enough to a regular file. But it forgot about chardevs, which behave the same way and work fine here.
This commit adds the missing S_ISCHR condition so that chardevs such as /dev/urandom can be directly spliced without strangely returning -EINVAL.
---
Resending this with Jens' reviewed-by attached (he wrote the original code this patch modifies). The prior submission seems to have been buried/forgotten. This is presumably for Al's tree, though if somebody else wants to take it, I'd be happy to get it in anywhere. The prior forgotten thread is here for reference:
https://lore.kernel.org/lkml/[email protected]/T/#u
fs/splice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/splice.c +1 -1
@@ -824,7 +824,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,* piped splicing for that! */ i_mode =file_inode (in)->i_mode; -if (unlikely (!S_ISREG (i_mode) && !S_ISBLK (i_mode))) +if (unlikely (!S_ISREG (i_mode) && !S_ISBLK (i_mode) && !S_ISCHR (i_mode)))return -EINVAL ;/*
Signature · 1 line
2.35.1