VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   33 Branches   57 Tags
author: Darrick J. Wong <darrick.wong@oracle.com> 2016-10-03 09:11:14 -0700 committer: Darrick J. Wong <darrick.wong@oracle.com> 2016-10-03 09:11:14 -0700 commit: 71be6b4942dd64bc17728f82f787be98fd8afed7 parent: 0a6eab8bd4e0120d49511acbb294797d96ef9e4a
Commit Summary:
vfs: add a FALLOC_FL_UNSHARE mode to fallocate to unshare a range of blocks
Diffstat:
1 file changed, 5 insertions, 0 deletions
diff --git a/fs/open.c b/fs/open.c
index 4fd6e256f4f4..d58525dda28d 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -256,6 +256,11 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
 	    (mode & ~FALLOC_FL_INSERT_RANGE))
 		return -EINVAL;
 
+	/* Unshare range should only be used with allocate mode. */
+	if ((mode & FALLOC_FL_UNSHARE_RANGE) &&
+	    (mode & ~(FALLOC_FL_UNSHARE_RANGE | FALLOC_FL_KEEP_SIZE)))
+		return -EINVAL;
+
 	if (!(file->f_mode & FMODE_WRITE))
 		return -EBADF;