aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/udf/file.c')
-rw-r--r--fs/udf/file.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 7c7a1b39d56c..97c71ae7c689 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -45,12 +45,13 @@ static int udf_adinicb_readpage(struct file *file, struct page *page)
45{ 45{
46 struct inode *inode = page->mapping->host; 46 struct inode *inode = page->mapping->host;
47 char *kaddr; 47 char *kaddr;
48 struct udf_inode_info *iinfo = UDF_I(inode);
48 49
49 BUG_ON(!PageLocked(page)); 50 BUG_ON(!PageLocked(page));
50 51
51 kaddr = kmap(page); 52 kaddr = kmap(page);
52 memset(kaddr, 0, PAGE_CACHE_SIZE); 53 memset(kaddr, 0, PAGE_CACHE_SIZE);
53 memcpy(kaddr, UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), inode->i_size); 54 memcpy(kaddr, iinfo->i_ext.i_data + iinfo->i_lenEAttr, inode->i_size);
54 flush_dcache_page(page); 55 flush_dcache_page(page);
55 SetPageUptodate(page); 56 SetPageUptodate(page);
56 kunmap(page); 57 kunmap(page);
@@ -59,15 +60,17 @@ static int udf_adinicb_readpage(struct file *file, struct page *page)
59 return 0; 60 return 0;
60} 61}
61 62
62static int udf_adinicb_writepage(struct page *page, struct writeback_control *wbc) 63static int udf_adinicb_writepage(struct page *page,
64 struct writeback_control *wbc)
63{ 65{
64 struct inode *inode = page->mapping->host; 66 struct inode *inode = page->mapping->host;
65 char *kaddr; 67 char *kaddr;
68 struct udf_inode_info *iinfo = UDF_I(inode);
66 69
67 BUG_ON(!PageLocked(page)); 70 BUG_ON(!PageLocked(page));
68 71
69 kaddr = kmap(page); 72 kaddr = kmap(page);
70 memcpy(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), kaddr, inode->i_size); 73 memcpy(iinfo->i_ext.i_data + iinfo->i_lenEAttr, kaddr, inode->i_size);
71 mark_inode_dirty(inode); 74 mark_inode_dirty(inode);
72 SetPageUptodate(page); 75 SetPageUptodate(page);
73 kunmap(page); 76 kunmap(page);
@@ -84,9 +87,10 @@ static int udf_adinicb_write_end(struct file *file,
84 struct inode *inode = mapping->host; 87 struct inode *inode = mapping->host;
85 unsigned offset = pos & (PAGE_CACHE_SIZE - 1); 88 unsigned offset = pos & (PAGE_CACHE_SIZE - 1);
86 char *kaddr; 89 char *kaddr;
90 struct udf_inode_info *iinfo = UDF_I(inode);
87 91
88 kaddr = kmap_atomic(page, KM_USER0); 92 kaddr = kmap_atomic(page, KM_USER0);
89 memcpy(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode) + offset, 93 memcpy(iinfo->i_ext.i_data + iinfo->i_lenEAttr + offset,
90 kaddr + offset, copied); 94 kaddr + offset, copied);
91 kunmap_atomic(kaddr, KM_USER0); 95 kunmap_atomic(kaddr, KM_USER0);
92 96
@@ -109,25 +113,27 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
109 struct inode *inode = file->f_path.dentry->d_inode; 113 struct inode *inode = file->f_path.dentry->d_inode;
110 int err, pos; 114 int err, pos;
111 size_t count = iocb->ki_left; 115 size_t count = iocb->ki_left;
116 struct udf_inode_info *iinfo = UDF_I(inode);
112 117
113 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { 118 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
114 if (file->f_flags & O_APPEND) 119 if (file->f_flags & O_APPEND)
115 pos = inode->i_size; 120 pos = inode->i_size;
116 else 121 else
117 pos = ppos; 122 pos = ppos;
118 123
119 if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) + 124 if (inode->i_sb->s_blocksize <
125 (udf_file_entry_alloc_offset(inode) +
120 pos + count)) { 126 pos + count)) {
121 udf_expand_file_adinicb(inode, pos + count, &err); 127 udf_expand_file_adinicb(inode, pos + count, &err);
122 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { 128 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
123 udf_debug("udf_expand_adinicb: err=%d\n", err); 129 udf_debug("udf_expand_adinicb: err=%d\n", err);
124 return err; 130 return err;
125 } 131 }
126 } else { 132 } else {
127 if (pos + count > inode->i_size) 133 if (pos + count > inode->i_size)
128 UDF_I_LENALLOC(inode) = pos + count; 134 iinfo->i_lenAlloc = pos + count;
129 else 135 else
130 UDF_I_LENALLOC(inode) = inode->i_size; 136 iinfo->i_lenAlloc = inode->i_size;
131 } 137 }
132 } 138 }
133 139
@@ -191,23 +197,28 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
191 197
192 switch (cmd) { 198 switch (cmd) {
193 case UDF_GETVOLIDENT: 199 case UDF_GETVOLIDENT:
194 return copy_to_user((char __user *)arg, 200 if (copy_to_user((char __user *)arg,
195 UDF_SB_VOLIDENT(inode->i_sb), 32) ? -EFAULT : 0; 201 UDF_SB(inode->i_sb)->s_volume_ident, 32))
202 return -EFAULT;
203 else
204 return 0;
196 case UDF_RELOCATE_BLOCKS: 205 case UDF_RELOCATE_BLOCKS:
197 if (!capable(CAP_SYS_ADMIN)) 206 if (!capable(CAP_SYS_ADMIN))
198 return -EACCES; 207 return -EACCES;
199 if (get_user(old_block, (long __user *)arg)) 208 if (get_user(old_block, (long __user *)arg))
200 return -EFAULT; 209 return -EFAULT;
201 if ((result = udf_relocate_blocks(inode->i_sb, 210 result = udf_relocate_blocks(inode->i_sb,
202 old_block, &new_block)) == 0) 211 old_block, &new_block);
212 if (result == 0)
203 result = put_user(new_block, (long __user *)arg); 213 result = put_user(new_block, (long __user *)arg);
204 return result; 214 return result;
205 case UDF_GETEASIZE: 215 case UDF_GETEASIZE:
206 result = put_user(UDF_I_LENEATTR(inode), (int __user *)arg); 216 result = put_user(UDF_I(inode)->i_lenEAttr, (int __user *)arg);
207 break; 217 break;
208 case UDF_GETEABLOCK: 218 case UDF_GETEABLOCK:
209 result = copy_to_user((char __user *)arg, UDF_I_DATA(inode), 219 result = copy_to_user((char __user *)arg,
210 UDF_I_LENEATTR(inode)) ? -EFAULT : 0; 220 UDF_I(inode)->i_ext.i_data,
221 UDF_I(inode)->i_lenEAttr) ? -EFAULT : 0;
211 break; 222 break;
212 } 223 }
213 224