diff options
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index df2006ba0cfa..a38619a4a6af 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -3041,6 +3041,30 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in, | |||
3041 | return 0; | 3041 | return 0; |
3042 | } | 3042 | } |
3043 | 3043 | ||
3044 | |||
3045 | /* | ||
3046 | * Performs common checks before doing a file copy/clone | ||
3047 | * from @file_in to @file_out. | ||
3048 | */ | ||
3049 | int generic_file_rw_checks(struct file *file_in, struct file *file_out) | ||
3050 | { | ||
3051 | struct inode *inode_in = file_inode(file_in); | ||
3052 | struct inode *inode_out = file_inode(file_out); | ||
3053 | |||
3054 | /* Don't copy dirs, pipes, sockets... */ | ||
3055 | if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode)) | ||
3056 | return -EISDIR; | ||
3057 | if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) | ||
3058 | return -EINVAL; | ||
3059 | |||
3060 | if (!(file_in->f_mode & FMODE_READ) || | ||
3061 | !(file_out->f_mode & FMODE_WRITE) || | ||
3062 | (file_out->f_flags & O_APPEND)) | ||
3063 | return -EBADF; | ||
3064 | |||
3065 | return 0; | ||
3066 | } | ||
3067 | |||
3044 | int pagecache_write_begin(struct file *file, struct address_space *mapping, | 3068 | int pagecache_write_begin(struct file *file, struct address_space *mapping, |
3045 | loff_t pos, unsigned len, unsigned flags, | 3069 | loff_t pos, unsigned len, unsigned flags, |
3046 | struct page **pagep, void **fsdata) | 3070 | struct page **pagep, void **fsdata) |