diff options
Diffstat (limited to 'fs/udf/file.c')
-rw-r--r-- | fs/udf/file.c | 72 |
1 files changed, 34 insertions, 38 deletions
diff --git a/fs/udf/file.c b/fs/udf/file.c index 67bf36bd3e6e..5d7a4ea27753 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <linux/udf_fs.h> | 30 | #include <linux/udf_fs.h> |
31 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
33 | #include <linux/string.h> /* memset */ | 33 | #include <linux/string.h> /* memset */ |
34 | #include <linux/capability.h> | 34 | #include <linux/capability.h> |
35 | #include <linux/errno.h> | 35 | #include <linux/errno.h> |
36 | #include <linux/smp_lock.h> | 36 | #include <linux/smp_lock.h> |
@@ -55,11 +55,11 @@ static int udf_adinicb_readpage(struct file *file, struct page *page) | |||
55 | SetPageUptodate(page); | 55 | SetPageUptodate(page); |
56 | kunmap(page); | 56 | kunmap(page); |
57 | unlock_page(page); | 57 | unlock_page(page); |
58 | |||
58 | return 0; | 59 | return 0; |
59 | } | 60 | } |
60 | 61 | ||
61 | static int udf_adinicb_writepage(struct page *page, | 62 | static int udf_adinicb_writepage(struct page *page, struct writeback_control *wbc) |
62 | struct writeback_control *wbc) | ||
63 | { | 63 | { |
64 | struct inode *inode = page->mapping->host; | 64 | struct inode *inode = page->mapping->host; |
65 | char *kaddr; | 65 | char *kaddr; |
@@ -72,6 +72,7 @@ static int udf_adinicb_writepage(struct page *page, | |||
72 | SetPageUptodate(page); | 72 | SetPageUptodate(page); |
73 | kunmap(page); | 73 | kunmap(page); |
74 | unlock_page(page); | 74 | unlock_page(page); |
75 | |||
75 | return 0; | 76 | return 0; |
76 | } | 77 | } |
77 | 78 | ||
@@ -100,11 +101,11 @@ static int udf_adinicb_commit_write(struct file *file, struct page *page, | |||
100 | } | 101 | } |
101 | 102 | ||
102 | const struct address_space_operations udf_adinicb_aops = { | 103 | const struct address_space_operations udf_adinicb_aops = { |
103 | .readpage = udf_adinicb_readpage, | 104 | .readpage = udf_adinicb_readpage, |
104 | .writepage = udf_adinicb_writepage, | 105 | .writepage = udf_adinicb_writepage, |
105 | .sync_page = block_sync_page, | 106 | .sync_page = block_sync_page, |
106 | .prepare_write = udf_adinicb_prepare_write, | 107 | .prepare_write = udf_adinicb_prepare_write, |
107 | .commit_write = udf_adinicb_commit_write, | 108 | .commit_write = udf_adinicb_commit_write, |
108 | }; | 109 | }; |
109 | 110 | ||
110 | static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | 111 | static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov, |
@@ -122,8 +123,8 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
122 | else | 123 | else |
123 | pos = ppos; | 124 | pos = ppos; |
124 | 125 | ||
125 | if (inode->i_sb->s_blocksize < | 126 | if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) + |
126 | (udf_file_entry_alloc_offset(inode) + pos + count)) { | 127 | pos + count)) { |
127 | udf_expand_file_adinicb(inode, pos + count, &err); | 128 | udf_expand_file_adinicb(inode, pos + count, &err); |
128 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { | 129 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { |
129 | udf_debug("udf_expand_adinicb: err=%d\n", err); | 130 | udf_debug("udf_expand_adinicb: err=%d\n", err); |
@@ -138,9 +139,9 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
138 | } | 139 | } |
139 | 140 | ||
140 | retval = generic_file_aio_write(iocb, iov, nr_segs, ppos); | 141 | retval = generic_file_aio_write(iocb, iov, nr_segs, ppos); |
141 | |||
142 | if (retval > 0) | 142 | if (retval > 0) |
143 | mark_inode_dirty(inode); | 143 | mark_inode_dirty(inode); |
144 | |||
144 | return retval; | 145 | return retval; |
145 | } | 146 | } |
146 | 147 | ||
@@ -181,10 +182,12 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
181 | int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | 182 | int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, |
182 | unsigned long arg) | 183 | unsigned long arg) |
183 | { | 184 | { |
185 | long old_block, new_block; | ||
184 | int result = -EINVAL; | 186 | int result = -EINVAL; |
185 | 187 | ||
186 | if (file_permission(filp, MAY_READ) != 0) { | 188 | if (file_permission(filp, MAY_READ) != 0) { |
187 | udf_debug("no permission to access inode %lu\n", inode->i_ino); | 189 | udf_debug("no permission to access inode %lu\n", |
190 | inode->i_ino); | ||
188 | return -EPERM; | 191 | return -EPERM; |
189 | } | 192 | } |
190 | 193 | ||
@@ -196,26 +199,19 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | |||
196 | switch (cmd) { | 199 | switch (cmd) { |
197 | case UDF_GETVOLIDENT: | 200 | case UDF_GETVOLIDENT: |
198 | return copy_to_user((char __user *)arg, | 201 | return copy_to_user((char __user *)arg, |
199 | UDF_SB_VOLIDENT(inode->i_sb), | 202 | UDF_SB_VOLIDENT(inode->i_sb), 32) ? -EFAULT : 0; |
200 | 32) ? -EFAULT : 0; | ||
201 | case UDF_RELOCATE_BLOCKS: | 203 | case UDF_RELOCATE_BLOCKS: |
202 | { | 204 | if (!capable(CAP_SYS_ADMIN)) |
203 | long old, new; | 205 | return -EACCES; |
204 | 206 | if (get_user(old_block, (long __user *)arg)) | |
205 | if (!capable(CAP_SYS_ADMIN)) | 207 | return -EFAULT; |
206 | return -EACCES; | 208 | if ((result = udf_relocate_blocks(inode->i_sb, |
207 | if (get_user(old, (long __user *)arg)) | 209 | old_block, &new_block)) == 0) |
208 | return -EFAULT; | 210 | result = put_user(new_block, (long __user *)arg); |
209 | if ((result = udf_relocate_blocks(inode->i_sb, | 211 | return result; |
210 | old, &new)) == 0) | ||
211 | result = put_user(new, (long __user *)arg); | ||
212 | |||
213 | return result; | ||
214 | } | ||
215 | case UDF_GETEASIZE: | 212 | case UDF_GETEASIZE: |
216 | result = put_user(UDF_I_LENEATTR(inode), (int __user *)arg); | 213 | result = put_user(UDF_I_LENEATTR(inode), (int __user *)arg); |
217 | break; | 214 | break; |
218 | |||
219 | case UDF_GETEABLOCK: | 215 | case UDF_GETEABLOCK: |
220 | result = copy_to_user((char __user *)arg, UDF_I_DATA(inode), | 216 | result = copy_to_user((char __user *)arg, UDF_I_DATA(inode), |
221 | UDF_I_LENEATTR(inode)) ? -EFAULT : 0; | 217 | UDF_I_LENEATTR(inode)) ? -EFAULT : 0; |
@@ -248,16 +244,16 @@ static int udf_release_file(struct inode *inode, struct file *filp) | |||
248 | } | 244 | } |
249 | 245 | ||
250 | const struct file_operations udf_file_operations = { | 246 | const struct file_operations udf_file_operations = { |
251 | .read = do_sync_read, | 247 | .read = do_sync_read, |
252 | .aio_read = generic_file_aio_read, | 248 | .aio_read = generic_file_aio_read, |
253 | .ioctl = udf_ioctl, | 249 | .ioctl = udf_ioctl, |
254 | .open = generic_file_open, | 250 | .open = generic_file_open, |
255 | .mmap = generic_file_mmap, | 251 | .mmap = generic_file_mmap, |
256 | .write = do_sync_write, | 252 | .write = do_sync_write, |
257 | .aio_write = udf_file_aio_write, | 253 | .aio_write = udf_file_aio_write, |
258 | .release = udf_release_file, | 254 | .release = udf_release_file, |
259 | .fsync = udf_fsync_file, | 255 | .fsync = udf_fsync_file, |
260 | .splice_read = generic_file_splice_read, | 256 | .splice_read = generic_file_splice_read, |
261 | }; | 257 | }; |
262 | 258 | ||
263 | const struct inode_operations udf_file_inode_operations = { | 259 | const struct inode_operations udf_file_inode_operations = { |