aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/directory.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/udf/directory.c')
-rw-r--r--fs/udf/directory.c68
1 files changed, 27 insertions, 41 deletions
diff --git a/fs/udf/directory.c b/fs/udf/directory.c
index 8adc77c1d579..ff8c08fd7bf5 100644
--- a/fs/udf/directory.c
+++ b/fs/udf/directory.c
@@ -31,7 +31,7 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
31 31
32 *error = 0; 32 *error = 0;
33 33
34 ad = (uint8_t *) (*bh)->b_data + *offset; 34 ad = (uint8_t *)(*bh)->b_data + *offset;
35 *offset += ad_size; 35 *offset += ad_size;
36 36
37 if (!ad) { 37 if (!ad) {
@@ -51,7 +51,7 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
51 ad = tmpad; 51 ad = tmpad;
52 52
53 remainder = dir->i_sb->s_blocksize - loffset; 53 remainder = dir->i_sb->s_blocksize - loffset;
54 memcpy((uint8_t *) ad, (*bh)->b_data + loffset, remainder); 54 memcpy((uint8_t *)ad, (*bh)->b_data + loffset, remainder);
55 55
56 brelse(*bh); 56 brelse(*bh);
57 block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos); 57 block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
@@ -60,10 +60,10 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
60 if (!((*bh) = udf_tread(dir->i_sb, block))) 60 if (!((*bh) = udf_tread(dir->i_sb, block)))
61 return NULL; 61 return NULL;
62 62
63 memcpy((uint8_t *) ad + remainder, (*bh)->b_data, 63 memcpy((uint8_t *)ad + remainder, (*bh)->b_data, ad_size - remainder);
64 ad_size - remainder);
65 *offset = ad_size - remainder; 64 *offset = ad_size - remainder;
66 } 65 }
66
67 return ad; 67 return ad;
68} 68}
69#endif 69#endif
@@ -86,15 +86,13 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
86 (UDF_I_EFE(dir) ? 86 (UDF_I_EFE(dir) ?
87 sizeof(struct extendedFileEntry) : 87 sizeof(struct extendedFileEntry) :
88 sizeof(struct fileEntry)), 88 sizeof(struct fileEntry)),
89 dir->i_sb->s_blocksize, 89 dir->i_sb->s_blocksize, &(fibh->eoffset));
90 &(fibh->eoffset));
91
92 if (!fi) 90 if (!fi)
93 return NULL; 91 return NULL;
94 92
95 *nf_pos += ((fibh->eoffset - fibh->soffset) >> 2); 93 *nf_pos += ((fibh->eoffset - fibh->soffset) >> 2);
96 94
97 memcpy((uint8_t *) cfi, (uint8_t *) fi, 95 memcpy((uint8_t *)cfi, (uint8_t *)fi,
98 sizeof(struct fileIdentDesc)); 96 sizeof(struct fileIdentDesc));
99 97
100 return fi; 98 return fi;
@@ -121,21 +119,14 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
121 return NULL; 119 return NULL;
122 fibh->soffset = fibh->eoffset = 0; 120 fibh->soffset = fibh->eoffset = 0;
123 121
124 if (! 122 if (!(*offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) {
125 (*offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1)))
126 {
127 i = 16 >> (dir->i_sb->s_blocksize_bits - 9); 123 i = 16 >> (dir->i_sb->s_blocksize_bits - 9);
128 if (i + *offset > 124 if (i + *offset > (*elen >> dir->i_sb->s_blocksize_bits))
129 (*elen >> dir->i_sb->s_blocksize_bits)) 125 i = (*elen >> dir->i_sb->s_blocksize_bits)-*offset;
130 i = (*elen >> dir->i_sb->s_blocksize_bits) -
131 *offset;
132 for (num = 0; i > 0; i--) { 126 for (num = 0; i > 0; i--) {
133 block = 127 block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset + i);
134 udf_get_lb_pblock(dir->i_sb, *eloc,
135 *offset + i);
136 tmp = udf_tgetblk(dir->i_sb, block); 128 tmp = udf_tgetblk(dir->i_sb, block);
137 if (tmp && !buffer_uptodate(tmp) 129 if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
138 && !buffer_locked(tmp))
139 bha[num++] = tmp; 130 bha[num++] = tmp;
140 else 131 else
141 brelse(tmp); 132 brelse(tmp);
@@ -160,7 +151,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
160 *nf_pos += ((fibh->eoffset - fibh->soffset) >> 2); 151 *nf_pos += ((fibh->eoffset - fibh->soffset) >> 2);
161 152
162 if (fibh->eoffset <= dir->i_sb->s_blocksize) { 153 if (fibh->eoffset <= dir->i_sb->s_blocksize) {
163 memcpy((uint8_t *) cfi, (uint8_t *) fi, 154 memcpy((uint8_t *)cfi, (uint8_t *)fi,
164 sizeof(struct fileIdentDesc)); 155 sizeof(struct fileIdentDesc));
165 } else if (fibh->eoffset > dir->i_sb->s_blocksize) { 156 } else if (fibh->eoffset > dir->i_sb->s_blocksize) {
166 int lextoffset = epos->offset; 157 int lextoffset = epos->offset;
@@ -187,21 +178,17 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
187 if (sizeof(struct fileIdentDesc) > -fibh->soffset) { 178 if (sizeof(struct fileIdentDesc) > -fibh->soffset) {
188 int fi_len; 179 int fi_len;
189 180
190 memcpy((uint8_t *) cfi, (uint8_t *) fi, -fibh->soffset); 181 memcpy((uint8_t *)cfi, (uint8_t *)fi, -fibh->soffset);
191 memcpy((uint8_t *) cfi - fibh->soffset, 182 memcpy((uint8_t *)cfi - fibh->soffset, fibh->ebh->b_data,
192 fibh->ebh->b_data,
193 sizeof(struct fileIdentDesc) + fibh->soffset); 183 sizeof(struct fileIdentDesc) + fibh->soffset);
194 184
195 fi_len = 185 fi_len = (sizeof(struct fileIdentDesc) + cfi->lengthFileIdent +
196 (sizeof(struct fileIdentDesc) + 186 le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3;
197 cfi->lengthFileIdent +
198 le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3;
199 187
200 *nf_pos += 188 *nf_pos += ((fi_len - (fibh->eoffset - fibh->soffset)) >> 2);
201 ((fi_len - (fibh->eoffset - fibh->soffset)) >> 2);
202 fibh->eoffset = fibh->soffset + fi_len; 189 fibh->eoffset = fibh->soffset + fi_len;
203 } else { 190 } else {
204 memcpy((uint8_t *) cfi, (uint8_t *) fi, 191 memcpy((uint8_t *)cfi, (uint8_t *)fi,
205 sizeof(struct fileIdentDesc)); 192 sizeof(struct fileIdentDesc));
206 } 193 }
207 } 194 }
@@ -237,9 +224,10 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
237 } 224 }
238 if ((*offset + sizeof(struct fileIdentDesc)) > bufsize) { 225 if ((*offset + sizeof(struct fileIdentDesc)) > bufsize) {
239 lengthThisIdent = sizeof(struct fileIdentDesc); 226 lengthThisIdent = sizeof(struct fileIdentDesc);
240 } else 227 } else {
241 lengthThisIdent = sizeof(struct fileIdentDesc) + 228 lengthThisIdent = sizeof(struct fileIdentDesc) +
242 fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse); 229 fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse);
230 }
243 231
244 /* we need to figure padding, too! */ 232 /* we need to figure padding, too! */
245 padlen = lengthThisIdent % UDF_NAME_PAD; 233 padlen = lengthThisIdent % UDF_NAME_PAD;
@@ -270,22 +258,20 @@ static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset)
270 return NULL; 258 return NULL;
271 } 259 }
272 260
273 ptr = 261 ptr = (uint8_t *)(fe->extendedAttr) + le32_to_cpu(fe->lengthExtendedAttr);
274 (uint8_t *) (fe->extendedAttr) +
275 le32_to_cpu(fe->lengthExtendedAttr);
276 262
277 if ((*offset > 0) && (*offset < le32_to_cpu(fe->lengthAllocDescs))) { 263 if ((*offset > 0) && (*offset < le32_to_cpu(fe->lengthAllocDescs))) {
278 ptr += *offset; 264 ptr += *offset;
279 } 265 }
280 266
281 ext = (extent_ad *) ptr; 267 ext = (extent_ad *)ptr;
282 268
283 *offset = *offset + sizeof(extent_ad); 269 *offset = *offset + sizeof(extent_ad);
284 return ext; 270 return ext;
285} 271}
286#endif 272#endif
287 273
288short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset, 274short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, int *offset,
289 int inc) 275 int inc)
290{ 276{
291 short_ad *sa; 277 short_ad *sa;
@@ -297,7 +283,7 @@ short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset,
297 283
298 if ((*offset < 0) || ((*offset + sizeof(short_ad)) > maxoffset)) 284 if ((*offset < 0) || ((*offset + sizeof(short_ad)) > maxoffset))
299 return NULL; 285 return NULL;
300 else if ((sa = (short_ad *) ptr)->extLength == 0) 286 else if ((sa = (short_ad *)ptr)->extLength == 0)
301 return NULL; 287 return NULL;
302 288
303 if (inc) 289 if (inc)
@@ -305,7 +291,7 @@ short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset,
305 return sa; 291 return sa;
306} 292}
307 293
308long_ad *udf_get_filelongad(uint8_t * ptr, int maxoffset, int *offset, int inc) 294long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, int *offset, int inc)
309{ 295{
310 long_ad *la; 296 long_ad *la;
311 297
@@ -316,7 +302,7 @@ long_ad *udf_get_filelongad(uint8_t * ptr, int maxoffset, int *offset, int inc)
316 302
317 if ((*offset < 0) || ((*offset + sizeof(long_ad)) > maxoffset)) 303 if ((*offset < 0) || ((*offset + sizeof(long_ad)) > maxoffset))
318 return NULL; 304 return NULL;
319 else if ((la = (long_ad *) ptr)->extLength == 0) 305 else if ((la = (long_ad *)ptr)->extLength == 0)
320 return NULL; 306 return NULL;
321 307
322 if (inc) 308 if (inc)