Skip to content

Commit 5149439

Browse files
dhowellsaxboe
authored andcommitted
ntfs3: Provide a splice-read wrapper
Provide a splice_read wrapper for NTFS3 to perform various checks before allowing the operation to proceed. Signed-off-by: David Howells <[email protected]> cc: Christoph Hellwig <[email protected]> cc: Al Viro <[email protected]> cc: Jens Axboe <[email protected]> cc: Konstantin Komarov <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected] cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent a7db503 commit 5149439

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

fs/ntfs3/file.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,35 @@ static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
744744
return generic_file_read_iter(iocb, iter);
745745
}
746746

747+
static ssize_t ntfs_file_splice_read(struct file *in, loff_t *ppos,
748+
struct pipe_inode_info *pipe,
749+
size_t len, unsigned int flags)
750+
{
751+
struct inode *inode = in->f_mapping->host;
752+
struct ntfs_inode *ni = ntfs_i(inode);
753+
754+
if (is_encrypted(ni)) {
755+
ntfs_inode_warn(inode, "encrypted i/o not supported");
756+
return -EOPNOTSUPP;
757+
}
758+
759+
#ifndef CONFIG_NTFS3_LZX_XPRESS
760+
if (ni->ni_flags & NI_FLAG_COMPRESSED_MASK) {
761+
ntfs_inode_warn(
762+
inode,
763+
"activate CONFIG_NTFS3_LZX_XPRESS to read external compressed files");
764+
return -EOPNOTSUPP;
765+
}
766+
#endif
767+
768+
if (is_dedup(ni)) {
769+
ntfs_inode_warn(inode, "read deduplicated not supported");
770+
return -EOPNOTSUPP;
771+
}
772+
773+
return generic_file_splice_read(in, ppos, pipe, len, flags);
774+
}
775+
747776
/*
748777
* ntfs_get_frame_pages
749778
*
@@ -1159,7 +1188,7 @@ const struct file_operations ntfs_file_operations = {
11591188
#ifdef CONFIG_COMPAT
11601189
.compat_ioctl = ntfs_compat_ioctl,
11611190
#endif
1162-
.splice_read = generic_file_splice_read,
1191+
.splice_read = ntfs_file_splice_read,
11631192
.mmap = ntfs_file_mmap,
11641193
.open = ntfs_file_open,
11651194
.fsync = generic_file_fsync,

0 commit comments

Comments
 (0)