From 1548d6d880fbcc83d57825b6357f7fa0be8148f8 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sat, 7 Jan 2017 19:14:29 +0100 Subject: splice: introduce FMODE_SPLICE_READ and FMODE_SPLICE_WRITE Introduce FMODE_SPLICE_READ and FMODE_SPLICE_WRITE. These modes check whether it is legal to read or write a file using splice. Both get automatically set on regular files and are not checked when a 'struct fileoperations' includes the splice_{read,write} methods. Change-Id: Ice6a3fab20bf0ac131f8d908f4bb0f7dc34bf4e3 Suggested-by: Linus Torvalds Cc: Al Viro Signed-off-by: Johannes Thumshirn --- fs/open.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'fs/open.c') diff --git a/fs/open.c b/fs/open.c index 5f129683b..1930f2362 100644 --- a/fs/open.c +++ b/fs/open.c @@ -680,6 +680,10 @@ static int do_dentry_open(struct file *f, return 0; } + if (S_ISREG(inode->i_mode)) + f->f_mode |= FMODE_SPLICE_WRITE | FMODE_SPLICE_READ; + + f->f_op = fops_get(inode->i_fop); error = security_file_open(f, cred); -- cgit v1.2.3