Commit 9e79b132 authored by Amir Goldstein's avatar Amir Goldstein Committed by Miklos Szeredi

vfs: deny fallocate() on directory

There was an obscure use case of fallocate of directory inode
in the vfs helper with the comment:
"Let individual file system decide if it supports preallocation
 for directories or not."

But there is no in-tree file system that implements fallocate
for directory operations.

Deny an attempt to fallocate a directory with EISDIR error.

This change is needed prior to converting sb_start_write()
to  file_start_write(), so freeze protection is correctly
handled for cases of fallocate file and blockdev.

Cc: linux-api@vger.kernel.org
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent af7bd4dc
...@@ -301,12 +301,10 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len) ...@@ -301,12 +301,10 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
if (S_ISFIFO(inode->i_mode)) if (S_ISFIFO(inode->i_mode))
return -ESPIPE; return -ESPIPE;
/* if (S_ISDIR(inode->i_mode))
* Let individual file system decide if it supports preallocation return -EISDIR;
* for directories or not.
*/ if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))
if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode) &&
!S_ISBLK(inode->i_mode))
return -ENODEV; return -ENODEV;
/* Check for wrap through zero too */ /* Check for wrap through zero too */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment