diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2007-07-21 07:37:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-21 20:49:14 -0400 |
commit | 28de7948a896763bc97ccd416bba5b9422158350 (patch) | |
tree | abee128b137a6fa9fa4104b7bbc4ee409467c38f /fs | |
parent | 71133027febfabd501fde7583b30008224f4d799 (diff) |
UDF: coding style conversion - lindent fixups
This patch fixes up sources after conversion by Lindent.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Jan Kara <jack@ucw.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/udf/balloc.c | 420 | ||||
-rw-r--r-- | fs/udf/crc.c | 4 | ||||
-rw-r--r-- | fs/udf/dir.c | 60 | ||||
-rw-r--r-- | fs/udf/directory.c | 68 | ||||
-rw-r--r-- | fs/udf/ecma_167.h | 684 | ||||
-rw-r--r-- | fs/udf/file.c | 72 | ||||
-rw-r--r-- | fs/udf/fsync.c | 2 | ||||
-rw-r--r-- | fs/udf/ialloc.c | 38 | ||||
-rw-r--r-- | fs/udf/inode.c | 948 | ||||
-rw-r--r-- | fs/udf/lowlevel.c | 4 | ||||
-rw-r--r-- | fs/udf/misc.c | 87 | ||||
-rw-r--r-- | fs/udf/namei.c | 410 | ||||
-rw-r--r-- | fs/udf/osta_udf.h | 164 | ||||
-rw-r--r-- | fs/udf/partition.c | 212 | ||||
-rw-r--r-- | fs/udf/super.c | 1023 | ||||
-rw-r--r-- | fs/udf/symlink.c | 14 | ||||
-rw-r--r-- | fs/udf/truncate.c | 113 | ||||
-rw-r--r-- | fs/udf/udf_i.h | 2 | ||||
-rw-r--r-- | fs/udf/udf_sb.h | 26 | ||||
-rw-r--r-- | fs/udf/udfdecl.h | 4 | ||||
-rw-r--r-- | fs/udf/udfend.h | 20 | ||||
-rw-r--r-- | fs/udf/udftime.c | 82 | ||||
-rw-r--r-- | fs/udf/unicode.c | 155 |
23 files changed, 1910 insertions, 2702 deletions
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c index ef48d094dd2b..276f7207a564 100644 --- a/fs/udf/balloc.c +++ b/fs/udf/balloc.c | |||
@@ -70,9 +70,9 @@ static inline int find_next_one_bit(void *addr, int size, int offset) | |||
70 | if (!size) | 70 | if (!size) |
71 | return result; | 71 | return result; |
72 | tmp = leBPL_to_cpup(p); | 72 | tmp = leBPL_to_cpup(p); |
73 | found_first: | 73 | found_first: |
74 | tmp &= ~0UL >> (BITS_PER_LONG - size); | 74 | tmp &= ~0UL >> (BITS_PER_LONG - size); |
75 | found_middle: | 75 | found_middle: |
76 | return result + ffz(~tmp); | 76 | return result + ffz(~tmp); |
77 | } | 77 | } |
78 | 78 | ||
@@ -110,11 +110,11 @@ static int __load_block_bitmap(struct super_block *sb, | |||
110 | nr_groups); | 110 | nr_groups); |
111 | } | 111 | } |
112 | 112 | ||
113 | if (bitmap->s_block_bitmap[block_group]) | 113 | if (bitmap->s_block_bitmap[block_group]) { |
114 | return block_group; | 114 | return block_group; |
115 | else { | 115 | } else { |
116 | retval = | 116 | retval = read_block_bitmap(sb, bitmap, block_group, |
117 | read_block_bitmap(sb, bitmap, block_group, block_group); | 117 | block_group); |
118 | if (retval < 0) | 118 | if (retval < 0) |
119 | return retval; | 119 | return retval; |
120 | return block_group; | 120 | return block_group; |
@@ -155,22 +155,16 @@ static void udf_bitmap_free_blocks(struct super_block *sb, | |||
155 | 155 | ||
156 | mutex_lock(&sbi->s_alloc_mutex); | 156 | mutex_lock(&sbi->s_alloc_mutex); |
157 | if (bloc.logicalBlockNum < 0 || | 157 | if (bloc.logicalBlockNum < 0 || |
158 | (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, | 158 | (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)) { |
159 | bloc. | 159 | udf_debug("%d < %d || %d + %d > %d\n", |
160 | partitionReferenceNum)) | 160 | bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, |
161 | { | 161 | UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)); |
162 | udf_debug("%d < %d || %d + %d > %d\n", bloc.logicalBlockNum, 0, | ||
163 | bloc.logicalBlockNum, count, UDF_SB_PARTLEN(sb, | ||
164 | bloc. | ||
165 | partitionReferenceNum)); | ||
166 | goto error_return; | 162 | goto error_return; |
167 | } | 163 | } |
168 | 164 | ||
169 | block = | 165 | block = bloc.logicalBlockNum + offset + (sizeof(struct spaceBitmapDesc) << 3); |
170 | bloc.logicalBlockNum + offset + | ||
171 | (sizeof(struct spaceBitmapDesc) << 3); | ||
172 | 166 | ||
173 | do_more: | 167 | do_more: |
174 | overflow = 0; | 168 | overflow = 0; |
175 | block_group = block >> (sb->s_blocksize_bits + 3); | 169 | block_group = block >> (sb->s_blocksize_bits + 3); |
176 | bit = block % (sb->s_blocksize << 3); | 170 | bit = block % (sb->s_blocksize << 3); |
@@ -190,18 +184,13 @@ static void udf_bitmap_free_blocks(struct super_block *sb, | |||
190 | for (i = 0; i < count; i++) { | 184 | for (i = 0; i < count; i++) { |
191 | if (udf_set_bit(bit + i, bh->b_data)) { | 185 | if (udf_set_bit(bit + i, bh->b_data)) { |
192 | udf_debug("bit %ld already set\n", bit + i); | 186 | udf_debug("bit %ld already set\n", bit + i); |
193 | udf_debug("byte=%2x\n", | 187 | udf_debug("byte=%2x\n", ((char *)bh->b_data)[(bit + i) >> 3]); |
194 | ((char *)bh->b_data)[(bit + i) >> 3]); | ||
195 | } else { | 188 | } else { |
196 | if (inode) | 189 | if (inode) |
197 | DQUOT_FREE_BLOCK(inode, 1); | 190 | DQUOT_FREE_BLOCK(inode, 1); |
198 | if (UDF_SB_LVIDBH(sb)) { | 191 | if (UDF_SB_LVIDBH(sb)) { |
199 | UDF_SB_LVID(sb)-> | 192 | UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)] = |
200 | freeSpaceTable[UDF_SB_PARTITION(sb)] = | 193 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]) + 1); |
201 | cpu_to_le32(le32_to_cpu | ||
202 | (UDF_SB_LVID(sb)-> | ||
203 | freeSpaceTable[UDF_SB_PARTITION | ||
204 | (sb)]) + 1); | ||
205 | } | 194 | } |
206 | } | 195 | } |
207 | } | 196 | } |
@@ -211,7 +200,7 @@ static void udf_bitmap_free_blocks(struct super_block *sb, | |||
211 | count = overflow; | 200 | count = overflow; |
212 | goto do_more; | 201 | goto do_more; |
213 | } | 202 | } |
214 | error_return: | 203 | error_return: |
215 | sb->s_dirt = 1; | 204 | sb->s_dirt = 1; |
216 | if (UDF_SB_LVIDBH(sb)) | 205 | if (UDF_SB_LVIDBH(sb)) |
217 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 206 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); |
@@ -238,7 +227,7 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb, | |||
238 | if (first_block + block_count > UDF_SB_PARTLEN(sb, partition)) | 227 | if (first_block + block_count > UDF_SB_PARTLEN(sb, partition)) |
239 | block_count = UDF_SB_PARTLEN(sb, partition) - first_block; | 228 | block_count = UDF_SB_PARTLEN(sb, partition) - first_block; |
240 | 229 | ||
241 | repeat: | 230 | repeat: |
242 | nr_groups = (UDF_SB_PARTLEN(sb, partition) + | 231 | nr_groups = (UDF_SB_PARTLEN(sb, partition) + |
243 | (sizeof(struct spaceBitmapDesc) << 3) + | 232 | (sizeof(struct spaceBitmapDesc) << 3) + |
244 | (sb->s_blocksize * 8) - 1) / (sb->s_blocksize * 8); | 233 | (sb->s_blocksize * 8) - 1) / (sb->s_blocksize * 8); |
@@ -254,11 +243,11 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb, | |||
254 | bit = block % (sb->s_blocksize << 3); | 243 | bit = block % (sb->s_blocksize << 3); |
255 | 244 | ||
256 | while (bit < (sb->s_blocksize << 3) && block_count > 0) { | 245 | while (bit < (sb->s_blocksize << 3) && block_count > 0) { |
257 | if (!udf_test_bit(bit, bh->b_data)) | 246 | if (!udf_test_bit(bit, bh->b_data)) { |
258 | goto out; | 247 | goto out; |
259 | else if (DQUOT_PREALLOC_BLOCK(inode, 1)) | 248 | } else if (DQUOT_PREALLOC_BLOCK(inode, 1)) { |
260 | goto out; | 249 | goto out; |
261 | else if (!udf_clear_bit(bit, bh->b_data)) { | 250 | } else if (!udf_clear_bit(bit, bh->b_data)) { |
262 | udf_debug("bit already cleared for block %d\n", bit); | 251 | udf_debug("bit already cleared for block %d\n", bit); |
263 | DQUOT_FREE_BLOCK(inode, 1); | 252 | DQUOT_FREE_BLOCK(inode, 1); |
264 | goto out; | 253 | goto out; |
@@ -271,12 +260,10 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb, | |||
271 | mark_buffer_dirty(bh); | 260 | mark_buffer_dirty(bh); |
272 | if (block_count > 0) | 261 | if (block_count > 0) |
273 | goto repeat; | 262 | goto repeat; |
274 | out: | 263 | out: |
275 | if (UDF_SB_LVIDBH(sb)) { | 264 | if (UDF_SB_LVIDBH(sb)) { |
276 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = | 265 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = |
277 | cpu_to_le32(le32_to_cpu | 266 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - alloc_count); |
278 | (UDF_SB_LVID(sb)->freeSpaceTable[partition]) - | ||
279 | alloc_count); | ||
280 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 267 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); |
281 | } | 268 | } |
282 | sb->s_dirt = 1; | 269 | sb->s_dirt = 1; |
@@ -299,7 +286,7 @@ static int udf_bitmap_new_block(struct super_block *sb, | |||
299 | *err = -ENOSPC; | 286 | *err = -ENOSPC; |
300 | mutex_lock(&sbi->s_alloc_mutex); | 287 | mutex_lock(&sbi->s_alloc_mutex); |
301 | 288 | ||
302 | repeat: | 289 | repeat: |
303 | if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition)) | 290 | if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition)) |
304 | goal = 0; | 291 | goal = 0; |
305 | 292 | ||
@@ -312,31 +299,27 @@ static int udf_bitmap_new_block(struct super_block *sb, | |||
312 | if (bitmap_nr < 0) | 299 | if (bitmap_nr < 0) |
313 | goto error_return; | 300 | goto error_return; |
314 | bh = bitmap->s_block_bitmap[bitmap_nr]; | 301 | bh = bitmap->s_block_bitmap[bitmap_nr]; |
315 | ptr = | 302 | ptr = memscan((char *)bh->b_data + group_start, 0xFF, |
316 | memscan((char *)bh->b_data + group_start, 0xFF, | 303 | sb->s_blocksize - group_start); |
317 | sb->s_blocksize - group_start); | ||
318 | 304 | ||
319 | if ((ptr - ((char *)bh->b_data)) < sb->s_blocksize) { | 305 | if ((ptr - ((char *)bh->b_data)) < sb->s_blocksize) { |
320 | bit = block % (sb->s_blocksize << 3); | 306 | bit = block % (sb->s_blocksize << 3); |
321 | 307 | if (udf_test_bit(bit, bh->b_data)) | |
322 | if (udf_test_bit(bit, bh->b_data)) { | ||
323 | goto got_block; | 308 | goto got_block; |
324 | } | 309 | |
325 | end_goal = (bit + 63) & ~63; | 310 | end_goal = (bit + 63) & ~63; |
326 | bit = udf_find_next_one_bit(bh->b_data, end_goal, bit); | 311 | bit = udf_find_next_one_bit(bh->b_data, end_goal, bit); |
327 | if (bit < end_goal) | 312 | if (bit < end_goal) |
328 | goto got_block; | 313 | goto got_block; |
329 | ptr = | 314 | |
330 | memscan((char *)bh->b_data + (bit >> 3), 0xFF, | 315 | ptr = memscan((char *)bh->b_data + (bit >> 3), 0xFF, sb->s_blocksize - ((bit + 7) >> 3)); |
331 | sb->s_blocksize - ((bit + 7) >> 3)); | ||
332 | newbit = (ptr - ((char *)bh->b_data)) << 3; | 316 | newbit = (ptr - ((char *)bh->b_data)) << 3; |
333 | if (newbit < sb->s_blocksize << 3) { | 317 | if (newbit < sb->s_blocksize << 3) { |
334 | bit = newbit; | 318 | bit = newbit; |
335 | goto search_back; | 319 | goto search_back; |
336 | } | 320 | } |
337 | newbit = | 321 | |
338 | udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, | 322 | newbit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, bit); |
339 | bit); | ||
340 | if (newbit < sb->s_blocksize << 3) { | 323 | if (newbit < sb->s_blocksize << 3) { |
341 | bit = newbit; | 324 | bit = newbit; |
342 | goto got_block; | 325 | goto got_block; |
@@ -354,18 +337,16 @@ static int udf_bitmap_new_block(struct super_block *sb, | |||
354 | goto error_return; | 337 | goto error_return; |
355 | bh = bitmap->s_block_bitmap[bitmap_nr]; | 338 | bh = bitmap->s_block_bitmap[bitmap_nr]; |
356 | if (i < nr_groups) { | 339 | if (i < nr_groups) { |
357 | ptr = | 340 | ptr = memscan((char *)bh->b_data + group_start, 0xFF, |
358 | memscan((char *)bh->b_data + group_start, 0xFF, | 341 | sb->s_blocksize - group_start); |
359 | sb->s_blocksize - group_start); | ||
360 | if ((ptr - ((char *)bh->b_data)) < sb->s_blocksize) { | 342 | if ((ptr - ((char *)bh->b_data)) < sb->s_blocksize) { |
361 | bit = (ptr - ((char *)bh->b_data)) << 3; | 343 | bit = (ptr - ((char *)bh->b_data)) << 3; |
362 | break; | 344 | break; |
363 | } | 345 | } |
364 | } else { | 346 | } else { |
365 | bit = | 347 | bit = udf_find_next_one_bit((char *)bh->b_data, |
366 | udf_find_next_one_bit((char *)bh->b_data, | 348 | sb->s_blocksize << 3, |
367 | sb->s_blocksize << 3, | 349 | group_start << 3); |
368 | group_start << 3); | ||
369 | if (bit < sb->s_blocksize << 3) | 350 | if (bit < sb->s_blocksize << 3) |
370 | break; | 351 | break; |
371 | } | 352 | } |
@@ -377,20 +358,17 @@ static int udf_bitmap_new_block(struct super_block *sb, | |||
377 | if (bit < sb->s_blocksize << 3) | 358 | if (bit < sb->s_blocksize << 3) |
378 | goto search_back; | 359 | goto search_back; |
379 | else | 360 | else |
380 | bit = | 361 | bit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, group_start << 3); |
381 | udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, | ||
382 | group_start << 3); | ||
383 | if (bit >= sb->s_blocksize << 3) { | 362 | if (bit >= sb->s_blocksize << 3) { |
384 | mutex_unlock(&sbi->s_alloc_mutex); | 363 | mutex_unlock(&sbi->s_alloc_mutex); |
385 | return 0; | 364 | return 0; |
386 | } | 365 | } |
387 | 366 | ||
388 | search_back: | 367 | search_back: |
389 | for (i = 0; | 368 | for (i = 0; i < 7 && bit > (group_start << 3) && udf_test_bit(bit - 1, bh->b_data); i++, bit--) |
390 | i < 7 && bit > (group_start << 3) | 369 | ; /* empty loop */ |
391 | && udf_test_bit(bit - 1, bh->b_data); i++, bit--) ; | ||
392 | 370 | ||
393 | got_block: | 371 | got_block: |
394 | 372 | ||
395 | /* | 373 | /* |
396 | * Check quota for allocation of this block. | 374 | * Check quota for allocation of this block. |
@@ -402,7 +380,7 @@ static int udf_bitmap_new_block(struct super_block *sb, | |||
402 | } | 380 | } |
403 | 381 | ||
404 | newblock = bit + (block_group << (sb->s_blocksize_bits + 3)) - | 382 | newblock = bit + (block_group << (sb->s_blocksize_bits + 3)) - |
405 | (sizeof(struct spaceBitmapDesc) << 3); | 383 | (sizeof(struct spaceBitmapDesc) << 3); |
406 | 384 | ||
407 | if (!udf_clear_bit(bit, bh->b_data)) { | 385 | if (!udf_clear_bit(bit, bh->b_data)) { |
408 | udf_debug("bit already cleared for block %d\n", bit); | 386 | udf_debug("bit already cleared for block %d\n", bit); |
@@ -413,9 +391,7 @@ static int udf_bitmap_new_block(struct super_block *sb, | |||
413 | 391 | ||
414 | if (UDF_SB_LVIDBH(sb)) { | 392 | if (UDF_SB_LVIDBH(sb)) { |
415 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = | 393 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = |
416 | cpu_to_le32(le32_to_cpu | 394 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - 1); |
417 | (UDF_SB_LVID(sb)->freeSpaceTable[partition]) - | ||
418 | 1); | ||
419 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 395 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); |
420 | } | 396 | } |
421 | sb->s_dirt = 1; | 397 | sb->s_dirt = 1; |
@@ -423,7 +399,7 @@ static int udf_bitmap_new_block(struct super_block *sb, | |||
423 | *err = 0; | 399 | *err = 0; |
424 | return newblock; | 400 | return newblock; |
425 | 401 | ||
426 | error_return: | 402 | error_return: |
427 | *err = -EIO; | 403 | *err = -EIO; |
428 | mutex_unlock(&sbi->s_alloc_mutex); | 404 | mutex_unlock(&sbi->s_alloc_mutex); |
429 | return 0; | 405 | return 0; |
@@ -445,14 +421,10 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
445 | 421 | ||
446 | mutex_lock(&sbi->s_alloc_mutex); | 422 | mutex_lock(&sbi->s_alloc_mutex); |
447 | if (bloc.logicalBlockNum < 0 || | 423 | if (bloc.logicalBlockNum < 0 || |
448 | (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, | 424 | (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)) { |
449 | bloc. | 425 | udf_debug("%d < %d || %d + %d > %d\n", |
450 | partitionReferenceNum)) | 426 | bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, |
451 | { | 427 | UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)); |
452 | udf_debug("%d < %d || %d + %d > %d\n", bloc.logicalBlockNum, 0, | ||
453 | bloc.logicalBlockNum, count, UDF_SB_PARTLEN(sb, | ||
454 | bloc. | ||
455 | partitionReferenceNum)); | ||
456 | goto error_return; | 428 | goto error_return; |
457 | } | 429 | } |
458 | 430 | ||
@@ -462,9 +434,7 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
462 | DQUOT_FREE_BLOCK(inode, count); | 434 | DQUOT_FREE_BLOCK(inode, count); |
463 | if (UDF_SB_LVIDBH(sb)) { | 435 | if (UDF_SB_LVIDBH(sb)) { |
464 | UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)] = | 436 | UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)] = |
465 | cpu_to_le32(le32_to_cpu | 437 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]) + count); |
466 | (UDF_SB_LVID(sb)-> | ||
467 | freeSpaceTable[UDF_SB_PARTITION(sb)]) + count); | ||
468 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 438 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); |
469 | } | 439 | } |
470 | 440 | ||
@@ -476,47 +446,28 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
476 | epos.block = oepos.block = UDF_I_LOCATION(table); | 446 | epos.block = oepos.block = UDF_I_LOCATION(table); |
477 | epos.bh = oepos.bh = NULL; | 447 | epos.bh = oepos.bh = NULL; |
478 | 448 | ||
479 | while (count && (etype = | 449 | while (count && |
480 | udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { | 450 | (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { |
481 | if (((eloc.logicalBlockNum + (elen >> sb->s_blocksize_bits)) == | 451 | if (((eloc.logicalBlockNum + (elen >> sb->s_blocksize_bits)) == start)) { |
482 | start)) { | 452 | if ((0x3FFFFFFF - elen) < (count << sb->s_blocksize_bits)) { |
483 | if ((0x3FFFFFFF - elen) < | 453 | count -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits); |
484 | (count << sb->s_blocksize_bits)) { | 454 | start += ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits); |
485 | count -= | 455 | elen = (etype << 30) | (0x40000000 - sb->s_blocksize); |
486 | ((0x3FFFFFFF - | ||
487 | elen) >> sb->s_blocksize_bits); | ||
488 | start += | ||
489 | ((0x3FFFFFFF - | ||
490 | elen) >> sb->s_blocksize_bits); | ||
491 | elen = | ||
492 | (etype << 30) | (0x40000000 - | ||
493 | sb->s_blocksize); | ||
494 | } else { | 456 | } else { |
495 | elen = (etype << 30) | | 457 | elen = (etype << 30) | (elen + (count << sb->s_blocksize_bits)); |
496 | (elen + (count << sb->s_blocksize_bits)); | ||
497 | start += count; | 458 | start += count; |
498 | count = 0; | 459 | count = 0; |
499 | } | 460 | } |
500 | udf_write_aext(table, &oepos, eloc, elen, 1); | 461 | udf_write_aext(table, &oepos, eloc, elen, 1); |
501 | } else if (eloc.logicalBlockNum == (end + 1)) { | 462 | } else if (eloc.logicalBlockNum == (end + 1)) { |
502 | if ((0x3FFFFFFF - elen) < | 463 | if ((0x3FFFFFFF - elen) < (count << sb->s_blocksize_bits)) { |
503 | (count << sb->s_blocksize_bits)) { | 464 | count -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits); |
504 | count -= | 465 | end -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits); |
505 | ((0x3FFFFFFF - | 466 | eloc.logicalBlockNum -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits); |
506 | elen) >> sb->s_blocksize_bits); | 467 | elen = (etype << 30) | (0x40000000 - sb->s_blocksize); |
507 | end -= | ||
508 | ((0x3FFFFFFF - | ||
509 | elen) >> sb->s_blocksize_bits); | ||
510 | eloc.logicalBlockNum -= | ||
511 | ((0x3FFFFFFF - | ||
512 | elen) >> sb->s_blocksize_bits); | ||
513 | elen = | ||
514 | (etype << 30) | (0x40000000 - | ||
515 | sb->s_blocksize); | ||
516 | } else { | 468 | } else { |
517 | eloc.logicalBlockNum = start; | 469 | eloc.logicalBlockNum = start; |
518 | elen = (etype << 30) | | 470 | elen = (etype << 30) | (elen + (count << sb->s_blocksize_bits)); |
519 | (elen + (count << sb->s_blocksize_bits)); | ||
520 | end -= count; | 471 | end -= count; |
521 | count = 0; | 472 | count = 0; |
522 | } | 473 | } |
@@ -530,21 +481,23 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
530 | get_bh(epos.bh); | 481 | get_bh(epos.bh); |
531 | oepos.bh = epos.bh; | 482 | oepos.bh = epos.bh; |
532 | oepos.offset = 0; | 483 | oepos.offset = 0; |
533 | } else | 484 | } else { |
534 | oepos.offset = epos.offset; | 485 | oepos.offset = epos.offset; |
486 | } | ||
535 | } | 487 | } |
536 | 488 | ||
537 | if (count) { | 489 | if (count) { |
538 | /* NOTE: we CANNOT use udf_add_aext here, as it can try to allocate | 490 | /* |
539 | a new block, and since we hold the super block lock already | 491 | * NOTE: we CANNOT use udf_add_aext here, as it can try to allocate |
540 | very bad things would happen :) | 492 | * a new block, and since we hold the super block lock already |
541 | 493 | * very bad things would happen :) | |
542 | We copy the behavior of udf_add_aext, but instead of | 494 | * |
543 | trying to allocate a new block close to the existing one, | 495 | * We copy the behavior of udf_add_aext, but instead of |
544 | we just steal a block from the extent we are trying to add. | 496 | * trying to allocate a new block close to the existing one, |
545 | 497 | * we just steal a block from the extent we are trying to add. | |
546 | It would be nice if the blocks were close together, but it | 498 | * |
547 | isn't required. | 499 | * It would be nice if the blocks were close together, but it |
500 | * isn't required. | ||
548 | */ | 501 | */ |
549 | 502 | ||
550 | int adsize; | 503 | int adsize; |
@@ -553,13 +506,14 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
553 | struct allocExtDesc *aed; | 506 | struct allocExtDesc *aed; |
554 | 507 | ||
555 | eloc.logicalBlockNum = start; | 508 | eloc.logicalBlockNum = start; |
556 | elen = EXT_RECORDED_ALLOCATED | (count << sb->s_blocksize_bits); | 509 | elen = EXT_RECORDED_ALLOCATED | |
510 | (count << sb->s_blocksize_bits); | ||
557 | 511 | ||
558 | if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT) | 512 | if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT) { |
559 | adsize = sizeof(short_ad); | 513 | adsize = sizeof(short_ad); |
560 | else if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_LONG) | 514 | } else if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_LONG) { |
561 | adsize = sizeof(long_ad); | 515 | adsize = sizeof(long_ad); |
562 | else { | 516 | } else { |
563 | brelse(oepos.bh); | 517 | brelse(oepos.bh); |
564 | brelse(epos.bh); | 518 | brelse(epos.bh); |
565 | goto error_return; | 519 | goto error_return; |
@@ -577,28 +531,21 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
577 | eloc.logicalBlockNum++; | 531 | eloc.logicalBlockNum++; |
578 | elen -= sb->s_blocksize; | 532 | elen -= sb->s_blocksize; |
579 | 533 | ||
580 | if (!(epos.bh = udf_tread(sb, | 534 | if (!(epos.bh = udf_tread(sb, udf_get_lb_pblock(sb, epos.block, 0)))) { |
581 | udf_get_lb_pblock(sb, | ||
582 | epos.block, | ||
583 | 0)))) { | ||
584 | brelse(oepos.bh); | 535 | brelse(oepos.bh); |
585 | goto error_return; | 536 | goto error_return; |
586 | } | 537 | } |
587 | aed = (struct allocExtDesc *)(epos.bh->b_data); | 538 | aed = (struct allocExtDesc *)(epos.bh->b_data); |
588 | aed->previousAllocExtLocation = | 539 | aed->previousAllocExtLocation = cpu_to_le32(oepos.block.logicalBlockNum); |
589 | cpu_to_le32(oepos.block.logicalBlockNum); | ||
590 | if (epos.offset + adsize > sb->s_blocksize) { | 540 | if (epos.offset + adsize > sb->s_blocksize) { |
591 | loffset = epos.offset; | 541 | loffset = epos.offset; |
592 | aed->lengthAllocDescs = cpu_to_le32(adsize); | 542 | aed->lengthAllocDescs = cpu_to_le32(adsize); |
593 | sptr = UDF_I_DATA(inode) + epos.offset - | 543 | sptr = UDF_I_DATA(inode) + epos.offset - |
594 | udf_file_entry_alloc_offset(inode) + | 544 | udf_file_entry_alloc_offset(inode) + |
595 | UDF_I_LENEATTR(inode) - adsize; | 545 | UDF_I_LENEATTR(inode) - adsize; |
596 | dptr = | 546 | dptr = epos.bh->b_data + sizeof(struct allocExtDesc); |
597 | epos.bh->b_data + | ||
598 | sizeof(struct allocExtDesc); | ||
599 | memcpy(dptr, sptr, adsize); | 547 | memcpy(dptr, sptr, adsize); |
600 | epos.offset = | 548 | epos.offset = sizeof(struct allocExtDesc) + adsize; |
601 | sizeof(struct allocExtDesc) + adsize; | ||
602 | } else { | 549 | } else { |
603 | loffset = epos.offset + adsize; | 550 | loffset = epos.offset + adsize; |
604 | aed->lengthAllocDescs = cpu_to_le32(0); | 551 | aed->lengthAllocDescs = cpu_to_le32(0); |
@@ -606,60 +553,46 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
606 | epos.offset = sizeof(struct allocExtDesc); | 553 | epos.offset = sizeof(struct allocExtDesc); |
607 | 554 | ||
608 | if (oepos.bh) { | 555 | if (oepos.bh) { |
609 | aed = | 556 | aed = (struct allocExtDesc *)oepos.bh->b_data; |
610 | (struct allocExtDesc *)oepos.bh-> | ||
611 | b_data; | ||
612 | aed->lengthAllocDescs = | 557 | aed->lengthAllocDescs = |
613 | cpu_to_le32(le32_to_cpu | 558 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); |
614 | (aed-> | ||
615 | lengthAllocDescs) + | ||
616 | adsize); | ||
617 | } else { | 559 | } else { |
618 | UDF_I_LENALLOC(table) += adsize; | 560 | UDF_I_LENALLOC(table) += adsize; |
619 | mark_inode_dirty(table); | 561 | mark_inode_dirty(table); |
620 | } | 562 | } |
621 | } | 563 | } |
622 | if (UDF_SB_UDFREV(sb) >= 0x0200) | 564 | if (UDF_SB_UDFREV(sb) >= 0x0200) |
623 | udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 3, | 565 | udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 3, 1, |
624 | 1, epos.block.logicalBlockNum, | 566 | epos.block.logicalBlockNum, sizeof(tag)); |
625 | sizeof(tag)); | ||
626 | else | 567 | else |
627 | udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 2, | 568 | udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 2, 1, |
628 | 1, epos.block.logicalBlockNum, | 569 | epos.block.logicalBlockNum, sizeof(tag)); |
629 | sizeof(tag)); | 570 | |
630 | switch (UDF_I_ALLOCTYPE(table)) { | 571 | switch (UDF_I_ALLOCTYPE(table)) { |
631 | case ICBTAG_FLAG_AD_SHORT: | 572 | case ICBTAG_FLAG_AD_SHORT: |
632 | { | 573 | sad = (short_ad *)sptr; |
633 | sad = (short_ad *) sptr; | 574 | sad->extLength = cpu_to_le32( |
634 | sad->extLength = | 575 | EXT_NEXT_EXTENT_ALLOCDECS | |
635 | cpu_to_le32 | 576 | sb->s_blocksize); |
636 | (EXT_NEXT_EXTENT_ALLOCDECS | sb-> | 577 | sad->extPosition = cpu_to_le32(epos.block.logicalBlockNum); |
637 | s_blocksize); | ||
638 | sad->extPosition = | ||
639 | cpu_to_le32(epos.block. | ||
640 | logicalBlockNum); | ||
641 | break; | 578 | break; |
642 | } | 579 | case ICBTAG_FLAG_AD_LONG: |
643 | case ICBTAG_FLAG_AD_LONG: | 580 | lad = (long_ad *)sptr; |
644 | { | 581 | lad->extLength = cpu_to_le32( |
645 | lad = (long_ad *) sptr; | 582 | EXT_NEXT_EXTENT_ALLOCDECS | |
646 | lad->extLength = | 583 | sb->s_blocksize); |
647 | cpu_to_le32 | 584 | lad->extLocation = cpu_to_lelb(epos.block); |
648 | (EXT_NEXT_EXTENT_ALLOCDECS | sb-> | ||
649 | s_blocksize); | ||
650 | lad->extLocation = | ||
651 | cpu_to_lelb(epos.block); | ||
652 | break; | 585 | break; |
653 | } | ||
654 | } | 586 | } |
655 | if (oepos.bh) { | 587 | if (oepos.bh) { |
656 | udf_update_tag(oepos.bh->b_data, loffset); | 588 | udf_update_tag(oepos.bh->b_data, loffset); |
657 | mark_buffer_dirty(oepos.bh); | 589 | mark_buffer_dirty(oepos.bh); |
658 | } else | 590 | } else { |
659 | mark_inode_dirty(table); | 591 | mark_inode_dirty(table); |
592 | } | ||
660 | } | 593 | } |
661 | 594 | ||
662 | if (elen) { /* It's possible that stealing the block emptied the extent */ | 595 | if (elen) { /* It's possible that stealing the block emptied the extent */ |
663 | udf_write_aext(table, &epos, eloc, elen, 1); | 596 | udf_write_aext(table, &epos, eloc, elen, 1); |
664 | 597 | ||
665 | if (!epos.bh) { | 598 | if (!epos.bh) { |
@@ -668,9 +601,7 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
668 | } else { | 601 | } else { |
669 | aed = (struct allocExtDesc *)epos.bh->b_data; | 602 | aed = (struct allocExtDesc *)epos.bh->b_data; |
670 | aed->lengthAllocDescs = | 603 | aed->lengthAllocDescs = |
671 | cpu_to_le32(le32_to_cpu | 604 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); |
672 | (aed->lengthAllocDescs) + | ||
673 | adsize); | ||
674 | udf_update_tag(epos.bh->b_data, epos.offset); | 605 | udf_update_tag(epos.bh->b_data, epos.offset); |
675 | mark_buffer_dirty(epos.bh); | 606 | mark_buffer_dirty(epos.bh); |
676 | } | 607 | } |
@@ -680,7 +611,7 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
680 | brelse(epos.bh); | 611 | brelse(epos.bh); |
681 | brelse(oepos.bh); | 612 | brelse(oepos.bh); |
682 | 613 | ||
683 | error_return: | 614 | error_return: |
684 | sb->s_dirt = 1; | 615 | sb->s_dirt = 1; |
685 | mutex_unlock(&sbi->s_alloc_mutex); | 616 | mutex_unlock(&sbi->s_alloc_mutex); |
686 | return; | 617 | return; |
@@ -714,47 +645,36 @@ static int udf_table_prealloc_blocks(struct super_block *sb, | |||
714 | epos.bh = NULL; | 645 | epos.bh = NULL; |
715 | eloc.logicalBlockNum = 0xFFFFFFFF; | 646 | eloc.logicalBlockNum = 0xFFFFFFFF; |
716 | 647 | ||
717 | while (first_block != eloc.logicalBlockNum && (etype = | 648 | while (first_block != eloc.logicalBlockNum && |
718 | udf_next_aext(table, | 649 | (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { |
719 | &epos, | ||
720 | &eloc, | ||
721 | &elen, | ||
722 | 1)) != | ||
723 | -1) { | ||
724 | udf_debug("eloc=%d, elen=%d, first_block=%d\n", | 650 | udf_debug("eloc=%d, elen=%d, first_block=%d\n", |
725 | eloc.logicalBlockNum, elen, first_block); | 651 | eloc.logicalBlockNum, elen, first_block); |
726 | ; /* empty loop body */ | 652 | ; /* empty loop body */ |
727 | } | 653 | } |
728 | 654 | ||
729 | if (first_block == eloc.logicalBlockNum) { | 655 | if (first_block == eloc.logicalBlockNum) { |
730 | epos.offset -= adsize; | 656 | epos.offset -= adsize; |
731 | 657 | ||
732 | alloc_count = (elen >> sb->s_blocksize_bits); | 658 | alloc_count = (elen >> sb->s_blocksize_bits); |
733 | if (inode | 659 | if (inode && DQUOT_PREALLOC_BLOCK(inode, alloc_count > block_count ? block_count : alloc_count)) { |
734 | && DQUOT_PREALLOC_BLOCK(inode, | ||
735 | alloc_count > | ||
736 | block_count ? block_count : | ||
737 | alloc_count)) | ||
738 | alloc_count = 0; | 660 | alloc_count = 0; |
739 | else if (alloc_count > block_count) { | 661 | } else if (alloc_count > block_count) { |
740 | alloc_count = block_count; | 662 | alloc_count = block_count; |
741 | eloc.logicalBlockNum += alloc_count; | 663 | eloc.logicalBlockNum += alloc_count; |
742 | elen -= (alloc_count << sb->s_blocksize_bits); | 664 | elen -= (alloc_count << sb->s_blocksize_bits); |
743 | udf_write_aext(table, &epos, eloc, (etype << 30) | elen, | 665 | udf_write_aext(table, &epos, eloc, (etype << 30) | elen, 1); |
744 | 1); | 666 | } else { |
745 | } else | 667 | udf_delete_aext(table, epos, eloc, (etype << 30) | elen); |
746 | udf_delete_aext(table, epos, eloc, | 668 | } |
747 | (etype << 30) | elen); | 669 | } else { |
748 | } else | ||
749 | alloc_count = 0; | 670 | alloc_count = 0; |
671 | } | ||
750 | 672 | ||
751 | brelse(epos.bh); | 673 | brelse(epos.bh); |
752 | 674 | ||
753 | if (alloc_count && UDF_SB_LVIDBH(sb)) { | 675 | if (alloc_count && UDF_SB_LVIDBH(sb)) { |
754 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = | 676 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = |
755 | cpu_to_le32(le32_to_cpu | 677 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - alloc_count); |
756 | (UDF_SB_LVID(sb)->freeSpaceTable[partition]) - | ||
757 | alloc_count); | ||
758 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 678 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); |
759 | sb->s_dirt = 1; | 679 | sb->s_dirt = 1; |
760 | } | 680 | } |
@@ -797,18 +717,17 @@ static int udf_table_new_block(struct super_block *sb, | |||
797 | epos.block = UDF_I_LOCATION(table); | 717 | epos.block = UDF_I_LOCATION(table); |
798 | epos.bh = goal_epos.bh = NULL; | 718 | epos.bh = goal_epos.bh = NULL; |
799 | 719 | ||
800 | while (spread && (etype = | 720 | while (spread && |
801 | udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { | 721 | (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { |
802 | if (goal >= eloc.logicalBlockNum) { | 722 | if (goal >= eloc.logicalBlockNum) { |
803 | if (goal < | 723 | if (goal < eloc.logicalBlockNum + (elen >> sb->s_blocksize_bits)) |
804 | eloc.logicalBlockNum + | ||
805 | (elen >> sb->s_blocksize_bits)) | ||
806 | nspread = 0; | 724 | nspread = 0; |
807 | else | 725 | else |
808 | nspread = goal - eloc.logicalBlockNum - | 726 | nspread = goal - eloc.logicalBlockNum - |
809 | (elen >> sb->s_blocksize_bits); | 727 | (elen >> sb->s_blocksize_bits); |
810 | } else | 728 | } else { |
811 | nspread = eloc.logicalBlockNum - goal; | 729 | nspread = eloc.logicalBlockNum - goal; |
730 | } | ||
812 | 731 | ||
813 | if (nspread < spread) { | 732 | if (nspread < spread) { |
814 | spread = nspread; | 733 | spread = nspread; |
@@ -856,9 +775,7 @@ static int udf_table_new_block(struct super_block *sb, | |||
856 | 775 | ||
857 | if (UDF_SB_LVIDBH(sb)) { | 776 | if (UDF_SB_LVIDBH(sb)) { |
858 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = | 777 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = |
859 | cpu_to_le32(le32_to_cpu | 778 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - 1); |
860 | (UDF_SB_LVID(sb)->freeSpaceTable[partition]) - | ||
861 | 1); | ||
862 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 779 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); |
863 | } | 780 | } |
864 | 781 | ||
@@ -877,27 +794,23 @@ inline void udf_free_blocks(struct super_block *sb, | |||
877 | 794 | ||
878 | if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) { | 795 | if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) { |
879 | return udf_bitmap_free_blocks(sb, inode, | 796 | return udf_bitmap_free_blocks(sb, inode, |
880 | UDF_SB_PARTMAPS(sb)[partition]. | 797 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap, |
881 | s_uspace.s_bitmap, bloc, offset, | 798 | bloc, offset, count); |
882 | count); | 799 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) { |
883 | } else if (UDF_SB_PARTFLAGS(sb, partition) & | ||
884 | UDF_PART_FLAG_UNALLOC_TABLE) { | ||
885 | return udf_table_free_blocks(sb, inode, | 800 | return udf_table_free_blocks(sb, inode, |
886 | UDF_SB_PARTMAPS(sb)[partition]. | 801 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table, |
887 | s_uspace.s_table, bloc, offset, | 802 | bloc, offset, count); |
888 | count); | ||
889 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) { | 803 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) { |
890 | return udf_bitmap_free_blocks(sb, inode, | 804 | return udf_bitmap_free_blocks(sb, inode, |
891 | UDF_SB_PARTMAPS(sb)[partition]. | 805 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap, |
892 | s_fspace.s_bitmap, bloc, offset, | 806 | bloc, offset, count); |
893 | count); | ||
894 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) { | 807 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) { |
895 | return udf_table_free_blocks(sb, inode, | 808 | return udf_table_free_blocks(sb, inode, |
896 | UDF_SB_PARTMAPS(sb)[partition]. | 809 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table, |
897 | s_fspace.s_table, bloc, offset, | 810 | bloc, offset, count); |
898 | count); | 811 | } else { |
899 | } else | ||
900 | return; | 812 | return; |
813 | } | ||
901 | } | 814 | } |
902 | 815 | ||
903 | inline int udf_prealloc_blocks(struct super_block *sb, | 816 | inline int udf_prealloc_blocks(struct super_block *sb, |
@@ -907,29 +820,23 @@ inline int udf_prealloc_blocks(struct super_block *sb, | |||
907 | { | 820 | { |
908 | if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) { | 821 | if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) { |
909 | return udf_bitmap_prealloc_blocks(sb, inode, | 822 | return udf_bitmap_prealloc_blocks(sb, inode, |
910 | UDF_SB_PARTMAPS(sb) | 823 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap, |
911 | [partition].s_uspace.s_bitmap, | 824 | partition, first_block, block_count); |
912 | partition, first_block, | 825 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) { |
913 | block_count); | ||
914 | } else if (UDF_SB_PARTFLAGS(sb, partition) & | ||
915 | UDF_PART_FLAG_UNALLOC_TABLE) { | ||
916 | return udf_table_prealloc_blocks(sb, inode, | 826 | return udf_table_prealloc_blocks(sb, inode, |
917 | UDF_SB_PARTMAPS(sb)[partition]. | 827 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table, |
918 | s_uspace.s_table, partition, | 828 | partition, first_block, block_count); |
919 | first_block, block_count); | ||
920 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) { | 829 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) { |
921 | return udf_bitmap_prealloc_blocks(sb, inode, | 830 | return udf_bitmap_prealloc_blocks(sb, inode, |
922 | UDF_SB_PARTMAPS(sb) | 831 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap, |
923 | [partition].s_fspace.s_bitmap, | 832 | partition, first_block, block_count); |
924 | partition, first_block, | ||
925 | block_count); | ||
926 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) { | 833 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) { |
927 | return udf_table_prealloc_blocks(sb, inode, | 834 | return udf_table_prealloc_blocks(sb, inode, |
928 | UDF_SB_PARTMAPS(sb)[partition]. | 835 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table, |
929 | s_fspace.s_table, partition, | 836 | partition, first_block, block_count); |
930 | first_block, block_count); | 837 | } else { |
931 | } else | ||
932 | return 0; | 838 | return 0; |
839 | } | ||
933 | } | 840 | } |
934 | 841 | ||
935 | inline int udf_new_block(struct super_block *sb, | 842 | inline int udf_new_block(struct super_block *sb, |
@@ -940,26 +847,21 @@ inline int udf_new_block(struct super_block *sb, | |||
940 | 847 | ||
941 | if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) { | 848 | if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) { |
942 | ret = udf_bitmap_new_block(sb, inode, | 849 | ret = udf_bitmap_new_block(sb, inode, |
943 | UDF_SB_PARTMAPS(sb)[partition]. | 850 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap, |
944 | s_uspace.s_bitmap, partition, goal, | 851 | partition, goal, err); |
945 | err); | ||
946 | return ret; | 852 | return ret; |
947 | } else if (UDF_SB_PARTFLAGS(sb, partition) & | 853 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) { |
948 | UDF_PART_FLAG_UNALLOC_TABLE) { | ||
949 | return udf_table_new_block(sb, inode, | 854 | return udf_table_new_block(sb, inode, |
950 | UDF_SB_PARTMAPS(sb)[partition]. | 855 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table, |
951 | s_uspace.s_table, partition, goal, | 856 | partition, goal, err); |
952 | err); | ||
953 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) { | 857 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) { |
954 | return udf_bitmap_new_block(sb, inode, | 858 | return udf_bitmap_new_block(sb, inode, |
955 | UDF_SB_PARTMAPS(sb)[partition]. | 859 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap, |
956 | s_fspace.s_bitmap, partition, goal, | 860 | partition, goal, err); |
957 | err); | ||
958 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) { | 861 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) { |
959 | return udf_table_new_block(sb, inode, | 862 | return udf_table_new_block(sb, inode, |
960 | UDF_SB_PARTMAPS(sb)[partition]. | 863 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table, |
961 | s_fspace.s_table, partition, goal, | 864 | partition, goal, err); |
962 | err); | ||
963 | } else { | 865 | } else { |
964 | *err = -EIO; | 866 | *err = -EIO; |
965 | return 0; | 867 | return 0; |
diff --git a/fs/udf/crc.c b/fs/udf/crc.c index ae3d49790941..85aaee5fab26 100644 --- a/fs/udf/crc.c +++ b/fs/udf/crc.c | |||
@@ -111,7 +111,7 @@ int main(void) | |||
111 | return 0; | 111 | return 0; |
112 | } | 112 | } |
113 | 113 | ||
114 | #endif /* defined(TEST) */ | 114 | #endif /* defined(TEST) */ |
115 | 115 | ||
116 | /****************************************************************************/ | 116 | /****************************************************************************/ |
117 | #if defined(GENERATE) | 117 | #if defined(GENERATE) |
@@ -169,4 +169,4 @@ int main(int argc, char **argv) | |||
169 | return 0; | 169 | return 0; |
170 | } | 170 | } |
171 | 171 | ||
172 | #endif /* defined(GENERATE) */ | 172 | #endif /* defined(GENERATE) */ |
diff --git a/fs/udf/dir.c b/fs/udf/dir.c index 79bab9fe120c..9e3b9f97ddbc 100644 --- a/fs/udf/dir.c +++ b/fs/udf/dir.c | |||
@@ -43,10 +43,10 @@ static int do_udf_readdir(struct inode *, struct file *, filldir_t, void *); | |||
43 | /* readdir and lookup functions */ | 43 | /* readdir and lookup functions */ |
44 | 44 | ||
45 | const struct file_operations udf_dir_operations = { | 45 | const struct file_operations udf_dir_operations = { |
46 | .read = generic_read_dir, | 46 | .read = generic_read_dir, |
47 | .readdir = udf_readdir, | 47 | .readdir = udf_readdir, |
48 | .ioctl = udf_ioctl, | 48 | .ioctl = udf_ioctl, |
49 | .fsync = udf_fsync_file, | 49 | .fsync = udf_fsync_file, |
50 | }; | 50 | }; |
51 | 51 | ||
52 | /* | 52 | /* |
@@ -83,8 +83,7 @@ int udf_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
83 | lock_kernel(); | 83 | lock_kernel(); |
84 | 84 | ||
85 | if (filp->f_pos == 0) { | 85 | if (filp->f_pos == 0) { |
86 | if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < | 86 | if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < 0) { |
87 | 0) { | ||
88 | unlock_kernel(); | 87 | unlock_kernel(); |
89 | return 0; | 88 | return 0; |
90 | } | 89 | } |
@@ -93,7 +92,7 @@ int udf_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
93 | 92 | ||
94 | result = do_udf_readdir(dir, filp, filldir, dirent); | 93 | result = do_udf_readdir(dir, filp, filldir, dirent); |
95 | unlock_kernel(); | 94 | unlock_kernel(); |
96 | return result; | 95 | return result; |
97 | } | 96 | } |
98 | 97 | ||
99 | static int | 98 | static int |
@@ -125,21 +124,20 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir, | |||
125 | if (nf_pos == 0) | 124 | if (nf_pos == 0) |
126 | nf_pos = (udf_ext0_offset(dir) >> 2); | 125 | nf_pos = (udf_ext0_offset(dir) >> 2); |
127 | 126 | ||
128 | fibh.soffset = fibh.eoffset = | 127 | fibh.soffset = fibh.eoffset = (nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; |
129 | (nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; | 128 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { |
130 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) | ||
131 | fibh.sbh = fibh.ebh = NULL; | 129 | fibh.sbh = fibh.ebh = NULL; |
132 | else if (inode_bmap(dir, nf_pos >> (dir->i_sb->s_blocksize_bits - 2), | 130 | } else if (inode_bmap(dir, nf_pos >> (dir->i_sb->s_blocksize_bits - 2), |
133 | &epos, &eloc, &elen, | 131 | &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { |
134 | &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { | ||
135 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); | 132 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); |
136 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { | 133 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { |
137 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) | 134 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) |
138 | epos.offset -= sizeof(short_ad); | 135 | epos.offset -= sizeof(short_ad); |
139 | else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) | 136 | else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) |
140 | epos.offset -= sizeof(long_ad); | 137 | epos.offset -= sizeof(long_ad); |
141 | } else | 138 | } else { |
142 | offset = 0; | 139 | offset = 0; |
140 | } | ||
143 | 141 | ||
144 | if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) { | 142 | if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) { |
145 | brelse(epos.bh); | 143 | brelse(epos.bh); |
@@ -149,15 +147,11 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir, | |||
149 | if (!(offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) { | 147 | if (!(offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) { |
150 | i = 16 >> (dir->i_sb->s_blocksize_bits - 9); | 148 | i = 16 >> (dir->i_sb->s_blocksize_bits - 9); |
151 | if (i + offset > (elen >> dir->i_sb->s_blocksize_bits)) | 149 | if (i + offset > (elen >> dir->i_sb->s_blocksize_bits)) |
152 | i = (elen >> dir->i_sb->s_blocksize_bits) - | 150 | i = (elen >> dir->i_sb->s_blocksize_bits) - offset; |
153 | offset; | ||
154 | for (num = 0; i > 0; i--) { | 151 | for (num = 0; i > 0; i--) { |
155 | block = | 152 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset + i); |
156 | udf_get_lb_pblock(dir->i_sb, eloc, | ||
157 | offset + i); | ||
158 | tmp = udf_tgetblk(dir->i_sb, block); | 153 | tmp = udf_tgetblk(dir->i_sb, block); |
159 | if (tmp && !buffer_uptodate(tmp) | 154 | if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp)) |
160 | && !buffer_locked(tmp)) | ||
161 | bha[num++] = tmp; | 155 | bha[num++] = tmp; |
162 | else | 156 | else |
163 | brelse(tmp); | 157 | brelse(tmp); |
@@ -178,7 +172,6 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir, | |||
178 | 172 | ||
179 | fi = udf_fileident_read(dir, &nf_pos, &fibh, &cfi, &epos, &eloc, | 173 | fi = udf_fileident_read(dir, &nf_pos, &fibh, &cfi, &epos, &eloc, |
180 | &elen, &offset); | 174 | &elen, &offset); |
181 | |||
182 | if (!fi) { | 175 | if (!fi) { |
183 | if (fibh.sbh != fibh.ebh) | 176 | if (fibh.sbh != fibh.ebh) |
184 | brelse(fibh.ebh); | 177 | brelse(fibh.ebh); |
@@ -190,19 +183,16 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir, | |||
190 | liu = le16_to_cpu(cfi.lengthOfImpUse); | 183 | liu = le16_to_cpu(cfi.lengthOfImpUse); |
191 | lfi = cfi.lengthFileIdent; | 184 | lfi = cfi.lengthFileIdent; |
192 | 185 | ||
193 | if (fibh.sbh == fibh.ebh) | 186 | if (fibh.sbh == fibh.ebh) { |
194 | nameptr = fi->fileIdent + liu; | 187 | nameptr = fi->fileIdent + liu; |
195 | else { | 188 | } else { |
196 | int poffset; /* Unpaded ending offset */ | 189 | int poffset; /* Unpaded ending offset */ |
197 | 190 | ||
198 | poffset = | 191 | poffset = fibh.soffset + sizeof(struct fileIdentDesc) + liu + lfi; |
199 | fibh.soffset + sizeof(struct fileIdentDesc) + liu + | ||
200 | lfi; | ||
201 | 192 | ||
202 | if (poffset >= lfi) | 193 | if (poffset >= lfi) { |
203 | nameptr = | 194 | nameptr = (char *)(fibh.ebh->b_data + poffset - lfi); |
204 | (char *)(fibh.ebh->b_data + poffset - lfi); | 195 | } else { |
205 | else { | ||
206 | nameptr = fname; | 196 | nameptr = fname; |
207 | memcpy(nameptr, fi->fileIdent + liu, | 197 | memcpy(nameptr, fi->fileIdent + liu, |
208 | lfi - poffset); | 198 | lfi - poffset); |
@@ -235,17 +225,15 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir, | |||
235 | } | 225 | } |
236 | 226 | ||
237 | if (flen) { | 227 | if (flen) { |
238 | if (filldir | 228 | if (filldir(dirent, fname, flen, filp->f_pos, iblock, dt_type) < 0) { |
239 | (dirent, fname, flen, filp->f_pos, iblock, | ||
240 | dt_type) < 0) { | ||
241 | if (fibh.sbh != fibh.ebh) | 229 | if (fibh.sbh != fibh.ebh) |
242 | brelse(fibh.ebh); | 230 | brelse(fibh.ebh); |
243 | brelse(fibh.sbh); | 231 | brelse(fibh.sbh); |
244 | brelse(epos.bh); | 232 | brelse(epos.bh); |
245 | return 0; | 233 | return 0; |
246 | } | 234 | } |
247 | } | 235 | } |
248 | } /* end while */ | 236 | } /* end while */ |
249 | 237 | ||
250 | filp->f_pos = nf_pos + 1; | 238 | filp->f_pos = nf_pos + 1; |
251 | 239 | ||
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 | ||
288 | short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset, | 274 | short_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 | ||
308 | long_ad *udf_get_filelongad(uint8_t * ptr, int maxoffset, int *offset, int inc) | 294 | long_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) |
diff --git a/fs/udf/ecma_167.h b/fs/udf/ecma_167.h index 294ce2daa03a..56387711589b 100644 --- a/fs/udf/ecma_167.h +++ b/fs/udf/ecma_167.h | |||
@@ -39,8 +39,8 @@ | |||
39 | 39 | ||
40 | /* Character set specification (ECMA 167r3 1/7.2.1) */ | 40 | /* Character set specification (ECMA 167r3 1/7.2.1) */ |
41 | typedef struct { | 41 | typedef struct { |
42 | uint8_t charSetType; | 42 | uint8_t charSetType; |
43 | uint8_t charSetInfo[63]; | 43 | uint8_t charSetInfo[63]; |
44 | } __attribute__ ((packed)) charspec; | 44 | } __attribute__ ((packed)) charspec; |
45 | 45 | ||
46 | /* Character Set Type (ECMA 167r3 1/7.2.1.1) */ | 46 | /* Character Set Type (ECMA 167r3 1/7.2.1.1) */ |
@@ -54,33 +54,33 @@ typedef struct { | |||
54 | #define CHARSPEC_TYPE_CS7 0x07 /* (1/7.2.9) */ | 54 | #define CHARSPEC_TYPE_CS7 0x07 /* (1/7.2.9) */ |
55 | #define CHARSPEC_TYPE_CS8 0x08 /* (1/7.2.10) */ | 55 | #define CHARSPEC_TYPE_CS8 0x08 /* (1/7.2.10) */ |
56 | 56 | ||
57 | typedef uint8_t dstring; | 57 | typedef uint8_t dstring; |
58 | 58 | ||
59 | /* Timestamp (ECMA 167r3 1/7.3) */ | 59 | /* Timestamp (ECMA 167r3 1/7.3) */ |
60 | typedef struct { | 60 | typedef struct { |
61 | __le16 typeAndTimezone; | 61 | __le16 typeAndTimezone; |
62 | __le16 year; | 62 | __le16 year; |
63 | uint8_t month; | 63 | uint8_t month; |
64 | uint8_t day; | 64 | uint8_t day; |
65 | uint8_t hour; | 65 | uint8_t hour; |
66 | uint8_t minute; | 66 | uint8_t minute; |
67 | uint8_t second; | 67 | uint8_t second; |
68 | uint8_t centiseconds; | 68 | uint8_t centiseconds; |
69 | uint8_t hundredsOfMicroseconds; | 69 | uint8_t hundredsOfMicroseconds; |
70 | uint8_t microseconds; | 70 | uint8_t microseconds; |
71 | } __attribute__ ((packed)) timestamp; | 71 | } __attribute__ ((packed)) timestamp; |
72 | 72 | ||
73 | typedef struct { | 73 | typedef struct { |
74 | uint16_t typeAndTimezone; | 74 | uint16_t typeAndTimezone; |
75 | int16_t year; | 75 | int16_t year; |
76 | uint8_t month; | 76 | uint8_t month; |
77 | uint8_t day; | 77 | uint8_t day; |
78 | uint8_t hour; | 78 | uint8_t hour; |
79 | uint8_t minute; | 79 | uint8_t minute; |
80 | uint8_t second; | 80 | uint8_t second; |
81 | uint8_t centiseconds; | 81 | uint8_t centiseconds; |
82 | uint8_t hundredsOfMicroseconds; | 82 | uint8_t hundredsOfMicroseconds; |
83 | uint8_t microseconds; | 83 | uint8_t microseconds; |
84 | } __attribute__ ((packed)) kernel_timestamp; | 84 | } __attribute__ ((packed)) kernel_timestamp; |
85 | 85 | ||
86 | /* Type and Time Zone (ECMA 167r3 1/7.3.1) */ | 86 | /* Type and Time Zone (ECMA 167r3 1/7.3.1) */ |
@@ -92,9 +92,9 @@ typedef struct { | |||
92 | 92 | ||
93 | /* Entity identifier (ECMA 167r3 1/7.4) */ | 93 | /* Entity identifier (ECMA 167r3 1/7.4) */ |
94 | typedef struct { | 94 | typedef struct { |
95 | uint8_t flags; | 95 | uint8_t flags; |
96 | uint8_t ident[23]; | 96 | uint8_t ident[23]; |
97 | uint8_t identSuffix[8]; | 97 | uint8_t identSuffix[8]; |
98 | } __attribute__ ((packed)) regid; | 98 | } __attribute__ ((packed)) regid; |
99 | 99 | ||
100 | /* Flags (ECMA 167r3 1/7.4.1) */ | 100 | /* Flags (ECMA 167r3 1/7.4.1) */ |
@@ -104,10 +104,10 @@ typedef struct { | |||
104 | /* Volume Structure Descriptor (ECMA 167r3 2/9.1) */ | 104 | /* Volume Structure Descriptor (ECMA 167r3 2/9.1) */ |
105 | #define VSD_STD_ID_LEN 5 | 105 | #define VSD_STD_ID_LEN 5 |
106 | struct volStructDesc { | 106 | struct volStructDesc { |
107 | uint8_t structType; | 107 | uint8_t structType; |
108 | uint8_t stdIdent[VSD_STD_ID_LEN]; | 108 | uint8_t stdIdent[VSD_STD_ID_LEN]; |
109 | uint8_t structVersion; | 109 | uint8_t structVersion; |
110 | uint8_t structData[2041]; | 110 | uint8_t structData[2041]; |
111 | } __attribute__ ((packed)); | 111 | } __attribute__ ((packed)); |
112 | 112 | ||
113 | /* Standard Identifier (EMCA 167r2 2/9.1.2) */ | 113 | /* Standard Identifier (EMCA 167r2 2/9.1.2) */ |
@@ -123,36 +123,36 @@ struct volStructDesc { | |||
123 | 123 | ||
124 | /* Beginning Extended Area Descriptor (ECMA 167r3 2/9.2) */ | 124 | /* Beginning Extended Area Descriptor (ECMA 167r3 2/9.2) */ |
125 | struct beginningExtendedAreaDesc { | 125 | struct beginningExtendedAreaDesc { |
126 | uint8_t structType; | 126 | uint8_t structType; |
127 | uint8_t stdIdent[VSD_STD_ID_LEN]; | 127 | uint8_t stdIdent[VSD_STD_ID_LEN]; |
128 | uint8_t structVersion; | 128 | uint8_t structVersion; |
129 | uint8_t structData[2041]; | 129 | uint8_t structData[2041]; |
130 | } __attribute__ ((packed)); | 130 | } __attribute__ ((packed)); |
131 | 131 | ||
132 | /* Terminating Extended Area Descriptor (ECMA 167r3 2/9.3) */ | 132 | /* Terminating Extended Area Descriptor (ECMA 167r3 2/9.3) */ |
133 | struct terminatingExtendedAreaDesc { | 133 | struct terminatingExtendedAreaDesc { |
134 | uint8_t structType; | 134 | uint8_t structType; |
135 | uint8_t stdIdent[VSD_STD_ID_LEN]; | 135 | uint8_t stdIdent[VSD_STD_ID_LEN]; |
136 | uint8_t structVersion; | 136 | uint8_t structVersion; |
137 | uint8_t structData[2041]; | 137 | uint8_t structData[2041]; |
138 | } __attribute__ ((packed)); | 138 | } __attribute__ ((packed)); |
139 | 139 | ||
140 | /* Boot Descriptor (ECMA 167r3 2/9.4) */ | 140 | /* Boot Descriptor (ECMA 167r3 2/9.4) */ |
141 | struct bootDesc { | 141 | struct bootDesc { |
142 | uint8_t structType; | 142 | uint8_t structType; |
143 | uint8_t stdIdent[VSD_STD_ID_LEN]; | 143 | uint8_t stdIdent[VSD_STD_ID_LEN]; |
144 | uint8_t structVersion; | 144 | uint8_t structVersion; |
145 | uint8_t reserved1; | 145 | uint8_t reserved1; |
146 | regid archType; | 146 | regid archType; |
147 | regid bootIdent; | 147 | regid bootIdent; |
148 | __le32 bootExtLocation; | 148 | __le32 bootExtLocation; |
149 | __le32 bootExtLength; | 149 | __le32 bootExtLength; |
150 | __le64 loadAddress; | 150 | __le64 loadAddress; |
151 | __le64 startAddress; | 151 | __le64 startAddress; |
152 | timestamp descCreationDateAndTime; | 152 | timestamp descCreationDateAndTime; |
153 | __le16 flags; | 153 | __le16 flags; |
154 | uint8_t reserved2[32]; | 154 | uint8_t reserved2[32]; |
155 | uint8_t bootUse[1906]; | 155 | uint8_t bootUse[1906]; |
156 | } __attribute__ ((packed)); | 156 | } __attribute__ ((packed)); |
157 | 157 | ||
158 | /* Flags (ECMA 167r3 2/9.4.12) */ | 158 | /* Flags (ECMA 167r3 2/9.4.12) */ |
@@ -160,25 +160,25 @@ struct bootDesc { | |||
160 | 160 | ||
161 | /* Extent Descriptor (ECMA 167r3 3/7.1) */ | 161 | /* Extent Descriptor (ECMA 167r3 3/7.1) */ |
162 | typedef struct { | 162 | typedef struct { |
163 | __le32 extLength; | 163 | __le32 extLength; |
164 | __le32 extLocation; | 164 | __le32 extLocation; |
165 | } __attribute__ ((packed)) extent_ad; | 165 | } __attribute__ ((packed)) extent_ad; |
166 | 166 | ||
167 | typedef struct { | 167 | typedef struct { |
168 | uint32_t extLength; | 168 | uint32_t extLength; |
169 | uint32_t extLocation; | 169 | uint32_t extLocation; |
170 | } kernel_extent_ad; | 170 | } kernel_extent_ad; |
171 | 171 | ||
172 | /* Descriptor Tag (ECMA 167r3 3/7.2) */ | 172 | /* Descriptor Tag (ECMA 167r3 3/7.2) */ |
173 | typedef struct { | 173 | typedef struct { |
174 | __le16 tagIdent; | 174 | __le16 tagIdent; |
175 | __le16 descVersion; | 175 | __le16 descVersion; |
176 | uint8_t tagChecksum; | 176 | uint8_t tagChecksum; |
177 | uint8_t reserved; | 177 | uint8_t reserved; |
178 | __le16 tagSerialNum; | 178 | __le16 tagSerialNum; |
179 | __le16 descCRC; | 179 | __le16 descCRC; |
180 | __le16 descCRCLength; | 180 | __le16 descCRCLength; |
181 | __le32 tagLocation; | 181 | __le32 tagLocation; |
182 | } __attribute__ ((packed)) tag; | 182 | } __attribute__ ((packed)) tag; |
183 | 183 | ||
184 | /* Tag Identifier (ECMA 167r3 3/7.2.1) */ | 184 | /* Tag Identifier (ECMA 167r3 3/7.2.1) */ |
@@ -194,37 +194,37 @@ typedef struct { | |||
194 | 194 | ||
195 | /* NSR Descriptor (ECMA 167r3 3/9.1) */ | 195 | /* NSR Descriptor (ECMA 167r3 3/9.1) */ |
196 | struct NSRDesc { | 196 | struct NSRDesc { |
197 | uint8_t structType; | 197 | uint8_t structType; |
198 | uint8_t stdIdent[VSD_STD_ID_LEN]; | 198 | uint8_t stdIdent[VSD_STD_ID_LEN]; |
199 | uint8_t structVersion; | 199 | uint8_t structVersion; |
200 | uint8_t reserved; | 200 | uint8_t reserved; |
201 | uint8_t structData[2040]; | 201 | uint8_t structData[2040]; |
202 | } __attribute__ ((packed)); | 202 | } __attribute__ ((packed)); |
203 | 203 | ||
204 | /* Primary Volume Descriptor (ECMA 167r3 3/10.1) */ | 204 | /* Primary Volume Descriptor (ECMA 167r3 3/10.1) */ |
205 | struct primaryVolDesc { | 205 | struct primaryVolDesc { |
206 | tag descTag; | 206 | tag descTag; |
207 | __le32 volDescSeqNum; | 207 | __le32 volDescSeqNum; |
208 | __le32 primaryVolDescNum; | 208 | __le32 primaryVolDescNum; |
209 | dstring volIdent[32]; | 209 | dstring volIdent[32]; |
210 | __le16 volSeqNum; | 210 | __le16 volSeqNum; |
211 | __le16 maxVolSeqNum; | 211 | __le16 maxVolSeqNum; |
212 | __le16 interchangeLvl; | 212 | __le16 interchangeLvl; |
213 | __le16 maxInterchangeLvl; | 213 | __le16 maxInterchangeLvl; |
214 | __le32 charSetList; | 214 | __le32 charSetList; |
215 | __le32 maxCharSetList; | 215 | __le32 maxCharSetList; |
216 | dstring volSetIdent[128]; | 216 | dstring volSetIdent[128]; |
217 | charspec descCharSet; | 217 | charspec descCharSet; |
218 | charspec explanatoryCharSet; | 218 | charspec explanatoryCharSet; |
219 | extent_ad volAbstract; | 219 | extent_ad volAbstract; |
220 | extent_ad volCopyright; | 220 | extent_ad volCopyright; |
221 | regid appIdent; | 221 | regid appIdent; |
222 | timestamp recordingDateAndTime; | 222 | timestamp recordingDateAndTime; |
223 | regid impIdent; | 223 | regid impIdent; |
224 | uint8_t impUse[64]; | 224 | uint8_t impUse[64]; |
225 | __le32 predecessorVolDescSeqLocation; | 225 | __le32 predecessorVolDescSeqLocation; |
226 | __le16 flags; | 226 | __le16 flags; |
227 | uint8_t reserved[22]; | 227 | uint8_t reserved[22]; |
228 | } __attribute__ ((packed)); | 228 | } __attribute__ ((packed)); |
229 | 229 | ||
230 | /* Flags (ECMA 167r3 3/10.1.21) */ | 230 | /* Flags (ECMA 167r3 3/10.1.21) */ |
@@ -232,26 +232,26 @@ struct primaryVolDesc { | |||
232 | 232 | ||
233 | /* Anchor Volume Descriptor Pointer (ECMA 167r3 3/10.2) */ | 233 | /* Anchor Volume Descriptor Pointer (ECMA 167r3 3/10.2) */ |
234 | struct anchorVolDescPtr { | 234 | struct anchorVolDescPtr { |
235 | tag descTag; | 235 | tag descTag; |
236 | extent_ad mainVolDescSeqExt; | 236 | extent_ad mainVolDescSeqExt; |
237 | extent_ad reserveVolDescSeqExt; | 237 | extent_ad reserveVolDescSeqExt; |
238 | uint8_t reserved[480]; | 238 | uint8_t reserved[480]; |
239 | } __attribute__ ((packed)); | 239 | } __attribute__ ((packed)); |
240 | 240 | ||
241 | /* Volume Descriptor Pointer (ECMA 167r3 3/10.3) */ | 241 | /* Volume Descriptor Pointer (ECMA 167r3 3/10.3) */ |
242 | struct volDescPtr { | 242 | struct volDescPtr { |
243 | tag descTag; | 243 | tag descTag; |
244 | __le32 volDescSeqNum; | 244 | __le32 volDescSeqNum; |
245 | extent_ad nextVolDescSeqExt; | 245 | extent_ad nextVolDescSeqExt; |
246 | uint8_t reserved[484]; | 246 | uint8_t reserved[484]; |
247 | } __attribute__ ((packed)); | 247 | } __attribute__ ((packed)); |
248 | 248 | ||
249 | /* Implementation Use Volume Descriptor (ECMA 167r3 3/10.4) */ | 249 | /* Implementation Use Volume Descriptor (ECMA 167r3 3/10.4) */ |
250 | struct impUseVolDesc { | 250 | struct impUseVolDesc { |
251 | tag descTag; | 251 | tag descTag; |
252 | __le32 volDescSeqNum; | 252 | __le32 volDescSeqNum; |
253 | regid impIdent; | 253 | regid impIdent; |
254 | uint8_t impUse[460]; | 254 | uint8_t impUse[460]; |
255 | } __attribute__ ((packed)); | 255 | } __attribute__ ((packed)); |
256 | 256 | ||
257 | /* Partition Descriptor (ECMA 167r3 3/10.5) */ | 257 | /* Partition Descriptor (ECMA 167r3 3/10.5) */ |
@@ -291,26 +291,26 @@ struct partitionDesc { | |||
291 | 291 | ||
292 | /* Logical Volume Descriptor (ECMA 167r3 3/10.6) */ | 292 | /* Logical Volume Descriptor (ECMA 167r3 3/10.6) */ |
293 | struct logicalVolDesc { | 293 | struct logicalVolDesc { |
294 | tag descTag; | 294 | tag descTag; |
295 | __le32 volDescSeqNum; | 295 | __le32 volDescSeqNum; |
296 | charspec descCharSet; | 296 | charspec descCharSet; |
297 | dstring logicalVolIdent[128]; | 297 | dstring logicalVolIdent[128]; |
298 | __le32 logicalBlockSize; | 298 | __le32 logicalBlockSize; |
299 | regid domainIdent; | 299 | regid domainIdent; |
300 | uint8_t logicalVolContentsUse[16]; | 300 | uint8_t logicalVolContentsUse[16]; |
301 | __le32 mapTableLength; | 301 | __le32 mapTableLength; |
302 | __le32 numPartitionMaps; | 302 | __le32 numPartitionMaps; |
303 | regid impIdent; | 303 | regid impIdent; |
304 | uint8_t impUse[128]; | 304 | uint8_t impUse[128]; |
305 | extent_ad integritySeqExt; | 305 | extent_ad integritySeqExt; |
306 | uint8_t partitionMaps[0]; | 306 | uint8_t partitionMaps[0]; |
307 | } __attribute__ ((packed)); | 307 | } __attribute__ ((packed)); |
308 | 308 | ||
309 | /* Generic Partition Map (ECMA 167r3 3/10.7.1) */ | 309 | /* Generic Partition Map (ECMA 167r3 3/10.7.1) */ |
310 | struct genericPartitionMap { | 310 | struct genericPartitionMap { |
311 | uint8_t partitionMapType; | 311 | uint8_t partitionMapType; |
312 | uint8_t partitionMapLength; | 312 | uint8_t partitionMapLength; |
313 | uint8_t partitionMapping[0]; | 313 | uint8_t partitionMapping[0]; |
314 | } __attribute__ ((packed)); | 314 | } __attribute__ ((packed)); |
315 | 315 | ||
316 | /* Partition Map Type (ECMA 167r3 3/10.7.1.1) */ | 316 | /* Partition Map Type (ECMA 167r3 3/10.7.1.1) */ |
@@ -320,45 +320,45 @@ struct genericPartitionMap { | |||
320 | 320 | ||
321 | /* Type 1 Partition Map (ECMA 167r3 3/10.7.2) */ | 321 | /* Type 1 Partition Map (ECMA 167r3 3/10.7.2) */ |
322 | struct genericPartitionMap1 { | 322 | struct genericPartitionMap1 { |
323 | uint8_t partitionMapType; | 323 | uint8_t partitionMapType; |
324 | uint8_t partitionMapLength; | 324 | uint8_t partitionMapLength; |
325 | __le16 volSeqNum; | 325 | __le16 volSeqNum; |
326 | __le16 partitionNum; | 326 | __le16 partitionNum; |
327 | } __attribute__ ((packed)); | 327 | } __attribute__ ((packed)); |
328 | 328 | ||
329 | /* Type 2 Partition Map (ECMA 167r3 3/10.7.3) */ | 329 | /* Type 2 Partition Map (ECMA 167r3 3/10.7.3) */ |
330 | struct genericPartitionMap2 { | 330 | struct genericPartitionMap2 { |
331 | uint8_t partitionMapType; | 331 | uint8_t partitionMapType; |
332 | uint8_t partitionMapLength; | 332 | uint8_t partitionMapLength; |
333 | uint8_t partitionIdent[62]; | 333 | uint8_t partitionIdent[62]; |
334 | } __attribute__ ((packed)); | 334 | } __attribute__ ((packed)); |
335 | 335 | ||
336 | /* Unallocated Space Descriptor (ECMA 167r3 3/10.8) */ | 336 | /* Unallocated Space Descriptor (ECMA 167r3 3/10.8) */ |
337 | struct unallocSpaceDesc { | 337 | struct unallocSpaceDesc { |
338 | tag descTag; | 338 | tag descTag; |
339 | __le32 volDescSeqNum; | 339 | __le32 volDescSeqNum; |
340 | __le32 numAllocDescs; | 340 | __le32 numAllocDescs; |
341 | extent_ad allocDescs[0]; | 341 | extent_ad allocDescs[0]; |
342 | } __attribute__ ((packed)); | 342 | } __attribute__ ((packed)); |
343 | 343 | ||
344 | /* Terminating Descriptor (ECMA 167r3 3/10.9) */ | 344 | /* Terminating Descriptor (ECMA 167r3 3/10.9) */ |
345 | struct terminatingDesc { | 345 | struct terminatingDesc { |
346 | tag descTag; | 346 | tag descTag; |
347 | uint8_t reserved[496]; | 347 | uint8_t reserved[496]; |
348 | } __attribute__ ((packed)); | 348 | } __attribute__ ((packed)); |
349 | 349 | ||
350 | /* Logical Volume Integrity Descriptor (ECMA 167r3 3/10.10) */ | 350 | /* Logical Volume Integrity Descriptor (ECMA 167r3 3/10.10) */ |
351 | struct logicalVolIntegrityDesc { | 351 | struct logicalVolIntegrityDesc { |
352 | tag descTag; | 352 | tag descTag; |
353 | timestamp recordingDateAndTime; | 353 | timestamp recordingDateAndTime; |
354 | __le32 integrityType; | 354 | __le32 integrityType; |
355 | extent_ad nextIntegrityExt; | 355 | extent_ad nextIntegrityExt; |
356 | uint8_t logicalVolContentsUse[32]; | 356 | uint8_t logicalVolContentsUse[32]; |
357 | __le32 numOfPartitions; | 357 | __le32 numOfPartitions; |
358 | __le32 lengthOfImpUse; | 358 | __le32 lengthOfImpUse; |
359 | __le32 freeSpaceTable[0]; | 359 | __le32 freeSpaceTable[0]; |
360 | __le32 sizeTable[0]; | 360 | __le32 sizeTable[0]; |
361 | uint8_t impUse[0]; | 361 | uint8_t impUse[0]; |
362 | } __attribute__ ((packed)); | 362 | } __attribute__ ((packed)); |
363 | 363 | ||
364 | /* Integrity Type (ECMA 167r3 3/10.10.3) */ | 364 | /* Integrity Type (ECMA 167r3 3/10.10.3) */ |
@@ -367,48 +367,48 @@ struct logicalVolIntegrityDesc { | |||
367 | 367 | ||
368 | /* Recorded Address (ECMA 167r3 4/7.1) */ | 368 | /* Recorded Address (ECMA 167r3 4/7.1) */ |
369 | typedef struct { | 369 | typedef struct { |
370 | __le32 logicalBlockNum; | 370 | __le32 logicalBlockNum; |
371 | __le16 partitionReferenceNum; | 371 | __le16 partitionReferenceNum; |
372 | } __attribute__ ((packed)) lb_addr; | 372 | } __attribute__ ((packed)) lb_addr; |
373 | 373 | ||
374 | /* ... and its in-core analog */ | 374 | /* ... and its in-core analog */ |
375 | typedef struct { | 375 | typedef struct { |
376 | uint32_t logicalBlockNum; | 376 | uint32_t logicalBlockNum; |
377 | uint16_t partitionReferenceNum; | 377 | uint16_t partitionReferenceNum; |
378 | } kernel_lb_addr; | 378 | } kernel_lb_addr; |
379 | 379 | ||
380 | /* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */ | 380 | /* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */ |
381 | typedef struct { | 381 | typedef struct { |
382 | __le32 extLength; | 382 | __le32 extLength; |
383 | __le32 extPosition; | 383 | __le32 extPosition; |
384 | } __attribute__ ((packed)) short_ad; | 384 | } __attribute__ ((packed)) short_ad; |
385 | 385 | ||
386 | /* Long Allocation Descriptor (ECMA 167r3 4/14.14.2) */ | 386 | /* Long Allocation Descriptor (ECMA 167r3 4/14.14.2) */ |
387 | typedef struct { | 387 | typedef struct { |
388 | __le32 extLength; | 388 | __le32 extLength; |
389 | lb_addr extLocation; | 389 | lb_addr extLocation; |
390 | uint8_t impUse[6]; | 390 | uint8_t impUse[6]; |
391 | } __attribute__ ((packed)) long_ad; | 391 | } __attribute__ ((packed)) long_ad; |
392 | 392 | ||
393 | typedef struct { | 393 | typedef struct { |
394 | uint32_t extLength; | 394 | uint32_t extLength; |
395 | kernel_lb_addr extLocation; | 395 | kernel_lb_addr extLocation; |
396 | uint8_t impUse[6]; | 396 | uint8_t impUse[6]; |
397 | } kernel_long_ad; | 397 | } kernel_long_ad; |
398 | 398 | ||
399 | /* Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */ | 399 | /* Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */ |
400 | typedef struct { | 400 | typedef struct { |
401 | __le32 extLength; | 401 | __le32 extLength; |
402 | __le32 recordedLength; | 402 | __le32 recordedLength; |
403 | __le32 informationLength; | 403 | __le32 informationLength; |
404 | lb_addr extLocation; | 404 | lb_addr extLocation; |
405 | } __attribute__ ((packed)) ext_ad; | 405 | } __attribute__ ((packed)) ext_ad; |
406 | 406 | ||
407 | typedef struct { | 407 | typedef struct { |
408 | uint32_t extLength; | 408 | uint32_t extLength; |
409 | uint32_t recordedLength; | 409 | uint32_t recordedLength; |
410 | uint32_t informationLength; | 410 | uint32_t informationLength; |
411 | kernel_lb_addr extLocation; | 411 | kernel_lb_addr extLocation; |
412 | } kernel_ext_ad; | 412 | } kernel_ext_ad; |
413 | 413 | ||
414 | /* Descriptor Tag (ECMA 167r3 4/7.2 - See 3/7.2) */ | 414 | /* Descriptor Tag (ECMA 167r3 4/7.2 - See 3/7.2) */ |
@@ -428,48 +428,48 @@ typedef struct { | |||
428 | 428 | ||
429 | /* File Set Descriptor (ECMA 167r3 4/14.1) */ | 429 | /* File Set Descriptor (ECMA 167r3 4/14.1) */ |
430 | struct fileSetDesc { | 430 | struct fileSetDesc { |
431 | tag descTag; | 431 | tag descTag; |
432 | timestamp recordingDateAndTime; | 432 | timestamp recordingDateAndTime; |
433 | __le16 interchangeLvl; | 433 | __le16 interchangeLvl; |
434 | __le16 maxInterchangeLvl; | 434 | __le16 maxInterchangeLvl; |
435 | __le32 charSetList; | 435 | __le32 charSetList; |
436 | __le32 maxCharSetList; | 436 | __le32 maxCharSetList; |
437 | __le32 fileSetNum; | 437 | __le32 fileSetNum; |
438 | __le32 fileSetDescNum; | 438 | __le32 fileSetDescNum; |
439 | charspec logicalVolIdentCharSet; | 439 | charspec logicalVolIdentCharSet; |
440 | dstring logicalVolIdent[128]; | 440 | dstring logicalVolIdent[128]; |
441 | charspec fileSetCharSet; | 441 | charspec fileSetCharSet; |
442 | dstring fileSetIdent[32]; | 442 | dstring fileSetIdent[32]; |
443 | dstring copyrightFileIdent[32]; | 443 | dstring copyrightFileIdent[32]; |
444 | dstring abstractFileIdent[32]; | 444 | dstring abstractFileIdent[32]; |
445 | long_ad rootDirectoryICB; | 445 | long_ad rootDirectoryICB; |
446 | regid domainIdent; | 446 | regid domainIdent; |
447 | long_ad nextExt; | 447 | long_ad nextExt; |
448 | long_ad streamDirectoryICB; | 448 | long_ad streamDirectoryICB; |
449 | uint8_t reserved[32]; | 449 | uint8_t reserved[32]; |
450 | } __attribute__ ((packed)); | 450 | } __attribute__ ((packed)); |
451 | 451 | ||
452 | /* Partition Header Descriptor (ECMA 167r3 4/14.3) */ | 452 | /* Partition Header Descriptor (ECMA 167r3 4/14.3) */ |
453 | struct partitionHeaderDesc { | 453 | struct partitionHeaderDesc { |
454 | short_ad unallocSpaceTable; | 454 | short_ad unallocSpaceTable; |
455 | short_ad unallocSpaceBitmap; | 455 | short_ad unallocSpaceBitmap; |
456 | short_ad partitionIntegrityTable; | 456 | short_ad partitionIntegrityTable; |
457 | short_ad freedSpaceTable; | 457 | short_ad freedSpaceTable; |
458 | short_ad freedSpaceBitmap; | 458 | short_ad freedSpaceBitmap; |
459 | uint8_t reserved[88]; | 459 | uint8_t reserved[88]; |
460 | } __attribute__ ((packed)); | 460 | } __attribute__ ((packed)); |
461 | 461 | ||
462 | /* File Identifier Descriptor (ECMA 167r3 4/14.4) */ | 462 | /* File Identifier Descriptor (ECMA 167r3 4/14.4) */ |
463 | struct fileIdentDesc { | 463 | struct fileIdentDesc { |
464 | tag descTag; | 464 | tag descTag; |
465 | __le16 fileVersionNum; | 465 | __le16 fileVersionNum; |
466 | uint8_t fileCharacteristics; | 466 | uint8_t fileCharacteristics; |
467 | uint8_t lengthFileIdent; | 467 | uint8_t lengthFileIdent; |
468 | long_ad icb; | 468 | long_ad icb; |
469 | __le16 lengthOfImpUse; | 469 | __le16 lengthOfImpUse; |
470 | uint8_t impUse[0]; | 470 | uint8_t impUse[0]; |
471 | uint8_t fileIdent[0]; | 471 | uint8_t fileIdent[0]; |
472 | uint8_t padding[0]; | 472 | uint8_t padding[0]; |
473 | } __attribute__ ((packed)); | 473 | } __attribute__ ((packed)); |
474 | 474 | ||
475 | /* File Characteristics (ECMA 167r3 4/14.4.3) */ | 475 | /* File Characteristics (ECMA 167r3 4/14.4.3) */ |
@@ -481,21 +481,21 @@ struct fileIdentDesc { | |||
481 | 481 | ||
482 | /* Allocation Ext Descriptor (ECMA 167r3 4/14.5) */ | 482 | /* Allocation Ext Descriptor (ECMA 167r3 4/14.5) */ |
483 | struct allocExtDesc { | 483 | struct allocExtDesc { |
484 | tag descTag; | 484 | tag descTag; |
485 | __le32 previousAllocExtLocation; | 485 | __le32 previousAllocExtLocation; |
486 | __le32 lengthAllocDescs; | 486 | __le32 lengthAllocDescs; |
487 | } __attribute__ ((packed)); | 487 | } __attribute__ ((packed)); |
488 | 488 | ||
489 | /* ICB Tag (ECMA 167r3 4/14.6) */ | 489 | /* ICB Tag (ECMA 167r3 4/14.6) */ |
490 | typedef struct { | 490 | typedef struct { |
491 | __le32 priorRecordedNumDirectEntries; | 491 | __le32 priorRecordedNumDirectEntries; |
492 | __le16 strategyType; | 492 | __le16 strategyType; |
493 | __le16 strategyParameter; | 493 | __le16 strategyParameter; |
494 | __le16 numEntries; | 494 | __le16 numEntries; |
495 | uint8_t reserved; | 495 | uint8_t reserved; |
496 | uint8_t fileType; | 496 | uint8_t fileType; |
497 | lb_addr parentICBLocation; | 497 | lb_addr parentICBLocation; |
498 | __le16 flags; | 498 | __le16 flags; |
499 | } __attribute__ ((packed)) icbtag; | 499 | } __attribute__ ((packed)) icbtag; |
500 | 500 | ||
501 | /* Strategy Type (ECMA 167r3 4/14.6.2) */ | 501 | /* Strategy Type (ECMA 167r3 4/14.6.2) */ |
@@ -541,41 +541,41 @@ typedef struct { | |||
541 | 541 | ||
542 | /* Indirect Entry (ECMA 167r3 4/14.7) */ | 542 | /* Indirect Entry (ECMA 167r3 4/14.7) */ |
543 | struct indirectEntry { | 543 | struct indirectEntry { |
544 | tag descTag; | 544 | tag descTag; |
545 | icbtag icbTag; | 545 | icbtag icbTag; |
546 | long_ad indirectICB; | 546 | long_ad indirectICB; |
547 | } __attribute__ ((packed)); | 547 | } __attribute__ ((packed)); |
548 | 548 | ||
549 | /* Terminal Entry (ECMA 167r3 4/14.8) */ | 549 | /* Terminal Entry (ECMA 167r3 4/14.8) */ |
550 | struct terminalEntry { | 550 | struct terminalEntry { |
551 | tag descTag; | 551 | tag descTag; |
552 | icbtag icbTag; | 552 | icbtag icbTag; |
553 | } __attribute__ ((packed)); | 553 | } __attribute__ ((packed)); |
554 | 554 | ||
555 | /* File Entry (ECMA 167r3 4/14.9) */ | 555 | /* File Entry (ECMA 167r3 4/14.9) */ |
556 | struct fileEntry { | 556 | struct fileEntry { |
557 | tag descTag; | 557 | tag descTag; |
558 | icbtag icbTag; | 558 | icbtag icbTag; |
559 | __le32 uid; | 559 | __le32 uid; |
560 | __le32 gid; | 560 | __le32 gid; |
561 | __le32 permissions; | 561 | __le32 permissions; |
562 | __le16 fileLinkCount; | 562 | __le16 fileLinkCount; |
563 | uint8_t recordFormat; | 563 | uint8_t recordFormat; |
564 | uint8_t recordDisplayAttr; | 564 | uint8_t recordDisplayAttr; |
565 | __le32 recordLength; | 565 | __le32 recordLength; |
566 | __le64 informationLength; | 566 | __le64 informationLength; |
567 | __le64 logicalBlocksRecorded; | 567 | __le64 logicalBlocksRecorded; |
568 | timestamp accessTime; | 568 | timestamp accessTime; |
569 | timestamp modificationTime; | 569 | timestamp modificationTime; |
570 | timestamp attrTime; | 570 | timestamp attrTime; |
571 | __le32 checkpoint; | 571 | __le32 checkpoint; |
572 | long_ad extendedAttrICB; | 572 | long_ad extendedAttrICB; |
573 | regid impIdent; | 573 | regid impIdent; |
574 | __le64 uniqueID; | 574 | __le64 uniqueID; |
575 | __le32 lengthExtendedAttr; | 575 | __le32 lengthExtendedAttr; |
576 | __le32 lengthAllocDescs; | 576 | __le32 lengthAllocDescs; |
577 | uint8_t extendedAttr[0]; | 577 | uint8_t extendedAttr[0]; |
578 | uint8_t allocDescs[0]; | 578 | uint8_t allocDescs[0]; |
579 | } __attribute__ ((packed)); | 579 | } __attribute__ ((packed)); |
580 | 580 | ||
581 | /* Permissions (ECMA 167r3 4/14.9.5) */ | 581 | /* Permissions (ECMA 167r3 4/14.9.5) */ |
@@ -617,51 +617,51 @@ struct fileEntry { | |||
617 | 617 | ||
618 | /* Extended Attribute Header Descriptor (ECMA 167r3 4/14.10.1) */ | 618 | /* Extended Attribute Header Descriptor (ECMA 167r3 4/14.10.1) */ |
619 | struct extendedAttrHeaderDesc { | 619 | struct extendedAttrHeaderDesc { |
620 | tag descTag; | 620 | tag descTag; |
621 | __le32 impAttrLocation; | 621 | __le32 impAttrLocation; |
622 | __le32 appAttrLocation; | 622 | __le32 appAttrLocation; |
623 | } __attribute__ ((packed)); | 623 | } __attribute__ ((packed)); |
624 | 624 | ||
625 | /* Generic Format (ECMA 167r3 4/14.10.2) */ | 625 | /* Generic Format (ECMA 167r3 4/14.10.2) */ |
626 | struct genericFormat { | 626 | struct genericFormat { |
627 | __le32 attrType; | 627 | __le32 attrType; |
628 | uint8_t attrSubtype; | 628 | uint8_t attrSubtype; |
629 | uint8_t reserved[3]; | 629 | uint8_t reserved[3]; |
630 | __le32 attrLength; | 630 | __le32 attrLength; |
631 | uint8_t attrData[0]; | 631 | uint8_t attrData[0]; |
632 | } __attribute__ ((packed)); | 632 | } __attribute__ ((packed)); |
633 | 633 | ||
634 | /* Character Set Information (ECMA 167r3 4/14.10.3) */ | 634 | /* Character Set Information (ECMA 167r3 4/14.10.3) */ |
635 | struct charSetInfo { | 635 | struct charSetInfo { |
636 | __le32 attrType; | 636 | __le32 attrType; |
637 | uint8_t attrSubtype; | 637 | uint8_t attrSubtype; |
638 | uint8_t reserved[3]; | 638 | uint8_t reserved[3]; |
639 | __le32 attrLength; | 639 | __le32 attrLength; |
640 | __le32 escapeSeqLength; | 640 | __le32 escapeSeqLength; |
641 | uint8_t charSetType; | 641 | uint8_t charSetType; |
642 | uint8_t escapeSeq[0]; | 642 | uint8_t escapeSeq[0]; |
643 | } __attribute__ ((packed)); | 643 | } __attribute__ ((packed)); |
644 | 644 | ||
645 | /* Alternate Permissions (ECMA 167r3 4/14.10.4) */ | 645 | /* Alternate Permissions (ECMA 167r3 4/14.10.4) */ |
646 | struct altPerms { | 646 | struct altPerms { |
647 | __le32 attrType; | 647 | __le32 attrType; |
648 | uint8_t attrSubtype; | 648 | uint8_t attrSubtype; |
649 | uint8_t reserved[3]; | 649 | uint8_t reserved[3]; |
650 | __le32 attrLength; | 650 | __le32 attrLength; |
651 | __le16 ownerIdent; | 651 | __le16 ownerIdent; |
652 | __le16 groupIdent; | 652 | __le16 groupIdent; |
653 | __le16 permission; | 653 | __le16 permission; |
654 | } __attribute__ ((packed)); | 654 | } __attribute__ ((packed)); |
655 | 655 | ||
656 | /* File Times Extended Attribute (ECMA 167r3 4/14.10.5) */ | 656 | /* File Times Extended Attribute (ECMA 167r3 4/14.10.5) */ |
657 | struct fileTimesExtAttr { | 657 | struct fileTimesExtAttr { |
658 | __le32 attrType; | 658 | __le32 attrType; |
659 | uint8_t attrSubtype; | 659 | uint8_t attrSubtype; |
660 | uint8_t reserved[3]; | 660 | uint8_t reserved[3]; |
661 | __le32 attrLength; | 661 | __le32 attrLength; |
662 | __le32 dataLength; | 662 | __le32 dataLength; |
663 | __le32 fileTimeExistence; | 663 | __le32 fileTimeExistence; |
664 | uint8_t fileTimes; | 664 | uint8_t fileTimes; |
665 | } __attribute__ ((packed)); | 665 | } __attribute__ ((packed)); |
666 | 666 | ||
667 | /* FileTimeExistence (ECMA 167r3 4/14.10.5.6) */ | 667 | /* FileTimeExistence (ECMA 167r3 4/14.10.5.6) */ |
@@ -672,47 +672,47 @@ struct fileTimesExtAttr { | |||
672 | 672 | ||
673 | /* Information Times Extended Attribute (ECMA 167r3 4/14.10.6) */ | 673 | /* Information Times Extended Attribute (ECMA 167r3 4/14.10.6) */ |
674 | struct infoTimesExtAttr { | 674 | struct infoTimesExtAttr { |
675 | __le32 attrType; | 675 | __le32 attrType; |
676 | uint8_t attrSubtype; | 676 | uint8_t attrSubtype; |
677 | uint8_t reserved[3]; | 677 | uint8_t reserved[3]; |
678 | __le32 attrLength; | 678 | __le32 attrLength; |
679 | __le32 dataLength; | 679 | __le32 dataLength; |
680 | __le32 infoTimeExistence; | 680 | __le32 infoTimeExistence; |
681 | uint8_t infoTimes[0]; | 681 | uint8_t infoTimes[0]; |
682 | } __attribute__ ((packed)); | 682 | } __attribute__ ((packed)); |
683 | 683 | ||
684 | /* Device Specification (ECMA 167r3 4/14.10.7) */ | 684 | /* Device Specification (ECMA 167r3 4/14.10.7) */ |
685 | struct deviceSpec { | 685 | struct deviceSpec { |
686 | __le32 attrType; | 686 | __le32 attrType; |
687 | uint8_t attrSubtype; | 687 | uint8_t attrSubtype; |
688 | uint8_t reserved[3]; | 688 | uint8_t reserved[3]; |
689 | __le32 attrLength; | 689 | __le32 attrLength; |
690 | __le32 impUseLength; | 690 | __le32 impUseLength; |
691 | __le32 majorDeviceIdent; | 691 | __le32 majorDeviceIdent; |
692 | __le32 minorDeviceIdent; | 692 | __le32 minorDeviceIdent; |
693 | uint8_t impUse[0]; | 693 | uint8_t impUse[0]; |
694 | } __attribute__ ((packed)); | 694 | } __attribute__ ((packed)); |
695 | 695 | ||
696 | /* Implementation Use Extended Attr (ECMA 167r3 4/14.10.8) */ | 696 | /* Implementation Use Extended Attr (ECMA 167r3 4/14.10.8) */ |
697 | struct impUseExtAttr { | 697 | struct impUseExtAttr { |
698 | __le32 attrType; | 698 | __le32 attrType; |
699 | uint8_t attrSubtype; | 699 | uint8_t attrSubtype; |
700 | uint8_t reserved[3]; | 700 | uint8_t reserved[3]; |
701 | __le32 attrLength; | 701 | __le32 attrLength; |
702 | __le32 impUseLength; | 702 | __le32 impUseLength; |
703 | regid impIdent; | 703 | regid impIdent; |
704 | uint8_t impUse[0]; | 704 | uint8_t impUse[0]; |
705 | } __attribute__ ((packed)); | 705 | } __attribute__ ((packed)); |
706 | 706 | ||
707 | /* Application Use Extended Attribute (ECMA 167r3 4/14.10.9) */ | 707 | /* Application Use Extended Attribute (ECMA 167r3 4/14.10.9) */ |
708 | struct appUseExtAttr { | 708 | struct appUseExtAttr { |
709 | __le32 attrType; | 709 | __le32 attrType; |
710 | uint8_t attrSubtype; | 710 | uint8_t attrSubtype; |
711 | uint8_t reserved[3]; | 711 | uint8_t reserved[3]; |
712 | __le32 attrLength; | 712 | __le32 attrLength; |
713 | __le32 appUseLength; | 713 | __le32 appUseLength; |
714 | regid appIdent; | 714 | regid appIdent; |
715 | uint8_t appUse[0]; | 715 | uint8_t appUse[0]; |
716 | } __attribute__ ((packed)); | 716 | } __attribute__ ((packed)); |
717 | 717 | ||
718 | #define EXTATTR_CHAR_SET 1 | 718 | #define EXTATTR_CHAR_SET 1 |
@@ -725,29 +725,29 @@ struct appUseExtAttr { | |||
725 | 725 | ||
726 | /* Unallocated Space Entry (ECMA 167r3 4/14.11) */ | 726 | /* Unallocated Space Entry (ECMA 167r3 4/14.11) */ |
727 | struct unallocSpaceEntry { | 727 | struct unallocSpaceEntry { |
728 | tag descTag; | 728 | tag descTag; |
729 | icbtag icbTag; | 729 | icbtag icbTag; |
730 | __le32 lengthAllocDescs; | 730 | __le32 lengthAllocDescs; |
731 | uint8_t allocDescs[0]; | 731 | uint8_t allocDescs[0]; |
732 | } __attribute__ ((packed)); | 732 | } __attribute__ ((packed)); |
733 | 733 | ||
734 | /* Space Bitmap Descriptor (ECMA 167r3 4/14.12) */ | 734 | /* Space Bitmap Descriptor (ECMA 167r3 4/14.12) */ |
735 | struct spaceBitmapDesc { | 735 | struct spaceBitmapDesc { |
736 | tag descTag; | 736 | tag descTag; |
737 | __le32 numOfBits; | 737 | __le32 numOfBits; |
738 | __le32 numOfBytes; | 738 | __le32 numOfBytes; |
739 | uint8_t bitmap[0]; | 739 | uint8_t bitmap[0]; |
740 | } __attribute__ ((packed)); | 740 | } __attribute__ ((packed)); |
741 | 741 | ||
742 | /* Partition Integrity Entry (ECMA 167r3 4/14.13) */ | 742 | /* Partition Integrity Entry (ECMA 167r3 4/14.13) */ |
743 | struct partitionIntegrityEntry { | 743 | struct partitionIntegrityEntry { |
744 | tag descTag; | 744 | tag descTag; |
745 | icbtag icbTag; | 745 | icbtag icbTag; |
746 | timestamp recordingDateAndTime; | 746 | timestamp recordingDateAndTime; |
747 | uint8_t integrityType; | 747 | uint8_t integrityType; |
748 | uint8_t reserved[175]; | 748 | uint8_t reserved[175]; |
749 | regid impIdent; | 749 | regid impIdent; |
750 | uint8_t impUse[256]; | 750 | uint8_t impUse[256]; |
751 | } __attribute__ ((packed)); | 751 | } __attribute__ ((packed)); |
752 | 752 | ||
753 | /* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */ | 753 | /* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */ |
@@ -764,46 +764,46 @@ struct partitionIntegrityEntry { | |||
764 | 764 | ||
765 | /* Logical Volume Header Descriptor (ECMA 167r3 4/14.15) */ | 765 | /* Logical Volume Header Descriptor (ECMA 167r3 4/14.15) */ |
766 | struct logicalVolHeaderDesc { | 766 | struct logicalVolHeaderDesc { |
767 | __le64 uniqueID; | 767 | __le64 uniqueID; |
768 | uint8_t reserved[24]; | 768 | uint8_t reserved[24]; |
769 | } __attribute__ ((packed)); | 769 | } __attribute__ ((packed)); |
770 | 770 | ||
771 | /* Path Component (ECMA 167r3 4/14.16.1) */ | 771 | /* Path Component (ECMA 167r3 4/14.16.1) */ |
772 | struct pathComponent { | 772 | struct pathComponent { |
773 | uint8_t componentType; | 773 | uint8_t componentType; |
774 | uint8_t lengthComponentIdent; | 774 | uint8_t lengthComponentIdent; |
775 | __le16 componentFileVersionNum; | 775 | __le16 componentFileVersionNum; |
776 | dstring componentIdent[0]; | 776 | dstring componentIdent[0]; |
777 | } __attribute__ ((packed)); | 777 | } __attribute__ ((packed)); |
778 | 778 | ||
779 | /* File Entry (ECMA 167r3 4/14.17) */ | 779 | /* File Entry (ECMA 167r3 4/14.17) */ |
780 | struct extendedFileEntry { | 780 | struct extendedFileEntry { |
781 | tag descTag; | 781 | tag descTag; |
782 | icbtag icbTag; | 782 | icbtag icbTag; |
783 | __le32 uid; | 783 | __le32 uid; |
784 | __le32 gid; | 784 | __le32 gid; |
785 | __le32 permissions; | 785 | __le32 permissions; |
786 | __le16 fileLinkCount; | 786 | __le16 fileLinkCount; |
787 | uint8_t recordFormat; | 787 | uint8_t recordFormat; |
788 | uint8_t recordDisplayAttr; | 788 | uint8_t recordDisplayAttr; |
789 | __le32 recordLength; | 789 | __le32 recordLength; |
790 | __le64 informationLength; | 790 | __le64 informationLength; |
791 | __le64 objectSize; | 791 | __le64 objectSize; |
792 | __le64 logicalBlocksRecorded; | 792 | __le64 logicalBlocksRecorded; |
793 | timestamp accessTime; | 793 | timestamp accessTime; |
794 | timestamp modificationTime; | 794 | timestamp modificationTime; |
795 | timestamp createTime; | 795 | timestamp createTime; |
796 | timestamp attrTime; | 796 | timestamp attrTime; |
797 | __le32 checkpoint; | 797 | __le32 checkpoint; |
798 | __le32 reserved; | 798 | __le32 reserved; |
799 | long_ad extendedAttrICB; | 799 | long_ad extendedAttrICB; |
800 | long_ad streamDirectoryICB; | 800 | long_ad streamDirectoryICB; |
801 | regid impIdent; | 801 | regid impIdent; |
802 | __le64 uniqueID; | 802 | __le64 uniqueID; |
803 | __le32 lengthExtendedAttr; | 803 | __le32 lengthExtendedAttr; |
804 | __le32 lengthAllocDescs; | 804 | __le32 lengthAllocDescs; |
805 | uint8_t extendedAttr[0]; | 805 | uint8_t extendedAttr[0]; |
806 | uint8_t allocDescs[0]; | 806 | uint8_t allocDescs[0]; |
807 | } __attribute__ ((packed)); | 807 | } __attribute__ ((packed)); |
808 | 808 | ||
809 | #endif /* _ECMA_167_H */ | 809 | #endif /* _ECMA_167_H */ |
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 = { |
diff --git a/fs/udf/fsync.c b/fs/udf/fsync.c index 7f0901c4f1f1..b2c472b733b8 100644 --- a/fs/udf/fsync.c +++ b/fs/udf/fsync.c | |||
@@ -32,6 +32,7 @@ static int udf_fsync_inode(struct inode *, int); | |||
32 | int udf_fsync_file(struct file *file, struct dentry *dentry, int datasync) | 32 | int udf_fsync_file(struct file *file, struct dentry *dentry, int datasync) |
33 | { | 33 | { |
34 | struct inode *inode = dentry->d_inode; | 34 | struct inode *inode = dentry->d_inode; |
35 | |||
35 | return udf_fsync_inode(inode, datasync); | 36 | return udf_fsync_inode(inode, datasync); |
36 | } | 37 | } |
37 | 38 | ||
@@ -46,5 +47,6 @@ static int udf_fsync_inode(struct inode *inode, int datasync) | |||
46 | return err; | 47 | return err; |
47 | 48 | ||
48 | err |= udf_sync_inode(inode); | 49 | err |= udf_sync_inode(inode); |
50 | |||
49 | return err ? -EIO : 0; | 51 | return err ? -EIO : 0; |
50 | } | 52 | } |
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c index 2eb503806bce..636d8f613929 100644 --- a/fs/udf/ialloc.c +++ b/fs/udf/ialloc.c | |||
@@ -46,12 +46,10 @@ void udf_free_inode(struct inode *inode) | |||
46 | if (sbi->s_lvidbh) { | 46 | if (sbi->s_lvidbh) { |
47 | if (S_ISDIR(inode->i_mode)) | 47 | if (S_ISDIR(inode->i_mode)) |
48 | UDF_SB_LVIDIU(sb)->numDirs = | 48 | UDF_SB_LVIDIU(sb)->numDirs = |
49 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) | 49 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) - 1); |
50 | - 1); | ||
51 | else | 50 | else |
52 | UDF_SB_LVIDIU(sb)->numFiles = | 51 | UDF_SB_LVIDIU(sb)->numFiles = |
53 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) | 52 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1); |
54 | - 1); | ||
55 | 53 | ||
56 | mark_buffer_dirty(sbi->s_lvidbh); | 54 | mark_buffer_dirty(sbi->s_lvidbh); |
57 | } | 55 | } |
@@ -82,10 +80,8 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) | |||
82 | UDF_I_NEXT_ALLOC_GOAL(inode) = 0; | 80 | UDF_I_NEXT_ALLOC_GOAL(inode) = 0; |
83 | UDF_I_STRAT4096(inode) = 0; | 81 | UDF_I_STRAT4096(inode) = 0; |
84 | 82 | ||
85 | block = | 83 | block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum, |
86 | udf_new_block(dir->i_sb, NULL, | 84 | start, err); |
87 | UDF_I_LOCATION(dir).partitionReferenceNum, start, | ||
88 | err); | ||
89 | if (*err) { | 85 | if (*err) { |
90 | iput(inode); | 86 | iput(inode); |
91 | return NULL; | 87 | return NULL; |
@@ -95,17 +91,13 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) | |||
95 | if (UDF_SB_LVIDBH(sb)) { | 91 | if (UDF_SB_LVIDBH(sb)) { |
96 | struct logicalVolHeaderDesc *lvhd; | 92 | struct logicalVolHeaderDesc *lvhd; |
97 | uint64_t uniqueID; | 93 | uint64_t uniqueID; |
98 | lvhd = | 94 | lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->logicalVolContentsUse); |
99 | (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)-> | ||
100 | logicalVolContentsUse); | ||
101 | if (S_ISDIR(mode)) | 95 | if (S_ISDIR(mode)) |
102 | UDF_SB_LVIDIU(sb)->numDirs = | 96 | UDF_SB_LVIDIU(sb)->numDirs = |
103 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) | 97 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) + 1); |
104 | + 1); | ||
105 | else | 98 | else |
106 | UDF_SB_LVIDIU(sb)->numFiles = | 99 | UDF_SB_LVIDIU(sb)->numFiles = |
107 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) | 100 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + 1); |
108 | + 1); | ||
109 | UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID); | 101 | UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID); |
110 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) | 102 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) |
111 | uniqueID += 16; | 103 | uniqueID += 16; |
@@ -118,12 +110,12 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) | |||
118 | inode->i_gid = dir->i_gid; | 110 | inode->i_gid = dir->i_gid; |
119 | if (S_ISDIR(mode)) | 111 | if (S_ISDIR(mode)) |
120 | mode |= S_ISGID; | 112 | mode |= S_ISGID; |
121 | } else | 113 | } else { |
122 | inode->i_gid = current->fsgid; | 114 | inode->i_gid = current->fsgid; |
115 | } | ||
123 | 116 | ||
124 | UDF_I_LOCATION(inode).logicalBlockNum = block; | 117 | UDF_I_LOCATION(inode).logicalBlockNum = block; |
125 | UDF_I_LOCATION(inode).partitionReferenceNum = | 118 | UDF_I_LOCATION(inode).partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum; |
126 | UDF_I_LOCATION(dir).partitionReferenceNum; | ||
127 | inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0); | 119 | inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0); |
128 | inode->i_blocks = 0; | 120 | inode->i_blocks = 0; |
129 | UDF_I_LENEATTR(inode) = 0; | 121 | UDF_I_LENEATTR(inode) = 0; |
@@ -132,14 +124,10 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) | |||
132 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) { | 124 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) { |
133 | UDF_I_EFE(inode) = 1; | 125 | UDF_I_EFE(inode) = 1; |
134 | UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE); | 126 | UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE); |
135 | UDF_I_DATA(inode) = | 127 | UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL); |
136 | kzalloc(inode->i_sb->s_blocksize - | ||
137 | sizeof(struct extendedFileEntry), GFP_KERNEL); | ||
138 | } else { | 128 | } else { |
139 | UDF_I_EFE(inode) = 0; | 129 | UDF_I_EFE(inode) = 0; |
140 | UDF_I_DATA(inode) = | 130 | UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL); |
141 | kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), | ||
142 | GFP_KERNEL); | ||
143 | } | 131 | } |
144 | if (!UDF_I_DATA(inode)) { | 132 | if (!UDF_I_DATA(inode)) { |
145 | iput(inode); | 133 | iput(inode); |
@@ -154,7 +142,7 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) | |||
154 | else | 142 | else |
155 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_LONG; | 143 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_LONG; |
156 | inode->i_mtime = inode->i_atime = inode->i_ctime = | 144 | inode->i_mtime = inode->i_atime = inode->i_ctime = |
157 | UDF_I_CRTIME(inode) = current_fs_time(inode->i_sb); | 145 | UDF_I_CRTIME(inode) = current_fs_time(inode->i_sb); |
158 | insert_inode_hash(inode); | 146 | insert_inode_hash(inode); |
159 | mark_inode_dirty(inode); | 147 | mark_inode_dirty(inode); |
160 | mutex_unlock(&sbi->s_alloc_mutex); | 148 | mutex_unlock(&sbi->s_alloc_mutex); |
diff --git a/fs/udf/inode.c b/fs/udf/inode.c index be6326f449a1..0d2c41666cd2 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c | |||
@@ -97,7 +97,8 @@ void udf_delete_inode(struct inode *inode) | |||
97 | 97 | ||
98 | unlock_kernel(); | 98 | unlock_kernel(); |
99 | return; | 99 | return; |
100 | no_delete: | 100 | |
101 | no_delete: | ||
101 | clear_inode(inode); | 102 | clear_inode(inode); |
102 | } | 103 | } |
103 | 104 | ||
@@ -144,12 +145,12 @@ static sector_t udf_bmap(struct address_space *mapping, sector_t block) | |||
144 | } | 145 | } |
145 | 146 | ||
146 | const struct address_space_operations udf_aops = { | 147 | const struct address_space_operations udf_aops = { |
147 | .readpage = udf_readpage, | 148 | .readpage = udf_readpage, |
148 | .writepage = udf_writepage, | 149 | .writepage = udf_writepage, |
149 | .sync_page = block_sync_page, | 150 | .sync_page = block_sync_page, |
150 | .prepare_write = udf_prepare_write, | 151 | .prepare_write = udf_prepare_write, |
151 | .commit_write = generic_commit_write, | 152 | .commit_write = generic_commit_write, |
152 | .bmap = udf_bmap, | 153 | .bmap = udf_bmap, |
153 | }; | 154 | }; |
154 | 155 | ||
155 | void udf_expand_file_adinicb(struct inode *inode, int newsize, int *err) | 156 | void udf_expand_file_adinicb(struct inode *inode, int newsize, int *err) |
@@ -230,12 +231,10 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
230 | *block = udf_new_block(inode->i_sb, inode, | 231 | *block = udf_new_block(inode->i_sb, inode, |
231 | UDF_I_LOCATION(inode).partitionReferenceNum, | 232 | UDF_I_LOCATION(inode).partitionReferenceNum, |
232 | UDF_I_LOCATION(inode).logicalBlockNum, err); | 233 | UDF_I_LOCATION(inode).logicalBlockNum, err); |
233 | |||
234 | if (!(*block)) | 234 | if (!(*block)) |
235 | return NULL; | 235 | return NULL; |
236 | newblock = udf_get_pblock(inode->i_sb, *block, | 236 | newblock = udf_get_pblock(inode->i_sb, *block, |
237 | UDF_I_LOCATION(inode).partitionReferenceNum, | 237 | UDF_I_LOCATION(inode).partitionReferenceNum, 0); |
238 | 0); | ||
239 | if (!newblock) | 238 | if (!newblock) |
240 | return NULL; | 239 | return NULL; |
241 | dbh = udf_tgetblk(inode->i_sb, newblock); | 240 | dbh = udf_tgetblk(inode->i_sb, newblock); |
@@ -247,16 +246,13 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
247 | unlock_buffer(dbh); | 246 | unlock_buffer(dbh); |
248 | mark_buffer_dirty_inode(dbh, inode); | 247 | mark_buffer_dirty_inode(dbh, inode); |
249 | 248 | ||
250 | sfibh.soffset = sfibh.eoffset = | 249 | sfibh.soffset = sfibh.eoffset = (f_pos & ((inode->i_sb->s_blocksize - 1) >> 2)) << 2; |
251 | (f_pos & ((inode->i_sb->s_blocksize - 1) >> 2)) << 2; | ||
252 | sfibh.sbh = sfibh.ebh = NULL; | 250 | sfibh.sbh = sfibh.ebh = NULL; |
253 | dfibh.soffset = dfibh.eoffset = 0; | 251 | dfibh.soffset = dfibh.eoffset = 0; |
254 | dfibh.sbh = dfibh.ebh = dbh; | 252 | dfibh.sbh = dfibh.ebh = dbh; |
255 | while ((f_pos < size)) { | 253 | while ((f_pos < size)) { |
256 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; | 254 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; |
257 | sfi = | 255 | sfi = udf_fileident_read(inode, &f_pos, &sfibh, &cfi, NULL, NULL, NULL, NULL); |
258 | udf_fileident_read(inode, &f_pos, &sfibh, &cfi, NULL, NULL, | ||
259 | NULL, NULL); | ||
260 | if (!sfi) { | 256 | if (!sfi) { |
261 | brelse(dbh); | 257 | brelse(dbh); |
262 | return NULL; | 258 | return NULL; |
@@ -267,8 +263,7 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
267 | dfibh.eoffset += (sfibh.eoffset - sfibh.soffset); | 263 | dfibh.eoffset += (sfibh.eoffset - sfibh.soffset); |
268 | dfi = (struct fileIdentDesc *)(dbh->b_data + dfibh.soffset); | 264 | dfi = (struct fileIdentDesc *)(dbh->b_data + dfibh.soffset); |
269 | if (udf_write_fi(inode, sfi, dfi, &dfibh, sfi->impUse, | 265 | if (udf_write_fi(inode, sfi, dfi, &dfibh, sfi->impUse, |
270 | sfi->fileIdent + | 266 | sfi->fileIdent + le16_to_cpu(sfi->lengthOfImpUse))) { |
271 | le16_to_cpu(sfi->lengthOfImpUse))) { | ||
272 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; | 267 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; |
273 | brelse(dbh); | 268 | brelse(dbh); |
274 | return NULL; | 269 | return NULL; |
@@ -276,12 +271,10 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
276 | } | 271 | } |
277 | mark_buffer_dirty_inode(dbh, inode); | 272 | mark_buffer_dirty_inode(dbh, inode); |
278 | 273 | ||
279 | memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), 0, | 274 | memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), 0, UDF_I_LENALLOC(inode)); |
280 | UDF_I_LENALLOC(inode)); | ||
281 | UDF_I_LENALLOC(inode) = 0; | 275 | UDF_I_LENALLOC(inode) = 0; |
282 | eloc.logicalBlockNum = *block; | 276 | eloc.logicalBlockNum = *block; |
283 | eloc.partitionReferenceNum = | 277 | eloc.partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum; |
284 | UDF_I_LOCATION(inode).partitionReferenceNum; | ||
285 | elen = inode->i_size; | 278 | elen = inode->i_size; |
286 | UDF_I_LENEXTENTS(inode) = elen; | 279 | UDF_I_LENEXTENTS(inode) = elen; |
287 | epos.bh = NULL; | 280 | epos.bh = NULL; |
@@ -334,11 +327,12 @@ static int udf_get_block(struct inode *inode, sector_t block, | |||
334 | if (new) | 327 | if (new) |
335 | set_buffer_new(bh_result); | 328 | set_buffer_new(bh_result); |
336 | map_bh(bh_result, inode->i_sb, phys); | 329 | map_bh(bh_result, inode->i_sb, phys); |
337 | abort: | 330 | |
331 | abort: | ||
338 | unlock_kernel(); | 332 | unlock_kernel(); |
339 | return err; | 333 | return err; |
340 | 334 | ||
341 | abort_negative: | 335 | abort_negative: |
342 | udf_warning(inode->i_sb, "udf_get_block", "block < 0"); | 336 | udf_warning(inode->i_sb, "udf_get_block", "block < 0"); |
343 | goto abort; | 337 | goto abort; |
344 | } | 338 | } |
@@ -346,13 +340,13 @@ static int udf_get_block(struct inode *inode, sector_t block, | |||
346 | static struct buffer_head *udf_getblk(struct inode *inode, long block, | 340 | static struct buffer_head *udf_getblk(struct inode *inode, long block, |
347 | int create, int *err) | 341 | int create, int *err) |
348 | { | 342 | { |
343 | struct buffer_head *bh; | ||
349 | struct buffer_head dummy; | 344 | struct buffer_head dummy; |
350 | 345 | ||
351 | dummy.b_state = 0; | 346 | dummy.b_state = 0; |
352 | dummy.b_blocknr = -1000; | 347 | dummy.b_blocknr = -1000; |
353 | *err = udf_get_block(inode, block, &dummy, create); | 348 | *err = udf_get_block(inode, block, &dummy, create); |
354 | if (!*err && buffer_mapped(&dummy)) { | 349 | if (!*err && buffer_mapped(&dummy)) { |
355 | struct buffer_head *bh; | ||
356 | bh = sb_getblk(inode->i_sb, dummy.b_blocknr); | 350 | bh = sb_getblk(inode->i_sb, dummy.b_blocknr); |
357 | if (buffer_new(&dummy)) { | 351 | if (buffer_new(&dummy)) { |
358 | lock_buffer(bh); | 352 | lock_buffer(bh); |
@@ -363,6 +357,7 @@ static struct buffer_head *udf_getblk(struct inode *inode, long block, | |||
363 | } | 357 | } |
364 | return bh; | 358 | return bh; |
365 | } | 359 | } |
360 | |||
366 | return NULL; | 361 | return NULL; |
367 | } | 362 | } |
368 | 363 | ||
@@ -373,42 +368,41 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
373 | sector_t add; | 368 | sector_t add; |
374 | int count = 0, fake = !(last_ext->extLength & UDF_EXTENT_LENGTH_MASK); | 369 | int count = 0, fake = !(last_ext->extLength & UDF_EXTENT_LENGTH_MASK); |
375 | struct super_block *sb = inode->i_sb; | 370 | struct super_block *sb = inode->i_sb; |
376 | kernel_lb_addr prealloc_loc = { 0, 0 }; | 371 | kernel_lb_addr prealloc_loc = {}; |
377 | int prealloc_len = 0; | 372 | int prealloc_len = 0; |
378 | 373 | ||
379 | /* The previous extent is fake and we should not extend by anything | 374 | /* The previous extent is fake and we should not extend by anything |
380 | * - there's nothing to do... */ | 375 | * - there's nothing to do... */ |
381 | if (!blocks && fake) | 376 | if (!blocks && fake) |
382 | return 0; | 377 | return 0; |
378 | |||
383 | /* Round the last extent up to a multiple of block size */ | 379 | /* Round the last extent up to a multiple of block size */ |
384 | if (last_ext->extLength & (sb->s_blocksize - 1)) { | 380 | if (last_ext->extLength & (sb->s_blocksize - 1)) { |
385 | last_ext->extLength = | 381 | last_ext->extLength = |
386 | (last_ext->extLength & UDF_EXTENT_FLAG_MASK) | | 382 | (last_ext->extLength & UDF_EXTENT_FLAG_MASK) | |
387 | (((last_ext->extLength & UDF_EXTENT_LENGTH_MASK) + | 383 | (((last_ext->extLength & UDF_EXTENT_LENGTH_MASK) + |
388 | sb->s_blocksize - 1) & ~(sb->s_blocksize - 1)); | 384 | sb->s_blocksize - 1) & ~(sb->s_blocksize - 1)); |
389 | UDF_I_LENEXTENTS(inode) = | 385 | UDF_I_LENEXTENTS(inode) = |
390 | (UDF_I_LENEXTENTS(inode) + sb->s_blocksize - 1) & | 386 | (UDF_I_LENEXTENTS(inode) + sb->s_blocksize - 1) & |
391 | ~(sb->s_blocksize - 1); | 387 | ~(sb->s_blocksize - 1); |
392 | } | 388 | } |
389 | |||
393 | /* Last extent are just preallocated blocks? */ | 390 | /* Last extent are just preallocated blocks? */ |
394 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == | 391 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == EXT_NOT_RECORDED_ALLOCATED) { |
395 | EXT_NOT_RECORDED_ALLOCATED) { | ||
396 | /* Save the extent so that we can reattach it to the end */ | 392 | /* Save the extent so that we can reattach it to the end */ |
397 | prealloc_loc = last_ext->extLocation; | 393 | prealloc_loc = last_ext->extLocation; |
398 | prealloc_len = last_ext->extLength; | 394 | prealloc_len = last_ext->extLength; |
399 | /* Mark the extent as a hole */ | 395 | /* Mark the extent as a hole */ |
400 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | | 396 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | |
401 | (last_ext->extLength & UDF_EXTENT_LENGTH_MASK); | 397 | (last_ext->extLength & UDF_EXTENT_LENGTH_MASK); |
402 | last_ext->extLocation.logicalBlockNum = 0; | 398 | last_ext->extLocation.logicalBlockNum = 0; |
403 | last_ext->extLocation.partitionReferenceNum = 0; | 399 | last_ext->extLocation.partitionReferenceNum = 0; |
404 | } | 400 | } |
401 | |||
405 | /* Can we merge with the previous extent? */ | 402 | /* Can we merge with the previous extent? */ |
406 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == | 403 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == EXT_NOT_RECORDED_NOT_ALLOCATED) { |
407 | EXT_NOT_RECORDED_NOT_ALLOCATED) { | 404 | add = ((1 << 30) - sb->s_blocksize - (last_ext->extLength & |
408 | add = | 405 | UDF_EXTENT_LENGTH_MASK)) >> sb->s_blocksize_bits; |
409 | ((1 << 30) - sb->s_blocksize - | ||
410 | (last_ext->extLength & UDF_EXTENT_LENGTH_MASK)) >> sb-> | ||
411 | s_blocksize_bits; | ||
412 | if (add > blocks) | 406 | if (add > blocks) |
413 | add = blocks; | 407 | add = blocks; |
414 | blocks -= add; | 408 | blocks -= add; |
@@ -419,19 +413,20 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
419 | udf_add_aext(inode, last_pos, last_ext->extLocation, | 413 | udf_add_aext(inode, last_pos, last_ext->extLocation, |
420 | last_ext->extLength, 1); | 414 | last_ext->extLength, 1); |
421 | count++; | 415 | count++; |
422 | } else | 416 | } else { |
423 | udf_write_aext(inode, last_pos, last_ext->extLocation, | 417 | udf_write_aext(inode, last_pos, last_ext->extLocation, last_ext->extLength, 1); |
424 | last_ext->extLength, 1); | 418 | } |
419 | |||
425 | /* Managed to do everything necessary? */ | 420 | /* Managed to do everything necessary? */ |
426 | if (!blocks) | 421 | if (!blocks) |
427 | goto out; | 422 | goto out; |
428 | 423 | ||
429 | /* All further extents will be NOT_RECORDED_NOT_ALLOCATED */ | 424 | /* All further extents will be NOT_RECORDED_NOT_ALLOCATED */ |
430 | last_ext->extLocation.logicalBlockNum = 0; | 425 | last_ext->extLocation.logicalBlockNum = 0; |
431 | last_ext->extLocation.partitionReferenceNum = 0; | 426 | last_ext->extLocation.partitionReferenceNum = 0; |
432 | add = (1 << (30 - sb->s_blocksize_bits)) - 1; | 427 | add = (1 << (30-sb->s_blocksize_bits)) - 1; |
433 | last_ext->extLength = | 428 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | (add << sb->s_blocksize_bits); |
434 | EXT_NOT_RECORDED_NOT_ALLOCATED | (add << sb->s_blocksize_bits); | 429 | |
435 | /* Create enough extents to cover the whole hole */ | 430 | /* Create enough extents to cover the whole hole */ |
436 | while (blocks > add) { | 431 | while (blocks > add) { |
437 | blocks -= add; | 432 | blocks -= add; |
@@ -442,22 +437,23 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
442 | } | 437 | } |
443 | if (blocks) { | 438 | if (blocks) { |
444 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | | 439 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | |
445 | (blocks << sb->s_blocksize_bits); | 440 | (blocks << sb->s_blocksize_bits); |
446 | if (udf_add_aext(inode, last_pos, last_ext->extLocation, | 441 | if (udf_add_aext(inode, last_pos, last_ext->extLocation, |
447 | last_ext->extLength, 1) == -1) | 442 | last_ext->extLength, 1) == -1) |
448 | return -1; | 443 | return -1; |
449 | count++; | 444 | count++; |
450 | } | 445 | } |
451 | out: | 446 | |
447 | out: | ||
452 | /* Do we have some preallocated blocks saved? */ | 448 | /* Do we have some preallocated blocks saved? */ |
453 | if (prealloc_len) { | 449 | if (prealloc_len) { |
454 | if (udf_add_aext(inode, last_pos, prealloc_loc, prealloc_len, 1) | 450 | if (udf_add_aext(inode, last_pos, prealloc_loc, prealloc_len, 1) == -1) |
455 | == -1) | ||
456 | return -1; | 451 | return -1; |
457 | last_ext->extLocation = prealloc_loc; | 452 | last_ext->extLocation = prealloc_loc; |
458 | last_ext->extLength = prealloc_len; | 453 | last_ext->extLength = prealloc_len; |
459 | count++; | 454 | count++; |
460 | } | 455 | } |
456 | |||
461 | /* last_pos should point to the last written extent... */ | 457 | /* last_pos should point to the last written extent... */ |
462 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) | 458 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) |
463 | last_pos->offset -= sizeof(short_ad); | 459 | last_pos->offset -= sizeof(short_ad); |
@@ -465,6 +461,7 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
465 | last_pos->offset -= sizeof(long_ad); | 461 | last_pos->offset -= sizeof(long_ad); |
466 | else | 462 | else |
467 | return -1; | 463 | return -1; |
464 | |||
468 | return count; | 465 | return count; |
469 | } | 466 | } |
470 | 467 | ||
@@ -490,7 +487,7 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
490 | prev_epos.block = UDF_I_LOCATION(inode); | 487 | prev_epos.block = UDF_I_LOCATION(inode); |
491 | prev_epos.bh = NULL; | 488 | prev_epos.bh = NULL; |
492 | cur_epos = next_epos = prev_epos; | 489 | cur_epos = next_epos = prev_epos; |
493 | b_off = (loff_t) block << inode->i_sb->s_blocksize_bits; | 490 | b_off = (loff_t)block << inode->i_sb->s_blocksize_bits; |
494 | 491 | ||
495 | /* find the extent which contains the block we are looking for. | 492 | /* find the extent which contains the block we are looking for. |
496 | alternate between laarr[0] and laarr[1] for locations of the | 493 | alternate between laarr[0] and laarr[1] for locations of the |
@@ -515,8 +512,7 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
515 | prev_epos.offset = cur_epos.offset; | 512 | prev_epos.offset = cur_epos.offset; |
516 | cur_epos.offset = next_epos.offset; | 513 | cur_epos.offset = next_epos.offset; |
517 | 514 | ||
518 | if ((etype = | 515 | if ((etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 1)) == -1) |
519 | udf_next_aext(inode, &next_epos, &eloc, &elen, 1)) == -1) | ||
520 | break; | 516 | break; |
521 | 517 | ||
522 | c = !c; | 518 | c = !c; |
@@ -526,8 +522,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
526 | 522 | ||
527 | if (etype != (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) | 523 | if (etype != (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) |
528 | pgoal = eloc.logicalBlockNum + | 524 | pgoal = eloc.logicalBlockNum + |
529 | ((elen + inode->i_sb->s_blocksize - 1) >> | 525 | ((elen + inode->i_sb->s_blocksize - 1) >> |
530 | inode->i_sb->s_blocksize_bits); | 526 | inode->i_sb->s_blocksize_bits); |
531 | 527 | ||
532 | count++; | 528 | count++; |
533 | } while (lbcount + elen <= b_off); | 529 | } while (lbcount + elen <= b_off); |
@@ -547,8 +543,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
547 | if (etype == (EXT_RECORDED_ALLOCATED >> 30)) { | 543 | if (etype == (EXT_RECORDED_ALLOCATED >> 30)) { |
548 | if (elen & (inode->i_sb->s_blocksize - 1)) { | 544 | if (elen & (inode->i_sb->s_blocksize - 1)) { |
549 | elen = EXT_RECORDED_ALLOCATED | | 545 | elen = EXT_RECORDED_ALLOCATED | |
550 | ((elen + inode->i_sb->s_blocksize - 1) & | 546 | ((elen + inode->i_sb->s_blocksize - 1) & |
551 | ~(inode->i_sb->s_blocksize - 1)); | 547 | ~(inode->i_sb->s_blocksize - 1)); |
552 | etype = udf_write_aext(inode, &cur_epos, eloc, elen, 1); | 548 | etype = udf_write_aext(inode, &cur_epos, eloc, elen, 1); |
553 | } | 549 | } |
554 | brelse(prev_epos.bh); | 550 | brelse(prev_epos.bh); |
@@ -570,8 +566,7 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
570 | startnum = 1; | 566 | startnum = 1; |
571 | } else { | 567 | } else { |
572 | /* Create a fake extent when there's not one */ | 568 | /* Create a fake extent when there's not one */ |
573 | memset(&laarr[0].extLocation, 0x00, | 569 | memset(&laarr[0].extLocation, 0x00, sizeof(kernel_lb_addr)); |
574 | sizeof(kernel_lb_addr)); | ||
575 | laarr[0].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED; | 570 | laarr[0].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED; |
576 | /* Will udf_extend_file() create real extent from a fake one? */ | 571 | /* Will udf_extend_file() create real extent from a fake one? */ |
577 | startnum = (offset > 0); | 572 | startnum = (offset > 0); |
@@ -591,16 +586,14 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
591 | offset = 0; | 586 | offset = 0; |
592 | count += ret; | 587 | count += ret; |
593 | /* We are not covered by a preallocated extent? */ | 588 | /* We are not covered by a preallocated extent? */ |
594 | if ((laarr[0].extLength & UDF_EXTENT_FLAG_MASK) != | 589 | if ((laarr[0].extLength & UDF_EXTENT_FLAG_MASK) != EXT_NOT_RECORDED_ALLOCATED) { |
595 | EXT_NOT_RECORDED_ALLOCATED) { | ||
596 | /* Is there any real extent? - otherwise we overwrite | 590 | /* Is there any real extent? - otherwise we overwrite |
597 | * the fake one... */ | 591 | * the fake one... */ |
598 | if (count) | 592 | if (count) |
599 | c = !c; | 593 | c = !c; |
600 | laarr[c].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | | 594 | laarr[c].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | |
601 | inode->i_sb->s_blocksize; | 595 | inode->i_sb->s_blocksize; |
602 | memset(&laarr[c].extLocation, 0x00, | 596 | memset(&laarr[c].extLocation, 0x00, sizeof(kernel_lb_addr)); |
603 | sizeof(kernel_lb_addr)); | ||
604 | count++; | 597 | count++; |
605 | endnum++; | 598 | endnum++; |
606 | } | 599 | } |
@@ -618,8 +611,7 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
618 | } | 611 | } |
619 | 612 | ||
620 | /* if the current block is located in an extent, read the next extent */ | 613 | /* if the current block is located in an extent, read the next extent */ |
621 | if ((etype = | 614 | if ((etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 0)) != -1) { |
622 | udf_next_aext(inode, &next_epos, &eloc, &elen, 0)) != -1) { | ||
623 | laarr[c + 1].extLength = (etype << 30) | elen; | 615 | laarr[c + 1].extLength = (etype << 30) | elen; |
624 | laarr[c + 1].extLocation = eloc; | 616 | laarr[c + 1].extLocation = eloc; |
625 | count++; | 617 | count++; |
@@ -631,24 +623,21 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
631 | } | 623 | } |
632 | 624 | ||
633 | /* if the current extent is not recorded but allocated, get the | 625 | /* if the current extent is not recorded but allocated, get the |
634 | block in the extent corresponding to the requested block */ | 626 | * block in the extent corresponding to the requested block */ |
635 | if ((laarr[c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) | 627 | if ((laarr[c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { |
636 | newblocknum = laarr[c].extLocation.logicalBlockNum + offset; | 628 | newblocknum = laarr[c].extLocation.logicalBlockNum + offset; |
637 | else { /* otherwise, allocate a new block */ | 629 | } else { /* otherwise, allocate a new block */ |
638 | |||
639 | if (UDF_I_NEXT_ALLOC_BLOCK(inode) == block) | 630 | if (UDF_I_NEXT_ALLOC_BLOCK(inode) == block) |
640 | goal = UDF_I_NEXT_ALLOC_GOAL(inode); | 631 | goal = UDF_I_NEXT_ALLOC_GOAL(inode); |
641 | 632 | ||
642 | if (!goal) { | 633 | if (!goal) { |
643 | if (!(goal = pgoal)) | 634 | if (!(goal = pgoal)) |
644 | goal = | 635 | goal = UDF_I_LOCATION(inode).logicalBlockNum + 1; |
645 | UDF_I_LOCATION(inode).logicalBlockNum + 1; | ||
646 | } | 636 | } |
647 | 637 | ||
648 | if (!(newblocknum = udf_new_block(inode->i_sb, inode, | 638 | if (!(newblocknum = udf_new_block(inode->i_sb, inode, |
649 | UDF_I_LOCATION(inode). | 639 | UDF_I_LOCATION(inode).partitionReferenceNum, |
650 | partitionReferenceNum, goal, | 640 | goal, err))) { |
651 | err))) { | ||
652 | brelse(prev_epos.bh); | 641 | brelse(prev_epos.bh); |
653 | *err = -ENOSPC; | 642 | *err = -ENOSPC; |
654 | return NULL; | 643 | return NULL; |
@@ -657,8 +646,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
657 | } | 646 | } |
658 | 647 | ||
659 | /* if the extent the requsted block is located in contains multiple blocks, | 648 | /* if the extent the requsted block is located in contains multiple blocks, |
660 | split the extent into at most three extents. blocks prior to requested | 649 | * split the extent into at most three extents. blocks prior to requested |
661 | block, requested block, and blocks after requested block */ | 650 | * block, requested block, and blocks after requested block */ |
662 | udf_split_extents(inode, &c, offset, newblocknum, laarr, &endnum); | 651 | udf_split_extents(inode, &c, offset, newblocknum, laarr, &endnum); |
663 | 652 | ||
664 | #ifdef UDF_PREALLOCATE | 653 | #ifdef UDF_PREALLOCATE |
@@ -670,15 +659,14 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
670 | udf_merge_extents(inode, laarr, &endnum); | 659 | udf_merge_extents(inode, laarr, &endnum); |
671 | 660 | ||
672 | /* write back the new extents, inserting new extents if the new number | 661 | /* write back the new extents, inserting new extents if the new number |
673 | of extents is greater than the old number, and deleting extents if | 662 | * of extents is greater than the old number, and deleting extents if |
674 | the new number of extents is less than the old number */ | 663 | * the new number of extents is less than the old number */ |
675 | udf_update_extents(inode, laarr, startnum, endnum, &prev_epos); | 664 | udf_update_extents(inode, laarr, startnum, endnum, &prev_epos); |
676 | 665 | ||
677 | brelse(prev_epos.bh); | 666 | brelse(prev_epos.bh); |
678 | 667 | ||
679 | if (!(newblock = udf_get_pblock(inode->i_sb, newblocknum, | 668 | if (!(newblock = udf_get_pblock(inode->i_sb, newblocknum, |
680 | UDF_I_LOCATION(inode). | 669 | UDF_I_LOCATION(inode).partitionReferenceNum, 0))) { |
681 | partitionReferenceNum, 0))) { | ||
682 | return NULL; | 670 | return NULL; |
683 | } | 671 | } |
684 | *phys = newblock; | 672 | *phys = newblock; |
@@ -692,6 +680,7 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
692 | udf_sync_inode(inode); | 680 | udf_sync_inode(inode); |
693 | else | 681 | else |
694 | mark_inode_dirty(inode); | 682 | mark_inode_dirty(inode); |
683 | |||
695 | return result; | 684 | return result; |
696 | } | 685 | } |
697 | 686 | ||
@@ -701,16 +690,15 @@ static void udf_split_extents(struct inode *inode, int *c, int offset, | |||
701 | int *endnum) | 690 | int *endnum) |
702 | { | 691 | { |
703 | if ((laarr[*c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30) || | 692 | if ((laarr[*c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30) || |
704 | (laarr[*c].extLength >> 30) == | 693 | (laarr[*c].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) { |
705 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) { | ||
706 | int curr = *c; | 694 | int curr = *c; |
707 | int blen = ((laarr[curr].extLength & UDF_EXTENT_LENGTH_MASK) + | 695 | int blen = ((laarr[curr].extLength & UDF_EXTENT_LENGTH_MASK) + |
708 | inode->i_sb->s_blocksize - | 696 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits; |
709 | 1) >> inode->i_sb->s_blocksize_bits; | ||
710 | int8_t etype = (laarr[curr].extLength >> 30); | 697 | int8_t etype = (laarr[curr].extLength >> 30); |
711 | 698 | ||
712 | if (blen == 1) ; | 699 | if (blen == 1) { |
713 | else if (!offset || blen == offset + 1) { | 700 | ; |
701 | } else if (!offset || blen == offset + 1) { | ||
714 | laarr[curr + 2] = laarr[curr + 1]; | 702 | laarr[curr + 2] = laarr[curr + 1]; |
715 | laarr[curr + 1] = laarr[curr]; | 703 | laarr[curr + 1] = laarr[curr]; |
716 | } else { | 704 | } else { |
@@ -720,20 +708,15 @@ static void udf_split_extents(struct inode *inode, int *c, int offset, | |||
720 | 708 | ||
721 | if (offset) { | 709 | if (offset) { |
722 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | 710 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { |
723 | udf_free_blocks(inode->i_sb, inode, | 711 | udf_free_blocks(inode->i_sb, inode, laarr[curr].extLocation, 0, offset); |
724 | laarr[curr].extLocation, 0, | 712 | laarr[curr].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | |
725 | offset); | 713 | (offset << inode->i_sb->s_blocksize_bits); |
726 | laarr[curr].extLength = | ||
727 | EXT_NOT_RECORDED_NOT_ALLOCATED | (offset << | ||
728 | inode-> | ||
729 | i_sb-> | ||
730 | s_blocksize_bits); | ||
731 | laarr[curr].extLocation.logicalBlockNum = 0; | 714 | laarr[curr].extLocation.logicalBlockNum = 0; |
732 | laarr[curr].extLocation.partitionReferenceNum = | 715 | laarr[curr].extLocation.partitionReferenceNum = 0; |
733 | 0; | 716 | } else { |
734 | } else | ||
735 | laarr[curr].extLength = (etype << 30) | | 717 | laarr[curr].extLength = (etype << 30) | |
736 | (offset << inode->i_sb->s_blocksize_bits); | 718 | (offset << inode->i_sb->s_blocksize_bits); |
719 | } | ||
737 | curr++; | 720 | curr++; |
738 | (*c)++; | 721 | (*c)++; |
739 | (*endnum)++; | 722 | (*endnum)++; |
@@ -742,18 +725,16 @@ static void udf_split_extents(struct inode *inode, int *c, int offset, | |||
742 | laarr[curr].extLocation.logicalBlockNum = newblocknum; | 725 | laarr[curr].extLocation.logicalBlockNum = newblocknum; |
743 | if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) | 726 | if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) |
744 | laarr[curr].extLocation.partitionReferenceNum = | 727 | laarr[curr].extLocation.partitionReferenceNum = |
745 | UDF_I_LOCATION(inode).partitionReferenceNum; | 728 | UDF_I_LOCATION(inode).partitionReferenceNum; |
746 | laarr[curr].extLength = EXT_RECORDED_ALLOCATED | | 729 | laarr[curr].extLength = EXT_RECORDED_ALLOCATED | |
747 | inode->i_sb->s_blocksize; | 730 | inode->i_sb->s_blocksize; |
748 | curr++; | 731 | curr++; |
749 | 732 | ||
750 | if (blen != offset + 1) { | 733 | if (blen != offset + 1) { |
751 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) | 734 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) |
752 | laarr[curr].extLocation.logicalBlockNum += | 735 | laarr[curr].extLocation.logicalBlockNum += (offset + 1); |
753 | (offset + 1); | 736 | laarr[curr].extLength = (etype << 30) | |
754 | laarr[curr].extLength = | 737 | ((blen - (offset + 1)) << inode->i_sb->s_blocksize_bits); |
755 | (etype << 30) | ((blen - (offset + 1)) << inode-> | ||
756 | i_sb->s_blocksize_bits); | ||
757 | curr++; | 738 | curr++; |
758 | (*endnum)++; | 739 | (*endnum)++; |
759 | } | 740 | } |
@@ -772,90 +753,69 @@ static void udf_prealloc_extents(struct inode *inode, int c, int lastblock, | |||
772 | else | 753 | else |
773 | start = c; | 754 | start = c; |
774 | } else { | 755 | } else { |
775 | if ((laarr[c + 1].extLength >> 30) == | 756 | if ((laarr[c + 1].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { |
776 | (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | ||
777 | start = c + 1; | 757 | start = c + 1; |
778 | length = currlength = | 758 | length = currlength = (((laarr[c + 1].extLength & UDF_EXTENT_LENGTH_MASK) + |
779 | (((laarr[c + 1]. | 759 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); |
780 | extLength & UDF_EXTENT_LENGTH_MASK) + | 760 | } else { |
781 | inode->i_sb->s_blocksize - | ||
782 | 1) >> inode->i_sb->s_blocksize_bits); | ||
783 | } else | ||
784 | start = c; | 761 | start = c; |
762 | } | ||
785 | } | 763 | } |
786 | 764 | ||
787 | for (i = start + 1; i <= *endnum; i++) { | 765 | for (i = start + 1; i <= *endnum; i++) { |
788 | if (i == *endnum) { | 766 | if (i == *endnum) { |
789 | if (lastblock) | 767 | if (lastblock) |
790 | length += UDF_DEFAULT_PREALLOC_BLOCKS; | 768 | length += UDF_DEFAULT_PREALLOC_BLOCKS; |
791 | } else if ((laarr[i].extLength >> 30) == | 769 | } else if ((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) { |
792 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) | 770 | length += (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + |
793 | length += | 771 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); |
794 | (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 772 | } else { |
795 | inode->i_sb->s_blocksize - | ||
796 | 1) >> inode->i_sb->s_blocksize_bits); | ||
797 | else | ||
798 | break; | 773 | break; |
774 | } | ||
799 | } | 775 | } |
800 | 776 | ||
801 | if (length) { | 777 | if (length) { |
802 | int next = laarr[start].extLocation.logicalBlockNum + | 778 | int next = laarr[start].extLocation.logicalBlockNum + |
803 | (((laarr[start].extLength & UDF_EXTENT_LENGTH_MASK) + | 779 | (((laarr[start].extLength & UDF_EXTENT_LENGTH_MASK) + |
804 | inode->i_sb->s_blocksize - | 780 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); |
805 | 1) >> inode->i_sb->s_blocksize_bits); | ||
806 | int numalloc = udf_prealloc_blocks(inode->i_sb, inode, | 781 | int numalloc = udf_prealloc_blocks(inode->i_sb, inode, |
807 | laarr[start].extLocation. | 782 | laarr[start].extLocation.partitionReferenceNum, |
808 | partitionReferenceNum, | 783 | next, (UDF_DEFAULT_PREALLOC_BLOCKS > length ? length : |
809 | next, | 784 | UDF_DEFAULT_PREALLOC_BLOCKS) - currlength); |
810 | (UDF_DEFAULT_PREALLOC_BLOCKS | 785 | if (numalloc) { |
811 | > | 786 | if (start == (c + 1)) { |
812 | length ? length : | ||
813 | UDF_DEFAULT_PREALLOC_BLOCKS) | ||
814 | - currlength); | ||
815 | |||
816 | if (numalloc) { | ||
817 | if (start == (c + 1)) | ||
818 | laarr[start].extLength += | 787 | laarr[start].extLength += |
819 | (numalloc << inode->i_sb->s_blocksize_bits); | 788 | (numalloc << inode->i_sb->s_blocksize_bits); |
820 | else { | 789 | } else { |
821 | memmove(&laarr[c + 2], &laarr[c + 1], | 790 | memmove(&laarr[c + 2], &laarr[c + 1], |
822 | sizeof(long_ad) * (*endnum - (c + 1))); | 791 | sizeof(long_ad) * (*endnum - (c + 1))); |
823 | (*endnum)++; | 792 | (*endnum)++; |
824 | laarr[c + 1].extLocation.logicalBlockNum = next; | 793 | laarr[c + 1].extLocation.logicalBlockNum = next; |
825 | laarr[c + 1].extLocation.partitionReferenceNum = | 794 | laarr[c + 1].extLocation.partitionReferenceNum = |
826 | laarr[c].extLocation.partitionReferenceNum; | 795 | laarr[c].extLocation.partitionReferenceNum; |
827 | laarr[c + 1].extLength = | 796 | laarr[c + 1].extLength = EXT_NOT_RECORDED_ALLOCATED | |
828 | EXT_NOT_RECORDED_ALLOCATED | (numalloc << | 797 | (numalloc << inode->i_sb->s_blocksize_bits); |
829 | inode->i_sb-> | ||
830 | s_blocksize_bits); | ||
831 | start = c + 1; | 798 | start = c + 1; |
832 | } | 799 | } |
833 | 800 | ||
834 | for (i = start + 1; numalloc && i < *endnum; i++) { | 801 | for (i = start + 1; numalloc && i < *endnum; i++) { |
835 | int elen = | 802 | int elen = ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + |
836 | ((laarr[i]. | 803 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits; |
837 | extLength & UDF_EXTENT_LENGTH_MASK) + | ||
838 | inode->i_sb->s_blocksize - | ||
839 | 1) >> inode->i_sb->s_blocksize_bits; | ||
840 | 804 | ||
841 | if (elen > numalloc) { | 805 | if (elen > numalloc) { |
842 | laarr[i].extLength -= | 806 | laarr[i].extLength -= |
843 | (numalloc << inode->i_sb-> | 807 | (numalloc << inode->i_sb->s_blocksize_bits); |
844 | s_blocksize_bits); | ||
845 | numalloc = 0; | 808 | numalloc = 0; |
846 | } else { | 809 | } else { |
847 | numalloc -= elen; | 810 | numalloc -= elen; |
848 | if (*endnum > (i + 1)) | 811 | if (*endnum > (i + 1)) |
849 | memmove(&laarr[i], | 812 | memmove(&laarr[i], &laarr[i + 1], |
850 | &laarr[i + 1], | 813 | sizeof(long_ad) * (*endnum - (i + 1))); |
851 | sizeof(long_ad) * | ||
852 | (*endnum - (i + 1))); | ||
853 | i--; | 814 | i--; |
854 | (*endnum)--; | 815 | (*endnum)--; |
855 | } | 816 | } |
856 | } | 817 | } |
857 | UDF_I_LENEXTENTS(inode) += | 818 | UDF_I_LENEXTENTS(inode) += numalloc << inode->i_sb->s_blocksize_bits; |
858 | numalloc << inode->i_sb->s_blocksize_bits; | ||
859 | } | 819 | } |
860 | } | 820 | } |
861 | } | 821 | } |
@@ -867,119 +827,68 @@ static void udf_merge_extents(struct inode *inode, | |||
867 | int i; | 827 | int i; |
868 | 828 | ||
869 | for (i = 0; i < (*endnum - 1); i++) { | 829 | for (i = 0; i < (*endnum - 1); i++) { |
870 | if ((laarr[i].extLength >> 30) == | 830 | if ((laarr[i].extLength >> 30) == (laarr[i + 1].extLength >> 30)) { |
871 | (laarr[i + 1].extLength >> 30)) { | 831 | if (((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) || |
872 | if (((laarr[i].extLength >> 30) == | 832 | ((laarr[i + 1].extLocation.logicalBlockNum - laarr[i].extLocation.logicalBlockNum) == |
873 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) | ||
874 | || | ||
875 | ((laarr[i + 1].extLocation.logicalBlockNum - | ||
876 | laarr[i].extLocation.logicalBlockNum) == | ||
877 | (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 833 | (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + |
878 | inode->i_sb->s_blocksize - | 834 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits))) { |
879 | 1) >> inode->i_sb->s_blocksize_bits))) { | 835 | if (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + |
880 | if (((laarr[i]. | 836 | (laarr[i + 1].extLength & UDF_EXTENT_LENGTH_MASK) + |
881 | extLength & UDF_EXTENT_LENGTH_MASK) + | 837 | inode->i_sb->s_blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) { |
882 | (laarr[i + 1]. | 838 | laarr[i + 1].extLength = (laarr[i + 1].extLength - |
883 | extLength & UDF_EXTENT_LENGTH_MASK) + | 839 | (laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + |
884 | inode->i_sb->s_blocksize - | 840 | UDF_EXTENT_LENGTH_MASK) & ~(inode->i_sb->s_blocksize - 1); |
885 | 1) & ~UDF_EXTENT_LENGTH_MASK) { | 841 | laarr[i].extLength = (laarr[i].extLength & UDF_EXTENT_FLAG_MASK) + |
886 | laarr[i + 1].extLength = | 842 | (UDF_EXTENT_LENGTH_MASK + 1) - inode->i_sb->s_blocksize; |
887 | (laarr[i + 1].extLength - | 843 | laarr[i + 1].extLocation.logicalBlockNum = |
888 | (laarr[i]. | 844 | laarr[i].extLocation.logicalBlockNum + |
889 | extLength & | 845 | ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) >> |
890 | UDF_EXTENT_LENGTH_MASK) + | 846 | inode->i_sb->s_blocksize_bits); |
891 | UDF_EXTENT_LENGTH_MASK) & ~(inode-> | ||
892 | i_sb-> | ||
893 | s_blocksize | ||
894 | - 1); | ||
895 | laarr[i].extLength = | ||
896 | (laarr[i]. | ||
897 | extLength & UDF_EXTENT_FLAG_MASK) + | ||
898 | (UDF_EXTENT_LENGTH_MASK + 1) - | ||
899 | inode->i_sb->s_blocksize; | ||
900 | laarr[i + | ||
901 | 1].extLocation.logicalBlockNum = | ||
902 | laarr[i].extLocation. | ||
903 | logicalBlockNum + | ||
904 | ((laarr[i]. | ||
905 | extLength & | ||
906 | UDF_EXTENT_LENGTH_MASK) >> inode-> | ||
907 | i_sb->s_blocksize_bits); | ||
908 | } else { | 847 | } else { |
909 | laarr[i].extLength = | 848 | laarr[i].extLength = laarr[i + 1].extLength + |
910 | laarr[i + 1].extLength + | 849 | (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + |
911 | (((laarr[i]. | 850 | inode->i_sb->s_blocksize - 1) & ~(inode->i_sb->s_blocksize - 1)); |
912 | extLength & | ||
913 | UDF_EXTENT_LENGTH_MASK) + | ||
914 | inode->i_sb->s_blocksize - | ||
915 | 1) & ~(inode->i_sb->s_blocksize - | ||
916 | 1)); | ||
917 | if (*endnum > (i + 2)) | 851 | if (*endnum > (i + 2)) |
918 | memmove(&laarr[i + 1], | 852 | memmove(&laarr[i + 1], &laarr[i + 2], |
919 | &laarr[i + 2], | 853 | sizeof(long_ad) * (*endnum - (i + 2))); |
920 | sizeof(long_ad) * | ||
921 | (*endnum - (i + 2))); | ||
922 | i--; | 854 | i--; |
923 | (*endnum)--; | 855 | (*endnum)--; |
924 | } | 856 | } |
925 | } | 857 | } |
926 | } else | 858 | } else if (((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) && |
927 | if (((laarr[i].extLength >> 30) == | 859 | ((laarr[i + 1].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))) { |
928 | (EXT_NOT_RECORDED_ALLOCATED >> 30)) | 860 | udf_free_blocks(inode->i_sb, inode, laarr[i].extLocation, 0, |
929 | && ((laarr[i + 1].extLength >> 30) == | 861 | ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + |
930 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))) { | 862 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); |
931 | udf_free_blocks(inode->i_sb, inode, | ||
932 | laarr[i].extLocation, 0, | ||
933 | ((laarr[i]. | ||
934 | extLength & UDF_EXTENT_LENGTH_MASK) + | ||
935 | inode->i_sb->s_blocksize - | ||
936 | 1) >> inode->i_sb->s_blocksize_bits); | ||
937 | laarr[i].extLocation.logicalBlockNum = 0; | 863 | laarr[i].extLocation.logicalBlockNum = 0; |
938 | laarr[i].extLocation.partitionReferenceNum = 0; | 864 | laarr[i].extLocation.partitionReferenceNum = 0; |
939 | 865 | ||
940 | if (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 866 | if (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + |
941 | (laarr[i + 1].extLength & UDF_EXTENT_LENGTH_MASK) + | 867 | (laarr[i + 1].extLength & UDF_EXTENT_LENGTH_MASK) + |
942 | inode->i_sb->s_blocksize - | 868 | inode->i_sb->s_blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) { |
943 | 1) & ~UDF_EXTENT_LENGTH_MASK) { | 869 | laarr[i + 1].extLength = (laarr[i + 1].extLength - |
944 | laarr[i + 1].extLength = | 870 | (laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + |
945 | (laarr[i + 1].extLength - | 871 | UDF_EXTENT_LENGTH_MASK) & ~(inode->i_sb->s_blocksize - 1); |
946 | (laarr[i]. | 872 | laarr[i].extLength = (laarr[i].extLength & UDF_EXTENT_FLAG_MASK) + |
947 | extLength & UDF_EXTENT_LENGTH_MASK) + | 873 | (UDF_EXTENT_LENGTH_MASK + 1) - inode->i_sb->s_blocksize; |
948 | UDF_EXTENT_LENGTH_MASK) & ~(inode->i_sb-> | ||
949 | s_blocksize - | ||
950 | 1); | ||
951 | laarr[i].extLength = | ||
952 | (laarr[i]. | ||
953 | extLength & UDF_EXTENT_FLAG_MASK) + | ||
954 | (UDF_EXTENT_LENGTH_MASK + 1) - | ||
955 | inode->i_sb->s_blocksize; | ||
956 | } else { | 874 | } else { |
957 | laarr[i].extLength = laarr[i + 1].extLength + | 875 | laarr[i].extLength = laarr[i + 1].extLength + |
958 | (((laarr[i]. | 876 | (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + |
959 | extLength & UDF_EXTENT_LENGTH_MASK) + | 877 | inode->i_sb->s_blocksize - 1) & ~(inode->i_sb->s_blocksize - 1)); |
960 | inode->i_sb->s_blocksize - | ||
961 | 1) & ~(inode->i_sb->s_blocksize - 1)); | ||
962 | if (*endnum > (i + 2)) | 878 | if (*endnum > (i + 2)) |
963 | memmove(&laarr[i + 1], &laarr[i + 2], | 879 | memmove(&laarr[i + 1], &laarr[i + 2], |
964 | sizeof(long_ad) * (*endnum - | 880 | sizeof(long_ad) * (*endnum - (i + 2))); |
965 | (i + 2))); | ||
966 | i--; | 881 | i--; |
967 | (*endnum)--; | 882 | (*endnum)--; |
968 | } | 883 | } |
969 | } else if ((laarr[i].extLength >> 30) == | 884 | } else if ((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { |
970 | (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | 885 | udf_free_blocks(inode->i_sb, inode, laarr[i].extLocation, 0, |
971 | udf_free_blocks(inode->i_sb, inode, | 886 | ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + |
972 | laarr[i].extLocation, 0, | 887 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); |
973 | ((laarr[i]. | ||
974 | extLength & UDF_EXTENT_LENGTH_MASK) + | ||
975 | inode->i_sb->s_blocksize - | ||
976 | 1) >> inode->i_sb->s_blocksize_bits); | ||
977 | laarr[i].extLocation.logicalBlockNum = 0; | 888 | laarr[i].extLocation.logicalBlockNum = 0; |
978 | laarr[i].extLocation.partitionReferenceNum = 0; | 889 | laarr[i].extLocation.partitionReferenceNum = 0; |
979 | laarr[i].extLength = | 890 | laarr[i].extLength = (laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) | |
980 | (laarr[i]. | 891 | EXT_NOT_RECORDED_NOT_ALLOCATED; |
981 | extLength & UDF_EXTENT_LENGTH_MASK) | | ||
982 | EXT_NOT_RECORDED_NOT_ALLOCATED; | ||
983 | } | 892 | } |
984 | } | 893 | } |
985 | } | 894 | } |
@@ -1025,10 +934,13 @@ struct buffer_head *udf_bread(struct inode *inode, int block, | |||
1025 | 934 | ||
1026 | if (buffer_uptodate(bh)) | 935 | if (buffer_uptodate(bh)) |
1027 | return bh; | 936 | return bh; |
937 | |||
1028 | ll_rw_block(READ, 1, &bh); | 938 | ll_rw_block(READ, 1, &bh); |
939 | |||
1029 | wait_on_buffer(bh); | 940 | wait_on_buffer(bh); |
1030 | if (buffer_uptodate(bh)) | 941 | if (buffer_uptodate(bh)) |
1031 | return bh; | 942 | return bh; |
943 | |||
1032 | brelse(bh); | 944 | brelse(bh); |
1033 | *err = -EIO; | 945 | *err = -EIO; |
1034 | return NULL; | 946 | return NULL; |
@@ -1047,26 +959,24 @@ void udf_truncate(struct inode *inode) | |||
1047 | 959 | ||
1048 | lock_kernel(); | 960 | lock_kernel(); |
1049 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { | 961 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { |
1050 | if (inode->i_sb->s_blocksize < | 962 | if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) + |
1051 | (udf_file_entry_alloc_offset(inode) + inode->i_size)) { | 963 | inode->i_size)) { |
1052 | udf_expand_file_adinicb(inode, inode->i_size, &err); | 964 | udf_expand_file_adinicb(inode, inode->i_size, &err); |
1053 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { | 965 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { |
1054 | inode->i_size = UDF_I_LENALLOC(inode); | 966 | inode->i_size = UDF_I_LENALLOC(inode); |
1055 | unlock_kernel(); | 967 | unlock_kernel(); |
1056 | return; | 968 | return; |
1057 | } else | 969 | } else { |
1058 | udf_truncate_extents(inode); | 970 | udf_truncate_extents(inode); |
971 | } | ||
1059 | } else { | 972 | } else { |
1060 | offset = inode->i_size & (inode->i_sb->s_blocksize - 1); | 973 | offset = inode->i_size & (inode->i_sb->s_blocksize - 1); |
1061 | memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode) + | 974 | memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode) + offset, 0x00, |
1062 | offset, 0x00, | 975 | inode->i_sb->s_blocksize - offset - udf_file_entry_alloc_offset(inode)); |
1063 | inode->i_sb->s_blocksize - offset - | ||
1064 | udf_file_entry_alloc_offset(inode)); | ||
1065 | UDF_I_LENALLOC(inode) = inode->i_size; | 976 | UDF_I_LENALLOC(inode) = inode->i_size; |
1066 | } | 977 | } |
1067 | } else { | 978 | } else { |
1068 | block_truncate_page(inode->i_mapping, inode->i_size, | 979 | block_truncate_page(inode->i_mapping, inode->i_size, udf_get_block); |
1069 | udf_get_block); | ||
1070 | udf_truncate_extents(inode); | 980 | udf_truncate_extents(inode); |
1071 | } | 981 | } |
1072 | 982 | ||
@@ -1097,7 +1007,6 @@ static void __udf_read_inode(struct inode *inode) | |||
1097 | * i_op = NULL; | 1007 | * i_op = NULL; |
1098 | */ | 1008 | */ |
1099 | bh = udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 0, &ident); | 1009 | bh = udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 0, &ident); |
1100 | |||
1101 | if (!bh) { | 1010 | if (!bh) { |
1102 | printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n", | 1011 | printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n", |
1103 | inode->i_ino); | 1012 | inode->i_ino); |
@@ -1107,8 +1016,7 @@ static void __udf_read_inode(struct inode *inode) | |||
1107 | 1016 | ||
1108 | if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && | 1017 | if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && |
1109 | ident != TAG_IDENT_USE) { | 1018 | ident != TAG_IDENT_USE) { |
1110 | printk(KERN_ERR | 1019 | printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed ident=%d\n", |
1111 | "udf: udf_read_inode(ino %ld) failed ident=%d\n", | ||
1112 | inode->i_ino, ident); | 1020 | inode->i_ino, ident); |
1113 | brelse(bh); | 1021 | brelse(bh); |
1114 | make_bad_inode(inode); | 1022 | make_bad_inode(inode); |
@@ -1121,9 +1029,7 @@ static void __udf_read_inode(struct inode *inode) | |||
1121 | struct buffer_head *ibh = NULL, *nbh = NULL; | 1029 | struct buffer_head *ibh = NULL, *nbh = NULL; |
1122 | struct indirectEntry *ie; | 1030 | struct indirectEntry *ie; |
1123 | 1031 | ||
1124 | ibh = | 1032 | ibh = udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 1, &ident); |
1125 | udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 1, | ||
1126 | &ident); | ||
1127 | if (ident == TAG_IDENT_IE) { | 1033 | if (ident == TAG_IDENT_IE) { |
1128 | if (ibh) { | 1034 | if (ibh) { |
1129 | kernel_lb_addr loc; | 1035 | kernel_lb_addr loc; |
@@ -1132,13 +1038,10 @@ static void __udf_read_inode(struct inode *inode) | |||
1132 | loc = lelb_to_cpu(ie->indirectICB.extLocation); | 1038 | loc = lelb_to_cpu(ie->indirectICB.extLocation); |
1133 | 1039 | ||
1134 | if (ie->indirectICB.extLength && | 1040 | if (ie->indirectICB.extLength && |
1135 | (nbh = | 1041 | (nbh = udf_read_ptagged(inode->i_sb, loc, 0, &ident))) { |
1136 | udf_read_ptagged(inode->i_sb, loc, 0, | 1042 | if (ident == TAG_IDENT_FE || |
1137 | &ident))) { | 1043 | ident == TAG_IDENT_EFE) { |
1138 | if (ident == TAG_IDENT_FE | 1044 | memcpy(&UDF_I_LOCATION(inode), &loc, |
1139 | || ident == TAG_IDENT_EFE) { | ||
1140 | memcpy(&UDF_I_LOCATION(inode), | ||
1141 | &loc, | ||
1142 | sizeof(kernel_lb_addr)); | 1045 | sizeof(kernel_lb_addr)); |
1143 | brelse(bh); | 1046 | brelse(bh); |
1144 | brelse(ibh); | 1047 | brelse(ibh); |
@@ -1149,11 +1052,13 @@ static void __udf_read_inode(struct inode *inode) | |||
1149 | brelse(nbh); | 1052 | brelse(nbh); |
1150 | brelse(ibh); | 1053 | brelse(ibh); |
1151 | } | 1054 | } |
1152 | } else | 1055 | } else { |
1153 | brelse(ibh); | 1056 | brelse(ibh); |
1057 | } | ||
1154 | } | 1058 | } |
1155 | } else | 1059 | } else { |
1156 | brelse(ibh); | 1060 | brelse(ibh); |
1061 | } | ||
1157 | } else if (le16_to_cpu(fe->icbTag.strategyType) != 4) { | 1062 | } else if (le16_to_cpu(fe->icbTag.strategyType) != 4) { |
1158 | printk(KERN_ERR "udf: unsupported strategy type: %d\n", | 1063 | printk(KERN_ERR "udf: unsupported strategy type: %d\n", |
1159 | le16_to_cpu(fe->icbTag.strategyType)); | 1064 | le16_to_cpu(fe->icbTag.strategyType)); |
@@ -1179,11 +1084,10 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1179 | 1084 | ||
1180 | if (le16_to_cpu(fe->icbTag.strategyType) == 4) | 1085 | if (le16_to_cpu(fe->icbTag.strategyType) == 4) |
1181 | UDF_I_STRAT4096(inode) = 0; | 1086 | UDF_I_STRAT4096(inode) = 0; |
1182 | else /* if (le16_to_cpu(fe->icbTag.strategyType) == 4096) */ | 1087 | else /* if (le16_to_cpu(fe->icbTag.strategyType) == 4096) */ |
1183 | UDF_I_STRAT4096(inode) = 1; | 1088 | UDF_I_STRAT4096(inode) = 1; |
1184 | 1089 | ||
1185 | UDF_I_ALLOCTYPE(inode) = | 1090 | UDF_I_ALLOCTYPE(inode) = le16_to_cpu(fe->icbTag.flags) & ICBTAG_FLAG_AD_MASK; |
1186 | le16_to_cpu(fe->icbTag.flags) & ICBTAG_FLAG_AD_MASK; | ||
1187 | UDF_I_UNIQUE(inode) = 0; | 1091 | UDF_I_UNIQUE(inode) = 0; |
1188 | UDF_I_LENEATTR(inode) = 0; | 1092 | UDF_I_LENEATTR(inode) = 0; |
1189 | UDF_I_LENEXTENTS(inode) = 0; | 1093 | UDF_I_LENEXTENTS(inode) = 0; |
@@ -1193,23 +1097,16 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1193 | if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_EFE) { | 1097 | if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_EFE) { |
1194 | UDF_I_EFE(inode) = 1; | 1098 | UDF_I_EFE(inode) = 1; |
1195 | UDF_I_USE(inode) = 0; | 1099 | UDF_I_USE(inode) = 0; |
1196 | if (udf_alloc_i_data | 1100 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry))) { |
1197 | (inode, | ||
1198 | inode->i_sb->s_blocksize - | ||
1199 | sizeof(struct extendedFileEntry))) { | ||
1200 | make_bad_inode(inode); | 1101 | make_bad_inode(inode); |
1201 | return; | 1102 | return; |
1202 | } | 1103 | } |
1203 | memcpy(UDF_I_DATA(inode), | 1104 | memcpy(UDF_I_DATA(inode), bh->b_data + sizeof(struct extendedFileEntry), |
1204 | bh->b_data + sizeof(struct extendedFileEntry), | 1105 | inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry)); |
1205 | inode->i_sb->s_blocksize - | ||
1206 | sizeof(struct extendedFileEntry)); | ||
1207 | } else if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_FE) { | 1106 | } else if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_FE) { |
1208 | UDF_I_EFE(inode) = 0; | 1107 | UDF_I_EFE(inode) = 0; |
1209 | UDF_I_USE(inode) = 0; | 1108 | UDF_I_USE(inode) = 0; |
1210 | if (udf_alloc_i_data | 1109 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - sizeof(struct fileEntry))) { |
1211 | (inode, | ||
1212 | inode->i_sb->s_blocksize - sizeof(struct fileEntry))) { | ||
1213 | make_bad_inode(inode); | 1110 | make_bad_inode(inode); |
1214 | return; | 1111 | return; |
1215 | } | 1112 | } |
@@ -1219,19 +1116,13 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1219 | UDF_I_EFE(inode) = 0; | 1116 | UDF_I_EFE(inode) = 0; |
1220 | UDF_I_USE(inode) = 1; | 1117 | UDF_I_USE(inode) = 1; |
1221 | UDF_I_LENALLOC(inode) = | 1118 | UDF_I_LENALLOC(inode) = |
1222 | le32_to_cpu(((struct unallocSpaceEntry *)bh->b_data)-> | 1119 | le32_to_cpu(((struct unallocSpaceEntry *)bh->b_data)->lengthAllocDescs); |
1223 | lengthAllocDescs); | 1120 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - sizeof(struct unallocSpaceEntry))) { |
1224 | if (udf_alloc_i_data | ||
1225 | (inode, | ||
1226 | inode->i_sb->s_blocksize - | ||
1227 | sizeof(struct unallocSpaceEntry))) { | ||
1228 | make_bad_inode(inode); | 1121 | make_bad_inode(inode); |
1229 | return; | 1122 | return; |
1230 | } | 1123 | } |
1231 | memcpy(UDF_I_DATA(inode), | 1124 | memcpy(UDF_I_DATA(inode), bh->b_data + sizeof(struct unallocSpaceEntry), |
1232 | bh->b_data + sizeof(struct unallocSpaceEntry), | 1125 | inode->i_sb->s_blocksize - sizeof(struct unallocSpaceEntry)); |
1233 | inode->i_sb->s_blocksize - | ||
1234 | sizeof(struct unallocSpaceEntry)); | ||
1235 | return; | 1126 | return; |
1236 | } | 1127 | } |
1237 | 1128 | ||
@@ -1257,7 +1148,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1257 | 1148 | ||
1258 | if (UDF_I_EFE(inode) == 0) { | 1149 | if (UDF_I_EFE(inode) == 0) { |
1259 | inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) << | 1150 | inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) << |
1260 | (inode->i_sb->s_blocksize_bits - 9); | 1151 | (inode->i_sb->s_blocksize_bits - 9); |
1261 | 1152 | ||
1262 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1153 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
1263 | lets_to_cpu(fe->accessTime))) { | 1154 | lets_to_cpu(fe->accessTime))) { |
@@ -1326,78 +1217,56 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1326 | UDF_I_UNIQUE(inode) = le64_to_cpu(efe->uniqueID); | 1217 | UDF_I_UNIQUE(inode) = le64_to_cpu(efe->uniqueID); |
1327 | UDF_I_LENEATTR(inode) = le32_to_cpu(efe->lengthExtendedAttr); | 1218 | UDF_I_LENEATTR(inode) = le32_to_cpu(efe->lengthExtendedAttr); |
1328 | UDF_I_LENALLOC(inode) = le32_to_cpu(efe->lengthAllocDescs); | 1219 | UDF_I_LENALLOC(inode) = le32_to_cpu(efe->lengthAllocDescs); |
1329 | offset = | 1220 | offset = sizeof(struct extendedFileEntry) + UDF_I_LENEATTR(inode); |
1330 | sizeof(struct extendedFileEntry) + UDF_I_LENEATTR(inode); | ||
1331 | } | 1221 | } |
1332 | 1222 | ||
1333 | switch (fe->icbTag.fileType) { | 1223 | switch (fe->icbTag.fileType) { |
1334 | case ICBTAG_FILE_TYPE_DIRECTORY: | 1224 | case ICBTAG_FILE_TYPE_DIRECTORY: |
1335 | { | 1225 | inode->i_op = &udf_dir_inode_operations; |
1336 | inode->i_op = &udf_dir_inode_operations; | 1226 | inode->i_fop = &udf_dir_operations; |
1337 | inode->i_fop = &udf_dir_operations; | 1227 | inode->i_mode |= S_IFDIR; |
1338 | inode->i_mode |= S_IFDIR; | 1228 | inc_nlink(inode); |
1339 | inc_nlink(inode); | 1229 | break; |
1340 | break; | ||
1341 | } | ||
1342 | case ICBTAG_FILE_TYPE_REALTIME: | 1230 | case ICBTAG_FILE_TYPE_REALTIME: |
1343 | case ICBTAG_FILE_TYPE_REGULAR: | 1231 | case ICBTAG_FILE_TYPE_REGULAR: |
1344 | case ICBTAG_FILE_TYPE_UNDEF: | 1232 | case ICBTAG_FILE_TYPE_UNDEF: |
1345 | { | 1233 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) |
1346 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) | 1234 | inode->i_data.a_ops = &udf_adinicb_aops; |
1347 | inode->i_data.a_ops = &udf_adinicb_aops; | 1235 | else |
1348 | else | 1236 | inode->i_data.a_ops = &udf_aops; |
1349 | inode->i_data.a_ops = &udf_aops; | 1237 | inode->i_op = &udf_file_inode_operations; |
1350 | inode->i_op = &udf_file_inode_operations; | 1238 | inode->i_fop = &udf_file_operations; |
1351 | inode->i_fop = &udf_file_operations; | 1239 | inode->i_mode |= S_IFREG; |
1352 | inode->i_mode |= S_IFREG; | 1240 | break; |
1353 | break; | ||
1354 | } | ||
1355 | case ICBTAG_FILE_TYPE_BLOCK: | 1241 | case ICBTAG_FILE_TYPE_BLOCK: |
1356 | { | 1242 | inode->i_mode |= S_IFBLK; |
1357 | inode->i_mode |= S_IFBLK; | 1243 | break; |
1358 | break; | ||
1359 | } | ||
1360 | case ICBTAG_FILE_TYPE_CHAR: | 1244 | case ICBTAG_FILE_TYPE_CHAR: |
1361 | { | 1245 | inode->i_mode |= S_IFCHR; |
1362 | inode->i_mode |= S_IFCHR; | 1246 | break; |
1363 | break; | ||
1364 | } | ||
1365 | case ICBTAG_FILE_TYPE_FIFO: | 1247 | case ICBTAG_FILE_TYPE_FIFO: |
1366 | { | 1248 | init_special_inode(inode, inode->i_mode | S_IFIFO, 0); |
1367 | init_special_inode(inode, inode->i_mode | S_IFIFO, 0); | 1249 | break; |
1368 | break; | ||
1369 | } | ||
1370 | case ICBTAG_FILE_TYPE_SOCKET: | 1250 | case ICBTAG_FILE_TYPE_SOCKET: |
1371 | { | 1251 | init_special_inode(inode, inode->i_mode | S_IFSOCK, 0); |
1372 | init_special_inode(inode, inode->i_mode | S_IFSOCK, 0); | 1252 | break; |
1373 | break; | ||
1374 | } | ||
1375 | case ICBTAG_FILE_TYPE_SYMLINK: | 1253 | case ICBTAG_FILE_TYPE_SYMLINK: |
1376 | { | 1254 | inode->i_data.a_ops = &udf_symlink_aops; |
1377 | inode->i_data.a_ops = &udf_symlink_aops; | 1255 | inode->i_op = &page_symlink_inode_operations; |
1378 | inode->i_op = &page_symlink_inode_operations; | 1256 | inode->i_mode = S_IFLNK | S_IRWXUGO; |
1379 | inode->i_mode = S_IFLNK | S_IRWXUGO; | 1257 | break; |
1380 | break; | ||
1381 | } | ||
1382 | default: | 1258 | default: |
1383 | { | 1259 | printk(KERN_ERR "udf: udf_fill_inode(ino %ld) failed unknown file type=%d\n", |
1384 | printk(KERN_ERR | 1260 | inode->i_ino, fe->icbTag.fileType); |
1385 | "udf: udf_fill_inode(ino %ld) failed unknown file type=%d\n", | 1261 | make_bad_inode(inode); |
1386 | inode->i_ino, fe->icbTag.fileType); | 1262 | return; |
1387 | make_bad_inode(inode); | ||
1388 | return; | ||
1389 | } | ||
1390 | } | 1263 | } |
1391 | if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { | 1264 | if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { |
1392 | struct deviceSpec *dsea = (struct deviceSpec *) | 1265 | struct deviceSpec *dsea = (struct deviceSpec *)udf_get_extendedattr(inode, 12, 1); |
1393 | udf_get_extendedattr(inode, 12, 1); | ||
1394 | |||
1395 | if (dsea) { | 1266 | if (dsea) { |
1396 | init_special_inode(inode, inode->i_mode, | 1267 | init_special_inode(inode, inode->i_mode, |
1397 | MKDEV(le32_to_cpu | 1268 | MKDEV(le32_to_cpu(dsea->majorDeviceIdent), |
1398 | (dsea->majorDeviceIdent), | 1269 | le32_to_cpu(dsea->minorDeviceIdent))); |
1399 | le32_to_cpu(dsea-> | ||
1400 | minorDeviceIdent))); | ||
1401 | /* Developer ID ??? */ | 1270 | /* Developer ID ??? */ |
1402 | } else { | 1271 | } else { |
1403 | make_bad_inode(inode); | 1272 | make_bad_inode(inode); |
@@ -1410,8 +1279,7 @@ static int udf_alloc_i_data(struct inode *inode, size_t size) | |||
1410 | UDF_I_DATA(inode) = kmalloc(size, GFP_KERNEL); | 1279 | UDF_I_DATA(inode) = kmalloc(size, GFP_KERNEL); |
1411 | 1280 | ||
1412 | if (!UDF_I_DATA(inode)) { | 1281 | if (!UDF_I_DATA(inode)) { |
1413 | printk(KERN_ERR | 1282 | printk(KERN_ERR "udf:udf_alloc_i_data (ino %ld) no free memory\n", |
1414 | "udf:udf_alloc_i_data (ino %ld) no free memory\n", | ||
1415 | inode->i_ino); | 1283 | inode->i_ino); |
1416 | return -ENOMEM; | 1284 | return -ENOMEM; |
1417 | } | 1285 | } |
@@ -1428,12 +1296,12 @@ static mode_t udf_convert_permissions(struct fileEntry *fe) | |||
1428 | permissions = le32_to_cpu(fe->permissions); | 1296 | permissions = le32_to_cpu(fe->permissions); |
1429 | flags = le16_to_cpu(fe->icbTag.flags); | 1297 | flags = le16_to_cpu(fe->icbTag.flags); |
1430 | 1298 | ||
1431 | mode = ((permissions) & S_IRWXO) | | 1299 | mode = (( permissions ) & S_IRWXO) | |
1432 | ((permissions >> 2) & S_IRWXG) | | 1300 | (( permissions >> 2 ) & S_IRWXG) | |
1433 | ((permissions >> 4) & S_IRWXU) | | 1301 | (( permissions >> 4 ) & S_IRWXU) | |
1434 | ((flags & ICBTAG_FLAG_SETUID) ? S_ISUID : 0) | | 1302 | (( flags & ICBTAG_FLAG_SETUID) ? S_ISUID : 0) | |
1435 | ((flags & ICBTAG_FLAG_SETGID) ? S_ISGID : 0) | | 1303 | (( flags & ICBTAG_FLAG_SETGID) ? S_ISGID : 0) | |
1436 | ((flags & ICBTAG_FLAG_STICKY) ? S_ISVTX : 0); | 1304 | (( flags & ICBTAG_FLAG_STICKY) ? S_ISVTX : 0); |
1437 | 1305 | ||
1438 | return mode; | 1306 | return mode; |
1439 | } | 1307 | } |
@@ -1456,9 +1324,11 @@ static mode_t udf_convert_permissions(struct fileEntry *fe) | |||
1456 | int udf_write_inode(struct inode *inode, int sync) | 1324 | int udf_write_inode(struct inode *inode, int sync) |
1457 | { | 1325 | { |
1458 | int ret; | 1326 | int ret; |
1327 | |||
1459 | lock_kernel(); | 1328 | lock_kernel(); |
1460 | ret = udf_update_inode(inode, sync); | 1329 | ret = udf_update_inode(inode, sync); |
1461 | unlock_kernel(); | 1330 | unlock_kernel(); |
1331 | |||
1462 | return ret; | 1332 | return ret; |
1463 | } | 1333 | } |
1464 | 1334 | ||
@@ -1479,10 +1349,7 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1479 | kernel_timestamp cpu_time; | 1349 | kernel_timestamp cpu_time; |
1480 | int err = 0; | 1350 | int err = 0; |
1481 | 1351 | ||
1482 | bh = udf_tread(inode->i_sb, | 1352 | bh = udf_tread(inode->i_sb, udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode), 0)); |
1483 | udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode), | ||
1484 | 0)); | ||
1485 | |||
1486 | if (!bh) { | 1353 | if (!bh) { |
1487 | udf_debug("bread failure\n"); | 1354 | udf_debug("bread failure\n"); |
1488 | return -EIO; | 1355 | return -EIO; |
@@ -1495,27 +1362,21 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1495 | 1362 | ||
1496 | if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_USE) { | 1363 | if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_USE) { |
1497 | struct unallocSpaceEntry *use = | 1364 | struct unallocSpaceEntry *use = |
1498 | (struct unallocSpaceEntry *)bh->b_data; | 1365 | (struct unallocSpaceEntry *)bh->b_data; |
1499 | 1366 | ||
1500 | use->lengthAllocDescs = cpu_to_le32(UDF_I_LENALLOC(inode)); | 1367 | use->lengthAllocDescs = cpu_to_le32(UDF_I_LENALLOC(inode)); |
1501 | memcpy(bh->b_data + sizeof(struct unallocSpaceEntry), | 1368 | memcpy(bh->b_data + sizeof(struct unallocSpaceEntry), UDF_I_DATA(inode), |
1502 | UDF_I_DATA(inode), | 1369 | inode->i_sb->s_blocksize - sizeof(struct unallocSpaceEntry)); |
1503 | inode->i_sb->s_blocksize - | 1370 | crclen = sizeof(struct unallocSpaceEntry) + UDF_I_LENALLOC(inode) - sizeof(tag); |
1504 | sizeof(struct unallocSpaceEntry)); | 1371 | use->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); |
1505 | crclen = | ||
1506 | sizeof(struct unallocSpaceEntry) + UDF_I_LENALLOC(inode) - | ||
1507 | sizeof(tag); | ||
1508 | use->descTag.tagLocation = | ||
1509 | cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); | ||
1510 | use->descTag.descCRCLength = cpu_to_le16(crclen); | 1372 | use->descTag.descCRCLength = cpu_to_le16(crclen); |
1511 | use->descTag.descCRC = | 1373 | use->descTag.descCRC = cpu_to_le16(udf_crc((char *)use + sizeof(tag), crclen, 0)); |
1512 | cpu_to_le16(udf_crc((char *)use + sizeof(tag), crclen, 0)); | ||
1513 | 1374 | ||
1514 | use->descTag.tagChecksum = 0; | 1375 | use->descTag.tagChecksum = 0; |
1515 | for (i = 0; i < 16; i++) | 1376 | for (i = 0; i < 16; i++) { |
1516 | if (i != 4) | 1377 | if (i != 4) |
1517 | use->descTag.tagChecksum += | 1378 | use->descTag.tagChecksum += ((uint8_t *)&(use->descTag))[i]; |
1518 | ((uint8_t *) & (use->descTag))[i]; | 1379 | } |
1519 | 1380 | ||
1520 | mark_buffer_dirty(bh); | 1381 | mark_buffer_dirty(bh); |
1521 | brelse(bh); | 1382 | brelse(bh); |
@@ -1532,13 +1393,14 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1532 | else | 1393 | else |
1533 | fe->gid = cpu_to_le32(inode->i_gid); | 1394 | fe->gid = cpu_to_le32(inode->i_gid); |
1534 | 1395 | ||
1535 | udfperms = ((inode->i_mode & S_IRWXO)) | | 1396 | udfperms = ((inode->i_mode & S_IRWXO) ) | |
1536 | ((inode->i_mode & S_IRWXG) << 2) | ((inode->i_mode & S_IRWXU) << 4); | 1397 | ((inode->i_mode & S_IRWXG) << 2) | |
1398 | ((inode->i_mode & S_IRWXU) << 4); | ||
1537 | 1399 | ||
1538 | udfperms |= (le32_to_cpu(fe->permissions) & | 1400 | udfperms |= (le32_to_cpu(fe->permissions) & |
1539 | (FE_PERM_O_DELETE | FE_PERM_O_CHATTR | | 1401 | (FE_PERM_O_DELETE | FE_PERM_O_CHATTR | |
1540 | FE_PERM_G_DELETE | FE_PERM_G_CHATTR | | 1402 | FE_PERM_G_DELETE | FE_PERM_G_CHATTR | |
1541 | FE_PERM_U_DELETE | FE_PERM_U_CHATTR)); | 1403 | FE_PERM_U_DELETE | FE_PERM_U_CHATTR)); |
1542 | fe->permissions = cpu_to_le32(udfperms); | 1404 | fe->permissions = cpu_to_le32(udfperms); |
1543 | 1405 | ||
1544 | if (S_ISDIR(inode->i_mode)) | 1406 | if (S_ISDIR(inode->i_mode)) |
@@ -1550,22 +1412,20 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1550 | 1412 | ||
1551 | if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { | 1413 | if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { |
1552 | regid *eid; | 1414 | regid *eid; |
1553 | struct deviceSpec *dsea = (struct deviceSpec *) | 1415 | struct deviceSpec *dsea = |
1554 | udf_get_extendedattr(inode, 12, 1); | 1416 | (struct deviceSpec *)udf_get_extendedattr(inode, 12, 1); |
1555 | |||
1556 | if (!dsea) { | 1417 | if (!dsea) { |
1557 | dsea = (struct deviceSpec *) | 1418 | dsea = (struct deviceSpec *) |
1558 | udf_add_extendedattr(inode, | 1419 | udf_add_extendedattr(inode, |
1559 | sizeof(struct deviceSpec) + | 1420 | sizeof(struct deviceSpec) + |
1560 | sizeof(regid), 12, 0x3); | 1421 | sizeof(regid), 12, 0x3); |
1561 | dsea->attrType = cpu_to_le32(12); | 1422 | dsea->attrType = cpu_to_le32(12); |
1562 | dsea->attrSubtype = 1; | 1423 | dsea->attrSubtype = 1; |
1563 | dsea->attrLength = | 1424 | dsea->attrLength = cpu_to_le32(sizeof(struct deviceSpec) + |
1564 | cpu_to_le32(sizeof(struct deviceSpec) + | 1425 | sizeof(regid)); |
1565 | sizeof(regid)); | ||
1566 | dsea->impUseLength = cpu_to_le32(sizeof(regid)); | 1426 | dsea->impUseLength = cpu_to_le32(sizeof(regid)); |
1567 | } | 1427 | } |
1568 | eid = (regid *) dsea->impUse; | 1428 | eid = (regid *)dsea->impUse; |
1569 | memset(eid, 0, sizeof(regid)); | 1429 | memset(eid, 0, sizeof(regid)); |
1570 | strcpy(eid->ident, UDF_ID_DEVELOPER); | 1430 | strcpy(eid->ident, UDF_ID_DEVELOPER); |
1571 | eid->identSuffix[0] = UDF_OS_CLASS_UNIX; | 1431 | eid->identSuffix[0] = UDF_OS_CLASS_UNIX; |
@@ -1577,10 +1437,9 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1577 | if (UDF_I_EFE(inode) == 0) { | 1437 | if (UDF_I_EFE(inode) == 0) { |
1578 | memcpy(bh->b_data + sizeof(struct fileEntry), UDF_I_DATA(inode), | 1438 | memcpy(bh->b_data + sizeof(struct fileEntry), UDF_I_DATA(inode), |
1579 | inode->i_sb->s_blocksize - sizeof(struct fileEntry)); | 1439 | inode->i_sb->s_blocksize - sizeof(struct fileEntry)); |
1580 | fe->logicalBlocksRecorded = | 1440 | fe->logicalBlocksRecorded = cpu_to_le64( |
1581 | cpu_to_le64((inode->i_blocks + | 1441 | (inode->i_blocks + (1 << (inode->i_sb->s_blocksize_bits - 9)) - 1) >> |
1582 | (1 << (inode->i_sb->s_blocksize_bits - 9)) - | 1442 | (inode->i_sb->s_blocksize_bits - 9)); |
1583 | 1) >> (inode->i_sb->s_blocksize_bits - 9)); | ||
1584 | 1443 | ||
1585 | if (udf_time_to_stamp(&cpu_time, inode->i_atime)) | 1444 | if (udf_time_to_stamp(&cpu_time, inode->i_atime)) |
1586 | fe->accessTime = cpu_to_lets(cpu_time); | 1445 | fe->accessTime = cpu_to_lets(cpu_time); |
@@ -1598,19 +1457,12 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1598 | fe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_FE); | 1457 | fe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_FE); |
1599 | crclen = sizeof(struct fileEntry); | 1458 | crclen = sizeof(struct fileEntry); |
1600 | } else { | 1459 | } else { |
1601 | memcpy(bh->b_data + sizeof(struct extendedFileEntry), | 1460 | memcpy(bh->b_data + sizeof(struct extendedFileEntry), UDF_I_DATA(inode), |
1602 | UDF_I_DATA(inode), | 1461 | inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry)); |
1603 | inode->i_sb->s_blocksize - | ||
1604 | sizeof(struct extendedFileEntry)); | ||
1605 | efe->objectSize = cpu_to_le64(inode->i_size); | 1462 | efe->objectSize = cpu_to_le64(inode->i_size); |
1606 | efe->logicalBlocksRecorded = cpu_to_le64((inode->i_blocks + | 1463 | efe->logicalBlocksRecorded = cpu_to_le64( |
1607 | (1 << | 1464 | (inode->i_blocks + (1 << (inode->i_sb->s_blocksize_bits - 9)) - 1) >> |
1608 | (inode->i_sb-> | 1465 | (inode->i_sb->s_blocksize_bits - 9)); |
1609 | s_blocksize_bits - | ||
1610 | 9)) - | ||
1611 | 1) >> (inode->i_sb-> | ||
1612 | s_blocksize_bits | ||
1613 | - 9)); | ||
1614 | 1466 | ||
1615 | if (UDF_I_CRTIME(inode).tv_sec > inode->i_atime.tv_sec || | 1467 | if (UDF_I_CRTIME(inode).tv_sec > inode->i_atime.tv_sec || |
1616 | (UDF_I_CRTIME(inode).tv_sec == inode->i_atime.tv_sec && | 1468 | (UDF_I_CRTIME(inode).tv_sec == inode->i_atime.tv_sec && |
@@ -1671,13 +1523,13 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1671 | else if (S_ISSOCK(inode->i_mode)) | 1523 | else if (S_ISSOCK(inode->i_mode)) |
1672 | fe->icbTag.fileType = ICBTAG_FILE_TYPE_SOCKET; | 1524 | fe->icbTag.fileType = ICBTAG_FILE_TYPE_SOCKET; |
1673 | 1525 | ||
1674 | icbflags = UDF_I_ALLOCTYPE(inode) | | 1526 | icbflags = UDF_I_ALLOCTYPE(inode) | |
1675 | ((inode->i_mode & S_ISUID) ? ICBTAG_FLAG_SETUID : 0) | | 1527 | ((inode->i_mode & S_ISUID) ? ICBTAG_FLAG_SETUID : 0) | |
1676 | ((inode->i_mode & S_ISGID) ? ICBTAG_FLAG_SETGID : 0) | | 1528 | ((inode->i_mode & S_ISGID) ? ICBTAG_FLAG_SETGID : 0) | |
1677 | ((inode->i_mode & S_ISVTX) ? ICBTAG_FLAG_STICKY : 0) | | 1529 | ((inode->i_mode & S_ISVTX) ? ICBTAG_FLAG_STICKY : 0) | |
1678 | (le16_to_cpu(fe->icbTag.flags) & | 1530 | (le16_to_cpu(fe->icbTag.flags) & |
1679 | ~(ICBTAG_FLAG_AD_MASK | ICBTAG_FLAG_SETUID | | 1531 | ~(ICBTAG_FLAG_AD_MASK | ICBTAG_FLAG_SETUID | |
1680 | ICBTAG_FLAG_SETGID | ICBTAG_FLAG_STICKY)); | 1532 | ICBTAG_FLAG_SETGID | ICBTAG_FLAG_STICKY)); |
1681 | 1533 | ||
1682 | fe->icbTag.flags = cpu_to_le16(icbflags); | 1534 | fe->icbTag.flags = cpu_to_le16(icbflags); |
1683 | if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) | 1535 | if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) |
@@ -1685,18 +1537,16 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1685 | else | 1537 | else |
1686 | fe->descTag.descVersion = cpu_to_le16(2); | 1538 | fe->descTag.descVersion = cpu_to_le16(2); |
1687 | fe->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb)); | 1539 | fe->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb)); |
1688 | fe->descTag.tagLocation = | 1540 | fe->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); |
1689 | cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); | ||
1690 | crclen += UDF_I_LENEATTR(inode) + UDF_I_LENALLOC(inode) - sizeof(tag); | 1541 | crclen += UDF_I_LENEATTR(inode) + UDF_I_LENALLOC(inode) - sizeof(tag); |
1691 | fe->descTag.descCRCLength = cpu_to_le16(crclen); | 1542 | fe->descTag.descCRCLength = cpu_to_le16(crclen); |
1692 | fe->descTag.descCRC = | 1543 | fe->descTag.descCRC = cpu_to_le16(udf_crc((char *)fe + sizeof(tag), crclen, 0)); |
1693 | cpu_to_le16(udf_crc((char *)fe + sizeof(tag), crclen, 0)); | ||
1694 | 1544 | ||
1695 | fe->descTag.tagChecksum = 0; | 1545 | fe->descTag.tagChecksum = 0; |
1696 | for (i = 0; i < 16; i++) | 1546 | for (i = 0; i < 16; i++) { |
1697 | if (i != 4) | 1547 | if (i != 4) |
1698 | fe->descTag.tagChecksum += | 1548 | fe->descTag.tagChecksum += ((uint8_t *)&(fe->descTag))[i]; |
1699 | ((uint8_t *) & (fe->descTag))[i]; | 1549 | } |
1700 | 1550 | ||
1701 | /* write the data blocks */ | 1551 | /* write the data blocks */ |
1702 | mark_buffer_dirty(bh); | 1552 | mark_buffer_dirty(bh); |
@@ -1709,6 +1559,7 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1709 | } | 1559 | } |
1710 | } | 1560 | } |
1711 | brelse(bh); | 1561 | brelse(bh); |
1562 | |||
1712 | return err; | 1563 | return err; |
1713 | } | 1564 | } |
1714 | 1565 | ||
@@ -1729,8 +1580,7 @@ struct inode *udf_iget(struct super_block *sb, kernel_lb_addr ino) | |||
1729 | if (is_bad_inode(inode)) | 1580 | if (is_bad_inode(inode)) |
1730 | goto out_iput; | 1581 | goto out_iput; |
1731 | 1582 | ||
1732 | if (ino.logicalBlockNum >= | 1583 | if (ino.logicalBlockNum >= UDF_SB_PARTLEN(sb, ino.partitionReferenceNum)) { |
1733 | UDF_SB_PARTLEN(sb, ino.partitionReferenceNum)) { | ||
1734 | udf_debug("block=%d, partition=%d out of range\n", | 1584 | udf_debug("block=%d, partition=%d out of range\n", |
1735 | ino.logicalBlockNum, ino.partitionReferenceNum); | 1585 | ino.logicalBlockNum, ino.partitionReferenceNum); |
1736 | make_bad_inode(inode); | 1586 | make_bad_inode(inode); |
@@ -1739,7 +1589,7 @@ struct inode *udf_iget(struct super_block *sb, kernel_lb_addr ino) | |||
1739 | 1589 | ||
1740 | return inode; | 1590 | return inode; |
1741 | 1591 | ||
1742 | out_iput: | 1592 | out_iput: |
1743 | iput(inode); | 1593 | iput(inode); |
1744 | return NULL; | 1594 | return NULL; |
1745 | } | 1595 | } |
@@ -1755,9 +1605,7 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1755 | uint8_t *ptr; | 1605 | uint8_t *ptr; |
1756 | 1606 | ||
1757 | if (!epos->bh) | 1607 | if (!epos->bh) |
1758 | ptr = | 1608 | ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); |
1759 | UDF_I_DATA(inode) + epos->offset - | ||
1760 | udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); | ||
1761 | else | 1609 | else |
1762 | ptr = epos->bh->b_data + epos->offset; | 1610 | ptr = epos->bh->b_data + epos->offset; |
1763 | 1611 | ||
@@ -1774,18 +1622,13 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1774 | int err, loffset; | 1622 | int err, loffset; |
1775 | kernel_lb_addr obloc = epos->block; | 1623 | kernel_lb_addr obloc = epos->block; |
1776 | 1624 | ||
1777 | if (! | 1625 | if (!(epos->block.logicalBlockNum = udf_new_block(inode->i_sb, NULL, |
1778 | (epos->block.logicalBlockNum = | 1626 | obloc.partitionReferenceNum, |
1779 | udf_new_block(inode->i_sb, NULL, | 1627 | obloc.logicalBlockNum, &err))) { |
1780 | obloc.partitionReferenceNum, | ||
1781 | obloc.logicalBlockNum, &err))) { | ||
1782 | return -1; | 1628 | return -1; |
1783 | } | 1629 | } |
1784 | if (! | 1630 | if (!(nbh = udf_tgetblk(inode->i_sb, udf_get_lb_pblock(inode->i_sb, |
1785 | (nbh = | 1631 | epos->block, 0)))) { |
1786 | udf_tgetblk(inode->i_sb, | ||
1787 | udf_get_lb_pblock(inode->i_sb, epos->block, | ||
1788 | 0)))) { | ||
1789 | return -1; | 1632 | return -1; |
1790 | } | 1633 | } |
1791 | lock_buffer(nbh); | 1634 | lock_buffer(nbh); |
@@ -1796,8 +1639,7 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1796 | 1639 | ||
1797 | aed = (struct allocExtDesc *)(nbh->b_data); | 1640 | aed = (struct allocExtDesc *)(nbh->b_data); |
1798 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)) | 1641 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)) |
1799 | aed->previousAllocExtLocation = | 1642 | aed->previousAllocExtLocation = cpu_to_le32(obloc.logicalBlockNum); |
1800 | cpu_to_le32(obloc.logicalBlockNum); | ||
1801 | if (epos->offset + adsize > inode->i_sb->s_blocksize) { | 1643 | if (epos->offset + adsize > inode->i_sb->s_blocksize) { |
1802 | loffset = epos->offset; | 1644 | loffset = epos->offset; |
1803 | aed->lengthAllocDescs = cpu_to_le32(adsize); | 1645 | aed->lengthAllocDescs = cpu_to_le32(adsize); |
@@ -1814,9 +1656,7 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1814 | if (epos->bh) { | 1656 | if (epos->bh) { |
1815 | aed = (struct allocExtDesc *)epos->bh->b_data; | 1657 | aed = (struct allocExtDesc *)epos->bh->b_data; |
1816 | aed->lengthAllocDescs = | 1658 | aed->lengthAllocDescs = |
1817 | cpu_to_le32(le32_to_cpu | 1659 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); |
1818 | (aed->lengthAllocDescs) + | ||
1819 | adsize); | ||
1820 | } else { | 1660 | } else { |
1821 | UDF_I_LENALLOC(inode) += adsize; | 1661 | UDF_I_LENALLOC(inode) += adsize; |
1822 | mark_inode_dirty(inode); | 1662 | mark_inode_dirty(inode); |
@@ -1830,37 +1670,30 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1830 | epos->block.logicalBlockNum, sizeof(tag)); | 1670 | epos->block.logicalBlockNum, sizeof(tag)); |
1831 | switch (UDF_I_ALLOCTYPE(inode)) { | 1671 | switch (UDF_I_ALLOCTYPE(inode)) { |
1832 | case ICBTAG_FLAG_AD_SHORT: | 1672 | case ICBTAG_FLAG_AD_SHORT: |
1833 | { | 1673 | sad = (short_ad *)sptr; |
1834 | sad = (short_ad *) sptr; | 1674 | sad->extLength = cpu_to_le32(EXT_NEXT_EXTENT_ALLOCDECS | |
1835 | sad->extLength = | 1675 | inode->i_sb->s_blocksize); |
1836 | cpu_to_le32(EXT_NEXT_EXTENT_ALLOCDECS | | 1676 | sad->extPosition = cpu_to_le32(epos->block.logicalBlockNum); |
1837 | inode->i_sb->s_blocksize); | 1677 | break; |
1838 | sad->extPosition = | ||
1839 | cpu_to_le32(epos->block.logicalBlockNum); | ||
1840 | break; | ||
1841 | } | ||
1842 | case ICBTAG_FLAG_AD_LONG: | 1678 | case ICBTAG_FLAG_AD_LONG: |
1843 | { | 1679 | lad = (long_ad *)sptr; |
1844 | lad = (long_ad *) sptr; | 1680 | lad->extLength = cpu_to_le32(EXT_NEXT_EXTENT_ALLOCDECS | |
1845 | lad->extLength = | 1681 | inode->i_sb->s_blocksize); |
1846 | cpu_to_le32(EXT_NEXT_EXTENT_ALLOCDECS | | 1682 | lad->extLocation = cpu_to_lelb(epos->block); |
1847 | inode->i_sb->s_blocksize); | 1683 | memset(lad->impUse, 0x00, sizeof(lad->impUse)); |
1848 | lad->extLocation = cpu_to_lelb(epos->block); | 1684 | break; |
1849 | memset(lad->impUse, 0x00, sizeof(lad->impUse)); | ||
1850 | break; | ||
1851 | } | ||
1852 | } | 1685 | } |
1853 | if (epos->bh) { | 1686 | if (epos->bh) { |
1854 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) | 1687 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1855 | || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 1688 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) |
1856 | udf_update_tag(epos->bh->b_data, loffset); | 1689 | udf_update_tag(epos->bh->b_data, loffset); |
1857 | else | 1690 | else |
1858 | udf_update_tag(epos->bh->b_data, | 1691 | udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc)); |
1859 | sizeof(struct allocExtDesc)); | ||
1860 | mark_buffer_dirty_inode(epos->bh, inode); | 1692 | mark_buffer_dirty_inode(epos->bh, inode); |
1861 | brelse(epos->bh); | 1693 | brelse(epos->bh); |
1862 | } else | 1694 | } else { |
1863 | mark_inode_dirty(inode); | 1695 | mark_inode_dirty(inode); |
1696 | } | ||
1864 | epos->bh = nbh; | 1697 | epos->bh = nbh; |
1865 | } | 1698 | } |
1866 | 1699 | ||
@@ -1872,14 +1705,11 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1872 | } else { | 1705 | } else { |
1873 | aed = (struct allocExtDesc *)epos->bh->b_data; | 1706 | aed = (struct allocExtDesc *)epos->bh->b_data; |
1874 | aed->lengthAllocDescs = | 1707 | aed->lengthAllocDescs = |
1875 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); | 1708 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); |
1876 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) | 1709 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) |
1877 | || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 1710 | udf_update_tag(epos->bh->b_data, epos->offset + (inc ? 0 : adsize)); |
1878 | udf_update_tag(epos->bh->b_data, | ||
1879 | epos->offset + (inc ? 0 : adsize)); | ||
1880 | else | 1711 | else |
1881 | udf_update_tag(epos->bh->b_data, | 1712 | udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc)); |
1882 | sizeof(struct allocExtDesc)); | ||
1883 | mark_buffer_dirty_inode(epos->bh, inode); | 1713 | mark_buffer_dirty_inode(epos->bh, inode); |
1884 | } | 1714 | } |
1885 | 1715 | ||
@@ -1891,51 +1721,47 @@ int8_t udf_write_aext(struct inode * inode, struct extent_position * epos, | |||
1891 | { | 1721 | { |
1892 | int adsize; | 1722 | int adsize; |
1893 | uint8_t *ptr; | 1723 | uint8_t *ptr; |
1724 | short_ad *sad; | ||
1725 | long_ad *lad; | ||
1894 | 1726 | ||
1895 | if (!epos->bh) | 1727 | if (!epos->bh) |
1896 | ptr = | 1728 | ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); |
1897 | UDF_I_DATA(inode) + epos->offset - | ||
1898 | udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); | ||
1899 | else | 1729 | else |
1900 | ptr = epos->bh->b_data + epos->offset; | 1730 | ptr = epos->bh->b_data + epos->offset; |
1901 | 1731 | ||
1902 | switch (UDF_I_ALLOCTYPE(inode)) { | 1732 | switch (UDF_I_ALLOCTYPE(inode)) { |
1903 | case ICBTAG_FLAG_AD_SHORT: | 1733 | case ICBTAG_FLAG_AD_SHORT: |
1904 | { | 1734 | sad = (short_ad *)ptr; |
1905 | short_ad *sad = (short_ad *) ptr; | 1735 | sad->extLength = cpu_to_le32(elen); |
1906 | sad->extLength = cpu_to_le32(elen); | 1736 | sad->extPosition = cpu_to_le32(eloc.logicalBlockNum); |
1907 | sad->extPosition = cpu_to_le32(eloc.logicalBlockNum); | 1737 | adsize = sizeof(short_ad); |
1908 | adsize = sizeof(short_ad); | 1738 | break; |
1909 | break; | ||
1910 | } | ||
1911 | case ICBTAG_FLAG_AD_LONG: | 1739 | case ICBTAG_FLAG_AD_LONG: |
1912 | { | 1740 | lad = (long_ad *)ptr; |
1913 | long_ad *lad = (long_ad *) ptr; | 1741 | lad->extLength = cpu_to_le32(elen); |
1914 | lad->extLength = cpu_to_le32(elen); | 1742 | lad->extLocation = cpu_to_lelb(eloc); |
1915 | lad->extLocation = cpu_to_lelb(eloc); | 1743 | memset(lad->impUse, 0x00, sizeof(lad->impUse)); |
1916 | memset(lad->impUse, 0x00, sizeof(lad->impUse)); | 1744 | adsize = sizeof(long_ad); |
1917 | adsize = sizeof(long_ad); | 1745 | break; |
1918 | break; | ||
1919 | } | ||
1920 | default: | 1746 | default: |
1921 | return -1; | 1747 | return -1; |
1922 | } | 1748 | } |
1923 | 1749 | ||
1924 | if (epos->bh) { | 1750 | if (epos->bh) { |
1925 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) | 1751 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1926 | || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) { | 1752 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) { |
1927 | struct allocExtDesc *aed = | 1753 | struct allocExtDesc *aed = (struct allocExtDesc *)epos->bh->b_data; |
1928 | (struct allocExtDesc *)epos->bh->b_data; | ||
1929 | udf_update_tag(epos->bh->b_data, | 1754 | udf_update_tag(epos->bh->b_data, |
1930 | le32_to_cpu(aed->lengthAllocDescs) + | 1755 | le32_to_cpu(aed->lengthAllocDescs) + sizeof(struct allocExtDesc)); |
1931 | sizeof(struct allocExtDesc)); | ||
1932 | } | 1756 | } |
1933 | mark_buffer_dirty_inode(epos->bh, inode); | 1757 | mark_buffer_dirty_inode(epos->bh, inode); |
1934 | } else | 1758 | } else { |
1935 | mark_inode_dirty(inode); | 1759 | mark_inode_dirty(inode); |
1760 | } | ||
1936 | 1761 | ||
1937 | if (inc) | 1762 | if (inc) |
1938 | epos->offset += adsize; | 1763 | epos->offset += adsize; |
1764 | |||
1939 | return (elen >> 30); | 1765 | return (elen >> 30); |
1940 | } | 1766 | } |
1941 | 1767 | ||
@@ -1949,14 +1775,9 @@ int8_t udf_next_aext(struct inode * inode, struct extent_position * epos, | |||
1949 | epos->block = *eloc; | 1775 | epos->block = *eloc; |
1950 | epos->offset = sizeof(struct allocExtDesc); | 1776 | epos->offset = sizeof(struct allocExtDesc); |
1951 | brelse(epos->bh); | 1777 | brelse(epos->bh); |
1952 | if (! | 1778 | if (!(epos->bh = udf_tread(inode->i_sb, udf_get_lb_pblock(inode->i_sb, epos->block, 0)))) { |
1953 | (epos->bh = | ||
1954 | udf_tread(inode->i_sb, | ||
1955 | udf_get_lb_pblock(inode->i_sb, epos->block, | ||
1956 | 0)))) { | ||
1957 | udf_debug("reading block %d failed!\n", | 1779 | udf_debug("reading block %d failed!\n", |
1958 | udf_get_lb_pblock(inode->i_sb, epos->block, | 1780 | udf_get_lb_pblock(inode->i_sb, epos->block, 0)); |
1959 | 0)); | ||
1960 | return -1; | 1781 | return -1; |
1961 | } | 1782 | } |
1962 | } | 1783 | } |
@@ -1970,75 +1791,49 @@ int8_t udf_current_aext(struct inode * inode, struct extent_position * epos, | |||
1970 | int alen; | 1791 | int alen; |
1971 | int8_t etype; | 1792 | int8_t etype; |
1972 | uint8_t *ptr; | 1793 | uint8_t *ptr; |
1794 | short_ad *sad; | ||
1795 | long_ad *lad; | ||
1796 | |||
1973 | 1797 | ||
1974 | if (!epos->bh) { | 1798 | if (!epos->bh) { |
1975 | if (!epos->offset) | 1799 | if (!epos->offset) |
1976 | epos->offset = udf_file_entry_alloc_offset(inode); | 1800 | epos->offset = udf_file_entry_alloc_offset(inode); |
1977 | ptr = | 1801 | ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); |
1978 | UDF_I_DATA(inode) + epos->offset - | 1802 | alen = udf_file_entry_alloc_offset(inode) + UDF_I_LENALLOC(inode); |
1979 | udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); | ||
1980 | alen = | ||
1981 | udf_file_entry_alloc_offset(inode) + UDF_I_LENALLOC(inode); | ||
1982 | } else { | 1803 | } else { |
1983 | if (!epos->offset) | 1804 | if (!epos->offset) |
1984 | epos->offset = sizeof(struct allocExtDesc); | 1805 | epos->offset = sizeof(struct allocExtDesc); |
1985 | ptr = epos->bh->b_data + epos->offset; | 1806 | ptr = epos->bh->b_data + epos->offset; |
1986 | alen = | 1807 | alen = sizeof(struct allocExtDesc) + |
1987 | sizeof(struct allocExtDesc) + | 1808 | le32_to_cpu(((struct allocExtDesc *)epos->bh->b_data)->lengthAllocDescs); |
1988 | le32_to_cpu(((struct allocExtDesc *)epos->bh->b_data)-> | ||
1989 | lengthAllocDescs); | ||
1990 | } | 1809 | } |
1991 | 1810 | ||
1992 | switch (UDF_I_ALLOCTYPE(inode)) { | 1811 | switch (UDF_I_ALLOCTYPE(inode)) { |
1993 | case ICBTAG_FLAG_AD_SHORT: | 1812 | case ICBTAG_FLAG_AD_SHORT: |
1994 | { | 1813 | if (!(sad = udf_get_fileshortad(ptr, alen, &epos->offset, inc))) |
1995 | short_ad *sad; | 1814 | return -1; |
1996 | 1815 | etype = le32_to_cpu(sad->extLength) >> 30; | |
1997 | if (! | 1816 | eloc->logicalBlockNum = le32_to_cpu(sad->extPosition); |
1998 | (sad = | 1817 | eloc->partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum; |
1999 | udf_get_fileshortad(ptr, alen, &epos->offset, | 1818 | *elen = le32_to_cpu(sad->extLength) & UDF_EXTENT_LENGTH_MASK; |
2000 | inc))) | 1819 | break; |
2001 | return -1; | ||
2002 | |||
2003 | etype = le32_to_cpu(sad->extLength) >> 30; | ||
2004 | eloc->logicalBlockNum = le32_to_cpu(sad->extPosition); | ||
2005 | eloc->partitionReferenceNum = | ||
2006 | UDF_I_LOCATION(inode).partitionReferenceNum; | ||
2007 | *elen = | ||
2008 | le32_to_cpu(sad-> | ||
2009 | extLength) & UDF_EXTENT_LENGTH_MASK; | ||
2010 | break; | ||
2011 | } | ||
2012 | case ICBTAG_FLAG_AD_LONG: | 1820 | case ICBTAG_FLAG_AD_LONG: |
2013 | { | 1821 | if (!(lad = udf_get_filelongad(ptr, alen, &epos->offset, inc))) |
2014 | long_ad *lad; | ||
2015 | |||
2016 | if (! | ||
2017 | (lad = | ||
2018 | udf_get_filelongad(ptr, alen, &epos->offset, inc))) | ||
2019 | return -1; | ||
2020 | |||
2021 | etype = le32_to_cpu(lad->extLength) >> 30; | ||
2022 | *eloc = lelb_to_cpu(lad->extLocation); | ||
2023 | *elen = | ||
2024 | le32_to_cpu(lad-> | ||
2025 | extLength) & UDF_EXTENT_LENGTH_MASK; | ||
2026 | break; | ||
2027 | } | ||
2028 | default: | ||
2029 | { | ||
2030 | udf_debug("alloc_type = %d unsupported\n", | ||
2031 | UDF_I_ALLOCTYPE(inode)); | ||
2032 | return -1; | 1822 | return -1; |
2033 | } | 1823 | etype = le32_to_cpu(lad->extLength) >> 30; |
1824 | *eloc = lelb_to_cpu(lad->extLocation); | ||
1825 | *elen = le32_to_cpu(lad->extLength) & UDF_EXTENT_LENGTH_MASK; | ||
1826 | break; | ||
1827 | default: | ||
1828 | udf_debug("alloc_type = %d unsupported\n", UDF_I_ALLOCTYPE(inode)); | ||
1829 | return -1; | ||
2034 | } | 1830 | } |
2035 | 1831 | ||
2036 | return etype; | 1832 | return etype; |
2037 | } | 1833 | } |
2038 | 1834 | ||
2039 | static int8_t | 1835 | static int8_t udf_insert_aext(struct inode *inode, struct extent_position epos, |
2040 | udf_insert_aext(struct inode *inode, struct extent_position epos, | 1836 | kernel_lb_addr neloc, uint32_t nelen) |
2041 | kernel_lb_addr neloc, uint32_t nelen) | ||
2042 | { | 1837 | { |
2043 | kernel_lb_addr oeloc; | 1838 | kernel_lb_addr oeloc; |
2044 | uint32_t oelen; | 1839 | uint32_t oelen; |
@@ -2049,12 +1844,12 @@ udf_insert_aext(struct inode *inode, struct extent_position epos, | |||
2049 | 1844 | ||
2050 | while ((etype = udf_next_aext(inode, &epos, &oeloc, &oelen, 0)) != -1) { | 1845 | while ((etype = udf_next_aext(inode, &epos, &oeloc, &oelen, 0)) != -1) { |
2051 | udf_write_aext(inode, &epos, neloc, nelen, 1); | 1846 | udf_write_aext(inode, &epos, neloc, nelen, 1); |
2052 | |||
2053 | neloc = oeloc; | 1847 | neloc = oeloc; |
2054 | nelen = (etype << 30) | oelen; | 1848 | nelen = (etype << 30) | oelen; |
2055 | } | 1849 | } |
2056 | udf_add_aext(inode, &epos, neloc, nelen, 1); | 1850 | udf_add_aext(inode, &epos, neloc, nelen, 1); |
2057 | brelse(epos.bh); | 1851 | brelse(epos.bh); |
1852 | |||
2058 | return (nelen >> 30); | 1853 | return (nelen >> 30); |
2059 | } | 1854 | } |
2060 | 1855 | ||
@@ -2105,15 +1900,12 @@ int8_t udf_delete_aext(struct inode * inode, struct extent_position epos, | |||
2105 | } else { | 1900 | } else { |
2106 | aed = (struct allocExtDesc *)oepos.bh->b_data; | 1901 | aed = (struct allocExtDesc *)oepos.bh->b_data; |
2107 | aed->lengthAllocDescs = | 1902 | aed->lengthAllocDescs = |
2108 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - | 1903 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - (2 * adsize)); |
2109 | (2 * adsize)); | 1904 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
2110 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) | 1905 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) |
2111 | || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 1906 | udf_update_tag(oepos.bh->b_data, oepos.offset - (2 * adsize)); |
2112 | udf_update_tag(oepos.bh->b_data, | ||
2113 | oepos.offset - (2 * adsize)); | ||
2114 | else | 1907 | else |
2115 | udf_update_tag(oepos.bh->b_data, | 1908 | udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc)); |
2116 | sizeof(struct allocExtDesc)); | ||
2117 | mark_buffer_dirty_inode(oepos.bh, inode); | 1909 | mark_buffer_dirty_inode(oepos.bh, inode); |
2118 | } | 1910 | } |
2119 | } else { | 1911 | } else { |
@@ -2124,21 +1916,19 @@ int8_t udf_delete_aext(struct inode * inode, struct extent_position epos, | |||
2124 | } else { | 1916 | } else { |
2125 | aed = (struct allocExtDesc *)oepos.bh->b_data; | 1917 | aed = (struct allocExtDesc *)oepos.bh->b_data; |
2126 | aed->lengthAllocDescs = | 1918 | aed->lengthAllocDescs = |
2127 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - | 1919 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - adsize); |
2128 | adsize); | 1920 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
2129 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) | 1921 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) |
2130 | || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 1922 | udf_update_tag(oepos.bh->b_data, epos.offset - adsize); |
2131 | udf_update_tag(oepos.bh->b_data, | ||
2132 | epos.offset - adsize); | ||
2133 | else | 1923 | else |
2134 | udf_update_tag(oepos.bh->b_data, | 1924 | udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc)); |
2135 | sizeof(struct allocExtDesc)); | ||
2136 | mark_buffer_dirty_inode(oepos.bh, inode); | 1925 | mark_buffer_dirty_inode(oepos.bh, inode); |
2137 | } | 1926 | } |
2138 | } | 1927 | } |
2139 | 1928 | ||
2140 | brelse(epos.bh); | 1929 | brelse(epos.bh); |
2141 | brelse(oepos.bh); | 1930 | brelse(oepos.bh); |
1931 | |||
2142 | return (elen >> 30); | 1932 | return (elen >> 30); |
2143 | } | 1933 | } |
2144 | 1934 | ||
@@ -2162,8 +1952,7 @@ int8_t inode_bmap(struct inode * inode, sector_t block, | |||
2162 | 1952 | ||
2163 | do { | 1953 | do { |
2164 | if ((etype = udf_next_aext(inode, pos, eloc, elen, 1)) == -1) { | 1954 | if ((etype = udf_next_aext(inode, pos, eloc, elen, 1)) == -1) { |
2165 | *offset = | 1955 | *offset = (bcount - lbcount) >> inode->i_sb->s_blocksize_bits; |
2166 | (bcount - lbcount) >> inode->i_sb->s_blocksize_bits; | ||
2167 | UDF_I_LENEXTENTS(inode) = lbcount; | 1956 | UDF_I_LENEXTENTS(inode) = lbcount; |
2168 | return -1; | 1957 | return -1; |
2169 | } | 1958 | } |
@@ -2180,13 +1969,12 @@ long udf_block_map(struct inode *inode, sector_t block) | |||
2180 | kernel_lb_addr eloc; | 1969 | kernel_lb_addr eloc; |
2181 | uint32_t elen; | 1970 | uint32_t elen; |
2182 | sector_t offset; | 1971 | sector_t offset; |
2183 | struct extent_position epos = { NULL, 0, {0, 0} }; | 1972 | struct extent_position epos = {}; |
2184 | int ret; | 1973 | int ret; |
2185 | 1974 | ||
2186 | lock_kernel(); | 1975 | lock_kernel(); |
2187 | 1976 | ||
2188 | if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) == | 1977 | if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) |
2189 | (EXT_RECORDED_ALLOCATED >> 30)) | ||
2190 | ret = udf_get_lb_pblock(inode->i_sb, eloc, offset); | 1978 | ret = udf_get_lb_pblock(inode->i_sb, eloc, offset); |
2191 | else | 1979 | else |
2192 | ret = 0; | 1980 | ret = 0; |
diff --git a/fs/udf/lowlevel.c b/fs/udf/lowlevel.c index 4826c3616eef..579bae71e67e 100644 --- a/fs/udf/lowlevel.c +++ b/fs/udf/lowlevel.c | |||
@@ -43,7 +43,7 @@ unsigned int udf_get_last_session(struct super_block *sb) | |||
43 | udf_debug("XA disk: %s, vol_desc_start=%d\n", | 43 | udf_debug("XA disk: %s, vol_desc_start=%d\n", |
44 | (ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba); | 44 | (ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba); |
45 | #if WE_OBEY_THE_WRITTEN_STANDARDS | 45 | #if WE_OBEY_THE_WRITTEN_STANDARDS |
46 | if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */ | 46 | if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */ |
47 | #endif | 47 | #endif |
48 | vol_desc_start = ms_info.addr.lba; | 48 | vol_desc_start = ms_info.addr.lba; |
49 | } else { | 49 | } else { |
@@ -57,7 +57,7 @@ unsigned long udf_get_last_block(struct super_block *sb) | |||
57 | struct block_device *bdev = sb->s_bdev; | 57 | struct block_device *bdev = sb->s_bdev; |
58 | unsigned long lblock = 0; | 58 | unsigned long lblock = 0; |
59 | 59 | ||
60 | if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long)&lblock)) | 60 | if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock)) |
61 | lblock = bdev->bd_inode->i_size >> sb->s_blocksize_bits; | 61 | lblock = bdev->bd_inode->i_size >> sb->s_blocksize_bits; |
62 | 62 | ||
63 | if (lblock) | 63 | if (lblock) |
diff --git a/fs/udf/misc.c b/fs/udf/misc.c index a7f57277a96e..15297deb5051 100644 --- a/fs/udf/misc.c +++ b/fs/udf/misc.c | |||
@@ -54,15 +54,15 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, | |||
54 | int i; | 54 | int i; |
55 | 55 | ||
56 | ea = UDF_I_DATA(inode); | 56 | ea = UDF_I_DATA(inode); |
57 | if (UDF_I_LENEATTR(inode)) | 57 | if (UDF_I_LENEATTR(inode)) { |
58 | ad = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode); | 58 | ad = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode); |
59 | else { | 59 | } else { |
60 | ad = ea; | 60 | ad = ea; |
61 | size += sizeof(struct extendedAttrHeaderDesc); | 61 | size += sizeof(struct extendedAttrHeaderDesc); |
62 | } | 62 | } |
63 | 63 | ||
64 | offset = inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode) - | 64 | offset = inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode) - |
65 | UDF_I_LENALLOC(inode); | 65 | UDF_I_LENALLOC(inode); |
66 | 66 | ||
67 | /* TODO - Check for FreeEASpace */ | 67 | /* TODO - Check for FreeEASpace */ |
68 | 68 | ||
@@ -76,56 +76,45 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, | |||
76 | 76 | ||
77 | if (UDF_I_LENEATTR(inode)) { | 77 | if (UDF_I_LENEATTR(inode)) { |
78 | /* check checksum/crc */ | 78 | /* check checksum/crc */ |
79 | if (le16_to_cpu(eahd->descTag.tagIdent) != | 79 | if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD || |
80 | TAG_IDENT_EAHD | 80 | le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum) { |
81 | || le32_to_cpu(eahd->descTag.tagLocation) != | ||
82 | UDF_I_LOCATION(inode).logicalBlockNum) { | ||
83 | return NULL; | 81 | return NULL; |
84 | } | 82 | } |
85 | } else { | 83 | } else { |
86 | size -= sizeof(struct extendedAttrHeaderDesc); | 84 | size -= sizeof(struct extendedAttrHeaderDesc); |
87 | UDF_I_LENEATTR(inode) += | 85 | UDF_I_LENEATTR(inode) += sizeof(struct extendedAttrHeaderDesc); |
88 | sizeof(struct extendedAttrHeaderDesc); | ||
89 | eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD); | 86 | eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD); |
90 | if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) | 87 | if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) |
91 | eahd->descTag.descVersion = cpu_to_le16(3); | 88 | eahd->descTag.descVersion = cpu_to_le16(3); |
92 | else | 89 | else |
93 | eahd->descTag.descVersion = cpu_to_le16(2); | 90 | eahd->descTag.descVersion = cpu_to_le16(2); |
94 | eahd->descTag.tagSerialNum = | 91 | eahd->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb)); |
95 | cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb)); | 92 | eahd->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); |
96 | eahd->descTag.tagLocation = | ||
97 | cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); | ||
98 | eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF); | 93 | eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF); |
99 | eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF); | 94 | eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF); |
100 | } | 95 | } |
101 | 96 | ||
102 | offset = UDF_I_LENEATTR(inode); | 97 | offset = UDF_I_LENEATTR(inode); |
103 | if (type < 2048) { | 98 | if (type < 2048) { |
104 | if (le32_to_cpu(eahd->appAttrLocation) < | 99 | if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode)) { |
105 | UDF_I_LENEATTR(inode)) { | 100 | uint32_t aal = le32_to_cpu(eahd->appAttrLocation); |
106 | uint32_t aal = | 101 | memmove(&ea[offset - aal + size], |
107 | le32_to_cpu(eahd->appAttrLocation); | 102 | &ea[aal], offset - aal); |
108 | memmove(&ea[offset - aal + size], &ea[aal], | ||
109 | offset - aal); | ||
110 | offset -= aal; | 103 | offset -= aal; |
111 | eahd->appAttrLocation = cpu_to_le32(aal + size); | 104 | eahd->appAttrLocation = cpu_to_le32(aal + size); |
112 | } | 105 | } |
113 | if (le32_to_cpu(eahd->impAttrLocation) < | 106 | if (le32_to_cpu(eahd->impAttrLocation) < UDF_I_LENEATTR(inode)) { |
114 | UDF_I_LENEATTR(inode)) { | 107 | uint32_t ial = le32_to_cpu(eahd->impAttrLocation); |
115 | uint32_t ial = | 108 | memmove(&ea[offset - ial + size], |
116 | le32_to_cpu(eahd->impAttrLocation); | 109 | &ea[ial], offset - ial); |
117 | memmove(&ea[offset - ial + size], &ea[ial], | ||
118 | offset - ial); | ||
119 | offset -= ial; | 110 | offset -= ial; |
120 | eahd->impAttrLocation = cpu_to_le32(ial + size); | 111 | eahd->impAttrLocation = cpu_to_le32(ial + size); |
121 | } | 112 | } |
122 | } else if (type < 65536) { | 113 | } else if (type < 65536) { |
123 | if (le32_to_cpu(eahd->appAttrLocation) < | 114 | if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode)) { |
124 | UDF_I_LENEATTR(inode)) { | 115 | uint32_t aal = le32_to_cpu(eahd->appAttrLocation); |
125 | uint32_t aal = | 116 | memmove(&ea[offset - aal + size], |
126 | le32_to_cpu(eahd->appAttrLocation); | 117 | &ea[aal], offset - aal); |
127 | memmove(&ea[offset - aal + size], &ea[aal], | ||
128 | offset - aal); | ||
129 | offset -= aal; | 118 | offset -= aal; |
130 | eahd->appAttrLocation = cpu_to_le32(aal + size); | 119 | eahd->appAttrLocation = cpu_to_le32(aal + size); |
131 | } | 120 | } |
@@ -133,18 +122,18 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, | |||
133 | /* rewrite CRC + checksum of eahd */ | 122 | /* rewrite CRC + checksum of eahd */ |
134 | crclen = sizeof(struct extendedAttrHeaderDesc) - sizeof(tag); | 123 | crclen = sizeof(struct extendedAttrHeaderDesc) - sizeof(tag); |
135 | eahd->descTag.descCRCLength = cpu_to_le16(crclen); | 124 | eahd->descTag.descCRCLength = cpu_to_le16(crclen); |
136 | eahd->descTag.descCRC = | 125 | eahd->descTag.descCRC = cpu_to_le16(udf_crc((char *)eahd + |
137 | cpu_to_le16(udf_crc((char *)eahd + sizeof(tag), crclen, 0)); | 126 | sizeof(tag), crclen, 0)); |
138 | eahd->descTag.tagChecksum = 0; | 127 | eahd->descTag.tagChecksum = 0; |
139 | for (i = 0; i < 16; i++) | 128 | for (i = 0; i < 16; i++) |
140 | if (i != 4) | 129 | if (i != 4) |
141 | eahd->descTag.tagChecksum += | 130 | eahd->descTag.tagChecksum += ((uint8_t *)&(eahd->descTag))[i]; |
142 | ((uint8_t *) & (eahd->descTag))[i]; | ||
143 | UDF_I_LENEATTR(inode) += size; | 131 | UDF_I_LENEATTR(inode) += size; |
144 | return (struct genericFormat *)&ea[offset]; | 132 | return (struct genericFormat *)&ea[offset]; |
145 | } | 133 | } |
146 | if (loc & 0x02) { | 134 | if (loc & 0x02) { |
147 | } | 135 | } |
136 | |||
148 | return NULL; | 137 | return NULL; |
149 | } | 138 | } |
150 | 139 | ||
@@ -163,8 +152,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type, | |||
163 | 152 | ||
164 | /* check checksum/crc */ | 153 | /* check checksum/crc */ |
165 | if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD || | 154 | if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD || |
166 | le32_to_cpu(eahd->descTag.tagLocation) != | 155 | le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum) { |
167 | UDF_I_LOCATION(inode).logicalBlockNum) { | ||
168 | return NULL; | 156 | return NULL; |
169 | } | 157 | } |
170 | 158 | ||
@@ -177,13 +165,13 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type, | |||
177 | 165 | ||
178 | while (offset < UDF_I_LENEATTR(inode)) { | 166 | while (offset < UDF_I_LENEATTR(inode)) { |
179 | gaf = (struct genericFormat *)&ea[offset]; | 167 | gaf = (struct genericFormat *)&ea[offset]; |
180 | if (le32_to_cpu(gaf->attrType) == type | 168 | if (le32_to_cpu(gaf->attrType) == type && gaf->attrSubtype == subtype) |
181 | && gaf->attrSubtype == subtype) | ||
182 | return gaf; | 169 | return gaf; |
183 | else | 170 | else |
184 | offset += le32_to_cpu(gaf->attrLength); | 171 | offset += le32_to_cpu(gaf->attrLength); |
185 | } | 172 | } |
186 | } | 173 | } |
174 | |||
187 | return NULL; | 175 | return NULL; |
188 | } | 176 | } |
189 | 177 | ||
@@ -216,23 +204,22 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, | |||
216 | return NULL; | 204 | return NULL; |
217 | } | 205 | } |
218 | 206 | ||
219 | tag_p = (tag *) (bh->b_data); | 207 | tag_p = (tag *)(bh->b_data); |
220 | 208 | ||
221 | *ident = le16_to_cpu(tag_p->tagIdent); | 209 | *ident = le16_to_cpu(tag_p->tagIdent); |
222 | 210 | ||
223 | if (location != le32_to_cpu(tag_p->tagLocation)) { | 211 | if (location != le32_to_cpu(tag_p->tagLocation)) { |
224 | udf_debug("location mismatch block %u, tag %u != %u\n", | 212 | udf_debug("location mismatch block %u, tag %u != %u\n", |
225 | block + UDF_SB_SESSION(sb), | 213 | block + UDF_SB_SESSION(sb), le32_to_cpu(tag_p->tagLocation), location); |
226 | le32_to_cpu(tag_p->tagLocation), location); | ||
227 | goto error_out; | 214 | goto error_out; |
228 | } | 215 | } |
229 | 216 | ||
230 | /* Verify the tag checksum */ | 217 | /* Verify the tag checksum */ |
231 | checksum = 0U; | 218 | checksum = 0U; |
232 | for (i = 0; i < 4; i++) | 219 | for (i = 0; i < 4; i++) |
233 | checksum += (uint8_t) (bh->b_data[i]); | 220 | checksum += (uint8_t)(bh->b_data[i]); |
234 | for (i = 5; i < 16; i++) | 221 | for (i = 5; i < 16; i++) |
235 | checksum += (uint8_t) (bh->b_data[i]); | 222 | checksum += (uint8_t)(bh->b_data[i]); |
236 | if (checksum != tag_p->tagChecksum) { | 223 | if (checksum != tag_p->tagChecksum) { |
237 | printk(KERN_ERR "udf: tag checksum failed block %d\n", block); | 224 | printk(KERN_ERR "udf: tag checksum failed block %d\n", block); |
238 | goto error_out; | 225 | goto error_out; |
@@ -249,16 +236,14 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, | |||
249 | /* Verify the descriptor CRC */ | 236 | /* Verify the descriptor CRC */ |
250 | if (le16_to_cpu(tag_p->descCRCLength) + sizeof(tag) > sb->s_blocksize || | 237 | if (le16_to_cpu(tag_p->descCRCLength) + sizeof(tag) > sb->s_blocksize || |
251 | le16_to_cpu(tag_p->descCRC) == udf_crc(bh->b_data + sizeof(tag), | 238 | le16_to_cpu(tag_p->descCRC) == udf_crc(bh->b_data + sizeof(tag), |
252 | le16_to_cpu(tag_p-> | 239 | le16_to_cpu(tag_p->descCRCLength), 0)) { |
253 | descCRCLength), | ||
254 | 0)) { | ||
255 | return bh; | 240 | return bh; |
256 | } | 241 | } |
257 | udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", | 242 | udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", |
258 | block + UDF_SB_SESSION(sb), le16_to_cpu(tag_p->descCRC), | 243 | block + UDF_SB_SESSION(sb), le16_to_cpu(tag_p->descCRC), |
259 | le16_to_cpu(tag_p->descCRCLength)); | 244 | le16_to_cpu(tag_p->descCRCLength)); |
260 | 245 | ||
261 | error_out: | 246 | error_out: |
262 | brelse(bh); | 247 | brelse(bh); |
263 | return NULL; | 248 | return NULL; |
264 | } | 249 | } |
@@ -272,7 +257,7 @@ struct buffer_head *udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc, | |||
272 | 257 | ||
273 | void udf_update_tag(char *data, int length) | 258 | void udf_update_tag(char *data, int length) |
274 | { | 259 | { |
275 | tag *tptr = (tag *) data; | 260 | tag *tptr = (tag *)data; |
276 | int i; | 261 | int i; |
277 | 262 | ||
278 | length -= sizeof(tag); | 263 | length -= sizeof(tag); |
@@ -283,13 +268,13 @@ void udf_update_tag(char *data, int length) | |||
283 | 268 | ||
284 | for (i = 0; i < 16; i++) | 269 | for (i = 0; i < 16; i++) |
285 | if (i != 4) | 270 | if (i != 4) |
286 | tptr->tagChecksum += (uint8_t) (data[i]); | 271 | tptr->tagChecksum += (uint8_t)(data[i]); |
287 | } | 272 | } |
288 | 273 | ||
289 | void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum, | 274 | void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum, |
290 | uint32_t loc, int length) | 275 | uint32_t loc, int length) |
291 | { | 276 | { |
292 | tag *tptr = (tag *) data; | 277 | tag *tptr = (tag *)data; |
293 | tptr->tagIdent = cpu_to_le16(ident); | 278 | tptr->tagIdent = cpu_to_le16(ident); |
294 | tptr->descVersion = cpu_to_le16(version); | 279 | tptr->descVersion = cpu_to_le16(version); |
295 | tptr->tagSerialNum = cpu_to_le16(snum); | 280 | tptr->tagSerialNum = cpu_to_le16(snum); |
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 334d363a0903..bec96a6b3343 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c | |||
@@ -37,6 +37,7 @@ static inline int udf_match(int len1, const char *name1, int len2, | |||
37 | { | 37 | { |
38 | if (len1 != len2) | 38 | if (len1 != len2) |
39 | return 0; | 39 | return 0; |
40 | |||
40 | return !memcmp(name1, name2, len1); | 41 | return !memcmp(name1, name2, len1); |
41 | } | 42 | } |
42 | 43 | ||
@@ -52,7 +53,7 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi, | |||
52 | uint16_t liu = le16_to_cpu(cfi->lengthOfImpUse); | 53 | uint16_t liu = le16_to_cpu(cfi->lengthOfImpUse); |
53 | uint8_t lfi = cfi->lengthFileIdent; | 54 | uint8_t lfi = cfi->lengthFileIdent; |
54 | int padlen = fibh->eoffset - fibh->soffset - liu - lfi - | 55 | int padlen = fibh->eoffset - fibh->soffset - liu - lfi - |
55 | sizeof(struct fileIdentDesc); | 56 | sizeof(struct fileIdentDesc); |
56 | int adinicb = 0; | 57 | int adinicb = 0; |
57 | 58 | ||
58 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) | 59 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) |
@@ -61,85 +62,75 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi, | |||
61 | offset = fibh->soffset + sizeof(struct fileIdentDesc); | 62 | offset = fibh->soffset + sizeof(struct fileIdentDesc); |
62 | 63 | ||
63 | if (impuse) { | 64 | if (impuse) { |
64 | if (adinicb || (offset + liu < 0)) | 65 | if (adinicb || (offset + liu < 0)) { |
65 | memcpy((uint8_t *) sfi->impUse, impuse, liu); | 66 | memcpy((uint8_t *)sfi->impUse, impuse, liu); |
66 | else if (offset >= 0) | 67 | } else if (offset >= 0) { |
67 | memcpy(fibh->ebh->b_data + offset, impuse, liu); | 68 | memcpy(fibh->ebh->b_data + offset, impuse, liu); |
68 | else { | 69 | } else { |
69 | memcpy((uint8_t *) sfi->impUse, impuse, -offset); | 70 | memcpy((uint8_t *)sfi->impUse, impuse, -offset); |
70 | memcpy(fibh->ebh->b_data, impuse - offset, | 71 | memcpy(fibh->ebh->b_data, impuse - offset, liu + offset); |
71 | liu + offset); | ||
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | offset += liu; | 75 | offset += liu; |
76 | 76 | ||
77 | if (fileident) { | 77 | if (fileident) { |
78 | if (adinicb || (offset + lfi < 0)) | 78 | if (adinicb || (offset + lfi < 0)) { |
79 | memcpy((uint8_t *) sfi->fileIdent + liu, fileident, | 79 | memcpy((uint8_t *)sfi->fileIdent + liu, fileident, lfi); |
80 | lfi); | 80 | } else if (offset >= 0) { |
81 | else if (offset >= 0) | ||
82 | memcpy(fibh->ebh->b_data + offset, fileident, lfi); | 81 | memcpy(fibh->ebh->b_data + offset, fileident, lfi); |
83 | else { | 82 | } else { |
84 | memcpy((uint8_t *) sfi->fileIdent + liu, fileident, | 83 | memcpy((uint8_t *)sfi->fileIdent + liu, fileident, -offset); |
85 | -offset); | 84 | memcpy(fibh->ebh->b_data, fileident - offset, lfi + offset); |
86 | memcpy(fibh->ebh->b_data, fileident - offset, | ||
87 | lfi + offset); | ||
88 | } | 85 | } |
89 | } | 86 | } |
90 | 87 | ||
91 | offset += lfi; | 88 | offset += lfi; |
92 | 89 | ||
93 | if (adinicb || (offset + padlen < 0)) | 90 | if (adinicb || (offset + padlen < 0)) { |
94 | memset((uint8_t *) sfi->padding + liu + lfi, 0x00, padlen); | 91 | memset((uint8_t *)sfi->padding + liu + lfi, 0x00, padlen); |
95 | else if (offset >= 0) | 92 | } else if (offset >= 0) { |
96 | memset(fibh->ebh->b_data + offset, 0x00, padlen); | 93 | memset(fibh->ebh->b_data + offset, 0x00, padlen); |
97 | else { | 94 | } else { |
98 | memset((uint8_t *) sfi->padding + liu + lfi, 0x00, -offset); | 95 | memset((uint8_t *)sfi->padding + liu + lfi, 0x00, -offset); |
99 | memset(fibh->ebh->b_data, 0x00, padlen + offset); | 96 | memset(fibh->ebh->b_data, 0x00, padlen + offset); |
100 | } | 97 | } |
101 | 98 | ||
102 | crc = | 99 | crc = udf_crc((uint8_t *)cfi + sizeof(tag), |
103 | udf_crc((uint8_t *) cfi + sizeof(tag), | 100 | sizeof(struct fileIdentDesc) - sizeof(tag), 0); |
104 | sizeof(struct fileIdentDesc) - sizeof(tag), 0); | 101 | |
105 | 102 | if (fibh->sbh == fibh->ebh) { | |
106 | if (fibh->sbh == fibh->ebh) | 103 | crc = udf_crc((uint8_t *)sfi->impUse, |
107 | crc = udf_crc((uint8_t *) sfi->impUse, | 104 | crclen + sizeof(tag) - sizeof(struct fileIdentDesc), crc); |
108 | crclen + sizeof(tag) - | 105 | } else if (sizeof(struct fileIdentDesc) >= -fibh->soffset) { |
109 | sizeof(struct fileIdentDesc), crc); | 106 | crc = udf_crc(fibh->ebh->b_data + sizeof(struct fileIdentDesc) + fibh->soffset, |
110 | else if (sizeof(struct fileIdentDesc) >= -fibh->soffset) | 107 | crclen + sizeof(tag) - sizeof(struct fileIdentDesc), crc); |
111 | crc = | 108 | } else { |
112 | udf_crc(fibh->ebh->b_data + sizeof(struct fileIdentDesc) + | 109 | crc = udf_crc((uint8_t *)sfi->impUse, |
113 | fibh->soffset, | 110 | -fibh->soffset - sizeof(struct fileIdentDesc), crc); |
114 | crclen + sizeof(tag) - sizeof(struct fileIdentDesc), | ||
115 | crc); | ||
116 | else { | ||
117 | crc = udf_crc((uint8_t *) sfi->impUse, | ||
118 | -fibh->soffset - sizeof(struct fileIdentDesc), | ||
119 | crc); | ||
120 | crc = udf_crc(fibh->ebh->b_data, fibh->eoffset, crc); | 111 | crc = udf_crc(fibh->ebh->b_data, fibh->eoffset, crc); |
121 | } | 112 | } |
122 | 113 | ||
123 | cfi->descTag.descCRC = cpu_to_le16(crc); | 114 | cfi->descTag.descCRC = cpu_to_le16(crc); |
124 | cfi->descTag.descCRCLength = cpu_to_le16(crclen); | 115 | cfi->descTag.descCRCLength = cpu_to_le16(crclen); |
125 | 116 | ||
126 | for (i = 0; i < 16; i++) | 117 | for (i = 0; i < 16; i++) { |
127 | if (i != 4) | 118 | if (i != 4) |
128 | checksum += ((uint8_t *) & cfi->descTag)[i]; | 119 | checksum += ((uint8_t *)&cfi->descTag)[i]; |
120 | } | ||
129 | 121 | ||
130 | cfi->descTag.tagChecksum = checksum; | 122 | cfi->descTag.tagChecksum = checksum; |
131 | if (adinicb || (sizeof(struct fileIdentDesc) <= -fibh->soffset)) | 123 | if (adinicb || (sizeof(struct fileIdentDesc) <= -fibh->soffset)) { |
132 | memcpy((uint8_t *) sfi, (uint8_t *) cfi, | 124 | memcpy((uint8_t *)sfi, (uint8_t *)cfi, sizeof(struct fileIdentDesc)); |
133 | sizeof(struct fileIdentDesc)); | 125 | } else { |
134 | else { | 126 | memcpy((uint8_t *)sfi, (uint8_t *)cfi, -fibh->soffset); |
135 | memcpy((uint8_t *) sfi, (uint8_t *) cfi, -fibh->soffset); | 127 | memcpy(fibh->ebh->b_data, (uint8_t *)cfi - fibh->soffset, |
136 | memcpy(fibh->ebh->b_data, (uint8_t *) cfi - fibh->soffset, | ||
137 | sizeof(struct fileIdentDesc) + fibh->soffset); | 128 | sizeof(struct fileIdentDesc) + fibh->soffset); |
138 | } | 129 | } |
139 | 130 | ||
140 | if (adinicb) | 131 | if (adinicb) { |
141 | mark_inode_dirty(inode); | 132 | mark_inode_dirty(inode); |
142 | else { | 133 | } else { |
143 | if (fibh->sbh != fibh->ebh) | 134 | if (fibh->sbh != fibh->ebh) |
144 | mark_buffer_dirty_inode(fibh->ebh, inode); | 135 | mark_buffer_dirty_inode(fibh->ebh, inode); |
145 | mark_buffer_dirty_inode(fibh->sbh, inode); | 136 | mark_buffer_dirty_inode(fibh->sbh, inode); |
@@ -163,26 +154,25 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir, | |||
163 | kernel_lb_addr eloc; | 154 | kernel_lb_addr eloc; |
164 | uint32_t elen; | 155 | uint32_t elen; |
165 | sector_t offset; | 156 | sector_t offset; |
166 | struct extent_position epos = { NULL, 0, {0, 0} }; | 157 | struct extent_position epos = {}; |
167 | 158 | ||
168 | size = (udf_ext0_offset(dir) + dir->i_size) >> 2; | 159 | size = (udf_ext0_offset(dir) + dir->i_size) >> 2; |
169 | f_pos = (udf_ext0_offset(dir) >> 2); | 160 | f_pos = (udf_ext0_offset(dir) >> 2); |
170 | 161 | ||
171 | fibh->soffset = fibh->eoffset = | 162 | fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; |
172 | (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; | 163 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { |
173 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) | ||
174 | fibh->sbh = fibh->ebh = NULL; | 164 | fibh->sbh = fibh->ebh = NULL; |
175 | else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), | 165 | } else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), |
176 | &epos, &eloc, &elen, | 166 | &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { |
177 | &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { | ||
178 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); | 167 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); |
179 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { | 168 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { |
180 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) | 169 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) |
181 | epos.offset -= sizeof(short_ad); | 170 | epos.offset -= sizeof(short_ad); |
182 | else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) | 171 | else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) |
183 | epos.offset -= sizeof(long_ad); | 172 | epos.offset -= sizeof(long_ad); |
184 | } else | 173 | } else { |
185 | offset = 0; | 174 | offset = 0; |
175 | } | ||
186 | 176 | ||
187 | if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) { | 177 | if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) { |
188 | brelse(epos.bh); | 178 | brelse(epos.bh); |
@@ -196,7 +186,6 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir, | |||
196 | while ((f_pos < size)) { | 186 | while ((f_pos < size)) { |
197 | fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &epos, &eloc, | 187 | fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &epos, &eloc, |
198 | &elen, &offset); | 188 | &elen, &offset); |
199 | |||
200 | if (!fi) { | 189 | if (!fi) { |
201 | if (fibh->sbh != fibh->ebh) | 190 | if (fibh->sbh != fibh->ebh) |
202 | brelse(fibh->ebh); | 191 | brelse(fibh->ebh); |
@@ -213,20 +202,14 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir, | |||
213 | } else { | 202 | } else { |
214 | int poffset; /* Unpaded ending offset */ | 203 | int poffset; /* Unpaded ending offset */ |
215 | 204 | ||
216 | poffset = | 205 | poffset = fibh->soffset + sizeof(struct fileIdentDesc) + liu + lfi; |
217 | fibh->soffset + sizeof(struct fileIdentDesc) + liu + | ||
218 | lfi; | ||
219 | 206 | ||
220 | if (poffset >= lfi) | 207 | if (poffset >= lfi) { |
221 | nameptr = | 208 | nameptr = (uint8_t *)(fibh->ebh->b_data + poffset - lfi); |
222 | (uint8_t *) (fibh->ebh->b_data + poffset - | 209 | } else { |
223 | lfi); | ||
224 | else { | ||
225 | nameptr = fname; | 210 | nameptr = fname; |
226 | memcpy(nameptr, fi->fileIdent + liu, | 211 | memcpy(nameptr, fi->fileIdent + liu, lfi - poffset); |
227 | lfi - poffset); | 212 | memcpy(nameptr + lfi - poffset, fibh->ebh->b_data, poffset); |
228 | memcpy(nameptr + lfi - poffset, | ||
229 | fibh->ebh->b_data, poffset); | ||
230 | } | 213 | } |
231 | } | 214 | } |
232 | 215 | ||
@@ -244,18 +227,18 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir, | |||
244 | continue; | 227 | continue; |
245 | 228 | ||
246 | if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi))) { | 229 | if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi))) { |
247 | if (udf_match | 230 | if (udf_match(flen, fname, dentry->d_name.len, dentry->d_name.name)) { |
248 | (flen, fname, dentry->d_name.len, | ||
249 | dentry->d_name.name)) { | ||
250 | brelse(epos.bh); | 231 | brelse(epos.bh); |
251 | return fi; | 232 | return fi; |
252 | } | 233 | } |
253 | } | 234 | } |
254 | } | 235 | } |
236 | |||
255 | if (fibh->sbh != fibh->ebh) | 237 | if (fibh->sbh != fibh->ebh) |
256 | brelse(fibh->ebh); | 238 | brelse(fibh->ebh); |
257 | brelse(fibh->sbh); | 239 | brelse(fibh->sbh); |
258 | brelse(epos.bh); | 240 | brelse(epos.bh); |
241 | |||
259 | return NULL; | 242 | return NULL; |
260 | } | 243 | } |
261 | 244 | ||
@@ -306,15 +289,19 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry, | |||
306 | #ifdef UDF_RECOVERY | 289 | #ifdef UDF_RECOVERY |
307 | /* temporary shorthand for specifying files by inode number */ | 290 | /* temporary shorthand for specifying files by inode number */ |
308 | if (!strncmp(dentry->d_name.name, ".B=", 3)) { | 291 | if (!strncmp(dentry->d_name.name, ".B=", 3)) { |
309 | kernel_lb_addr lb = | 292 | kernel_lb_addr lb = { |
310 | { 0, simple_strtoul(dentry->d_name.name + 3, NULL, 0) }; | 293 | .logicalBlockNum = 0, |
294 | .partitionReferenceNum = simple_strtoul(dentry->d_name.name + 3, | ||
295 | NULL, 0), | ||
296 | }; | ||
311 | inode = udf_iget(dir->i_sb, lb); | 297 | inode = udf_iget(dir->i_sb, lb); |
312 | if (!inode) { | 298 | if (!inode) { |
313 | unlock_kernel(); | 299 | unlock_kernel(); |
314 | return ERR_PTR(-EACCES); | 300 | return ERR_PTR(-EACCES); |
315 | } | 301 | } |
316 | } else | 302 | } |
317 | #endif /* UDF_RECOVERY */ | 303 | else |
304 | #endif /* UDF_RECOVERY */ | ||
318 | 305 | ||
319 | if (udf_find_entry(dir, dentry, &fibh, &cfi)) { | 306 | if (udf_find_entry(dir, dentry, &fibh, &cfi)) { |
320 | if (fibh.sbh != fibh.ebh) | 307 | if (fibh.sbh != fibh.ebh) |
@@ -329,6 +316,7 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry, | |||
329 | } | 316 | } |
330 | unlock_kernel(); | 317 | unlock_kernel(); |
331 | d_add(dentry, inode); | 318 | d_add(dentry, inode); |
319 | |||
332 | return NULL; | 320 | return NULL; |
333 | } | 321 | } |
334 | 322 | ||
@@ -352,7 +340,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
352 | kernel_lb_addr eloc; | 340 | kernel_lb_addr eloc; |
353 | uint32_t elen; | 341 | uint32_t elen; |
354 | sector_t offset; | 342 | sector_t offset; |
355 | struct extent_position epos = { NULL, 0, {0, 0} }; | 343 | struct extent_position epos = {}; |
356 | 344 | ||
357 | sb = dir->i_sb; | 345 | sb = dir->i_sb; |
358 | 346 | ||
@@ -361,36 +349,33 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
361 | *err = -EINVAL; | 349 | *err = -EINVAL; |
362 | return NULL; | 350 | return NULL; |
363 | } | 351 | } |
364 | 352 | if (!(namelen = udf_put_filename(sb, dentry->d_name.name, name, | |
365 | if (! | 353 | dentry->d_name.len))) { |
366 | (namelen = | ||
367 | udf_put_filename(sb, dentry->d_name.name, name, | ||
368 | dentry->d_name.len))) { | ||
369 | *err = -ENAMETOOLONG; | 354 | *err = -ENAMETOOLONG; |
370 | return NULL; | 355 | return NULL; |
371 | } | 356 | } |
372 | } else | 357 | } else { |
373 | namelen = 0; | 358 | namelen = 0; |
359 | } | ||
374 | 360 | ||
375 | nfidlen = (sizeof(struct fileIdentDesc) + namelen + 3) & ~3; | 361 | nfidlen = (sizeof(struct fileIdentDesc) + namelen + 3) & ~3; |
376 | 362 | ||
377 | f_pos = (udf_ext0_offset(dir) >> 2); | 363 | f_pos = (udf_ext0_offset(dir) >> 2); |
378 | 364 | ||
379 | fibh->soffset = fibh->eoffset = | 365 | fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; |
380 | (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; | 366 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { |
381 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) | ||
382 | fibh->sbh = fibh->ebh = NULL; | 367 | fibh->sbh = fibh->ebh = NULL; |
383 | else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), | 368 | } else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), |
384 | &epos, &eloc, &elen, | 369 | &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { |
385 | &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { | ||
386 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); | 370 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); |
387 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { | 371 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { |
388 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) | 372 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) |
389 | epos.offset -= sizeof(short_ad); | 373 | epos.offset -= sizeof(short_ad); |
390 | else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) | 374 | else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) |
391 | epos.offset -= sizeof(long_ad); | 375 | epos.offset -= sizeof(long_ad); |
392 | } else | 376 | } else { |
393 | offset = 0; | 377 | offset = 0; |
378 | } | ||
394 | 379 | ||
395 | if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) { | 380 | if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) { |
396 | brelse(epos.bh); | 381 | brelse(epos.bh); |
@@ -423,40 +408,33 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
423 | liu = le16_to_cpu(cfi->lengthOfImpUse); | 408 | liu = le16_to_cpu(cfi->lengthOfImpUse); |
424 | lfi = cfi->lengthFileIdent; | 409 | lfi = cfi->lengthFileIdent; |
425 | 410 | ||
426 | if (fibh->sbh == fibh->ebh) | 411 | if (fibh->sbh == fibh->ebh) { |
427 | nameptr = fi->fileIdent + liu; | 412 | nameptr = fi->fileIdent + liu; |
428 | else { | 413 | } else { |
429 | int poffset; /* Unpaded ending offset */ | 414 | int poffset; /* Unpaded ending offset */ |
430 | 415 | ||
431 | poffset = | 416 | poffset = fibh->soffset + sizeof(struct fileIdentDesc) + liu + lfi; |
432 | fibh->soffset + sizeof(struct fileIdentDesc) + liu + | ||
433 | lfi; | ||
434 | 417 | ||
435 | if (poffset >= lfi) | 418 | if (poffset >= lfi) { |
436 | nameptr = | 419 | nameptr = (char *)(fibh->ebh->b_data + poffset - lfi); |
437 | (char *)(fibh->ebh->b_data + poffset - lfi); | 420 | } else { |
438 | else { | ||
439 | nameptr = fname; | 421 | nameptr = fname; |
440 | memcpy(nameptr, fi->fileIdent + liu, | 422 | memcpy(nameptr, fi->fileIdent + liu, lfi - poffset); |
441 | lfi - poffset); | 423 | memcpy(nameptr + lfi - poffset, fibh->ebh->b_data, poffset); |
442 | memcpy(nameptr + lfi - poffset, | ||
443 | fibh->ebh->b_data, poffset); | ||
444 | } | 424 | } |
445 | } | 425 | } |
446 | 426 | ||
447 | if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { | 427 | if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { |
448 | if (((sizeof(struct fileIdentDesc) + liu + lfi + | 428 | if (((sizeof(struct fileIdentDesc) + liu + lfi + 3) & ~3) == nfidlen) { |
449 | 3) & ~3) == nfidlen) { | ||
450 | brelse(epos.bh); | 429 | brelse(epos.bh); |
451 | cfi->descTag.tagSerialNum = cpu_to_le16(1); | 430 | cfi->descTag.tagSerialNum = cpu_to_le16(1); |
452 | cfi->fileVersionNum = cpu_to_le16(1); | 431 | cfi->fileVersionNum = cpu_to_le16(1); |
453 | cfi->fileCharacteristics = 0; | 432 | cfi->fileCharacteristics = 0; |
454 | cfi->lengthFileIdent = namelen; | 433 | cfi->lengthFileIdent = namelen; |
455 | cfi->lengthOfImpUse = cpu_to_le16(0); | 434 | cfi->lengthOfImpUse = cpu_to_le16(0); |
456 | if (!udf_write_fi | 435 | if (!udf_write_fi(dir, cfi, fi, fibh, NULL, name)) { |
457 | (dir, cfi, fi, fibh, NULL, name)) | ||
458 | return fi; | 436 | return fi; |
459 | else { | 437 | } else { |
460 | *err = -EIO; | 438 | *err = -EIO; |
461 | return NULL; | 439 | return NULL; |
462 | } | 440 | } |
@@ -467,8 +445,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
467 | continue; | 445 | continue; |
468 | 446 | ||
469 | if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi)) && | 447 | if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi)) && |
470 | udf_match(flen, fname, dentry->d_name.len, | 448 | udf_match(flen, fname, dentry->d_name.len, dentry->d_name.name)) { |
471 | dentry->d_name.name)) { | ||
472 | if (fibh->sbh != fibh->ebh) | 449 | if (fibh->sbh != fibh->ebh) |
473 | brelse(fibh->ebh); | 450 | brelse(fibh->ebh); |
474 | brelse(fibh->sbh); | 451 | brelse(fibh->sbh); |
@@ -478,7 +455,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
478 | } | 455 | } |
479 | } | 456 | } |
480 | 457 | ||
481 | add: | 458 | add: |
482 | f_pos += nfidlen; | 459 | f_pos += nfidlen; |
483 | 460 | ||
484 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB && | 461 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB && |
@@ -491,14 +468,11 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
491 | if (fibh->sbh != fibh->ebh) | 468 | if (fibh->sbh != fibh->ebh) |
492 | brelse(fibh->ebh); | 469 | brelse(fibh->ebh); |
493 | brelse(fibh->sbh); | 470 | brelse(fibh->sbh); |
494 | if (! | 471 | if (!(fibh->sbh = fibh->ebh = udf_expand_dir_adinicb(dir, &block, err))) |
495 | (fibh->sbh = fibh->ebh = | ||
496 | udf_expand_dir_adinicb(dir, &block, err))) | ||
497 | return NULL; | 472 | return NULL; |
498 | epos.block = UDF_I_LOCATION(dir); | 473 | epos.block = UDF_I_LOCATION(dir); |
499 | eloc.logicalBlockNum = block; | 474 | eloc.logicalBlockNum = block; |
500 | eloc.partitionReferenceNum = | 475 | eloc.partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum; |
501 | UDF_I_LOCATION(dir).partitionReferenceNum; | ||
502 | elen = dir->i_sb->s_blocksize; | 476 | elen = dir->i_sb->s_blocksize; |
503 | epos.offset = udf_file_entry_alloc_offset(dir); | 477 | epos.offset = udf_file_entry_alloc_offset(dir); |
504 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) | 478 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) |
@@ -517,16 +491,13 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
517 | 491 | ||
518 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | 492 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { |
519 | block = UDF_I_LOCATION(dir).logicalBlockNum; | 493 | block = UDF_I_LOCATION(dir).logicalBlockNum; |
520 | fi = (struct fileIdentDesc *)(UDF_I_DATA(dir) + | 494 | fi = (struct fileIdentDesc *)(UDF_I_DATA(dir) + fibh->soffset - |
521 | fibh->soffset - | ||
522 | udf_ext0_offset(dir) + | 495 | udf_ext0_offset(dir) + |
523 | UDF_I_LENEATTR(dir)); | 496 | UDF_I_LENEATTR(dir)); |
524 | } else { | 497 | } else { |
525 | block = eloc.logicalBlockNum + ((elen - 1) >> | 498 | block = eloc.logicalBlockNum + ((elen - 1) >> |
526 | dir->i_sb-> | 499 | dir->i_sb->s_blocksize_bits); |
527 | s_blocksize_bits); | 500 | fi = (struct fileIdentDesc *)(fibh->sbh->b_data + fibh->soffset); |
528 | fi = (struct fileIdentDesc *)(fibh->sbh->b_data + | ||
529 | fibh->soffset); | ||
530 | } | 501 | } |
531 | } else { | 502 | } else { |
532 | fibh->soffset = fibh->eoffset - sb->s_blocksize; | 503 | fibh->soffset = fibh->eoffset - sb->s_blocksize; |
@@ -538,42 +509,36 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
538 | 509 | ||
539 | block = eloc.logicalBlockNum + ((elen - 1) >> | 510 | block = eloc.logicalBlockNum + ((elen - 1) >> |
540 | dir->i_sb->s_blocksize_bits); | 511 | dir->i_sb->s_blocksize_bits); |
541 | 512 | fibh->ebh = udf_bread(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), 1, err); | |
542 | if (! | 513 | if (!fibh->ebh) { |
543 | (fibh->ebh = | ||
544 | udf_bread(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), | ||
545 | 1, err))) { | ||
546 | brelse(epos.bh); | 514 | brelse(epos.bh); |
547 | brelse(fibh->sbh); | 515 | brelse(fibh->sbh); |
548 | return NULL; | 516 | return NULL; |
549 | } | 517 | } |
550 | 518 | ||
551 | if (!(fibh->soffset)) { | 519 | if (!fibh->soffset) { |
552 | if (udf_next_aext(dir, &epos, &eloc, &elen, 1) == | 520 | if (udf_next_aext(dir, &epos, &eloc, &elen, 1) == |
553 | (EXT_RECORDED_ALLOCATED >> 30)) { | 521 | (EXT_RECORDED_ALLOCATED >> 30)) { |
554 | block = eloc.logicalBlockNum + ((elen - 1) >> | 522 | block = eloc.logicalBlockNum + ((elen - 1) >> |
555 | dir->i_sb-> | 523 | dir->i_sb->s_blocksize_bits); |
556 | s_blocksize_bits); | 524 | } else { |
557 | } else | ||
558 | block++; | 525 | block++; |
526 | } | ||
559 | 527 | ||
560 | brelse(fibh->sbh); | 528 | brelse(fibh->sbh); |
561 | fibh->sbh = fibh->ebh; | 529 | fibh->sbh = fibh->ebh; |
562 | fi = (struct fileIdentDesc *)(fibh->sbh->b_data); | 530 | fi = (struct fileIdentDesc *)(fibh->sbh->b_data); |
563 | } else { | 531 | } else { |
564 | fi = (struct fileIdentDesc *) | 532 | fi = (struct fileIdentDesc *) |
565 | (fibh->sbh->b_data + sb->s_blocksize + | 533 | (fibh->sbh->b_data + sb->s_blocksize + fibh->soffset); |
566 | fibh->soffset); | ||
567 | } | 534 | } |
568 | } | 535 | } |
569 | 536 | ||
570 | memset(cfi, 0, sizeof(struct fileIdentDesc)); | 537 | memset(cfi, 0, sizeof(struct fileIdentDesc)); |
571 | if (UDF_SB_UDFREV(sb) >= 0x0200) | 538 | if (UDF_SB_UDFREV(sb) >= 0x0200) |
572 | udf_new_tag((char *)cfi, TAG_IDENT_FID, 3, 1, block, | 539 | udf_new_tag((char *)cfi, TAG_IDENT_FID, 3, 1, block, sizeof(tag)); |
573 | sizeof(tag)); | ||
574 | else | 540 | else |
575 | udf_new_tag((char *)cfi, TAG_IDENT_FID, 2, 1, block, | 541 | udf_new_tag((char *)cfi, TAG_IDENT_FID, 2, 1, block, sizeof(tag)); |
576 | sizeof(tag)); | ||
577 | cfi->fileVersionNum = cpu_to_le16(1); | 542 | cfi->fileVersionNum = cpu_to_le16(1); |
578 | cfi->lengthFileIdent = namelen; | 543 | cfi->lengthFileIdent = namelen; |
579 | cfi->lengthOfImpUse = cpu_to_le16(0); | 544 | cfi->lengthOfImpUse = cpu_to_le16(0); |
@@ -599,8 +564,10 @@ static int udf_delete_entry(struct inode *inode, struct fileIdentDesc *fi, | |||
599 | struct fileIdentDesc *cfi) | 564 | struct fileIdentDesc *cfi) |
600 | { | 565 | { |
601 | cfi->fileCharacteristics |= FID_FILE_CHAR_DELETED; | 566 | cfi->fileCharacteristics |= FID_FILE_CHAR_DELETED; |
567 | |||
602 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)) | 568 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)) |
603 | memset(&(cfi->icb), 0x00, sizeof(long_ad)); | 569 | memset(&(cfi->icb), 0x00, sizeof(long_ad)); |
570 | |||
604 | return udf_write_fi(inode, cfi, fi, fibh, NULL, NULL); | 571 | return udf_write_fi(inode, cfi, fi, fibh, NULL, NULL); |
605 | } | 572 | } |
606 | 573 | ||
@@ -637,8 +604,8 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode, | |||
637 | } | 604 | } |
638 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 605 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
639 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); | 606 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); |
640 | *(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 607 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
641 | cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); | 608 | cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); |
642 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); | 609 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
643 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | 610 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { |
644 | mark_inode_dirty(dir); | 611 | mark_inode_dirty(dir); |
@@ -648,6 +615,7 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode, | |||
648 | brelse(fibh.sbh); | 615 | brelse(fibh.sbh); |
649 | unlock_kernel(); | 616 | unlock_kernel(); |
650 | d_instantiate(dentry, inode); | 617 | d_instantiate(dentry, inode); |
618 | |||
651 | return 0; | 619 | return 0; |
652 | } | 620 | } |
653 | 621 | ||
@@ -679,8 +647,8 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode, | |||
679 | } | 647 | } |
680 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 648 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
681 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); | 649 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); |
682 | *(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 650 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
683 | cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); | 651 | cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); |
684 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); | 652 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
685 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | 653 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { |
686 | mark_inode_dirty(dir); | 654 | mark_inode_dirty(dir); |
@@ -692,7 +660,8 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode, | |||
692 | brelse(fibh.sbh); | 660 | brelse(fibh.sbh); |
693 | d_instantiate(dentry, inode); | 661 | d_instantiate(dentry, inode); |
694 | err = 0; | 662 | err = 0; |
695 | out: | 663 | |
664 | out: | ||
696 | unlock_kernel(); | 665 | unlock_kernel(); |
697 | return err; | 666 | return err; |
698 | } | 667 | } |
@@ -725,10 +694,9 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
725 | inode->i_nlink = 2; | 694 | inode->i_nlink = 2; |
726 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 695 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
727 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(dir)); | 696 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(dir)); |
728 | *(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 697 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
729 | cpu_to_le32(UDF_I_UNIQUE(dir) & 0x00000000FFFFFFFFUL); | 698 | cpu_to_le32(UDF_I_UNIQUE(dir) & 0x00000000FFFFFFFFUL); |
730 | cfi.fileCharacteristics = | 699 | cfi.fileCharacteristics = FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT; |
731 | FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT; | ||
732 | udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL); | 700 | udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL); |
733 | brelse(fibh.sbh); | 701 | brelse(fibh.sbh); |
734 | inode->i_mode = S_IFDIR | mode; | 702 | inode->i_mode = S_IFDIR | mode; |
@@ -744,8 +712,8 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
744 | } | 712 | } |
745 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 713 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
746 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); | 714 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); |
747 | *(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 715 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
748 | cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); | 716 | cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); |
749 | cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY; | 717 | cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY; |
750 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); | 718 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
751 | inc_nlink(dir); | 719 | inc_nlink(dir); |
@@ -755,7 +723,8 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
755 | brelse(fibh.ebh); | 723 | brelse(fibh.ebh); |
756 | brelse(fibh.sbh); | 724 | brelse(fibh.sbh); |
757 | err = 0; | 725 | err = 0; |
758 | out: | 726 | |
727 | out: | ||
759 | unlock_kernel(); | 728 | unlock_kernel(); |
760 | return err; | 729 | return err; |
761 | } | 730 | } |
@@ -770,26 +739,25 @@ static int empty_dir(struct inode *dir) | |||
770 | kernel_lb_addr eloc; | 739 | kernel_lb_addr eloc; |
771 | uint32_t elen; | 740 | uint32_t elen; |
772 | sector_t offset; | 741 | sector_t offset; |
773 | struct extent_position epos = { NULL, 0, {0, 0} }; | 742 | struct extent_position epos = {}; |
774 | 743 | ||
775 | f_pos = (udf_ext0_offset(dir) >> 2); | 744 | f_pos = (udf_ext0_offset(dir) >> 2); |
776 | 745 | ||
777 | fibh.soffset = fibh.eoffset = | 746 | fibh.soffset = fibh.eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; |
778 | (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; | ||
779 | 747 | ||
780 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) | 748 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { |
781 | fibh.sbh = fibh.ebh = NULL; | 749 | fibh.sbh = fibh.ebh = NULL; |
782 | else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), | 750 | } else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), |
783 | &epos, &eloc, &elen, | 751 | &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { |
784 | &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { | ||
785 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); | 752 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); |
786 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { | 753 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { |
787 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) | 754 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) |
788 | epos.offset -= sizeof(short_ad); | 755 | epos.offset -= sizeof(short_ad); |
789 | else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) | 756 | else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) |
790 | epos.offset -= sizeof(long_ad); | 757 | epos.offset -= sizeof(long_ad); |
791 | } else | 758 | } else { |
792 | offset = 0; | 759 | offset = 0; |
760 | } | ||
793 | 761 | ||
794 | if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) { | 762 | if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) { |
795 | brelse(epos.bh); | 763 | brelse(epos.bh); |
@@ -803,7 +771,6 @@ static int empty_dir(struct inode *dir) | |||
803 | while ((f_pos < size)) { | 771 | while ((f_pos < size)) { |
804 | fi = udf_fileident_read(dir, &f_pos, &fibh, &cfi, &epos, &eloc, | 772 | fi = udf_fileident_read(dir, &f_pos, &fibh, &cfi, &epos, &eloc, |
805 | &elen, &offset); | 773 | &elen, &offset); |
806 | |||
807 | if (!fi) { | 774 | if (!fi) { |
808 | if (fibh.sbh != fibh.ebh) | 775 | if (fibh.sbh != fibh.ebh) |
809 | brelse(fibh.ebh); | 776 | brelse(fibh.ebh); |
@@ -812,8 +779,8 @@ static int empty_dir(struct inode *dir) | |||
812 | return 0; | 779 | return 0; |
813 | } | 780 | } |
814 | 781 | ||
815 | if (cfi.lengthFileIdent | 782 | if (cfi.lengthFileIdent && |
816 | && (cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) == 0) { | 783 | (cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) == 0) { |
817 | if (fibh.sbh != fibh.ebh) | 784 | if (fibh.sbh != fibh.ebh) |
818 | brelse(fibh.ebh); | 785 | brelse(fibh.ebh); |
819 | brelse(fibh.sbh); | 786 | brelse(fibh.sbh); |
@@ -821,10 +788,12 @@ static int empty_dir(struct inode *dir) | |||
821 | return 0; | 788 | return 0; |
822 | } | 789 | } |
823 | } | 790 | } |
791 | |||
824 | if (fibh.sbh != fibh.ebh) | 792 | if (fibh.sbh != fibh.ebh) |
825 | brelse(fibh.ebh); | 793 | brelse(fibh.ebh); |
826 | brelse(fibh.sbh); | 794 | brelse(fibh.sbh); |
827 | brelse(epos.bh); | 795 | brelse(epos.bh); |
796 | |||
828 | return 1; | 797 | return 1; |
829 | } | 798 | } |
830 | 799 | ||
@@ -859,15 +828,15 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry) | |||
859 | clear_nlink(inode); | 828 | clear_nlink(inode); |
860 | inode->i_size = 0; | 829 | inode->i_size = 0; |
861 | inode_dec_link_count(dir); | 830 | inode_dec_link_count(dir); |
862 | inode->i_ctime = dir->i_ctime = dir->i_mtime = | 831 | inode->i_ctime = dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb); |
863 | current_fs_time(dir->i_sb); | ||
864 | mark_inode_dirty(dir); | 832 | mark_inode_dirty(dir); |
865 | 833 | ||
866 | end_rmdir: | 834 | end_rmdir: |
867 | if (fibh.sbh != fibh.ebh) | 835 | if (fibh.sbh != fibh.ebh) |
868 | brelse(fibh.ebh); | 836 | brelse(fibh.ebh); |
869 | brelse(fibh.sbh); | 837 | brelse(fibh.sbh); |
870 | out: | 838 | |
839 | out: | ||
871 | unlock_kernel(); | 840 | unlock_kernel(); |
872 | return retval; | 841 | return retval; |
873 | } | 842 | } |
@@ -906,11 +875,12 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry) | |||
906 | inode->i_ctime = dir->i_ctime; | 875 | inode->i_ctime = dir->i_ctime; |
907 | retval = 0; | 876 | retval = 0; |
908 | 877 | ||
909 | end_unlink: | 878 | end_unlink: |
910 | if (fibh.sbh != fibh.ebh) | 879 | if (fibh.sbh != fibh.ebh) |
911 | brelse(fibh.ebh); | 880 | brelse(fibh.ebh); |
912 | brelse(fibh.sbh); | 881 | brelse(fibh.sbh); |
913 | out: | 882 | |
883 | out: | ||
914 | unlock_kernel(); | 884 | unlock_kernel(); |
915 | return retval; | 885 | return retval; |
916 | } | 886 | } |
@@ -922,7 +892,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
922 | struct pathComponent *pc; | 892 | struct pathComponent *pc; |
923 | char *compstart; | 893 | char *compstart; |
924 | struct udf_fileident_bh fibh; | 894 | struct udf_fileident_bh fibh; |
925 | struct extent_position epos = { NULL, 0, {0, 0} }; | 895 | struct extent_position epos = {}; |
926 | int eoffset, elen = 0; | 896 | int eoffset, elen = 0; |
927 | struct fileIdentDesc *fi; | 897 | struct fileIdentDesc *fi; |
928 | struct fileIdentDesc cfi; | 898 | struct fileIdentDesc cfi; |
@@ -945,26 +915,22 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
945 | uint32_t elen; | 915 | uint32_t elen; |
946 | 916 | ||
947 | block = udf_new_block(inode->i_sb, inode, | 917 | block = udf_new_block(inode->i_sb, inode, |
948 | UDF_I_LOCATION(inode). | 918 | UDF_I_LOCATION(inode).partitionReferenceNum, |
949 | partitionReferenceNum, | 919 | UDF_I_LOCATION(inode).logicalBlockNum, &err); |
950 | UDF_I_LOCATION(inode).logicalBlockNum, | ||
951 | &err); | ||
952 | if (!block) | 920 | if (!block) |
953 | goto out_no_entry; | 921 | goto out_no_entry; |
954 | epos.block = UDF_I_LOCATION(inode); | 922 | epos.block = UDF_I_LOCATION(inode); |
955 | epos.offset = udf_file_entry_alloc_offset(inode); | 923 | epos.offset = udf_file_entry_alloc_offset(inode); |
956 | epos.bh = NULL; | 924 | epos.bh = NULL; |
957 | eloc.logicalBlockNum = block; | 925 | eloc.logicalBlockNum = block; |
958 | eloc.partitionReferenceNum = | 926 | eloc.partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum; |
959 | UDF_I_LOCATION(inode).partitionReferenceNum; | ||
960 | elen = inode->i_sb->s_blocksize; | 927 | elen = inode->i_sb->s_blocksize; |
961 | UDF_I_LENEXTENTS(inode) = elen; | 928 | UDF_I_LENEXTENTS(inode) = elen; |
962 | udf_add_aext(inode, &epos, eloc, elen, 0); | 929 | udf_add_aext(inode, &epos, eloc, elen, 0); |
963 | brelse(epos.bh); | 930 | brelse(epos.bh); |
964 | 931 | ||
965 | block = udf_get_pblock(inode->i_sb, block, | 932 | block = udf_get_pblock(inode->i_sb, block, |
966 | UDF_I_LOCATION(inode). | 933 | UDF_I_LOCATION(inode).partitionReferenceNum, 0); |
967 | partitionReferenceNum, 0); | ||
968 | epos.bh = udf_tread(inode->i_sb, block); | 934 | epos.bh = udf_tread(inode->i_sb, block); |
969 | lock_buffer(epos.bh); | 935 | lock_buffer(epos.bh); |
970 | memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize); | 936 | memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize); |
@@ -972,8 +938,9 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
972 | unlock_buffer(epos.bh); | 938 | unlock_buffer(epos.bh); |
973 | mark_buffer_dirty_inode(epos.bh, inode); | 939 | mark_buffer_dirty_inode(epos.bh, inode); |
974 | ea = epos.bh->b_data + udf_ext0_offset(inode); | 940 | ea = epos.bh->b_data + udf_ext0_offset(inode); |
975 | } else | 941 | } else { |
976 | ea = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode); | 942 | ea = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode); |
943 | } | ||
977 | 944 | ||
978 | eoffset = inode->i_sb->s_blocksize - udf_ext0_offset(inode); | 945 | eoffset = inode->i_sb->s_blocksize - udf_ext0_offset(inode); |
979 | pc = (struct pathComponent *)ea; | 946 | pc = (struct pathComponent *)ea; |
@@ -1010,20 +977,17 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
1010 | if (compstart[0] == '.') { | 977 | if (compstart[0] == '.') { |
1011 | if ((symname - compstart) == 1) | 978 | if ((symname - compstart) == 1) |
1012 | pc->componentType = 4; | 979 | pc->componentType = 4; |
1013 | else if ((symname - compstart) == 2 | 980 | else if ((symname - compstart) == 2 && compstart[1] == '.') |
1014 | && compstart[1] == '.') | ||
1015 | pc->componentType = 3; | 981 | pc->componentType = 3; |
1016 | } | 982 | } |
1017 | 983 | ||
1018 | if (pc->componentType == 5) { | 984 | if (pc->componentType == 5) { |
1019 | if (! | 985 | namelen = udf_put_filename(inode->i_sb, compstart, name, |
1020 | (namelen = | 986 | symname - compstart); |
1021 | udf_put_filename(inode->i_sb, compstart, name, | 987 | if (!namelen) |
1022 | symname - compstart))) | ||
1023 | goto out_no_entry; | 988 | goto out_no_entry; |
1024 | 989 | ||
1025 | if (elen + sizeof(struct pathComponent) + namelen > | 990 | if (elen + sizeof(struct pathComponent) + namelen > eoffset) |
1026 | eoffset) | ||
1027 | goto out_no_entry; | 991 | goto out_no_entry; |
1028 | else | 992 | else |
1029 | pc->lengthComponentIdent = namelen; | 993 | pc->lengthComponentIdent = namelen; |
@@ -1053,12 +1017,10 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
1053 | if (UDF_SB_LVIDBH(inode->i_sb)) { | 1017 | if (UDF_SB_LVIDBH(inode->i_sb)) { |
1054 | struct logicalVolHeaderDesc *lvhd; | 1018 | struct logicalVolHeaderDesc *lvhd; |
1055 | uint64_t uniqueID; | 1019 | uint64_t uniqueID; |
1056 | lvhd = | 1020 | lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse); |
1057 | (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)-> | ||
1058 | logicalVolContentsUse); | ||
1059 | uniqueID = le64_to_cpu(lvhd->uniqueID); | 1021 | uniqueID = le64_to_cpu(lvhd->uniqueID); |
1060 | *(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 1022 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
1061 | cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); | 1023 | cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); |
1062 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) | 1024 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) |
1063 | uniqueID += 16; | 1025 | uniqueID += 16; |
1064 | lvhd->uniqueID = cpu_to_le64(uniqueID); | 1026 | lvhd->uniqueID = cpu_to_le64(uniqueID); |
@@ -1074,11 +1036,11 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
1074 | d_instantiate(dentry, inode); | 1036 | d_instantiate(dentry, inode); |
1075 | err = 0; | 1037 | err = 0; |
1076 | 1038 | ||
1077 | out: | 1039 | out: |
1078 | unlock_kernel(); | 1040 | unlock_kernel(); |
1079 | return err; | 1041 | return err; |
1080 | 1042 | ||
1081 | out_no_entry: | 1043 | out_no_entry: |
1082 | inode_dec_link_count(inode); | 1044 | inode_dec_link_count(inode); |
1083 | iput(inode); | 1045 | iput(inode); |
1084 | goto out; | 1046 | goto out; |
@@ -1107,12 +1069,10 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir, | |||
1107 | if (UDF_SB_LVIDBH(inode->i_sb)) { | 1069 | if (UDF_SB_LVIDBH(inode->i_sb)) { |
1108 | struct logicalVolHeaderDesc *lvhd; | 1070 | struct logicalVolHeaderDesc *lvhd; |
1109 | uint64_t uniqueID; | 1071 | uint64_t uniqueID; |
1110 | lvhd = | 1072 | lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse); |
1111 | (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)-> | ||
1112 | logicalVolContentsUse); | ||
1113 | uniqueID = le64_to_cpu(lvhd->uniqueID); | 1073 | uniqueID = le64_to_cpu(lvhd->uniqueID); |
1114 | *(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 1074 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
1115 | cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); | 1075 | cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); |
1116 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) | 1076 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) |
1117 | uniqueID += 16; | 1077 | uniqueID += 16; |
1118 | lvhd->uniqueID = cpu_to_le64(uniqueID); | 1078 | lvhd->uniqueID = cpu_to_le64(uniqueID); |
@@ -1122,6 +1082,7 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir, | |||
1122 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | 1082 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { |
1123 | mark_inode_dirty(dir); | 1083 | mark_inode_dirty(dir); |
1124 | } | 1084 | } |
1085 | |||
1125 | if (fibh.sbh != fibh.ebh) | 1086 | if (fibh.sbh != fibh.ebh) |
1126 | brelse(fibh.ebh); | 1087 | brelse(fibh.ebh); |
1127 | brelse(fibh.sbh); | 1088 | brelse(fibh.sbh); |
@@ -1131,6 +1092,7 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir, | |||
1131 | atomic_inc(&inode->i_count); | 1092 | atomic_inc(&inode->i_count); |
1132 | d_instantiate(dentry, inode); | 1093 | d_instantiate(dentry, inode); |
1133 | unlock_kernel(); | 1094 | unlock_kernel(); |
1095 | |||
1134 | return 0; | 1096 | return 0; |
1135 | } | 1097 | } |
1136 | 1098 | ||
@@ -1143,8 +1105,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1143 | struct inode *old_inode = old_dentry->d_inode; | 1105 | struct inode *old_inode = old_dentry->d_inode; |
1144 | struct inode *new_inode = new_dentry->d_inode; | 1106 | struct inode *new_inode = new_dentry->d_inode; |
1145 | struct udf_fileident_bh ofibh, nfibh; | 1107 | struct udf_fileident_bh ofibh, nfibh; |
1146 | struct fileIdentDesc *ofi = NULL, *nfi = NULL, *dir_fi = | 1108 | struct fileIdentDesc *ofi = NULL, *nfi = NULL, *dir_fi = NULL, ocfi, ncfi; |
1147 | NULL, ocfi, ncfi; | ||
1148 | struct buffer_head *dir_bh = NULL; | 1109 | struct buffer_head *dir_bh = NULL; |
1149 | int retval = -ENOENT; | 1110 | int retval = -ENOENT; |
1150 | kernel_lb_addr tloc; | 1111 | kernel_lb_addr tloc; |
@@ -1181,36 +1142,27 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1181 | if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) { | 1142 | if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) { |
1182 | dir_fi = udf_get_fileident(UDF_I_DATA(old_inode) - | 1143 | dir_fi = udf_get_fileident(UDF_I_DATA(old_inode) - |
1183 | (UDF_I_EFE(old_inode) ? | 1144 | (UDF_I_EFE(old_inode) ? |
1184 | sizeof(struct | 1145 | sizeof(struct extendedFileEntry) : |
1185 | extendedFileEntry) : | ||
1186 | sizeof(struct fileEntry)), | 1146 | sizeof(struct fileEntry)), |
1187 | old_inode->i_sb->s_blocksize, | 1147 | old_inode->i_sb->s_blocksize, &offset); |
1188 | &offset); | ||
1189 | } else { | 1148 | } else { |
1190 | dir_bh = udf_bread(old_inode, 0, 0, &retval); | 1149 | dir_bh = udf_bread(old_inode, 0, 0, &retval); |
1191 | if (!dir_bh) | 1150 | if (!dir_bh) |
1192 | goto end_rename; | 1151 | goto end_rename; |
1193 | dir_fi = | 1152 | dir_fi = udf_get_fileident(dir_bh->b_data, old_inode->i_sb->s_blocksize, &offset); |
1194 | udf_get_fileident(dir_bh->b_data, | ||
1195 | old_inode->i_sb->s_blocksize, | ||
1196 | &offset); | ||
1197 | } | 1153 | } |
1198 | if (!dir_fi) | 1154 | if (!dir_fi) |
1199 | goto end_rename; | 1155 | goto end_rename; |
1200 | tloc = lelb_to_cpu(dir_fi->icb.extLocation); | 1156 | tloc = lelb_to_cpu(dir_fi->icb.extLocation); |
1201 | if (udf_get_lb_pblock(old_inode->i_sb, tloc, 0) | 1157 | if (udf_get_lb_pblock(old_inode->i_sb, tloc, 0) != old_dir->i_ino) |
1202 | != old_dir->i_ino) | ||
1203 | goto end_rename; | 1158 | goto end_rename; |
1204 | 1159 | ||
1205 | retval = -EMLINK; | 1160 | retval = -EMLINK; |
1206 | if (!new_inode | 1161 | if (!new_inode && new_dir->i_nlink >= (256 << sizeof(new_dir->i_nlink)) - 1) |
1207 | && new_dir->i_nlink >= | ||
1208 | (256 << sizeof(new_dir->i_nlink)) - 1) | ||
1209 | goto end_rename; | 1162 | goto end_rename; |
1210 | } | 1163 | } |
1211 | if (!nfi) { | 1164 | if (!nfi) { |
1212 | nfi = | 1165 | nfi = udf_add_entry(new_dir, new_dentry, &nfibh, &ncfi, &retval); |
1213 | udf_add_entry(new_dir, new_dentry, &nfibh, &ncfi, &retval); | ||
1214 | if (!nfi) | 1166 | if (!nfi) |
1215 | goto end_rename; | 1167 | goto end_rename; |
1216 | } | 1168 | } |
@@ -1244,13 +1196,12 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1244 | if (dir_fi) { | 1196 | if (dir_fi) { |
1245 | dir_fi->icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(new_dir)); | 1197 | dir_fi->icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(new_dir)); |
1246 | udf_update_tag((char *)dir_fi, (sizeof(struct fileIdentDesc) + | 1198 | udf_update_tag((char *)dir_fi, (sizeof(struct fileIdentDesc) + |
1247 | le16_to_cpu(dir_fi-> | 1199 | le16_to_cpu(dir_fi->lengthOfImpUse) + 3) & ~3); |
1248 | lengthOfImpUse) + | ||
1249 | 3) & ~3); | ||
1250 | if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) { | 1200 | if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) { |
1251 | mark_inode_dirty(old_inode); | 1201 | mark_inode_dirty(old_inode); |
1252 | } else | 1202 | } else { |
1253 | mark_buffer_dirty_inode(dir_bh, old_inode); | 1203 | mark_buffer_dirty_inode(dir_bh, old_inode); |
1204 | } | ||
1254 | inode_dec_link_count(old_dir); | 1205 | inode_dec_link_count(old_dir); |
1255 | if (new_inode) { | 1206 | if (new_inode) { |
1256 | inode_dec_link_count(new_inode); | 1207 | inode_dec_link_count(new_inode); |
@@ -1268,7 +1219,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1268 | 1219 | ||
1269 | retval = 0; | 1220 | retval = 0; |
1270 | 1221 | ||
1271 | end_rename: | 1222 | end_rename: |
1272 | brelse(dir_bh); | 1223 | brelse(dir_bh); |
1273 | if (nfi) { | 1224 | if (nfi) { |
1274 | if (nfibh.sbh != nfibh.ebh) | 1225 | if (nfibh.sbh != nfibh.ebh) |
@@ -1276,17 +1227,18 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1276 | brelse(nfibh.sbh); | 1227 | brelse(nfibh.sbh); |
1277 | } | 1228 | } |
1278 | unlock_kernel(); | 1229 | unlock_kernel(); |
1230 | |||
1279 | return retval; | 1231 | return retval; |
1280 | } | 1232 | } |
1281 | 1233 | ||
1282 | const struct inode_operations udf_dir_inode_operations = { | 1234 | const struct inode_operations udf_dir_inode_operations = { |
1283 | .lookup = udf_lookup, | 1235 | .lookup = udf_lookup, |
1284 | .create = udf_create, | 1236 | .create = udf_create, |
1285 | .link = udf_link, | 1237 | .link = udf_link, |
1286 | .unlink = udf_unlink, | 1238 | .unlink = udf_unlink, |
1287 | .symlink = udf_symlink, | 1239 | .symlink = udf_symlink, |
1288 | .mkdir = udf_mkdir, | 1240 | .mkdir = udf_mkdir, |
1289 | .rmdir = udf_rmdir, | 1241 | .rmdir = udf_rmdir, |
1290 | .mknod = udf_mknod, | 1242 | .mknod = udf_mknod, |
1291 | .rename = udf_rename, | 1243 | .rename = udf_rename, |
1292 | }; | 1244 | }; |
diff --git a/fs/udf/osta_udf.h b/fs/udf/osta_udf.h index bec5d340d8c5..65ff47902bd2 100644 --- a/fs/udf/osta_udf.h +++ b/fs/udf/osta_udf.h | |||
@@ -66,64 +66,64 @@ | |||
66 | #define IS_DF_SOFT_WRITE_PROTECT 0x02 | 66 | #define IS_DF_SOFT_WRITE_PROTECT 0x02 |
67 | 67 | ||
68 | struct UDFIdentSuffix { | 68 | struct UDFIdentSuffix { |
69 | __le16 UDFRevision; | 69 | __le16 UDFRevision; |
70 | uint8_t OSClass; | 70 | uint8_t OSClass; |
71 | uint8_t OSIdentifier; | 71 | uint8_t OSIdentifier; |
72 | uint8_t reserved[4]; | 72 | uint8_t reserved[4]; |
73 | } __attribute__ ((packed)); | 73 | } __attribute__ ((packed)); |
74 | 74 | ||
75 | struct impIdentSuffix { | 75 | struct impIdentSuffix { |
76 | uint8_t OSClass; | 76 | uint8_t OSClass; |
77 | uint8_t OSIdentifier; | 77 | uint8_t OSIdentifier; |
78 | uint8_t reserved[6]; | 78 | uint8_t reserved[6]; |
79 | } __attribute__ ((packed)); | 79 | } __attribute__ ((packed)); |
80 | 80 | ||
81 | struct appIdentSuffix { | 81 | struct appIdentSuffix { |
82 | uint8_t impUse[8]; | 82 | uint8_t impUse[8]; |
83 | } __attribute__ ((packed)); | 83 | } __attribute__ ((packed)); |
84 | 84 | ||
85 | /* Logical Volume Integrity Descriptor (UDF 2.50 2.2.6) */ | 85 | /* Logical Volume Integrity Descriptor (UDF 2.50 2.2.6) */ |
86 | /* Implementation Use (UDF 2.50 2.2.6.4) */ | 86 | /* Implementation Use (UDF 2.50 2.2.6.4) */ |
87 | struct logicalVolIntegrityDescImpUse { | 87 | struct logicalVolIntegrityDescImpUse { |
88 | regid impIdent; | 88 | regid impIdent; |
89 | __le32 numFiles; | 89 | __le32 numFiles; |
90 | __le32 numDirs; | 90 | __le32 numDirs; |
91 | __le16 minUDFReadRev; | 91 | __le16 minUDFReadRev; |
92 | __le16 minUDFWriteRev; | 92 | __le16 minUDFWriteRev; |
93 | __le16 maxUDFWriteRev; | 93 | __le16 maxUDFWriteRev; |
94 | uint8_t impUse[0]; | 94 | uint8_t impUse[0]; |
95 | } __attribute__ ((packed)); | 95 | } __attribute__ ((packed)); |
96 | 96 | ||
97 | /* Implementation Use Volume Descriptor (UDF 2.50 2.2.7) */ | 97 | /* Implementation Use Volume Descriptor (UDF 2.50 2.2.7) */ |
98 | /* Implementation Use (UDF 2.50 2.2.7.2) */ | 98 | /* Implementation Use (UDF 2.50 2.2.7.2) */ |
99 | struct impUseVolDescImpUse { | 99 | struct impUseVolDescImpUse { |
100 | charspec LVICharset; | 100 | charspec LVICharset; |
101 | dstring logicalVolIdent[128]; | 101 | dstring logicalVolIdent[128]; |
102 | dstring LVInfo1[36]; | 102 | dstring LVInfo1[36]; |
103 | dstring LVInfo2[36]; | 103 | dstring LVInfo2[36]; |
104 | dstring LVInfo3[36]; | 104 | dstring LVInfo3[36]; |
105 | regid impIdent; | 105 | regid impIdent; |
106 | uint8_t impUse[128]; | 106 | uint8_t impUse[128]; |
107 | } __attribute__ ((packed)); | 107 | } __attribute__ ((packed)); |
108 | 108 | ||
109 | struct udfPartitionMap2 { | 109 | struct udfPartitionMap2 { |
110 | uint8_t partitionMapType; | 110 | uint8_t partitionMapType; |
111 | uint8_t partitionMapLength; | 111 | uint8_t partitionMapLength; |
112 | uint8_t reserved1[2]; | 112 | uint8_t reserved1[2]; |
113 | regid partIdent; | 113 | regid partIdent; |
114 | __le16 volSeqNum; | 114 | __le16 volSeqNum; |
115 | __le16 partitionNum; | 115 | __le16 partitionNum; |
116 | } __attribute__ ((packed)); | 116 | } __attribute__ ((packed)); |
117 | 117 | ||
118 | /* Virtual Partition Map (UDF 2.50 2.2.8) */ | 118 | /* Virtual Partition Map (UDF 2.50 2.2.8) */ |
119 | struct virtualPartitionMap { | 119 | struct virtualPartitionMap { |
120 | uint8_t partitionMapType; | 120 | uint8_t partitionMapType; |
121 | uint8_t partitionMapLength; | 121 | uint8_t partitionMapLength; |
122 | uint8_t reserved1[2]; | 122 | uint8_t reserved1[2]; |
123 | regid partIdent; | 123 | regid partIdent; |
124 | __le16 volSeqNum; | 124 | __le16 volSeqNum; |
125 | __le16 partitionNum; | 125 | __le16 partitionNum; |
126 | uint8_t reserved2[24]; | 126 | uint8_t reserved2[24]; |
127 | } __attribute__ ((packed)); | 127 | } __attribute__ ((packed)); |
128 | 128 | ||
129 | /* Sparable Partition Map (UDF 2.50 2.2.9) */ | 129 | /* Sparable Partition Map (UDF 2.50 2.2.9) */ |
@@ -143,62 +143,62 @@ struct sparablePartitionMap { | |||
143 | 143 | ||
144 | /* Metadata Partition Map (UDF 2.4.0 2.2.10) */ | 144 | /* Metadata Partition Map (UDF 2.4.0 2.2.10) */ |
145 | struct metadataPartitionMap { | 145 | struct metadataPartitionMap { |
146 | uint8_t partitionMapType; | 146 | uint8_t partitionMapType; |
147 | uint8_t partitionMapLength; | 147 | uint8_t partitionMapLength; |
148 | uint8_t reserved1[2]; | 148 | uint8_t reserved1[2]; |
149 | regid partIdent; | 149 | regid partIdent; |
150 | __le16 volSeqNum; | 150 | __le16 volSeqNum; |
151 | __le16 partitionNum; | 151 | __le16 partitionNum; |
152 | __le32 metadataFileLoc; | 152 | __le32 metadataFileLoc; |
153 | __le32 metadataMirrorFileLoc; | 153 | __le32 metadataMirrorFileLoc; |
154 | __le32 metadataBitmapFileLoc; | 154 | __le32 metadataBitmapFileLoc; |
155 | __le32 allocUnitSize; | 155 | __le32 allocUnitSize; |
156 | __le16 alignUnitSize; | 156 | __le16 alignUnitSize; |
157 | uint8_t flags; | 157 | uint8_t flags; |
158 | uint8_t reserved2[5]; | 158 | uint8_t reserved2[5]; |
159 | } __attribute__ ((packed)); | 159 | } __attribute__ ((packed)); |
160 | 160 | ||
161 | /* Virtual Allocation Table (UDF 1.5 2.2.10) */ | 161 | /* Virtual Allocation Table (UDF 1.5 2.2.10) */ |
162 | struct virtualAllocationTable15 { | 162 | struct virtualAllocationTable15 { |
163 | __le32 VirtualSector[0]; | 163 | __le32 VirtualSector[0]; |
164 | regid vatIdent; | 164 | regid vatIdent; |
165 | __le32 previousVATICBLoc; | 165 | __le32 previousVATICBLoc; |
166 | } __attribute__ ((packed)); | 166 | } __attribute__ ((packed)); |
167 | 167 | ||
168 | #define ICBTAG_FILE_TYPE_VAT15 0x00U | 168 | #define ICBTAG_FILE_TYPE_VAT15 0x00U |
169 | 169 | ||
170 | /* Virtual Allocation Table (UDF 2.50 2.2.11) */ | 170 | /* Virtual Allocation Table (UDF 2.50 2.2.11) */ |
171 | struct virtualAllocationTable20 { | 171 | struct virtualAllocationTable20 { |
172 | __le16 lengthHeader; | 172 | __le16 lengthHeader; |
173 | __le16 lengthImpUse; | 173 | __le16 lengthImpUse; |
174 | dstring logicalVolIdent[128]; | 174 | dstring logicalVolIdent[128]; |
175 | __le32 previousVATICBLoc; | 175 | __le32 previousVATICBLoc; |
176 | __le32 numFiles; | 176 | __le32 numFiles; |
177 | __le32 numDirs; | 177 | __le32 numDirs; |
178 | __le16 minReadRevision; | 178 | __le16 minReadRevision; |
179 | __le16 minWriteRevision; | 179 | __le16 minWriteRevision; |
180 | __le16 maxWriteRevision; | 180 | __le16 maxWriteRevision; |
181 | __le16 reserved; | 181 | __le16 reserved; |
182 | uint8_t impUse[0]; | 182 | uint8_t impUse[0]; |
183 | __le32 vatEntry[0]; | 183 | __le32 vatEntry[0]; |
184 | } __attribute__ ((packed)); | 184 | } __attribute__ ((packed)); |
185 | 185 | ||
186 | #define ICBTAG_FILE_TYPE_VAT20 0xF8U | 186 | #define ICBTAG_FILE_TYPE_VAT20 0xF8U |
187 | 187 | ||
188 | /* Sparing Table (UDF 2.50 2.2.12) */ | 188 | /* Sparing Table (UDF 2.50 2.2.12) */ |
189 | struct sparingEntry { | 189 | struct sparingEntry { |
190 | __le32 origLocation; | 190 | __le32 origLocation; |
191 | __le32 mappedLocation; | 191 | __le32 mappedLocation; |
192 | } __attribute__ ((packed)); | 192 | } __attribute__ ((packed)); |
193 | 193 | ||
194 | struct sparingTable { | 194 | struct sparingTable { |
195 | tag descTag; | 195 | tag descTag; |
196 | regid sparingIdent; | 196 | regid sparingIdent; |
197 | __le16 reallocationTableLen; | 197 | __le16 reallocationTableLen; |
198 | __le16 reserved; | 198 | __le16 reserved; |
199 | __le32 sequenceNum; | 199 | __le32 sequenceNum; |
200 | struct sparingEntry | 200 | struct sparingEntry |
201 | mapEntry[0]; | 201 | mapEntry[0]; |
202 | } __attribute__ ((packed)); | 202 | } __attribute__ ((packed)); |
203 | 203 | ||
204 | /* Metadata File (and Metadata Mirror File) (UDF 2.50 2.2.13.1) */ | 204 | /* Metadata File (and Metadata Mirror File) (UDF 2.50 2.2.13.1) */ |
@@ -208,8 +208,8 @@ struct sparingTable { | |||
208 | 208 | ||
209 | /* struct long_ad ICB - ADImpUse (UDF 2.50 2.2.4.3) */ | 209 | /* struct long_ad ICB - ADImpUse (UDF 2.50 2.2.4.3) */ |
210 | struct allocDescImpUse { | 210 | struct allocDescImpUse { |
211 | __le16 flags; | 211 | __le16 flags; |
212 | uint8_t impUse[4]; | 212 | uint8_t impUse[4]; |
213 | } __attribute__ ((packed)); | 213 | } __attribute__ ((packed)); |
214 | 214 | ||
215 | #define AD_IU_EXT_ERASED 0x0001 | 215 | #define AD_IU_EXT_ERASED 0x0001 |
@@ -220,23 +220,23 @@ struct allocDescImpUse { | |||
220 | /* Implementation Use Extended Attribute (UDF 2.50 3.3.4.5) */ | 220 | /* Implementation Use Extended Attribute (UDF 2.50 3.3.4.5) */ |
221 | /* FreeEASpace (UDF 2.50 3.3.4.5.1.1) */ | 221 | /* FreeEASpace (UDF 2.50 3.3.4.5.1.1) */ |
222 | struct freeEaSpace { | 222 | struct freeEaSpace { |
223 | __le16 headerChecksum; | 223 | __le16 headerChecksum; |
224 | uint8_t freeEASpace[0]; | 224 | uint8_t freeEASpace[0]; |
225 | } __attribute__ ((packed)); | 225 | } __attribute__ ((packed)); |
226 | 226 | ||
227 | /* DVD Copyright Management Information (UDF 2.50 3.3.4.5.1.2) */ | 227 | /* DVD Copyright Management Information (UDF 2.50 3.3.4.5.1.2) */ |
228 | struct DVDCopyrightImpUse { | 228 | struct DVDCopyrightImpUse { |
229 | __le16 headerChecksum; | 229 | __le16 headerChecksum; |
230 | uint8_t CGMSInfo; | 230 | uint8_t CGMSInfo; |
231 | uint8_t dataType; | 231 | uint8_t dataType; |
232 | uint8_t protectionSystemInfo[4]; | 232 | uint8_t protectionSystemInfo[4]; |
233 | } __attribute__ ((packed)); | 233 | } __attribute__ ((packed)); |
234 | 234 | ||
235 | /* Application Use Extended Attribute (UDF 2.50 3.3.4.6) */ | 235 | /* Application Use Extended Attribute (UDF 2.50 3.3.4.6) */ |
236 | /* FreeAppEASpace (UDF 2.50 3.3.4.6.1) */ | 236 | /* FreeAppEASpace (UDF 2.50 3.3.4.6.1) */ |
237 | struct freeAppEASpace { | 237 | struct freeAppEASpace { |
238 | __le16 headerChecksum; | 238 | __le16 headerChecksum; |
239 | uint8_t freeEASpace[0]; | 239 | uint8_t freeEASpace[0]; |
240 | } __attribute__ ((packed)); | 240 | } __attribute__ ((packed)); |
241 | 241 | ||
242 | /* UDF Defined System Stream (UDF 2.50 3.3.7) */ | 242 | /* UDF Defined System Stream (UDF 2.50 3.3.7) */ |
@@ -276,4 +276,4 @@ struct freeAppEASpace { | |||
276 | #define UDF_OS_ID_BEOS 0x00U | 276 | #define UDF_OS_ID_BEOS 0x00U |
277 | #define UDF_OS_ID_WINCE 0x00U | 277 | #define UDF_OS_ID_WINCE 0x00U |
278 | 278 | ||
279 | #endif /* _OSTA_UDF_H */ | 279 | #endif /* _OSTA_UDF_H */ |
diff --git a/fs/udf/partition.c b/fs/udf/partition.c index a95d830a674d..aaab24c8c498 100644 --- a/fs/udf/partition.c +++ b/fs/udf/partition.c | |||
@@ -14,7 +14,7 @@ | |||
14 | * | 14 | * |
15 | * HISTORY | 15 | * HISTORY |
16 | * | 16 | * |
17 | * 12/06/98 blf Created file. | 17 | * 12/06/98 blf Created file. |
18 | * | 18 | * |
19 | */ | 19 | */ |
20 | 20 | ||
@@ -32,19 +32,17 @@ inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block, | |||
32 | uint16_t partition, uint32_t offset) | 32 | uint16_t partition, uint32_t offset) |
33 | { | 33 | { |
34 | if (partition >= UDF_SB_NUMPARTS(sb)) { | 34 | if (partition >= UDF_SB_NUMPARTS(sb)) { |
35 | udf_debug | 35 | udf_debug("block=%d, partition=%d, offset=%d: invalid partition\n", |
36 | ("block=%d, partition=%d, offset=%d: invalid partition\n", | 36 | block, partition, offset); |
37 | block, partition, offset); | ||
38 | return 0xFFFFFFFF; | 37 | return 0xFFFFFFFF; |
39 | } | 38 | } |
40 | if (UDF_SB_PARTFUNC(sb, partition)) | 39 | if (UDF_SB_PARTFUNC(sb, partition)) |
41 | return UDF_SB_PARTFUNC(sb, partition) (sb, block, partition, | 40 | return UDF_SB_PARTFUNC(sb, partition)(sb, block, partition, offset); |
42 | offset); | ||
43 | else | 41 | else |
44 | return UDF_SB_PARTROOT(sb, partition) + block + offset; | 42 | return UDF_SB_PARTROOT(sb, partition) + block + offset; |
45 | } | 43 | } |
46 | 44 | ||
47 | uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block, | 45 | uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block, |
48 | uint16_t partition, uint32_t offset) | 46 | uint16_t partition, uint32_t offset) |
49 | { | 47 | { |
50 | struct buffer_head *bh = NULL; | 48 | struct buffer_head *bh = NULL; |
@@ -52,14 +50,11 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block, | |||
52 | uint32_t index; | 50 | uint32_t index; |
53 | uint32_t loc; | 51 | uint32_t loc; |
54 | 52 | ||
55 | index = | 53 | index = (sb->s_blocksize - UDF_SB_TYPEVIRT(sb,partition).s_start_offset) / sizeof(uint32_t); |
56 | (sb->s_blocksize - | ||
57 | UDF_SB_TYPEVIRT(sb, partition).s_start_offset) / sizeof(uint32_t); | ||
58 | 54 | ||
59 | if (block > UDF_SB_TYPEVIRT(sb, partition).s_num_entries) { | 55 | if (block > UDF_SB_TYPEVIRT(sb,partition).s_num_entries) { |
60 | udf_debug | 56 | udf_debug("Trying to access block beyond end of VAT (%d max %d)\n", |
61 | ("Trying to access block beyond end of VAT (%d max %d)\n", | 57 | block, UDF_SB_TYPEVIRT(sb,partition).s_num_entries); |
62 | block, UDF_SB_TYPEVIRT(sb, partition).s_num_entries); | ||
63 | return 0xFFFFFFFF; | 58 | return 0xFFFFFFFF; |
64 | } | 59 | } |
65 | 60 | ||
@@ -69,10 +64,7 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block, | |||
69 | index = block % (sb->s_blocksize / sizeof(uint32_t)); | 64 | index = block % (sb->s_blocksize / sizeof(uint32_t)); |
70 | } else { | 65 | } else { |
71 | newblock = 0; | 66 | newblock = 0; |
72 | index = | 67 | index = UDF_SB_TYPEVIRT(sb,partition).s_start_offset / sizeof(uint32_t) + block; |
73 | UDF_SB_TYPEVIRT(sb, | ||
74 | partition).s_start_offset / | ||
75 | sizeof(uint32_t) + block; | ||
76 | } | 68 | } |
77 | 69 | ||
78 | loc = udf_block_map(UDF_SB_VAT(sb), newblock); | 70 | loc = udf_block_map(UDF_SB_VAT(sb), newblock); |
@@ -83,7 +75,7 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block, | |||
83 | return 0xFFFFFFFF; | 75 | return 0xFFFFFFFF; |
84 | } | 76 | } |
85 | 77 | ||
86 | loc = le32_to_cpu(((__le32 *) bh->b_data)[index]); | 78 | loc = le32_to_cpu(((__le32 *)bh->b_data)[index]); |
87 | 79 | ||
88 | brelse(bh); | 80 | brelse(bh); |
89 | 81 | ||
@@ -93,8 +85,8 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block, | |||
93 | } | 85 | } |
94 | 86 | ||
95 | return udf_get_pblock(sb, loc, | 87 | return udf_get_pblock(sb, loc, |
96 | UDF_I_LOCATION(UDF_SB_VAT(sb)). | 88 | UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum, |
97 | partitionReferenceNum, offset); | 89 | offset); |
98 | } | 90 | } |
99 | 91 | ||
100 | inline uint32_t udf_get_pblock_virt20(struct super_block * sb, uint32_t block, | 92 | inline uint32_t udf_get_pblock_virt20(struct super_block * sb, uint32_t block, |
@@ -108,40 +100,29 @@ uint32_t udf_get_pblock_spar15(struct super_block * sb, uint32_t block, | |||
108 | { | 100 | { |
109 | int i; | 101 | int i; |
110 | struct sparingTable *st = NULL; | 102 | struct sparingTable *st = NULL; |
111 | uint32_t packet = | 103 | uint32_t packet = (block + offset) & ~(UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1); |
112 | (block + offset) & ~(UDF_SB_TYPESPAR(sb, partition).s_packet_len - | ||
113 | 1); | ||
114 | 104 | ||
115 | for (i = 0; i < 4; i++) { | 105 | for (i = 0; i < 4; i++) { |
116 | if (UDF_SB_TYPESPAR(sb, partition).s_spar_map[i] != NULL) { | 106 | if (UDF_SB_TYPESPAR(sb,partition).s_spar_map[i] != NULL) { |
117 | st = (struct sparingTable *)UDF_SB_TYPESPAR(sb, | 107 | st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,partition).s_spar_map[i]->b_data; |
118 | partition). | ||
119 | s_spar_map[i]->b_data; | ||
120 | break; | 108 | break; |
121 | } | 109 | } |
122 | } | 110 | } |
123 | 111 | ||
124 | if (st) { | 112 | if (st) { |
125 | for (i = 0; i < le16_to_cpu(st->reallocationTableLen); i++) { | 113 | for (i = 0; i < le16_to_cpu(st->reallocationTableLen); i++) { |
126 | if (le32_to_cpu(st->mapEntry[i].origLocation) >= | 114 | if (le32_to_cpu(st->mapEntry[i].origLocation) >= 0xFFFFFFF0) { |
127 | 0xFFFFFFF0) | ||
128 | break; | 115 | break; |
129 | else if (le32_to_cpu(st->mapEntry[i].origLocation) == | 116 | } else if (le32_to_cpu(st->mapEntry[i].origLocation) == packet) { |
130 | packet) { | 117 | return le32_to_cpu(st->mapEntry[i].mappedLocation) + |
131 | return le32_to_cpu(st->mapEntry[i]. | 118 | ((block + offset) & (UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1)); |
132 | mappedLocation) + ((block + | 119 | } else if (le32_to_cpu(st->mapEntry[i].origLocation) > packet) { |
133 | offset) & | ||
134 | (UDF_SB_TYPESPAR | ||
135 | (sb, | ||
136 | partition). | ||
137 | s_packet_len | ||
138 | - 1)); | ||
139 | } else if (le32_to_cpu(st->mapEntry[i].origLocation) > | ||
140 | packet) | ||
141 | break; | 120 | break; |
121 | } | ||
142 | } | 122 | } |
143 | } | 123 | } |
144 | return UDF_SB_PARTROOT(sb, partition) + block + offset; | 124 | |
125 | return UDF_SB_PARTROOT(sb,partition) + block + offset; | ||
145 | } | 126 | } |
146 | 127 | ||
147 | int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) | 128 | int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) |
@@ -153,20 +134,14 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) | |||
153 | int i, j, k, l; | 134 | int i, j, k, l; |
154 | 135 | ||
155 | for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { | 136 | for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { |
156 | if (old_block > UDF_SB_PARTROOT(sb, i) && | 137 | if (old_block > UDF_SB_PARTROOT(sb,i) && |
157 | old_block < UDF_SB_PARTROOT(sb, i) + UDF_SB_PARTLEN(sb, i)) | 138 | old_block < UDF_SB_PARTROOT(sb,i) + UDF_SB_PARTLEN(sb,i)) { |
158 | { | 139 | sdata = &UDF_SB_TYPESPAR(sb,i); |
159 | sdata = &UDF_SB_TYPESPAR(sb, i); | 140 | packet = (old_block - UDF_SB_PARTROOT(sb,i)) & ~(sdata->s_packet_len - 1); |
160 | packet = | ||
161 | (old_block - | ||
162 | UDF_SB_PARTROOT(sb, | ||
163 | i)) & ~(sdata->s_packet_len - 1); | ||
164 | 141 | ||
165 | for (j = 0; j < 4; j++) { | 142 | for (j = 0; j < 4; j++) { |
166 | if (UDF_SB_TYPESPAR(sb, i).s_spar_map[j] != | 143 | if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) { |
167 | NULL) { | 144 | st = (struct sparingTable *)sdata->s_spar_map[j]->b_data; |
168 | st = (struct sparingTable *)sdata-> | ||
169 | s_spar_map[j]->b_data; | ||
170 | break; | 145 | break; |
171 | } | 146 | } |
172 | } | 147 | } |
@@ -174,122 +149,51 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) | |||
174 | if (!st) | 149 | if (!st) |
175 | return 1; | 150 | return 1; |
176 | 151 | ||
177 | for (k = 0; k < le16_to_cpu(st->reallocationTableLen); | 152 | for (k = 0; k < le16_to_cpu(st->reallocationTableLen); k++) { |
178 | k++) { | 153 | if (le32_to_cpu(st->mapEntry[k].origLocation) == 0xFFFFFFFF) { |
179 | if (le32_to_cpu(st->mapEntry[k].origLocation) == | ||
180 | 0xFFFFFFFF) { | ||
181 | for (; j < 4; j++) { | 154 | for (; j < 4; j++) { |
182 | if (sdata->s_spar_map[j]) { | 155 | if (sdata->s_spar_map[j]) { |
183 | st = (struct | 156 | st = (struct sparingTable *)sdata->s_spar_map[j]->b_data; |
184 | sparingTable *) | 157 | st->mapEntry[k].origLocation = cpu_to_le32(packet); |
185 | sdata-> | 158 | udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry)); |
186 | s_spar_map[j]-> | 159 | mark_buffer_dirty(sdata->s_spar_map[j]); |
187 | b_data; | ||
188 | st->mapEntry[k]. | ||
189 | origLocation = | ||
190 | cpu_to_le32(packet); | ||
191 | udf_update_tag((char *) | ||
192 | st, | ||
193 | sizeof | ||
194 | (struct | ||
195 | sparingTable) | ||
196 | + | ||
197 | le16_to_cpu | ||
198 | (st-> | ||
199 | reallocationTableLen) | ||
200 | * | ||
201 | sizeof | ||
202 | (struct | ||
203 | sparingEntry)); | ||
204 | mark_buffer_dirty | ||
205 | (sdata-> | ||
206 | s_spar_map[j]); | ||
207 | } | 160 | } |
208 | } | 161 | } |
209 | *new_block = | 162 | *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) + |
210 | le32_to_cpu(st->mapEntry[k]. | 163 | ((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1)); |
211 | mappedLocation) + | ||
212 | ((old_block - | ||
213 | UDF_SB_PARTROOT(sb, | ||
214 | i)) & (sdata-> | ||
215 | s_packet_len | ||
216 | - 1)); | ||
217 | return 0; | 164 | return 0; |
218 | } else | 165 | } else if (le32_to_cpu(st->mapEntry[k].origLocation) == packet) { |
219 | if (le32_to_cpu | 166 | *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) + |
220 | (st->mapEntry[k].origLocation) == | 167 | ((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1)); |
221 | packet) { | ||
222 | *new_block = | ||
223 | le32_to_cpu(st->mapEntry[k]. | ||
224 | mappedLocation) + | ||
225 | ((old_block - | ||
226 | UDF_SB_PARTROOT(sb, | ||
227 | i)) & (sdata-> | ||
228 | s_packet_len | ||
229 | - 1)); | ||
230 | return 0; | 168 | return 0; |
231 | } else | 169 | } else if (le32_to_cpu(st->mapEntry[k].origLocation) > packet) { |
232 | if (le32_to_cpu | ||
233 | (st->mapEntry[k].origLocation) > packet) | ||
234 | break; | 170 | break; |
171 | } | ||
235 | } | 172 | } |
236 | for (l = k; l < le16_to_cpu(st->reallocationTableLen); | 173 | |
237 | l++) { | 174 | for (l = k; l < le16_to_cpu(st->reallocationTableLen); l++) { |
238 | if (le32_to_cpu(st->mapEntry[l].origLocation) == | 175 | if (le32_to_cpu(st->mapEntry[l].origLocation) == 0xFFFFFFFF) { |
239 | 0xFFFFFFFF) { | ||
240 | for (; j < 4; j++) { | 176 | for (; j < 4; j++) { |
241 | if (sdata->s_spar_map[j]) { | 177 | if (sdata->s_spar_map[j]) { |
242 | st = (struct | 178 | st = (struct sparingTable *)sdata->s_spar_map[j]->b_data; |
243 | sparingTable *) | 179 | mapEntry = st->mapEntry[l]; |
244 | sdata-> | 180 | mapEntry.origLocation = cpu_to_le32(packet); |
245 | s_spar_map[j]-> | 181 | memmove(&st->mapEntry[k + 1], &st->mapEntry[k], (l - k) * sizeof(struct sparingEntry)); |
246 | b_data; | 182 | st->mapEntry[k] = mapEntry; |
247 | mapEntry = | 183 | udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry)); |
248 | st->mapEntry[l]; | 184 | mark_buffer_dirty(sdata->s_spar_map[j]); |
249 | mapEntry.origLocation = | ||
250 | cpu_to_le32(packet); | ||
251 | memmove(&st-> | ||
252 | mapEntry[k + 1], | ||
253 | &st-> | ||
254 | mapEntry[k], | ||
255 | (l - | ||
256 | k) * | ||
257 | sizeof(struct | ||
258 | sparingEntry)); | ||
259 | st->mapEntry[k] = | ||
260 | mapEntry; | ||
261 | udf_update_tag((char *) | ||
262 | st, | ||
263 | sizeof | ||
264 | (struct | ||
265 | sparingTable) | ||
266 | + | ||
267 | le16_to_cpu | ||
268 | (st-> | ||
269 | reallocationTableLen) | ||
270 | * | ||
271 | sizeof | ||
272 | (struct | ||
273 | sparingEntry)); | ||
274 | mark_buffer_dirty | ||
275 | (sdata-> | ||
276 | s_spar_map[j]); | ||
277 | } | 185 | } |
278 | } | 186 | } |
279 | *new_block = | 187 | *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) + |
280 | le32_to_cpu(st->mapEntry[k]. | 188 | ((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1)); |
281 | mappedLocation) + | ||
282 | ((old_block - | ||
283 | UDF_SB_PARTROOT(sb, | ||
284 | i)) & (sdata-> | ||
285 | s_packet_len | ||
286 | - 1)); | ||
287 | return 0; | 189 | return 0; |
288 | } | 190 | } |
289 | } | 191 | } |
192 | |||
290 | return 1; | 193 | return 1; |
291 | } | 194 | } /* if old_block */ |
292 | } | 195 | } |
196 | |||
293 | if (i == UDF_SB_NUMPARTS(sb)) { | 197 | if (i == UDF_SB_NUMPARTS(sb)) { |
294 | /* outside of partitions */ | 198 | /* outside of partitions */ |
295 | /* for now, fail =) */ | 199 | /* for now, fail =) */ |
diff --git a/fs/udf/super.c b/fs/udf/super.c index 72097ee6b752..7b30964665db 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -104,11 +104,11 @@ static int udf_get_sb(struct file_system_type *fs_type, | |||
104 | } | 104 | } |
105 | 105 | ||
106 | static struct file_system_type udf_fstype = { | 106 | static struct file_system_type udf_fstype = { |
107 | .owner = THIS_MODULE, | 107 | .owner = THIS_MODULE, |
108 | .name = "udf", | 108 | .name = "udf", |
109 | .get_sb = udf_get_sb, | 109 | .get_sb = udf_get_sb, |
110 | .kill_sb = kill_block_super, | 110 | .kill_sb = kill_block_super, |
111 | .fs_flags = FS_REQUIRES_DEV, | 111 | .fs_flags = FS_REQUIRES_DEV, |
112 | }; | 112 | }; |
113 | 113 | ||
114 | static struct kmem_cache *udf_inode_cachep; | 114 | static struct kmem_cache *udf_inode_cachep; |
@@ -116,8 +116,7 @@ static struct kmem_cache *udf_inode_cachep; | |||
116 | static struct inode *udf_alloc_inode(struct super_block *sb) | 116 | static struct inode *udf_alloc_inode(struct super_block *sb) |
117 | { | 117 | { |
118 | struct udf_inode_info *ei; | 118 | struct udf_inode_info *ei; |
119 | ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, | 119 | ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, GFP_KERNEL); |
120 | GFP_KERNEL); | ||
121 | if (!ei) | 120 | if (!ei) |
122 | return NULL; | 121 | return NULL; |
123 | 122 | ||
@@ -150,7 +149,7 @@ static int init_inodecache(void) | |||
150 | 0, (SLAB_RECLAIM_ACCOUNT | | 149 | 0, (SLAB_RECLAIM_ACCOUNT | |
151 | SLAB_MEM_SPREAD), | 150 | SLAB_MEM_SPREAD), |
152 | init_once); | 151 | init_once); |
153 | if (udf_inode_cachep == NULL) | 152 | if (!udf_inode_cachep) |
154 | return -ENOMEM; | 153 | return -ENOMEM; |
155 | return 0; | 154 | return 0; |
156 | } | 155 | } |
@@ -162,15 +161,15 @@ static void destroy_inodecache(void) | |||
162 | 161 | ||
163 | /* Superblock operations */ | 162 | /* Superblock operations */ |
164 | static const struct super_operations udf_sb_ops = { | 163 | static const struct super_operations udf_sb_ops = { |
165 | .alloc_inode = udf_alloc_inode, | 164 | .alloc_inode = udf_alloc_inode, |
166 | .destroy_inode = udf_destroy_inode, | 165 | .destroy_inode = udf_destroy_inode, |
167 | .write_inode = udf_write_inode, | 166 | .write_inode = udf_write_inode, |
168 | .delete_inode = udf_delete_inode, | 167 | .delete_inode = udf_delete_inode, |
169 | .clear_inode = udf_clear_inode, | 168 | .clear_inode = udf_clear_inode, |
170 | .put_super = udf_put_super, | 169 | .put_super = udf_put_super, |
171 | .write_super = udf_write_super, | 170 | .write_super = udf_write_super, |
172 | .statfs = udf_statfs, | 171 | .statfs = udf_statfs, |
173 | .remount_fs = udf_remount_fs, | 172 | .remount_fs = udf_remount_fs, |
174 | }; | 173 | }; |
175 | 174 | ||
176 | struct udf_options { | 175 | struct udf_options { |
@@ -193,16 +192,20 @@ struct udf_options { | |||
193 | static int __init init_udf_fs(void) | 192 | static int __init init_udf_fs(void) |
194 | { | 193 | { |
195 | int err; | 194 | int err; |
195 | |||
196 | err = init_inodecache(); | 196 | err = init_inodecache(); |
197 | if (err) | 197 | if (err) |
198 | goto out1; | 198 | goto out1; |
199 | err = register_filesystem(&udf_fstype); | 199 | err = register_filesystem(&udf_fstype); |
200 | if (err) | 200 | if (err) |
201 | goto out; | 201 | goto out; |
202 | |||
202 | return 0; | 203 | return 0; |
203 | out: | 204 | |
205 | out: | ||
204 | destroy_inodecache(); | 206 | destroy_inodecache(); |
205 | out1: | 207 | |
208 | out1: | ||
206 | return err; | 209 | return err; |
207 | } | 210 | } |
208 | 211 | ||
@@ -213,7 +216,7 @@ static void __exit exit_udf_fs(void) | |||
213 | } | 216 | } |
214 | 217 | ||
215 | module_init(init_udf_fs) | 218 | module_init(init_udf_fs) |
216 | module_exit(exit_udf_fs) | 219 | module_exit(exit_udf_fs) |
217 | 220 | ||
218 | /* | 221 | /* |
219 | * udf_parse_options | 222 | * udf_parse_options |
@@ -239,7 +242,7 @@ module_init(init_udf_fs) | |||
239 | * | 242 | * |
240 | * The remaining are for debugging and disaster recovery: | 243 | * The remaining are for debugging and disaster recovery: |
241 | * | 244 | * |
242 | * novrs Skip volume sequence recognition | 245 | * novrs Skip volume sequence recognition |
243 | * | 246 | * |
244 | * The following expect a offset from 0. | 247 | * The following expect a offset from 0. |
245 | * | 248 | * |
@@ -268,6 +271,7 @@ module_init(init_udf_fs) | |||
268 | * July 1, 1997 - Andrew E. Mileski | 271 | * July 1, 1997 - Andrew E. Mileski |
269 | * Written, tested, and released. | 272 | * Written, tested, and released. |
270 | */ | 273 | */ |
274 | |||
271 | enum { | 275 | enum { |
272 | Opt_novrs, Opt_nostrict, Opt_bs, Opt_unhide, Opt_undelete, | 276 | Opt_novrs, Opt_nostrict, Opt_bs, Opt_unhide, Opt_undelete, |
273 | Opt_noadinicb, Opt_adinicb, Opt_shortad, Opt_longad, | 277 | Opt_noadinicb, Opt_adinicb, Opt_shortad, Opt_longad, |
@@ -278,32 +282,32 @@ enum { | |||
278 | }; | 282 | }; |
279 | 283 | ||
280 | static match_table_t tokens = { | 284 | static match_table_t tokens = { |
281 | {Opt_novrs, "novrs"}, | 285 | {Opt_novrs, "novrs"}, |
282 | {Opt_nostrict, "nostrict"}, | 286 | {Opt_nostrict, "nostrict"}, |
283 | {Opt_bs, "bs=%u"}, | 287 | {Opt_bs, "bs=%u"}, |
284 | {Opt_unhide, "unhide"}, | 288 | {Opt_unhide, "unhide"}, |
285 | {Opt_undelete, "undelete"}, | 289 | {Opt_undelete, "undelete"}, |
286 | {Opt_noadinicb, "noadinicb"}, | 290 | {Opt_noadinicb, "noadinicb"}, |
287 | {Opt_adinicb, "adinicb"}, | 291 | {Opt_adinicb, "adinicb"}, |
288 | {Opt_shortad, "shortad"}, | 292 | {Opt_shortad, "shortad"}, |
289 | {Opt_longad, "longad"}, | 293 | {Opt_longad, "longad"}, |
290 | {Opt_uforget, "uid=forget"}, | 294 | {Opt_uforget, "uid=forget"}, |
291 | {Opt_uignore, "uid=ignore"}, | 295 | {Opt_uignore, "uid=ignore"}, |
292 | {Opt_gforget, "gid=forget"}, | 296 | {Opt_gforget, "gid=forget"}, |
293 | {Opt_gignore, "gid=ignore"}, | 297 | {Opt_gignore, "gid=ignore"}, |
294 | {Opt_gid, "gid=%u"}, | 298 | {Opt_gid, "gid=%u"}, |
295 | {Opt_uid, "uid=%u"}, | 299 | {Opt_uid, "uid=%u"}, |
296 | {Opt_umask, "umask=%o"}, | 300 | {Opt_umask, "umask=%o"}, |
297 | {Opt_session, "session=%u"}, | 301 | {Opt_session, "session=%u"}, |
298 | {Opt_lastblock, "lastblock=%u"}, | 302 | {Opt_lastblock, "lastblock=%u"}, |
299 | {Opt_anchor, "anchor=%u"}, | 303 | {Opt_anchor, "anchor=%u"}, |
300 | {Opt_volume, "volume=%u"}, | 304 | {Opt_volume, "volume=%u"}, |
301 | {Opt_partition, "partition=%u"}, | 305 | {Opt_partition, "partition=%u"}, |
302 | {Opt_fileset, "fileset=%u"}, | 306 | {Opt_fileset, "fileset=%u"}, |
303 | {Opt_rootdir, "rootdir=%u"}, | 307 | {Opt_rootdir, "rootdir=%u"}, |
304 | {Opt_utf8, "utf8"}, | 308 | {Opt_utf8, "utf8"}, |
305 | {Opt_iocharset, "iocharset=%s"}, | 309 | {Opt_iocharset, "iocharset=%s"}, |
306 | {Opt_err, NULL} | 310 | {Opt_err, NULL} |
307 | }; | 311 | }; |
308 | 312 | ||
309 | static int udf_parse_options(char *options, struct udf_options *uopt) | 313 | static int udf_parse_options(char *options, struct udf_options *uopt) |
@@ -444,9 +448,11 @@ static int udf_parse_options(char *options, struct udf_options *uopt) | |||
444 | void udf_write_super(struct super_block *sb) | 448 | void udf_write_super(struct super_block *sb) |
445 | { | 449 | { |
446 | lock_kernel(); | 450 | lock_kernel(); |
451 | |||
447 | if (!(sb->s_flags & MS_RDONLY)) | 452 | if (!(sb->s_flags & MS_RDONLY)) |
448 | udf_open_lvid(sb); | 453 | udf_open_lvid(sb); |
449 | sb->s_dirt = 0; | 454 | sb->s_dirt = 0; |
455 | |||
450 | unlock_kernel(); | 456 | unlock_kernel(); |
451 | } | 457 | } |
452 | 458 | ||
@@ -455,16 +461,16 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options) | |||
455 | struct udf_options uopt; | 461 | struct udf_options uopt; |
456 | 462 | ||
457 | uopt.flags = UDF_SB(sb)->s_flags; | 463 | uopt.flags = UDF_SB(sb)->s_flags; |
458 | uopt.uid = UDF_SB(sb)->s_uid; | 464 | uopt.uid = UDF_SB(sb)->s_uid; |
459 | uopt.gid = UDF_SB(sb)->s_gid; | 465 | uopt.gid = UDF_SB(sb)->s_gid; |
460 | uopt.umask = UDF_SB(sb)->s_umask; | 466 | uopt.umask = UDF_SB(sb)->s_umask; |
461 | 467 | ||
462 | if (!udf_parse_options(options, &uopt)) | 468 | if (!udf_parse_options(options, &uopt)) |
463 | return -EINVAL; | 469 | return -EINVAL; |
464 | 470 | ||
465 | UDF_SB(sb)->s_flags = uopt.flags; | 471 | UDF_SB(sb)->s_flags = uopt.flags; |
466 | UDF_SB(sb)->s_uid = uopt.uid; | 472 | UDF_SB(sb)->s_uid = uopt.uid; |
467 | UDF_SB(sb)->s_gid = uopt.gid; | 473 | UDF_SB(sb)->s_gid = uopt.gid; |
468 | UDF_SB(sb)->s_umask = uopt.umask; | 474 | UDF_SB(sb)->s_umask = uopt.umask; |
469 | 475 | ||
470 | if (UDF_SB_LVIDBH(sb)) { | 476 | if (UDF_SB_LVIDBH(sb)) { |
@@ -517,6 +523,7 @@ static int udf_set_blocksize(struct super_block *sb, int bsize) | |||
517 | printk(KERN_ERR "udf: bad block size (%d)\n", bsize); | 523 | printk(KERN_ERR "udf: bad block size (%d)\n", bsize); |
518 | return 0; | 524 | return 0; |
519 | } | 525 | } |
526 | |||
520 | return sb->s_blocksize; | 527 | return sb->s_blocksize; |
521 | } | 528 | } |
522 | 529 | ||
@@ -552,15 +559,12 @@ static int udf_vrs(struct super_block *sb, int silent) | |||
552 | 559 | ||
553 | /* Look for ISO descriptors */ | 560 | /* Look for ISO descriptors */ |
554 | vsd = (struct volStructDesc *)(bh->b_data + | 561 | vsd = (struct volStructDesc *)(bh->b_data + |
555 | (sector & | 562 | (sector & (sb->s_blocksize - 1))); |
556 | (sb->s_blocksize - 1))); | ||
557 | 563 | ||
558 | if (vsd->stdIdent[0] == 0) { | 564 | if (vsd->stdIdent[0] == 0) { |
559 | brelse(bh); | 565 | brelse(bh); |
560 | break; | 566 | break; |
561 | } else | 567 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001, VSD_STD_ID_LEN)) { |
562 | if (!strncmp | ||
563 | (vsd->stdIdent, VSD_STD_ID_CD001, VSD_STD_ID_LEN)) { | ||
564 | iso9660 = sector; | 568 | iso9660 = sector; |
565 | switch (vsd->structType) { | 569 | switch (vsd->structType) { |
566 | case 0: | 570 | case 0: |
@@ -587,21 +591,13 @@ static int udf_vrs(struct super_block *sb, int silent) | |||
587 | vsd->structType); | 591 | vsd->structType); |
588 | break; | 592 | break; |
589 | } | 593 | } |
590 | } else | 594 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BEA01, VSD_STD_ID_LEN)) { |
591 | if (!strncmp | 595 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_TEA01, VSD_STD_ID_LEN)) { |
592 | (vsd->stdIdent, VSD_STD_ID_BEA01, VSD_STD_ID_LEN)) { | ||
593 | } else | ||
594 | if (!strncmp | ||
595 | (vsd->stdIdent, VSD_STD_ID_TEA01, VSD_STD_ID_LEN)) { | ||
596 | brelse(bh); | 596 | brelse(bh); |
597 | break; | 597 | break; |
598 | } else | 598 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR02, VSD_STD_ID_LEN)) { |
599 | if (!strncmp | ||
600 | (vsd->stdIdent, VSD_STD_ID_NSR02, VSD_STD_ID_LEN)) { | ||
601 | nsr02 = sector; | 599 | nsr02 = sector; |
602 | } else | 600 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR03, VSD_STD_ID_LEN)) { |
603 | if (!strncmp | ||
604 | (vsd->stdIdent, VSD_STD_ID_NSR03, VSD_STD_ID_LEN)) { | ||
605 | nsr03 = sector; | 601 | nsr03 = sector; |
606 | } | 602 | } |
607 | brelse(bh); | 603 | brelse(bh); |
@@ -644,11 +640,10 @@ static void udf_find_anchor(struct super_block *sb) | |||
644 | 640 | ||
645 | if (lastblock) { | 641 | if (lastblock) { |
646 | int varlastblock = udf_variable_to_fixed(lastblock); | 642 | int varlastblock = udf_variable_to_fixed(lastblock); |
647 | int last[] = { lastblock, lastblock - 2, | 643 | int last[] = { lastblock, lastblock - 2, |
648 | lastblock - 150, lastblock - 152, | 644 | lastblock - 150, lastblock - 152, |
649 | varlastblock, varlastblock - 2, | 645 | varlastblock, varlastblock - 2, |
650 | varlastblock - 150, varlastblock - 152 | 646 | varlastblock - 150, varlastblock - 152 }; |
651 | }; | ||
652 | 647 | ||
653 | lastblock = 0; | 648 | lastblock = 0; |
654 | 649 | ||
@@ -664,88 +659,54 @@ static void udf_find_anchor(struct super_block *sb) | |||
664 | if (last[i] < 0 || !(bh = sb_bread(sb, last[i]))) { | 659 | if (last[i] < 0 || !(bh = sb_bread(sb, last[i]))) { |
665 | ident = location = 0; | 660 | ident = location = 0; |
666 | } else { | 661 | } else { |
667 | ident = | 662 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); |
668 | le16_to_cpu(((tag *) bh->b_data)->tagIdent); | 663 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); |
669 | location = | ||
670 | le32_to_cpu(((tag *) bh->b_data)-> | ||
671 | tagLocation); | ||
672 | brelse(bh); | 664 | brelse(bh); |
673 | } | 665 | } |
674 | 666 | ||
675 | if (ident == TAG_IDENT_AVDP) { | 667 | if (ident == TAG_IDENT_AVDP) { |
676 | if (location == last[i] - UDF_SB_SESSION(sb)) { | 668 | if (location == last[i] - UDF_SB_SESSION(sb)) { |
677 | lastblock = UDF_SB_ANCHOR(sb)[0] = | 669 | lastblock = UDF_SB_ANCHOR(sb)[0] = last[i] - UDF_SB_SESSION(sb); |
678 | last[i] - UDF_SB_SESSION(sb); | 670 | UDF_SB_ANCHOR(sb)[1] = last[i] - 256 - UDF_SB_SESSION(sb); |
679 | UDF_SB_ANCHOR(sb)[1] = | 671 | } else if (location == udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb)) { |
680 | last[i] - 256 - UDF_SB_SESSION(sb); | ||
681 | } else if (location == | ||
682 | udf_variable_to_fixed(last[i]) - | ||
683 | UDF_SB_SESSION(sb)) { | ||
684 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); | 672 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); |
685 | lastblock = UDF_SB_ANCHOR(sb)[0] = | 673 | lastblock = UDF_SB_ANCHOR(sb)[0] = udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb); |
686 | udf_variable_to_fixed(last[i]) - | 674 | UDF_SB_ANCHOR(sb)[1] = lastblock - 256 - UDF_SB_SESSION(sb); |
687 | UDF_SB_SESSION(sb); | 675 | } else { |
688 | UDF_SB_ANCHOR(sb)[1] = | 676 | udf_debug("Anchor found at block %d, location mismatch %d.\n", |
689 | lastblock - 256 - | 677 | last[i], location); |
690 | UDF_SB_SESSION(sb); | 678 | } |
691 | } else | 679 | } else if (ident == TAG_IDENT_FE || ident == TAG_IDENT_EFE) { |
692 | udf_debug | ||
693 | ("Anchor found at block %d, location mismatch %d.\n", | ||
694 | last[i], location); | ||
695 | } else if (ident == TAG_IDENT_FE | ||
696 | || ident == TAG_IDENT_EFE) { | ||
697 | lastblock = last[i]; | 680 | lastblock = last[i]; |
698 | UDF_SB_ANCHOR(sb)[3] = 512; | 681 | UDF_SB_ANCHOR(sb)[3] = 512; |
699 | } else { | 682 | } else { |
700 | if (last[i] < 256 | 683 | if (last[i] < 256 || !(bh = sb_bread(sb, last[i] - 256))) { |
701 | || !(bh = sb_bread(sb, last[i] - 256))) { | ||
702 | ident = location = 0; | 684 | ident = location = 0; |
703 | } else { | 685 | } else { |
704 | ident = | 686 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); |
705 | le16_to_cpu(((tag *) bh->b_data)-> | 687 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); |
706 | tagIdent); | ||
707 | location = | ||
708 | le32_to_cpu(((tag *) bh->b_data)-> | ||
709 | tagLocation); | ||
710 | brelse(bh); | 688 | brelse(bh); |
711 | } | 689 | } |
712 | 690 | ||
713 | if (ident == TAG_IDENT_AVDP && | 691 | if (ident == TAG_IDENT_AVDP && |
714 | location == | 692 | location == last[i] - 256 - UDF_SB_SESSION(sb)) { |
715 | last[i] - 256 - UDF_SB_SESSION(sb)) { | ||
716 | lastblock = last[i]; | 693 | lastblock = last[i]; |
717 | UDF_SB_ANCHOR(sb)[1] = last[i] - 256; | 694 | UDF_SB_ANCHOR(sb)[1] = last[i] - 256; |
718 | } else { | 695 | } else { |
719 | if (last[i] < 312 + UDF_SB_SESSION(sb) | 696 | if (last[i] < 312 + UDF_SB_SESSION(sb) || |
720 | || !(bh = | 697 | !(bh = sb_bread(sb, last[i] - 312 - UDF_SB_SESSION(sb)))) { |
721 | sb_bread(sb, | ||
722 | last[i] - 312 - | ||
723 | UDF_SB_SESSION(sb)))) | ||
724 | { | ||
725 | ident = location = 0; | 698 | ident = location = 0; |
726 | } else { | 699 | } else { |
727 | ident = | 700 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); |
728 | le16_to_cpu(((tag *) bh-> | 701 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); |
729 | b_data)-> | ||
730 | tagIdent); | ||
731 | location = | ||
732 | le32_to_cpu(((tag *) bh-> | ||
733 | b_data)-> | ||
734 | tagLocation); | ||
735 | brelse(bh); | 702 | brelse(bh); |
736 | } | 703 | } |
737 | 704 | ||
738 | if (ident == TAG_IDENT_AVDP && | 705 | if (ident == TAG_IDENT_AVDP && |
739 | location == | 706 | location == udf_variable_to_fixed(last[i]) - 256) { |
740 | udf_variable_to_fixed(last[i]) - | 707 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); |
741 | 256) { | 708 | lastblock = udf_variable_to_fixed(last[i]); |
742 | UDF_SET_FLAG(sb, | 709 | UDF_SB_ANCHOR(sb)[1] = lastblock - 256; |
743 | UDF_FLAG_VARCONV); | ||
744 | lastblock = | ||
745 | udf_variable_to_fixed(last | ||
746 | [i]); | ||
747 | UDF_SB_ANCHOR(sb)[1] = | ||
748 | lastblock - 256; | ||
749 | } | 710 | } |
750 | } | 711 | } |
751 | } | 712 | } |
@@ -755,9 +716,8 @@ static void udf_find_anchor(struct super_block *sb) | |||
755 | if (!lastblock) { | 716 | if (!lastblock) { |
756 | /* We havn't found the lastblock. check 312 */ | 717 | /* We havn't found the lastblock. check 312 */ |
757 | if ((bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb)))) { | 718 | if ((bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb)))) { |
758 | ident = le16_to_cpu(((tag *) bh->b_data)->tagIdent); | 719 | ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent); |
759 | location = | 720 | location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); |
760 | le32_to_cpu(((tag *) bh->b_data)->tagLocation); | ||
761 | brelse(bh); | 721 | brelse(bh); |
762 | 722 | ||
763 | if (ident == TAG_IDENT_AVDP && location == 256) | 723 | if (ident == TAG_IDENT_AVDP && location == 256) |
@@ -767,19 +727,13 @@ static void udf_find_anchor(struct super_block *sb) | |||
767 | 727 | ||
768 | for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { | 728 | for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { |
769 | if (UDF_SB_ANCHOR(sb)[i]) { | 729 | if (UDF_SB_ANCHOR(sb)[i]) { |
770 | if (!(bh = udf_read_tagged(sb, | 730 | if (!(bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i], |
771 | UDF_SB_ANCHOR(sb)[i], | 731 | UDF_SB_ANCHOR(sb)[i], &ident))) { |
772 | UDF_SB_ANCHOR(sb)[i], | ||
773 | &ident))) { | ||
774 | UDF_SB_ANCHOR(sb)[i] = 0; | 732 | UDF_SB_ANCHOR(sb)[i] = 0; |
775 | } else { | 733 | } else { |
776 | brelse(bh); | 734 | brelse(bh); |
777 | if ((ident != TAG_IDENT_AVDP) && (i || | 735 | if ((ident != TAG_IDENT_AVDP) && |
778 | (ident != | 736 | (i || (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE))) { |
779 | TAG_IDENT_FE | ||
780 | && ident != | ||
781 | TAG_IDENT_EFE))) | ||
782 | { | ||
783 | UDF_SB_ANCHOR(sb)[i] = 0; | 737 | UDF_SB_ANCHOR(sb)[i] = 0; |
784 | } | 738 | } |
785 | } | 739 | } |
@@ -789,9 +743,7 @@ static void udf_find_anchor(struct super_block *sb) | |||
789 | UDF_SB_LASTBLOCK(sb) = lastblock; | 743 | UDF_SB_LASTBLOCK(sb) = lastblock; |
790 | } | 744 | } |
791 | 745 | ||
792 | static int | 746 | static int udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, kernel_lb_addr *root) |
793 | udf_find_fileset(struct super_block *sb, kernel_lb_addr * fileset, | ||
794 | kernel_lb_addr * root) | ||
795 | { | 747 | { |
796 | struct buffer_head *bh = NULL; | 748 | struct buffer_head *bh = NULL; |
797 | long lastblock; | 749 | long lastblock; |
@@ -801,18 +753,19 @@ udf_find_fileset(struct super_block *sb, kernel_lb_addr * fileset, | |||
801 | fileset->partitionReferenceNum != 0xFFFF) { | 753 | fileset->partitionReferenceNum != 0xFFFF) { |
802 | bh = udf_read_ptagged(sb, *fileset, 0, &ident); | 754 | bh = udf_read_ptagged(sb, *fileset, 0, &ident); |
803 | 755 | ||
804 | if (!bh) | 756 | if (!bh) { |
805 | return 1; | 757 | return 1; |
806 | else if (ident != TAG_IDENT_FSD) { | 758 | } else if (ident != TAG_IDENT_FSD) { |
807 | brelse(bh); | 759 | brelse(bh); |
808 | return 1; | 760 | return 1; |
809 | } | 761 | } |
810 | 762 | ||
811 | } | 763 | } |
812 | 764 | ||
813 | if (!bh) { /* Search backwards through the partitions */ | 765 | if (!bh) { /* Search backwards through the partitions */ |
814 | kernel_lb_addr newfileset; | 766 | kernel_lb_addr newfileset; |
815 | 767 | ||
768 | /* --> cvg: FIXME - is it reasonable? */ | ||
816 | return 1; | 769 | return 1; |
817 | 770 | ||
818 | for (newfileset.partitionReferenceNum = UDF_SB_NUMPARTS(sb) - 1; | 771 | for (newfileset.partitionReferenceNum = UDF_SB_NUMPARTS(sb) - 1; |
@@ -820,14 +773,11 @@ udf_find_fileset(struct super_block *sb, kernel_lb_addr * fileset, | |||
820 | fileset->logicalBlockNum == 0xFFFFFFFF && | 773 | fileset->logicalBlockNum == 0xFFFFFFFF && |
821 | fileset->partitionReferenceNum == 0xFFFF); | 774 | fileset->partitionReferenceNum == 0xFFFF); |
822 | newfileset.partitionReferenceNum--) { | 775 | newfileset.partitionReferenceNum--) { |
823 | lastblock = | 776 | lastblock = UDF_SB_PARTLEN(sb, newfileset.partitionReferenceNum); |
824 | UDF_SB_PARTLEN(sb, | ||
825 | newfileset.partitionReferenceNum); | ||
826 | newfileset.logicalBlockNum = 0; | 777 | newfileset.logicalBlockNum = 0; |
827 | 778 | ||
828 | do { | 779 | do { |
829 | bh = udf_read_ptagged(sb, newfileset, 0, | 780 | bh = udf_read_ptagged(sb, newfileset, 0, &ident); |
830 | &ident); | ||
831 | if (!bh) { | 781 | if (!bh) { |
832 | newfileset.logicalBlockNum++; | 782 | newfileset.logicalBlockNum++; |
833 | continue; | 783 | continue; |
@@ -835,38 +785,28 @@ udf_find_fileset(struct super_block *sb, kernel_lb_addr * fileset, | |||
835 | 785 | ||
836 | switch (ident) { | 786 | switch (ident) { |
837 | case TAG_IDENT_SBD: | 787 | case TAG_IDENT_SBD: |
838 | { | 788 | { |
839 | struct spaceBitmapDesc *sp; | 789 | struct spaceBitmapDesc *sp; |
840 | sp = (struct spaceBitmapDesc *) | 790 | sp = (struct spaceBitmapDesc *)bh->b_data; |
841 | bh->b_data; | 791 | newfileset.logicalBlockNum += 1 + |
842 | newfileset.logicalBlockNum += | 792 | ((le32_to_cpu(sp->numOfBytes) + |
843 | 1 + | 793 | sizeof(struct spaceBitmapDesc) - 1) |
844 | ((le32_to_cpu | 794 | >> sb->s_blocksize_bits); |
845 | (sp->numOfBytes) + | 795 | brelse(bh); |
846 | sizeof(struct | 796 | break; |
847 | spaceBitmapDesc) - | 797 | } |
848 | 1) | ||
849 | >> sb->s_blocksize_bits); | ||
850 | brelse(bh); | ||
851 | break; | ||
852 | } | ||
853 | case TAG_IDENT_FSD: | 798 | case TAG_IDENT_FSD: |
854 | { | 799 | *fileset = newfileset; |
855 | *fileset = newfileset; | 800 | break; |
856 | break; | ||
857 | } | ||
858 | default: | 801 | default: |
859 | { | 802 | newfileset.logicalBlockNum++; |
860 | newfileset.logicalBlockNum++; | 803 | brelse(bh); |
861 | brelse(bh); | 804 | bh = NULL; |
862 | bh = NULL; | 805 | break; |
863 | break; | ||
864 | } | ||
865 | } | 806 | } |
866 | } | 807 | } while (newfileset.logicalBlockNum < lastblock && |
867 | while (newfileset.logicalBlockNum < lastblock && | 808 | fileset->logicalBlockNum == 0xFFFFFFFF && |
868 | fileset->logicalBlockNum == 0xFFFFFFFF && | 809 | fileset->partitionReferenceNum == 0xFFFF); |
869 | fileset->partitionReferenceNum == 0xFFFF); | ||
870 | } | 810 | } |
871 | } | 811 | } |
872 | 812 | ||
@@ -898,10 +838,10 @@ static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh) | |||
898 | lets_to_cpu(pvoldesc->recordingDateAndTime))) { | 838 | lets_to_cpu(pvoldesc->recordingDateAndTime))) { |
899 | kernel_timestamp ts; | 839 | kernel_timestamp ts; |
900 | ts = lets_to_cpu(pvoldesc->recordingDateAndTime); | 840 | ts = lets_to_cpu(pvoldesc->recordingDateAndTime); |
901 | udf_debug | 841 | udf_debug("recording time %ld/%ld, %04u/%02u/%02u %02u:%02u (%x)\n", |
902 | ("recording time %ld/%ld, %04u/%02u/%02u %02u:%02u (%x)\n", | 842 | recording, recording_usec, |
903 | recording, recording_usec, ts.year, ts.month, ts.day, | 843 | ts.year, ts.month, ts.day, ts.hour, |
904 | ts.hour, ts.minute, ts.typeAndTimezone); | 844 | ts.minute, ts.typeAndTimezone); |
905 | UDF_SB_RECORDTIME(sb).tv_sec = recording; | 845 | UDF_SB_RECORDTIME(sb).tv_sec = recording; |
906 | UDF_SB_RECORDTIME(sb).tv_nsec = recording_usec * 1000; | 846 | UDF_SB_RECORDTIME(sb).tv_nsec = recording_usec * 1000; |
907 | } | 847 | } |
@@ -920,9 +860,8 @@ static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh) | |||
920 | } | 860 | } |
921 | } | 861 | } |
922 | 862 | ||
923 | static void | 863 | static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh, |
924 | udf_load_fileset(struct super_block *sb, struct buffer_head *bh, | 864 | kernel_lb_addr *root) |
925 | kernel_lb_addr * root) | ||
926 | { | 865 | { |
927 | struct fileSetDesc *fset; | 866 | struct fileSetDesc *fset; |
928 | 867 | ||
@@ -945,121 +884,72 @@ static void udf_load_partdesc(struct super_block *sb, struct buffer_head *bh) | |||
945 | 884 | ||
946 | for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { | 885 | for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { |
947 | udf_debug("Searching map: (%d == %d)\n", | 886 | udf_debug("Searching map: (%d == %d)\n", |
948 | UDF_SB_PARTMAPS(sb)[i].s_partition_num, | 887 | UDF_SB_PARTMAPS(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber)); |
949 | le16_to_cpu(p->partitionNumber)); | 888 | if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber)) { |
950 | if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == | 889 | UDF_SB_PARTLEN(sb,i) = le32_to_cpu(p->partitionLength); /* blocks */ |
951 | le16_to_cpu(p->partitionNumber)) { | 890 | UDF_SB_PARTROOT(sb,i) = le32_to_cpu(p->partitionStartingLocation); |
952 | UDF_SB_PARTLEN(sb, i) = le32_to_cpu(p->partitionLength); /* blocks */ | 891 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_READ_ONLY) |
953 | UDF_SB_PARTROOT(sb, i) = | 892 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_READ_ONLY; |
954 | le32_to_cpu(p->partitionStartingLocation); | 893 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_WRITE_ONCE) |
955 | if (le32_to_cpu(p->accessType) == | 894 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_WRITE_ONCE; |
956 | PD_ACCESS_TYPE_READ_ONLY) | 895 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_REWRITABLE) |
957 | UDF_SB_PARTFLAGS(sb, i) |= | 896 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_REWRITABLE; |
958 | UDF_PART_FLAG_READ_ONLY; | 897 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_OVERWRITABLE) |
959 | if (le32_to_cpu(p->accessType) == | 898 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_OVERWRITABLE; |
960 | PD_ACCESS_TYPE_WRITE_ONCE) | 899 | |
961 | UDF_SB_PARTFLAGS(sb, i) |= | 900 | if (!strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) || |
962 | UDF_PART_FLAG_WRITE_ONCE; | 901 | !strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03)) { |
963 | if (le32_to_cpu(p->accessType) == | ||
964 | PD_ACCESS_TYPE_REWRITABLE) | ||
965 | UDF_SB_PARTFLAGS(sb, i) |= | ||
966 | UDF_PART_FLAG_REWRITABLE; | ||
967 | if (le32_to_cpu(p->accessType) == | ||
968 | PD_ACCESS_TYPE_OVERWRITABLE) | ||
969 | UDF_SB_PARTFLAGS(sb, i) |= | ||
970 | UDF_PART_FLAG_OVERWRITABLE; | ||
971 | |||
972 | if (!strcmp | ||
973 | (p->partitionContents.ident, | ||
974 | PD_PARTITION_CONTENTS_NSR02) | ||
975 | || !strcmp(p->partitionContents.ident, | ||
976 | PD_PARTITION_CONTENTS_NSR03)) { | ||
977 | struct partitionHeaderDesc *phd; | 902 | struct partitionHeaderDesc *phd; |
978 | 903 | ||
979 | phd = | 904 | phd = (struct partitionHeaderDesc *)(p->partitionContentsUse); |
980 | (struct partitionHeaderDesc *)(p-> | ||
981 | partitionContentsUse); | ||
982 | if (phd->unallocSpaceTable.extLength) { | 905 | if (phd->unallocSpaceTable.extLength) { |
983 | kernel_lb_addr loc = | 906 | kernel_lb_addr loc = { |
984 | { le32_to_cpu(phd-> | 907 | .logicalBlockNum = le32_to_cpu(phd->unallocSpaceTable.extPosition), |
985 | unallocSpaceTable. | 908 | .partitionReferenceNum = i, |
986 | extPosition), i }; | 909 | }; |
987 | 910 | ||
988 | UDF_SB_PARTMAPS(sb)[i].s_uspace. | 911 | UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table = |
989 | s_table = udf_iget(sb, loc); | 912 | udf_iget(sb, loc); |
990 | UDF_SB_PARTFLAGS(sb, i) |= | 913 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_TABLE; |
991 | UDF_PART_FLAG_UNALLOC_TABLE; | 914 | udf_debug("unallocSpaceTable (part %d) @ %ld\n", |
992 | udf_debug | 915 | i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table->i_ino); |
993 | ("unallocSpaceTable (part %d) @ %ld\n", | ||
994 | i, | ||
995 | UDF_SB_PARTMAPS(sb)[i].s_uspace. | ||
996 | s_table->i_ino); | ||
997 | } | 916 | } |
998 | if (phd->unallocSpaceBitmap.extLength) { | 917 | if (phd->unallocSpaceBitmap.extLength) { |
999 | UDF_SB_ALLOC_BITMAP(sb, i, s_uspace); | 918 | UDF_SB_ALLOC_BITMAP(sb, i, s_uspace); |
1000 | if (UDF_SB_PARTMAPS(sb)[i].s_uspace. | 919 | if (UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap != NULL) { |
1001 | s_bitmap != NULL) { | 920 | UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extLength = |
1002 | UDF_SB_PARTMAPS(sb)[i].s_uspace. | 921 | le32_to_cpu(phd->unallocSpaceBitmap.extLength); |
1003 | s_bitmap->s_extLength = | 922 | UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition = |
1004 | le32_to_cpu(phd-> | 923 | le32_to_cpu(phd->unallocSpaceBitmap.extPosition); |
1005 | unallocSpaceBitmap. | 924 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_BITMAP; |
1006 | extLength); | 925 | udf_debug("unallocSpaceBitmap (part %d) @ %d\n", |
1007 | UDF_SB_PARTMAPS(sb)[i].s_uspace. | 926 | i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition); |
1008 | s_bitmap->s_extPosition = | ||
1009 | le32_to_cpu(phd-> | ||
1010 | unallocSpaceBitmap. | ||
1011 | extPosition); | ||
1012 | UDF_SB_PARTFLAGS(sb, i) |= | ||
1013 | UDF_PART_FLAG_UNALLOC_BITMAP; | ||
1014 | udf_debug | ||
1015 | ("unallocSpaceBitmap (part %d) @ %d\n", | ||
1016 | i, | ||
1017 | UDF_SB_PARTMAPS(sb)[i]. | ||
1018 | s_uspace.s_bitmap-> | ||
1019 | s_extPosition); | ||
1020 | } | 927 | } |
1021 | } | 928 | } |
1022 | if (phd->partitionIntegrityTable.extLength) | 929 | if (phd->partitionIntegrityTable.extLength) |
1023 | udf_debug | 930 | udf_debug("partitionIntegrityTable (part %d)\n", i); |
1024 | ("partitionIntegrityTable (part %d)\n", | ||
1025 | i); | ||
1026 | if (phd->freedSpaceTable.extLength) { | 931 | if (phd->freedSpaceTable.extLength) { |
1027 | kernel_lb_addr loc = | 932 | kernel_lb_addr loc = { |
1028 | { le32_to_cpu(phd->freedSpaceTable. | 933 | .logicalBlockNum = le32_to_cpu(phd->freedSpaceTable.extPosition), |
1029 | extPosition), i }; | 934 | .partitionReferenceNum = i, |
1030 | 935 | }; | |
1031 | UDF_SB_PARTMAPS(sb)[i].s_fspace. | 936 | |
1032 | s_table = udf_iget(sb, loc); | 937 | UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table = |
1033 | UDF_SB_PARTFLAGS(sb, i) |= | 938 | udf_iget(sb, loc); |
1034 | UDF_PART_FLAG_FREED_TABLE; | 939 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_TABLE; |
1035 | udf_debug | 940 | udf_debug("freedSpaceTable (part %d) @ %ld\n", |
1036 | ("freedSpaceTable (part %d) @ %ld\n", | 941 | i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table->i_ino); |
1037 | i, | ||
1038 | UDF_SB_PARTMAPS(sb)[i].s_fspace. | ||
1039 | s_table->i_ino); | ||
1040 | } | 942 | } |
1041 | if (phd->freedSpaceBitmap.extLength) { | 943 | if (phd->freedSpaceBitmap.extLength) { |
1042 | UDF_SB_ALLOC_BITMAP(sb, i, s_fspace); | 944 | UDF_SB_ALLOC_BITMAP(sb, i, s_fspace); |
1043 | if (UDF_SB_PARTMAPS(sb)[i].s_fspace. | 945 | if (UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap != NULL) { |
1044 | s_bitmap != NULL) { | 946 | UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extLength = |
1045 | UDF_SB_PARTMAPS(sb)[i].s_fspace. | 947 | le32_to_cpu(phd->freedSpaceBitmap.extLength); |
1046 | s_bitmap->s_extLength = | 948 | UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition = |
1047 | le32_to_cpu(phd-> | 949 | le32_to_cpu(phd->freedSpaceBitmap.extPosition); |
1048 | freedSpaceBitmap. | 950 | UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_BITMAP; |
1049 | extLength); | 951 | udf_debug("freedSpaceBitmap (part %d) @ %d\n", |
1050 | UDF_SB_PARTMAPS(sb)[i].s_fspace. | 952 | i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition); |
1051 | s_bitmap->s_extPosition = | ||
1052 | le32_to_cpu(phd-> | ||
1053 | freedSpaceBitmap. | ||
1054 | extPosition); | ||
1055 | UDF_SB_PARTFLAGS(sb, i) |= | ||
1056 | UDF_PART_FLAG_FREED_BITMAP; | ||
1057 | udf_debug | ||
1058 | ("freedSpaceBitmap (part %d) @ %d\n", | ||
1059 | i, | ||
1060 | UDF_SB_PARTMAPS(sb)[i]. | ||
1061 | s_fspace.s_bitmap-> | ||
1062 | s_extPosition); | ||
1063 | } | 953 | } |
1064 | } | 954 | } |
1065 | } | 955 | } |
@@ -1070,16 +960,14 @@ static void udf_load_partdesc(struct super_block *sb, struct buffer_head *bh) | |||
1070 | udf_debug("Partition (%d) not found in partition map\n", | 960 | udf_debug("Partition (%d) not found in partition map\n", |
1071 | le16_to_cpu(p->partitionNumber)); | 961 | le16_to_cpu(p->partitionNumber)); |
1072 | } else { | 962 | } else { |
1073 | udf_debug | 963 | udf_debug("Partition (%d:%d type %x) starts at physical %d, block length %d\n", |
1074 | ("Partition (%d:%d type %x) starts at physical %d, block length %d\n", | 964 | le16_to_cpu(p->partitionNumber), i, UDF_SB_PARTTYPE(sb,i), |
1075 | le16_to_cpu(p->partitionNumber), i, UDF_SB_PARTTYPE(sb, i), | 965 | UDF_SB_PARTROOT(sb,i), UDF_SB_PARTLEN(sb,i)); |
1076 | UDF_SB_PARTROOT(sb, i), UDF_SB_PARTLEN(sb, i)); | ||
1077 | } | 966 | } |
1078 | } | 967 | } |
1079 | 968 | ||
1080 | static int | 969 | static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh, |
1081 | udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh, | 970 | kernel_lb_addr *fileset) |
1082 | kernel_lb_addr * fileset) | ||
1083 | { | 971 | { |
1084 | struct logicalVolDesc *lvd; | 972 | struct logicalVolDesc *lvd; |
1085 | int i, j, offset; | 973 | int i, j, offset; |
@@ -1090,116 +978,69 @@ udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh, | |||
1090 | UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps)); | 978 | UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps)); |
1091 | 979 | ||
1092 | for (i = 0, offset = 0; | 980 | for (i = 0, offset = 0; |
1093 | i < UDF_SB_NUMPARTS(sb) | 981 | i < UDF_SB_NUMPARTS(sb) && offset < le32_to_cpu(lvd->mapTableLength); |
1094 | && offset < le32_to_cpu(lvd->mapTableLength); | 982 | i++, offset += ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapLength) { |
1095 | i++, offset += | 983 | type = ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapType; |
1096 | ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))-> | ||
1097 | partitionMapLength) { | ||
1098 | type = | ||
1099 | ((struct genericPartitionMap *) | ||
1100 | &(lvd->partitionMaps[offset]))->partitionMapType; | ||
1101 | if (type == 1) { | 984 | if (type == 1) { |
1102 | struct genericPartitionMap1 *gpm1 = | 985 | struct genericPartitionMap1 *gpm1 = (struct genericPartitionMap1 *)&(lvd->partitionMaps[offset]); |
1103 | (struct genericPartitionMap1 *)&(lvd-> | 986 | UDF_SB_PARTTYPE(sb,i) = UDF_TYPE1_MAP15; |
1104 | partitionMaps | 987 | UDF_SB_PARTVSN(sb,i) = le16_to_cpu(gpm1->volSeqNum); |
1105 | [offset]); | 988 | UDF_SB_PARTNUM(sb,i) = le16_to_cpu(gpm1->partitionNum); |
1106 | UDF_SB_PARTTYPE(sb, i) = UDF_TYPE1_MAP15; | 989 | UDF_SB_PARTFUNC(sb,i) = NULL; |
1107 | UDF_SB_PARTVSN(sb, i) = le16_to_cpu(gpm1->volSeqNum); | ||
1108 | UDF_SB_PARTNUM(sb, i) = le16_to_cpu(gpm1->partitionNum); | ||
1109 | UDF_SB_PARTFUNC(sb, i) = NULL; | ||
1110 | } else if (type == 2) { | 990 | } else if (type == 2) { |
1111 | struct udfPartitionMap2 *upm2 = | 991 | struct udfPartitionMap2 *upm2 = (struct udfPartitionMap2 *)&(lvd->partitionMaps[offset]); |
1112 | (struct udfPartitionMap2 *)&(lvd-> | 992 | if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL))) { |
1113 | partitionMaps[offset]); | 993 | if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0150) { |
1114 | if (!strncmp | 994 | UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP15; |
1115 | (upm2->partIdent.ident, UDF_ID_VIRTUAL, | 995 | UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt15; |
1116 | strlen(UDF_ID_VIRTUAL))) { | 996 | } else if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0200) { |
1117 | if (le16_to_cpu | 997 | UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP20; |
1118 | (((__le16 *) upm2->partIdent. | 998 | UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt20; |
1119 | identSuffix)[0]) == 0x0150) { | ||
1120 | UDF_SB_PARTTYPE(sb, i) = | ||
1121 | UDF_VIRTUAL_MAP15; | ||
1122 | UDF_SB_PARTFUNC(sb, i) = | ||
1123 | udf_get_pblock_virt15; | ||
1124 | } else | ||
1125 | if (le16_to_cpu | ||
1126 | (((__le16 *) upm2->partIdent. | ||
1127 | identSuffix)[0]) == 0x0200) { | ||
1128 | UDF_SB_PARTTYPE(sb, i) = | ||
1129 | UDF_VIRTUAL_MAP20; | ||
1130 | UDF_SB_PARTFUNC(sb, i) = | ||
1131 | udf_get_pblock_virt20; | ||
1132 | } | 999 | } |
1133 | } else | 1000 | } else if (!strncmp(upm2->partIdent.ident, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE))) { |
1134 | if (!strncmp | ||
1135 | (upm2->partIdent.ident, UDF_ID_SPARABLE, | ||
1136 | strlen(UDF_ID_SPARABLE))) { | ||
1137 | uint32_t loc; | 1001 | uint32_t loc; |
1138 | uint16_t ident; | 1002 | uint16_t ident; |
1139 | struct sparingTable *st; | 1003 | struct sparingTable *st; |
1140 | struct sparablePartitionMap *spm = | 1004 | struct sparablePartitionMap *spm = (struct sparablePartitionMap *)&(lvd->partitionMaps[offset]); |
1141 | (struct sparablePartitionMap *)&(lvd-> | 1005 | |
1142 | partitionMaps | 1006 | UDF_SB_PARTTYPE(sb,i) = UDF_SPARABLE_MAP15; |
1143 | [offset]); | 1007 | UDF_SB_TYPESPAR(sb,i).s_packet_len = le16_to_cpu(spm->packetLength); |
1144 | |||
1145 | UDF_SB_PARTTYPE(sb, i) = UDF_SPARABLE_MAP15; | ||
1146 | UDF_SB_TYPESPAR(sb, i).s_packet_len = | ||
1147 | le16_to_cpu(spm->packetLength); | ||
1148 | for (j = 0; j < spm->numSparingTables; j++) { | 1008 | for (j = 0; j < spm->numSparingTables; j++) { |
1149 | loc = | 1009 | loc = le32_to_cpu(spm->locSparingTable[j]); |
1150 | le32_to_cpu(spm-> | 1010 | UDF_SB_TYPESPAR(sb,i).s_spar_map[j] = |
1151 | locSparingTable[j]); | 1011 | udf_read_tagged(sb, loc, loc, &ident); |
1152 | UDF_SB_TYPESPAR(sb, i).s_spar_map[j] = | 1012 | if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) { |
1153 | udf_read_tagged(sb, loc, loc, | 1013 | st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,i).s_spar_map[j]->b_data; |
1154 | &ident); | 1014 | if (ident != 0 || |
1155 | if (UDF_SB_TYPESPAR(sb, i). | 1015 | strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING))) { |
1156 | s_spar_map[j] != NULL) { | 1016 | brelse(UDF_SB_TYPESPAR(sb,i).s_spar_map[j]); |
1157 | st = (struct sparingTable *) | 1017 | UDF_SB_TYPESPAR(sb,i).s_spar_map[j] = NULL; |
1158 | UDF_SB_TYPESPAR(sb, | ||
1159 | i). | ||
1160 | s_spar_map[j]->b_data; | ||
1161 | if (ident != 0 | ||
1162 | || strncmp(st->sparingIdent. | ||
1163 | ident, | ||
1164 | UDF_ID_SPARING, | ||
1165 | strlen | ||
1166 | (UDF_ID_SPARING))) | ||
1167 | { | ||
1168 | brelse(UDF_SB_TYPESPAR | ||
1169 | (sb, | ||
1170 | i). | ||
1171 | s_spar_map[j]); | ||
1172 | UDF_SB_TYPESPAR(sb, | ||
1173 | i). | ||
1174 | s_spar_map[j] = | ||
1175 | NULL; | ||
1176 | } | 1018 | } |
1177 | } | 1019 | } |
1178 | } | 1020 | } |
1179 | UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_spar15; | 1021 | UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_spar15; |
1180 | } else { | 1022 | } else { |
1181 | udf_debug("Unknown ident: %s\n", | 1023 | udf_debug("Unknown ident: %s\n", upm2->partIdent.ident); |
1182 | upm2->partIdent.ident); | ||
1183 | continue; | 1024 | continue; |
1184 | } | 1025 | } |
1185 | UDF_SB_PARTVSN(sb, i) = le16_to_cpu(upm2->volSeqNum); | 1026 | UDF_SB_PARTVSN(sb,i) = le16_to_cpu(upm2->volSeqNum); |
1186 | UDF_SB_PARTNUM(sb, i) = le16_to_cpu(upm2->partitionNum); | 1027 | UDF_SB_PARTNUM(sb,i) = le16_to_cpu(upm2->partitionNum); |
1187 | } | 1028 | } |
1188 | udf_debug("Partition (%d:%d) type %d on volume %d\n", | 1029 | udf_debug("Partition (%d:%d) type %d on volume %d\n", |
1189 | i, UDF_SB_PARTNUM(sb, i), type, UDF_SB_PARTVSN(sb, | 1030 | i, UDF_SB_PARTNUM(sb,i), type, UDF_SB_PARTVSN(sb,i)); |
1190 | i)); | ||
1191 | } | 1031 | } |
1192 | 1032 | ||
1193 | if (fileset) { | 1033 | if (fileset) { |
1194 | long_ad *la = (long_ad *) & (lvd->logicalVolContentsUse[0]); | 1034 | long_ad *la = (long_ad *)&(lvd->logicalVolContentsUse[0]); |
1195 | 1035 | ||
1196 | *fileset = lelb_to_cpu(la->extLocation); | 1036 | *fileset = lelb_to_cpu(la->extLocation); |
1197 | udf_debug | 1037 | udf_debug("FileSet found in LogicalVolDesc at block=%d, partition=%d\n", |
1198 | ("FileSet found in LogicalVolDesc at block=%d, partition=%d\n", | 1038 | fileset->logicalBlockNum, |
1199 | fileset->logicalBlockNum, fileset->partitionReferenceNum); | 1039 | fileset->partitionReferenceNum); |
1200 | } | 1040 | } |
1201 | if (lvd->integritySeqExt.extLength) | 1041 | if (lvd->integritySeqExt.extLength) |
1202 | udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt)); | 1042 | udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt)); |
1043 | |||
1203 | return 0; | 1044 | return 0; |
1204 | } | 1045 | } |
1205 | 1046 | ||
@@ -1219,9 +1060,7 @@ static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc) | |||
1219 | UDF_SB_LVIDBH(sb) = bh; | 1060 | UDF_SB_LVIDBH(sb) = bh; |
1220 | 1061 | ||
1221 | if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength) | 1062 | if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength) |
1222 | udf_load_logicalvolint(sb, | 1063 | udf_load_logicalvolint(sb, leea_to_cpu(UDF_SB_LVID(sb)->nextIntegrityExt)); |
1223 | leea_to_cpu(UDF_SB_LVID(sb)-> | ||
1224 | nextIntegrityExt)); | ||
1225 | 1064 | ||
1226 | if (UDF_SB_LVIDBH(sb) != bh) | 1065 | if (UDF_SB_LVIDBH(sb) != bh) |
1227 | brelse(bh); | 1066 | brelse(bh); |
@@ -1247,9 +1086,8 @@ static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc) | |||
1247 | * July 1, 1997 - Andrew E. Mileski | 1086 | * July 1, 1997 - Andrew E. Mileski |
1248 | * Written, tested, and released. | 1087 | * Written, tested, and released. |
1249 | */ | 1088 | */ |
1250 | static int | 1089 | static int udf_process_sequence(struct super_block *sb, long block, long lastblock, |
1251 | udf_process_sequence(struct super_block *sb, long block, long lastblock, | 1090 | kernel_lb_addr *fileset) |
1252 | kernel_lb_addr * fileset) | ||
1253 | { | 1091 | { |
1254 | struct buffer_head *bh = NULL; | 1092 | struct buffer_head *bh = NULL; |
1255 | struct udf_vds_record vds[VDS_POS_LENGTH]; | 1093 | struct udf_vds_record vds[VDS_POS_LENGTH]; |
@@ -1274,82 +1112,71 @@ udf_process_sequence(struct super_block *sb, long block, long lastblock, | |||
1274 | gd = (struct generic_desc *)bh->b_data; | 1112 | gd = (struct generic_desc *)bh->b_data; |
1275 | vdsn = le32_to_cpu(gd->volDescSeqNum); | 1113 | vdsn = le32_to_cpu(gd->volDescSeqNum); |
1276 | switch (ident) { | 1114 | switch (ident) { |
1277 | case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */ | 1115 | case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */ |
1278 | if (vdsn >= vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum) { | 1116 | if (vdsn >= vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum) { |
1279 | vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum = | 1117 | vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum = vdsn; |
1280 | vdsn; | ||
1281 | vds[VDS_POS_PRIMARY_VOL_DESC].block = block; | 1118 | vds[VDS_POS_PRIMARY_VOL_DESC].block = block; |
1282 | } | 1119 | } |
1283 | break; | 1120 | break; |
1284 | case TAG_IDENT_VDP: /* ISO 13346 3/10.3 */ | 1121 | case TAG_IDENT_VDP: /* ISO 13346 3/10.3 */ |
1285 | if (vdsn >= vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum) { | 1122 | if (vdsn >= vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum) { |
1286 | vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum = vdsn; | 1123 | vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum = vdsn; |
1287 | vds[VDS_POS_VOL_DESC_PTR].block = block; | 1124 | vds[VDS_POS_VOL_DESC_PTR].block = block; |
1288 | 1125 | ||
1289 | vdp = (struct volDescPtr *)bh->b_data; | 1126 | vdp = (struct volDescPtr *)bh->b_data; |
1290 | next_s = | 1127 | next_s = le32_to_cpu(vdp->nextVolDescSeqExt.extLocation); |
1291 | le32_to_cpu(vdp->nextVolDescSeqExt. | 1128 | next_e = le32_to_cpu(vdp->nextVolDescSeqExt.extLength); |
1292 | extLocation); | ||
1293 | next_e = | ||
1294 | le32_to_cpu(vdp->nextVolDescSeqExt. | ||
1295 | extLength); | ||
1296 | next_e = next_e >> sb->s_blocksize_bits; | 1129 | next_e = next_e >> sb->s_blocksize_bits; |
1297 | next_e += next_s; | 1130 | next_e += next_s; |
1298 | } | 1131 | } |
1299 | break; | 1132 | break; |
1300 | case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */ | 1133 | case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */ |
1301 | if (vdsn >= vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum) { | 1134 | if (vdsn >= vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum) { |
1302 | vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum = | 1135 | vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum = vdsn; |
1303 | vdsn; | ||
1304 | vds[VDS_POS_IMP_USE_VOL_DESC].block = block; | 1136 | vds[VDS_POS_IMP_USE_VOL_DESC].block = block; |
1305 | } | 1137 | } |
1306 | break; | 1138 | break; |
1307 | case TAG_IDENT_PD: /* ISO 13346 3/10.5 */ | 1139 | case TAG_IDENT_PD: /* ISO 13346 3/10.5 */ |
1308 | if (!vds[VDS_POS_PARTITION_DESC].block) | 1140 | if (!vds[VDS_POS_PARTITION_DESC].block) |
1309 | vds[VDS_POS_PARTITION_DESC].block = block; | 1141 | vds[VDS_POS_PARTITION_DESC].block = block; |
1310 | break; | 1142 | break; |
1311 | case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */ | 1143 | case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */ |
1312 | if (vdsn >= vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum) { | 1144 | if (vdsn >= vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum) { |
1313 | vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum = | 1145 | vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum = vdsn; |
1314 | vdsn; | ||
1315 | vds[VDS_POS_LOGICAL_VOL_DESC].block = block; | 1146 | vds[VDS_POS_LOGICAL_VOL_DESC].block = block; |
1316 | } | 1147 | } |
1317 | break; | 1148 | break; |
1318 | case TAG_IDENT_USD: /* ISO 13346 3/10.8 */ | 1149 | case TAG_IDENT_USD: /* ISO 13346 3/10.8 */ |
1319 | if (vdsn >= | 1150 | if (vdsn >= vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum) { |
1320 | vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum) { | 1151 | vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum = vdsn; |
1321 | vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum = | ||
1322 | vdsn; | ||
1323 | vds[VDS_POS_UNALLOC_SPACE_DESC].block = block; | 1152 | vds[VDS_POS_UNALLOC_SPACE_DESC].block = block; |
1324 | } | 1153 | } |
1325 | break; | 1154 | break; |
1326 | case TAG_IDENT_TD: /* ISO 13346 3/10.9 */ | 1155 | case TAG_IDENT_TD: /* ISO 13346 3/10.9 */ |
1327 | vds[VDS_POS_TERMINATING_DESC].block = block; | 1156 | vds[VDS_POS_TERMINATING_DESC].block = block; |
1328 | if (next_e) { | 1157 | if (next_e) { |
1329 | block = next_s; | 1158 | block = next_s; |
1330 | lastblock = next_e; | 1159 | lastblock = next_e; |
1331 | next_s = next_e = 0; | 1160 | next_s = next_e = 0; |
1332 | } else | 1161 | } else { |
1333 | done = 1; | 1162 | done = 1; |
1163 | } | ||
1334 | break; | 1164 | break; |
1335 | } | 1165 | } |
1336 | brelse(bh); | 1166 | brelse(bh); |
1337 | } | 1167 | } |
1338 | for (i = 0; i < VDS_POS_LENGTH; i++) { | 1168 | for (i = 0; i < VDS_POS_LENGTH; i++) { |
1339 | if (vds[i].block) { | 1169 | if (vds[i].block) { |
1340 | bh = udf_read_tagged(sb, vds[i].block, vds[i].block, | 1170 | bh = udf_read_tagged(sb, vds[i].block, vds[i].block, &ident); |
1341 | &ident); | ||
1342 | 1171 | ||
1343 | if (i == VDS_POS_PRIMARY_VOL_DESC) | 1172 | if (i == VDS_POS_PRIMARY_VOL_DESC) { |
1344 | udf_load_pvoldesc(sb, bh); | 1173 | udf_load_pvoldesc(sb, bh); |
1345 | else if (i == VDS_POS_LOGICAL_VOL_DESC) | 1174 | } else if (i == VDS_POS_LOGICAL_VOL_DESC) { |
1346 | udf_load_logicalvol(sb, bh, fileset); | 1175 | udf_load_logicalvol(sb, bh, fileset); |
1347 | else if (i == VDS_POS_PARTITION_DESC) { | 1176 | } else if (i == VDS_POS_PARTITION_DESC) { |
1348 | struct buffer_head *bh2 = NULL; | 1177 | struct buffer_head *bh2 = NULL; |
1349 | udf_load_partdesc(sb, bh); | 1178 | udf_load_partdesc(sb, bh); |
1350 | for (j = vds[i].block + 1; | 1179 | for (j = vds[i].block + 1; j < vds[VDS_POS_TERMINATING_DESC].block; j++) { |
1351 | j < vds[VDS_POS_TERMINATING_DESC].block; | ||
1352 | j++) { | ||
1353 | bh2 = udf_read_tagged(sb, j, j, &ident); | 1180 | bh2 = udf_read_tagged(sb, j, j, &ident); |
1354 | gd = (struct generic_desc *)bh2->b_data; | 1181 | gd = (struct generic_desc *)bh2->b_data; |
1355 | if (ident == TAG_IDENT_PD) | 1182 | if (ident == TAG_IDENT_PD) |
@@ -1378,16 +1205,17 @@ static int udf_check_valid(struct super_block *sb, int novrs, int silent) | |||
1378 | /* Check that it is NSR02 compliant */ | 1205 | /* Check that it is NSR02 compliant */ |
1379 | /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */ | 1206 | /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */ |
1380 | else if ((block = udf_vrs(sb, silent)) == -1) { | 1207 | else if ((block = udf_vrs(sb, silent)) == -1) { |
1381 | udf_debug | 1208 | udf_debug("Failed to read byte 32768. Assuming open disc. " |
1382 | ("Failed to read byte 32768. Assuming open disc. Skipping validity check\n"); | 1209 | "Skipping validity check\n"); |
1383 | if (!UDF_SB_LASTBLOCK(sb)) | 1210 | if (!UDF_SB_LASTBLOCK(sb)) |
1384 | UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb); | 1211 | UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb); |
1385 | return 0; | 1212 | return 0; |
1386 | } else | 1213 | } else { |
1387 | return !block; | 1214 | return !block; |
1215 | } | ||
1388 | } | 1216 | } |
1389 | 1217 | ||
1390 | static int udf_load_partition(struct super_block *sb, kernel_lb_addr * fileset) | 1218 | static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) |
1391 | { | 1219 | { |
1392 | struct anchorVolDescPtr *anchor; | 1220 | struct anchorVolDescPtr *anchor; |
1393 | uint16_t ident; | 1221 | uint16_t ident; |
@@ -1399,28 +1227,20 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr * fileset) | |||
1399 | return 1; | 1227 | return 1; |
1400 | 1228 | ||
1401 | for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { | 1229 | for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { |
1402 | if (UDF_SB_ANCHOR(sb)[i] && (bh = udf_read_tagged(sb, | 1230 | if (UDF_SB_ANCHOR(sb)[i] && |
1403 | UDF_SB_ANCHOR | 1231 | (bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i], |
1404 | (sb)[i], | 1232 | UDF_SB_ANCHOR(sb)[i], &ident))) { |
1405 | UDF_SB_ANCHOR | ||
1406 | (sb)[i], | ||
1407 | &ident))) { | ||
1408 | anchor = (struct anchorVolDescPtr *)bh->b_data; | 1233 | anchor = (struct anchorVolDescPtr *)bh->b_data; |
1409 | 1234 | ||
1410 | /* Locate the main sequence */ | 1235 | /* Locate the main sequence */ |
1411 | main_s = | 1236 | main_s = le32_to_cpu(anchor->mainVolDescSeqExt.extLocation); |
1412 | le32_to_cpu(anchor->mainVolDescSeqExt.extLocation); | 1237 | main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength ); |
1413 | main_e = | ||
1414 | le32_to_cpu(anchor->mainVolDescSeqExt.extLength); | ||
1415 | main_e = main_e >> sb->s_blocksize_bits; | 1238 | main_e = main_e >> sb->s_blocksize_bits; |
1416 | main_e += main_s; | 1239 | main_e += main_s; |
1417 | 1240 | ||
1418 | /* Locate the reserve sequence */ | 1241 | /* Locate the reserve sequence */ |
1419 | reserve_s = | 1242 | reserve_s = le32_to_cpu(anchor->reserveVolDescSeqExt.extLocation); |
1420 | le32_to_cpu(anchor->reserveVolDescSeqExt. | 1243 | reserve_e = le32_to_cpu(anchor->reserveVolDescSeqExt.extLength); |
1421 | extLocation); | ||
1422 | reserve_e = | ||
1423 | le32_to_cpu(anchor->reserveVolDescSeqExt.extLength); | ||
1424 | reserve_e = reserve_e >> sb->s_blocksize_bits; | 1244 | reserve_e = reserve_e >> sb->s_blocksize_bits; |
1425 | reserve_e += reserve_s; | 1245 | reserve_e += reserve_s; |
1426 | 1246 | ||
@@ -1428,10 +1248,8 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr * fileset) | |||
1428 | 1248 | ||
1429 | /* Process the main & reserve sequences */ | 1249 | /* Process the main & reserve sequences */ |
1430 | /* responsible for finding the PartitionDesc(s) */ | 1250 | /* responsible for finding the PartitionDesc(s) */ |
1431 | if (! | 1251 | if (!(udf_process_sequence(sb, main_s, main_e, fileset) && |
1432 | (udf_process_sequence(sb, main_s, main_e, fileset) | 1252 | udf_process_sequence(sb, reserve_s, reserve_e, fileset))) { |
1433 | && udf_process_sequence(sb, reserve_s, reserve_e, | ||
1434 | fileset))) { | ||
1435 | break; | 1253 | break; |
1436 | } | 1254 | } |
1437 | } | 1255 | } |
@@ -1444,81 +1262,67 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr * fileset) | |||
1444 | udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]); | 1262 | udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]); |
1445 | 1263 | ||
1446 | for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { | 1264 | for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { |
1265 | kernel_lb_addr uninitialized_var(ino); | ||
1447 | switch (UDF_SB_PARTTYPE(sb, i)) { | 1266 | switch (UDF_SB_PARTTYPE(sb, i)) { |
1448 | case UDF_VIRTUAL_MAP15: | 1267 | case UDF_VIRTUAL_MAP15: |
1449 | case UDF_VIRTUAL_MAP20: | 1268 | case UDF_VIRTUAL_MAP20: |
1450 | { | 1269 | if (!UDF_SB_LASTBLOCK(sb)) { |
1451 | kernel_lb_addr uninitialized_var(ino); | 1270 | UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb); |
1271 | udf_find_anchor(sb); | ||
1272 | } | ||
1452 | 1273 | ||
1453 | if (!UDF_SB_LASTBLOCK(sb)) { | 1274 | if (!UDF_SB_LASTBLOCK(sb)) { |
1454 | UDF_SB_LASTBLOCK(sb) = | 1275 | udf_debug("Unable to determine Lastblock (For " |
1455 | udf_get_last_block(sb); | 1276 | "Virtual Partition)\n"); |
1456 | udf_find_anchor(sb); | 1277 | return 1; |
1457 | } | 1278 | } |
1458 | 1279 | ||
1459 | if (!UDF_SB_LASTBLOCK(sb)) { | 1280 | for (j = 0; j < UDF_SB_NUMPARTS(sb); j++) { |
1460 | udf_debug | 1281 | if (j != i && UDF_SB_PARTVSN(sb, i) == |
1461 | ("Unable to determine Lastblock (For Virtual Partition)\n"); | 1282 | UDF_SB_PARTVSN(sb, j) && |
1462 | return 1; | 1283 | UDF_SB_PARTNUM(sb, i) == |
1284 | UDF_SB_PARTNUM(sb, j)) { | ||
1285 | ino.partitionReferenceNum = j; | ||
1286 | ino.logicalBlockNum = | ||
1287 | UDF_SB_LASTBLOCK(sb) - | ||
1288 | UDF_SB_PARTROOT(sb, j); | ||
1289 | break; | ||
1463 | } | 1290 | } |
1291 | } | ||
1464 | 1292 | ||
1465 | for (j = 0; j < UDF_SB_NUMPARTS(sb); j++) { | 1293 | if (j == UDF_SB_NUMPARTS(sb)) |
1466 | if (j != i && | 1294 | return 1; |
1467 | UDF_SB_PARTVSN(sb, | ||
1468 | i) == | ||
1469 | UDF_SB_PARTVSN(sb, j) | ||
1470 | && UDF_SB_PARTNUM(sb, | ||
1471 | i) == | ||
1472 | UDF_SB_PARTNUM(sb, j)) { | ||
1473 | ino.partitionReferenceNum = j; | ||
1474 | ino.logicalBlockNum = | ||
1475 | UDF_SB_LASTBLOCK(sb) - | ||
1476 | UDF_SB_PARTROOT(sb, j); | ||
1477 | break; | ||
1478 | } | ||
1479 | } | ||
1480 | 1295 | ||
1481 | if (j == UDF_SB_NUMPARTS(sb)) | 1296 | if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino))) |
1482 | return 1; | 1297 | return 1; |
1483 | 1298 | ||
1484 | if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino))) | 1299 | if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) { |
1485 | return 1; | 1300 | UDF_SB_TYPEVIRT(sb, i).s_start_offset = |
1301 | udf_ext0_offset(UDF_SB_VAT(sb)); | ||
1302 | UDF_SB_TYPEVIRT(sb, i).s_num_entries = | ||
1303 | (UDF_SB_VAT(sb)->i_size - 36) >> 2; | ||
1304 | } else if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP20) { | ||
1305 | struct buffer_head *bh = NULL; | ||
1306 | uint32_t pos; | ||
1486 | 1307 | ||
1487 | if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) { | 1308 | pos = udf_block_map(UDF_SB_VAT(sb), 0); |
1488 | UDF_SB_TYPEVIRT(sb, i).s_start_offset = | 1309 | bh = sb_bread(sb, pos); |
1489 | udf_ext0_offset(UDF_SB_VAT(sb)); | 1310 | if (!bh) |
1490 | UDF_SB_TYPEVIRT(sb, i).s_num_entries = | 1311 | return 1; |
1491 | (UDF_SB_VAT(sb)->i_size - 36) >> 2; | 1312 | UDF_SB_TYPEVIRT(sb, i).s_start_offset = |
1492 | } else if (UDF_SB_PARTTYPE(sb, i) == | 1313 | le16_to_cpu(((struct |
1493 | UDF_VIRTUAL_MAP20) { | 1314 | virtualAllocationTable20 *)bh->b_data + |
1494 | struct buffer_head *bh = NULL; | 1315 | udf_ext0_offset(UDF_SB_VAT(sb)))-> |
1495 | uint32_t pos; | 1316 | lengthHeader) + |
1496 | 1317 | udf_ext0_offset(UDF_SB_VAT(sb)); | |
1497 | pos = udf_block_map(UDF_SB_VAT(sb), 0); | 1318 | UDF_SB_TYPEVIRT(sb, i).s_num_entries = |
1498 | bh = sb_bread(sb, pos); | 1319 | (UDF_SB_VAT(sb)->i_size - |
1499 | if (!bh) | 1320 | UDF_SB_TYPEVIRT(sb, i).s_start_offset) >> 2; |
1500 | return 1; | 1321 | brelse(bh); |
1501 | UDF_SB_TYPEVIRT(sb, i).s_start_offset = | ||
1502 | le16_to_cpu(((struct | ||
1503 | virtualAllocationTable20 | ||
1504 | *)bh->b_data + | ||
1505 | udf_ext0_offset | ||
1506 | (UDF_SB_VAT(sb)))-> | ||
1507 | lengthHeader) + | ||
1508 | udf_ext0_offset(UDF_SB_VAT(sb)); | ||
1509 | UDF_SB_TYPEVIRT(sb, i).s_num_entries = | ||
1510 | (UDF_SB_VAT(sb)->i_size - | ||
1511 | UDF_SB_TYPEVIRT(sb, | ||
1512 | i). | ||
1513 | s_start_offset) >> 2; | ||
1514 | brelse(bh); | ||
1515 | } | ||
1516 | UDF_SB_PARTROOT(sb, i) = | ||
1517 | udf_get_pblock(sb, 0, i, 0); | ||
1518 | UDF_SB_PARTLEN(sb, i) = | ||
1519 | UDF_SB_PARTLEN(sb, | ||
1520 | ino.partitionReferenceNum); | ||
1521 | } | 1322 | } |
1323 | UDF_SB_PARTROOT(sb, i) = udf_get_pblock(sb, 0, i, 0); | ||
1324 | UDF_SB_PARTLEN(sb, i) = UDF_SB_PARTLEN(sb, | ||
1325 | ino.partitionReferenceNum); | ||
1522 | } | 1326 | } |
1523 | } | 1327 | } |
1524 | return 0; | 1328 | return 0; |
@@ -1555,42 +1359,32 @@ static void udf_open_lvid(struct super_block *sb) | |||
1555 | 1359 | ||
1556 | static void udf_close_lvid(struct super_block *sb) | 1360 | static void udf_close_lvid(struct super_block *sb) |
1557 | { | 1361 | { |
1362 | kernel_timestamp cpu_time; | ||
1363 | int i; | ||
1364 | |||
1558 | if (UDF_SB_LVIDBH(sb) && | 1365 | if (UDF_SB_LVIDBH(sb) && |
1559 | UDF_SB_LVID(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN) { | 1366 | UDF_SB_LVID(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN) { |
1560 | int i; | ||
1561 | kernel_timestamp cpu_time; | ||
1562 | |||
1563 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | 1367 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; |
1564 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | 1368 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; |
1565 | if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) | 1369 | if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) |
1566 | UDF_SB_LVID(sb)->recordingDateAndTime = | 1370 | UDF_SB_LVID(sb)->recordingDateAndTime = cpu_to_lets(cpu_time); |
1567 | cpu_to_lets(cpu_time); | 1371 | if (UDF_MAX_WRITE_VERSION > le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev)) |
1568 | if (UDF_MAX_WRITE_VERSION > | 1372 | UDF_SB_LVIDIU(sb)->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION); |
1569 | le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev)) | 1373 | if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev)) |
1570 | UDF_SB_LVIDIU(sb)->maxUDFWriteRev = | 1374 | UDF_SB_LVIDIU(sb)->minUDFReadRev = cpu_to_le16(UDF_SB_UDFREV(sb)); |
1571 | cpu_to_le16(UDF_MAX_WRITE_VERSION); | 1375 | if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev)) |
1572 | if (UDF_SB_UDFREV(sb) > | 1376 | UDF_SB_LVIDIU(sb)->minUDFWriteRev = cpu_to_le16(UDF_SB_UDFREV(sb)); |
1573 | le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev)) | 1377 | UDF_SB_LVID(sb)->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); |
1574 | UDF_SB_LVIDIU(sb)->minUDFReadRev = | ||
1575 | cpu_to_le16(UDF_SB_UDFREV(sb)); | ||
1576 | if (UDF_SB_UDFREV(sb) > | ||
1577 | le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev)) | ||
1578 | UDF_SB_LVIDIU(sb)->minUDFWriteRev = | ||
1579 | cpu_to_le16(UDF_SB_UDFREV(sb)); | ||
1580 | UDF_SB_LVID(sb)->integrityType = | ||
1581 | cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); | ||
1582 | 1378 | ||
1583 | UDF_SB_LVID(sb)->descTag.descCRC = | 1379 | UDF_SB_LVID(sb)->descTag.descCRC = |
1584 | cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag), | 1380 | cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag), |
1585 | le16_to_cpu(UDF_SB_LVID(sb)->descTag. | 1381 | le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0)); |
1586 | descCRCLength), 0)); | ||
1587 | 1382 | ||
1588 | UDF_SB_LVID(sb)->descTag.tagChecksum = 0; | 1383 | UDF_SB_LVID(sb)->descTag.tagChecksum = 0; |
1589 | for (i = 0; i < 16; i++) | 1384 | for (i = 0; i < 16; i++) |
1590 | if (i != 4) | 1385 | if (i != 4) |
1591 | UDF_SB_LVID(sb)->descTag.tagChecksum += | 1386 | UDF_SB_LVID(sb)->descTag.tagChecksum += |
1592 | ((uint8_t *) & | 1387 | ((uint8_t *)&(UDF_SB_LVID(sb)->descTag))[i]; |
1593 | (UDF_SB_LVID(sb)->descTag))[i]; | ||
1594 | 1388 | ||
1595 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 1389 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); |
1596 | } | 1390 | } |
@@ -1628,6 +1422,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1628 | sbi = kmalloc(sizeof(struct udf_sb_info), GFP_KERNEL); | 1422 | sbi = kmalloc(sizeof(struct udf_sb_info), GFP_KERNEL); |
1629 | if (!sbi) | 1423 | if (!sbi) |
1630 | return -ENOMEM; | 1424 | return -ENOMEM; |
1425 | |||
1631 | sb->s_fs_info = sbi; | 1426 | sb->s_fs_info = sbi; |
1632 | memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info)); | 1427 | memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info)); |
1633 | 1428 | ||
@@ -1679,7 +1474,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1679 | UDF_SB_ANCHOR(sb)[2] = uopt.anchor; | 1474 | UDF_SB_ANCHOR(sb)[2] = uopt.anchor; |
1680 | UDF_SB_ANCHOR(sb)[3] = 256; | 1475 | UDF_SB_ANCHOR(sb)[3] = 256; |
1681 | 1476 | ||
1682 | if (udf_check_valid(sb, uopt.novrs, silent)) { /* read volume recognition sequences */ | 1477 | if (udf_check_valid(sb, uopt.novrs, silent)) { /* read volume recognition sequences */ |
1683 | printk("UDF-fs: No VRS found\n"); | 1478 | printk("UDF-fs: No VRS found\n"); |
1684 | goto error_out; | 1479 | goto error_out; |
1685 | } | 1480 | } |
@@ -1701,10 +1496,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1701 | udf_debug("Lastblock=%d\n", UDF_SB_LASTBLOCK(sb)); | 1496 | udf_debug("Lastblock=%d\n", UDF_SB_LASTBLOCK(sb)); |
1702 | 1497 | ||
1703 | if (UDF_SB_LVIDBH(sb)) { | 1498 | if (UDF_SB_LVIDBH(sb)) { |
1704 | uint16_t minUDFReadRev = | 1499 | uint16_t minUDFReadRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev); |
1705 | le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev); | 1500 | uint16_t minUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev); |
1706 | uint16_t minUDFWriteRev = | ||
1707 | le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev); | ||
1708 | /* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */ | 1501 | /* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */ |
1709 | 1502 | ||
1710 | if (minUDFReadRev > UDF_MAX_READ_VERSION) { | 1503 | if (minUDFReadRev > UDF_MAX_READ_VERSION) { |
@@ -1729,10 +1522,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1729 | goto error_out; | 1522 | goto error_out; |
1730 | } | 1523 | } |
1731 | 1524 | ||
1732 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & | 1525 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_READ_ONLY) { |
1733 | UDF_PART_FLAG_READ_ONLY) { | 1526 | printk("UDF-fs: Partition marked readonly; forcing readonly mount\n"); |
1734 | printk | ||
1735 | ("UDF-fs: Partition marked readonly; forcing readonly mount\n"); | ||
1736 | sb->s_flags |= MS_RDONLY; | 1527 | sb->s_flags |= MS_RDONLY; |
1737 | } | 1528 | } |
1738 | 1529 | ||
@@ -1744,10 +1535,11 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1744 | if (!silent) { | 1535 | if (!silent) { |
1745 | kernel_timestamp ts; | 1536 | kernel_timestamp ts; |
1746 | udf_time_to_stamp(&ts, UDF_SB_RECORDTIME(sb)); | 1537 | udf_time_to_stamp(&ts, UDF_SB_RECORDTIME(sb)); |
1747 | udf_info | 1538 | udf_info("UDF %s (%s) Mounting volume '%s', " |
1748 | ("UDF %s (%s) Mounting volume '%s', timestamp %04u/%02u/%02u %02u:%02u (%x)\n", | 1539 | "timestamp %04u/%02u/%02u %02u:%02u (%x)\n", |
1749 | UDFFS_VERSION, UDFFS_DATE, UDF_SB_VOLIDENT(sb), ts.year, | 1540 | UDFFS_VERSION, UDFFS_DATE, |
1750 | ts.month, ts.day, ts.hour, ts.minute, ts.typeAndTimezone); | 1541 | UDF_SB_VOLIDENT(sb), ts.year, ts.month, ts.day, ts.hour, ts.minute, |
1542 | ts.typeAndTimezone); | ||
1751 | } | 1543 | } |
1752 | if (!(sb->s_flags & MS_RDONLY)) | 1544 | if (!(sb->s_flags & MS_RDONLY)) |
1753 | udf_open_lvid(sb); | 1545 | udf_open_lvid(sb); |
@@ -1772,30 +1564,21 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1772 | sb->s_maxbytes = MAX_LFS_FILESIZE; | 1564 | sb->s_maxbytes = MAX_LFS_FILESIZE; |
1773 | return 0; | 1565 | return 0; |
1774 | 1566 | ||
1775 | error_out: | 1567 | error_out: |
1776 | if (UDF_SB_VAT(sb)) | 1568 | if (UDF_SB_VAT(sb)) |
1777 | iput(UDF_SB_VAT(sb)); | 1569 | iput(UDF_SB_VAT(sb)); |
1778 | if (UDF_SB_NUMPARTS(sb)) { | 1570 | if (UDF_SB_NUMPARTS(sb)) { |
1779 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & | 1571 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) |
1780 | UDF_PART_FLAG_UNALLOC_TABLE) | 1572 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table); |
1781 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace. | 1573 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) |
1782 | s_table); | 1574 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table); |
1783 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & | 1575 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) |
1784 | UDF_PART_FLAG_FREED_TABLE) | 1576 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_uspace); |
1785 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace. | 1577 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) |
1786 | s_table); | 1578 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_fspace); |
1787 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & | 1579 | if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) { |
1788 | UDF_PART_FLAG_UNALLOC_BITMAP) | ||
1789 | UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace); | ||
1790 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & | ||
1791 | UDF_PART_FLAG_FREED_BITMAP) | ||
1792 | UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_fspace); | ||
1793 | if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == | ||
1794 | UDF_SPARABLE_MAP15) { | ||
1795 | for (i = 0; i < 4; i++) | 1580 | for (i = 0; i < 4; i++) |
1796 | brelse(UDF_SB_TYPESPAR | 1581 | brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]); |
1797 | (sb, | ||
1798 | UDF_SB_PARTITION(sb)).s_spar_map[i]); | ||
1799 | } | 1582 | } |
1800 | } | 1583 | } |
1801 | #ifdef CONFIG_UDF_NLS | 1584 | #ifdef CONFIG_UDF_NLS |
@@ -1808,6 +1591,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1808 | UDF_SB_FREE(sb); | 1591 | UDF_SB_FREE(sb); |
1809 | kfree(sbi); | 1592 | kfree(sbi); |
1810 | sb->s_fs_info = NULL; | 1593 | sb->s_fs_info = NULL; |
1594 | |||
1811 | return -EINVAL; | 1595 | return -EINVAL; |
1812 | } | 1596 | } |
1813 | 1597 | ||
@@ -1823,8 +1607,8 @@ void udf_error(struct super_block *sb, const char *function, | |||
1823 | va_start(args, fmt); | 1607 | va_start(args, fmt); |
1824 | vsnprintf(error_buf, sizeof(error_buf), fmt, args); | 1608 | vsnprintf(error_buf, sizeof(error_buf), fmt, args); |
1825 | va_end(args); | 1609 | va_end(args); |
1826 | printk(KERN_CRIT "UDF-fs error (device %s): %s: %s\n", | 1610 | printk (KERN_CRIT "UDF-fs error (device %s): %s: %s\n", |
1827 | sb->s_id, function, error_buf); | 1611 | sb->s_id, function, error_buf); |
1828 | } | 1612 | } |
1829 | 1613 | ||
1830 | void udf_warning(struct super_block *sb, const char *function, | 1614 | void udf_warning(struct super_block *sb, const char *function, |
@@ -1859,26 +1643,17 @@ static void udf_put_super(struct super_block *sb) | |||
1859 | if (UDF_SB_VAT(sb)) | 1643 | if (UDF_SB_VAT(sb)) |
1860 | iput(UDF_SB_VAT(sb)); | 1644 | iput(UDF_SB_VAT(sb)); |
1861 | if (UDF_SB_NUMPARTS(sb)) { | 1645 | if (UDF_SB_NUMPARTS(sb)) { |
1862 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & | 1646 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) |
1863 | UDF_PART_FLAG_UNALLOC_TABLE) | 1647 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table); |
1864 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace. | 1648 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) |
1865 | s_table); | 1649 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table); |
1866 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & | 1650 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) |
1867 | UDF_PART_FLAG_FREED_TABLE) | 1651 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_uspace); |
1868 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace. | 1652 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) |
1869 | s_table); | 1653 | UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_fspace); |
1870 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & | 1654 | if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) { |
1871 | UDF_PART_FLAG_UNALLOC_BITMAP) | ||
1872 | UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace); | ||
1873 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & | ||
1874 | UDF_PART_FLAG_FREED_BITMAP) | ||
1875 | UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_fspace); | ||
1876 | if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == | ||
1877 | UDF_SPARABLE_MAP15) { | ||
1878 | for (i = 0; i < 4; i++) | 1655 | for (i = 0; i < 4; i++) |
1879 | brelse(UDF_SB_TYPESPAR | 1656 | brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]); |
1880 | (sb, | ||
1881 | UDF_SB_PARTITION(sb)).s_spar_map[i]); | ||
1882 | } | 1657 | } |
1883 | } | 1658 | } |
1884 | #ifdef CONFIG_UDF_NLS | 1659 | #ifdef CONFIG_UDF_NLS |
@@ -1917,8 +1692,7 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
1917 | buf->f_bavail = buf->f_bfree; | 1692 | buf->f_bavail = buf->f_bfree; |
1918 | buf->f_files = (UDF_SB_LVIDBH(sb) ? | 1693 | buf->f_files = (UDF_SB_LVIDBH(sb) ? |
1919 | (le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + | 1694 | (le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + |
1920 | le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)) : 0) + | 1695 | le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)) : 0) + buf->f_bfree; |
1921 | buf->f_bfree; | ||
1922 | buf->f_ffree = buf->f_bfree; | 1696 | buf->f_ffree = buf->f_bfree; |
1923 | /* __kernel_fsid_t f_fsid */ | 1697 | /* __kernel_fsid_t f_fsid */ |
1924 | buf->f_namelen = UDF_NAME_LEN - 2; | 1698 | buf->f_namelen = UDF_NAME_LEN - 2; |
@@ -1930,8 +1704,7 @@ static unsigned char udf_bitmap_lookup[16] = { | |||
1930 | 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 | 1704 | 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 |
1931 | }; | 1705 | }; |
1932 | 1706 | ||
1933 | static unsigned int | 1707 | static unsigned int udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap) |
1934 | udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap) | ||
1935 | { | 1708 | { |
1936 | struct buffer_head *bh = NULL; | 1709 | struct buffer_head *bh = NULL; |
1937 | unsigned int accum = 0; | 1710 | unsigned int accum = 0; |
@@ -1961,8 +1734,8 @@ udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap) | |||
1961 | 1734 | ||
1962 | bm = (struct spaceBitmapDesc *)bh->b_data; | 1735 | bm = (struct spaceBitmapDesc *)bh->b_data; |
1963 | bytes = le32_to_cpu(bm->numOfBytes); | 1736 | bytes = le32_to_cpu(bm->numOfBytes); |
1964 | index = sizeof(struct spaceBitmapDesc); /* offset in first block only */ | 1737 | index = sizeof(struct spaceBitmapDesc); /* offset in first block only */ |
1965 | ptr = (uint8_t *) bh->b_data; | 1738 | ptr = (uint8_t *)bh->b_data; |
1966 | 1739 | ||
1967 | while (bytes > 0) { | 1740 | while (bytes > 0) { |
1968 | while ((bytes > 0) && (index < sb->s_blocksize)) { | 1741 | while ((bytes > 0) && (index < sb->s_blocksize)) { |
@@ -1981,19 +1754,18 @@ udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap) | |||
1981 | goto out; | 1754 | goto out; |
1982 | } | 1755 | } |
1983 | index = 0; | 1756 | index = 0; |
1984 | ptr = (uint8_t *) bh->b_data; | 1757 | ptr = (uint8_t *)bh->b_data; |
1985 | } | 1758 | } |
1986 | } | 1759 | } |
1987 | brelse(bh); | 1760 | brelse(bh); |
1988 | 1761 | ||
1989 | out: | 1762 | out: |
1990 | unlock_kernel(); | 1763 | unlock_kernel(); |
1991 | 1764 | ||
1992 | return accum; | 1765 | return accum; |
1993 | } | 1766 | } |
1994 | 1767 | ||
1995 | static unsigned int | 1768 | static unsigned int udf_count_free_table(struct super_block *sb, struct inode *table) |
1996 | udf_count_free_table(struct super_block *sb, struct inode *table) | ||
1997 | { | 1769 | { |
1998 | unsigned int accum = 0; | 1770 | unsigned int accum = 0; |
1999 | uint32_t elen; | 1771 | uint32_t elen; |
@@ -2007,8 +1779,9 @@ udf_count_free_table(struct super_block *sb, struct inode *table) | |||
2007 | epos.offset = sizeof(struct unallocSpaceEntry); | 1779 | epos.offset = sizeof(struct unallocSpaceEntry); |
2008 | epos.bh = NULL; | 1780 | epos.bh = NULL; |
2009 | 1781 | ||
2010 | while ((etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) | 1782 | while ((etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { |
2011 | accum += (elen >> table->i_sb->s_blocksize_bits); | 1783 | accum += (elen >> table->i_sb->s_blocksize_bits); |
1784 | } | ||
2012 | brelse(epos.bh); | 1785 | brelse(epos.bh); |
2013 | 1786 | ||
2014 | unlock_kernel(); | 1787 | unlock_kernel(); |
@@ -2021,12 +1794,8 @@ static unsigned int udf_count_free(struct super_block *sb) | |||
2021 | unsigned int accum = 0; | 1794 | unsigned int accum = 0; |
2022 | 1795 | ||
2023 | if (UDF_SB_LVIDBH(sb)) { | 1796 | if (UDF_SB_LVIDBH(sb)) { |
2024 | if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > | 1797 | if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > UDF_SB_PARTITION(sb)) { |
2025 | UDF_SB_PARTITION(sb)) { | 1798 | accum = le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]); |
2026 | accum = | ||
2027 | le32_to_cpu(UDF_SB_LVID(sb)-> | ||
2028 | freeSpaceTable[UDF_SB_PARTITION(sb)]); | ||
2029 | |||
2030 | if (accum == 0xFFFFFFFF) | 1799 | if (accum == 0xFFFFFFFF) |
2031 | accum = 0; | 1800 | accum = 0; |
2032 | } | 1801 | } |
@@ -2035,40 +1804,24 @@ static unsigned int udf_count_free(struct super_block *sb) | |||
2035 | if (accum) | 1804 | if (accum) |
2036 | return accum; | 1805 | return accum; |
2037 | 1806 | ||
2038 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & | 1807 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) { |
2039 | UDF_PART_FLAG_UNALLOC_BITMAP) { | 1808 | accum += udf_count_free_bitmap(sb, |
2040 | accum += | 1809 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_bitmap); |
2041 | udf_count_free_bitmap(sb, | ||
2042 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION | ||
2043 | (sb)].s_uspace. | ||
2044 | s_bitmap); | ||
2045 | } | 1810 | } |
2046 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & | 1811 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) { |
2047 | UDF_PART_FLAG_FREED_BITMAP) { | 1812 | accum += udf_count_free_bitmap(sb, |
2048 | accum += | 1813 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_bitmap); |
2049 | udf_count_free_bitmap(sb, | ||
2050 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION | ||
2051 | (sb)].s_fspace. | ||
2052 | s_bitmap); | ||
2053 | } | 1814 | } |
2054 | if (accum) | 1815 | if (accum) |
2055 | return accum; | 1816 | return accum; |
2056 | 1817 | ||
2057 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & | 1818 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) { |
2058 | UDF_PART_FLAG_UNALLOC_TABLE) { | 1819 | accum += udf_count_free_table(sb, |
2059 | accum += | 1820 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table); |
2060 | udf_count_free_table(sb, | ||
2061 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION | ||
2062 | (sb)].s_uspace. | ||
2063 | s_table); | ||
2064 | } | 1821 | } |
2065 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & | 1822 | if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) { |
2066 | UDF_PART_FLAG_FREED_TABLE) { | 1823 | accum += udf_count_free_table(sb, |
2067 | accum += | 1824 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table); |
2068 | udf_count_free_table(sb, | ||
2069 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION | ||
2070 | (sb)].s_fspace. | ||
2071 | s_table); | ||
2072 | } | 1825 | } |
2073 | 1826 | ||
2074 | return accum; | 1827 | return accum; |
diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c index c4b82a920082..e6f933dd6a7b 100644 --- a/fs/udf/symlink.c +++ b/fs/udf/symlink.c | |||
@@ -11,7 +11,7 @@ | |||
11 | * Each contributing author retains all rights to their own work. | 11 | * Each contributing author retains all rights to their own work. |
12 | * | 12 | * |
13 | * (C) 1998-2001 Ben Fennema | 13 | * (C) 1998-2001 Ben Fennema |
14 | * (C) 1999 Stelias Computing Inc | 14 | * (C) 1999 Stelias Computing Inc |
15 | * | 15 | * |
16 | * HISTORY | 16 | * HISTORY |
17 | * | 17 | * |
@@ -33,8 +33,7 @@ | |||
33 | #include <linux/buffer_head.h> | 33 | #include <linux/buffer_head.h> |
34 | #include "udf_i.h" | 34 | #include "udf_i.h" |
35 | 35 | ||
36 | static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen, | 36 | static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen, char *to) |
37 | char *to) | ||
38 | { | 37 | { |
39 | struct pathComponent *pc; | 38 | struct pathComponent *pc; |
40 | int elen = 0; | 39 | int elen = 0; |
@@ -81,9 +80,9 @@ static int udf_symlink_filler(struct file *file, struct page *page) | |||
81 | char *p = kmap(page); | 80 | char *p = kmap(page); |
82 | 81 | ||
83 | lock_kernel(); | 82 | lock_kernel(); |
84 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) | 83 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { |
85 | symlink = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode); | 84 | symlink = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode); |
86 | else { | 85 | } else { |
87 | bh = sb_bread(inode->i_sb, udf_block_map(inode, 0)); | 86 | bh = sb_bread(inode->i_sb, udf_block_map(inode, 0)); |
88 | 87 | ||
89 | if (!bh) | 88 | if (!bh) |
@@ -100,7 +99,8 @@ static int udf_symlink_filler(struct file *file, struct page *page) | |||
100 | kunmap(page); | 99 | kunmap(page); |
101 | unlock_page(page); | 100 | unlock_page(page); |
102 | return 0; | 101 | return 0; |
103 | out: | 102 | |
103 | out: | ||
104 | unlock_kernel(); | 104 | unlock_kernel(); |
105 | SetPageError(page); | 105 | SetPageError(page); |
106 | kunmap(page); | 106 | kunmap(page); |
@@ -112,5 +112,5 @@ static int udf_symlink_filler(struct file *file, struct page *page) | |||
112 | * symlinks can't do much... | 112 | * symlinks can't do much... |
113 | */ | 113 | */ |
114 | const struct address_space_operations udf_symlink_aops = { | 114 | const struct address_space_operations udf_symlink_aops = { |
115 | .readpage = udf_symlink_filler, | 115 | .readpage = udf_symlink_filler, |
116 | }; | 116 | }; |
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c index b2002da0a5c0..7fc3912885a5 100644 --- a/fs/udf/truncate.c +++ b/fs/udf/truncate.c | |||
@@ -32,13 +32,11 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos, | |||
32 | kernel_lb_addr eloc, int8_t etype, uint32_t elen, | 32 | kernel_lb_addr eloc, int8_t etype, uint32_t elen, |
33 | uint32_t nelen) | 33 | uint32_t nelen) |
34 | { | 34 | { |
35 | kernel_lb_addr neloc = { 0, 0 }; | 35 | kernel_lb_addr neloc = {}; |
36 | int last_block = | 36 | int last_block = (elen + inode->i_sb->s_blocksize - 1) >> |
37 | (elen + inode->i_sb->s_blocksize - | 37 | inode->i_sb->s_blocksize_bits; |
38 | 1) >> inode->i_sb->s_blocksize_bits; | 38 | int first_block = (nelen + inode->i_sb->s_blocksize - 1) >> |
39 | int first_block = | 39 | inode->i_sb->s_blocksize_bits; |
40 | (nelen + inode->i_sb->s_blocksize - | ||
41 | 1) >> inode->i_sb->s_blocksize_bits; | ||
42 | 40 | ||
43 | if (nelen) { | 41 | if (nelen) { |
44 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | 42 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { |
@@ -70,7 +68,7 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos, | |||
70 | */ | 68 | */ |
71 | void udf_truncate_tail_extent(struct inode *inode) | 69 | void udf_truncate_tail_extent(struct inode *inode) |
72 | { | 70 | { |
73 | struct extent_position epos = { NULL, 0, {0, 0} }; | 71 | struct extent_position epos = {}; |
74 | kernel_lb_addr eloc; | 72 | kernel_lb_addr eloc; |
75 | uint32_t elen, nelen; | 73 | uint32_t elen, nelen; |
76 | uint64_t lbcount = 0; | 74 | uint64_t lbcount = 0; |
@@ -156,16 +154,16 @@ void udf_discard_prealloc(struct inode *inode) | |||
156 | extent_trunc(inode, &epos, eloc, etype, elen, 0); | 154 | extent_trunc(inode, &epos, eloc, etype, elen, 0); |
157 | if (!epos.bh) { | 155 | if (!epos.bh) { |
158 | UDF_I_LENALLOC(inode) = | 156 | UDF_I_LENALLOC(inode) = |
159 | epos.offset - udf_file_entry_alloc_offset(inode); | 157 | epos.offset - udf_file_entry_alloc_offset(inode); |
160 | mark_inode_dirty(inode); | 158 | mark_inode_dirty(inode); |
161 | } else { | 159 | } else { |
162 | struct allocExtDesc *aed = | 160 | struct allocExtDesc *aed = |
163 | (struct allocExtDesc *)(epos.bh->b_data); | 161 | (struct allocExtDesc *)(epos.bh->b_data); |
164 | aed->lengthAllocDescs = | 162 | aed->lengthAllocDescs = |
165 | cpu_to_le32(epos.offset - | 163 | cpu_to_le32(epos.offset - |
166 | sizeof(struct allocExtDesc)); | 164 | sizeof(struct allocExtDesc)); |
167 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) | 165 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
168 | || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 166 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) |
169 | udf_update_tag(epos.bh->b_data, epos.offset); | 167 | udf_update_tag(epos.bh->b_data, epos.offset); |
170 | else | 168 | else |
171 | udf_update_tag(epos.bh->b_data, | 169 | udf_update_tag(epos.bh->b_data, |
@@ -182,7 +180,7 @@ void udf_discard_prealloc(struct inode *inode) | |||
182 | void udf_truncate_extents(struct inode *inode) | 180 | void udf_truncate_extents(struct inode *inode) |
183 | { | 181 | { |
184 | struct extent_position epos; | 182 | struct extent_position epos; |
185 | kernel_lb_addr eloc, neloc = { 0, 0 }; | 183 | kernel_lb_addr eloc, neloc = {}; |
186 | uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc; | 184 | uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc; |
187 | int8_t etype; | 185 | int8_t etype; |
188 | struct super_block *sb = inode->i_sb; | 186 | struct super_block *sb = inode->i_sb; |
@@ -198,9 +196,8 @@ void udf_truncate_extents(struct inode *inode) | |||
198 | BUG(); | 196 | BUG(); |
199 | 197 | ||
200 | etype = inode_bmap(inode, first_block, &epos, &eloc, &elen, &offset); | 198 | etype = inode_bmap(inode, first_block, &epos, &eloc, &elen, &offset); |
201 | byte_offset = | 199 | byte_offset = (offset << sb->s_blocksize_bits) + |
202 | (offset << sb->s_blocksize_bits) + | 200 | (inode->i_size & (sb->s_blocksize - 1)); |
203 | (inode->i_size & (sb->s_blocksize - 1)); | ||
204 | if (etype != -1) { | 201 | if (etype != -1) { |
205 | epos.offset -= adsize; | 202 | epos.offset -= adsize; |
206 | extent_trunc(inode, &epos, eloc, etype, elen, byte_offset); | 203 | extent_trunc(inode, &epos, eloc, etype, elen, byte_offset); |
@@ -215,9 +212,7 @@ void udf_truncate_extents(struct inode *inode) | |||
215 | else | 212 | else |
216 | lenalloc -= sizeof(struct allocExtDesc); | 213 | lenalloc -= sizeof(struct allocExtDesc); |
217 | 214 | ||
218 | while ((etype = | 215 | while ((etype = udf_current_aext(inode, &epos, &eloc, &elen, 0)) != -1) { |
219 | udf_current_aext(inode, &epos, &eloc, &elen, | ||
220 | 0)) != -1) { | ||
221 | if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) { | 216 | if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) { |
222 | udf_write_aext(inode, &epos, neloc, nelen, 0); | 217 | udf_write_aext(inode, &epos, neloc, nelen, 0); |
223 | if (indirect_ext_len) { | 218 | if (indirect_ext_len) { |
@@ -229,52 +224,35 @@ void udf_truncate_extents(struct inode *inode) | |||
229 | 0, indirect_ext_len); | 224 | 0, indirect_ext_len); |
230 | } else { | 225 | } else { |
231 | if (!epos.bh) { | 226 | if (!epos.bh) { |
232 | UDF_I_LENALLOC(inode) = | 227 | UDF_I_LENALLOC(inode) = lenalloc; |
233 | lenalloc; | ||
234 | mark_inode_dirty(inode); | 228 | mark_inode_dirty(inode); |
235 | } else { | 229 | } else { |
236 | struct allocExtDesc *aed = | 230 | struct allocExtDesc *aed = |
237 | (struct allocExtDesc | 231 | (struct allocExtDesc *)(epos.bh->b_data); |
238 | *)(epos.bh->b_data); | ||
239 | aed->lengthAllocDescs = | 232 | aed->lengthAllocDescs = |
240 | cpu_to_le32(lenalloc); | 233 | cpu_to_le32(lenalloc); |
241 | if (!UDF_QUERY_FLAG | 234 | if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) || |
242 | (sb, UDF_FLAG_STRICT) | 235 | UDF_SB_UDFREV(sb) >= 0x0201) |
243 | || UDF_SB_UDFREV(sb) >= | 236 | udf_update_tag(epos.bh->b_data, |
244 | 0x0201) | 237 | lenalloc + |
245 | udf_update_tag(epos.bh-> | 238 | sizeof(struct allocExtDesc)); |
246 | b_data, | ||
247 | lenalloc | ||
248 | + | ||
249 | sizeof | ||
250 | (struct | ||
251 | allocExtDesc)); | ||
252 | else | 239 | else |
253 | udf_update_tag(epos.bh-> | 240 | udf_update_tag(epos.bh->b_data, |
254 | b_data, | 241 | sizeof(struct allocExtDesc)); |
255 | sizeof | 242 | mark_buffer_dirty_inode(epos.bh, inode); |
256 | (struct | ||
257 | allocExtDesc)); | ||
258 | mark_buffer_dirty_inode(epos.bh, | ||
259 | inode); | ||
260 | } | 243 | } |
261 | } | 244 | } |
262 | brelse(epos.bh); | 245 | brelse(epos.bh); |
263 | epos.offset = sizeof(struct allocExtDesc); | 246 | epos.offset = sizeof(struct allocExtDesc); |
264 | epos.block = eloc; | 247 | epos.block = eloc; |
265 | epos.bh = | 248 | epos.bh = udf_tread(sb, udf_get_lb_pblock(sb, eloc, 0)); |
266 | udf_tread(sb, | ||
267 | udf_get_lb_pblock(sb, eloc, 0)); | ||
268 | if (elen) | 249 | if (elen) |
269 | indirect_ext_len = (elen + | 250 | indirect_ext_len = (elen + sb->s_blocksize -1) >> |
270 | sb->s_blocksize - | 251 | sb->s_blocksize_bits; |
271 | 1) >> sb-> | ||
272 | s_blocksize_bits; | ||
273 | else | 252 | else |
274 | indirect_ext_len = 1; | 253 | indirect_ext_len = 1; |
275 | } else { | 254 | } else { |
276 | extent_trunc(inode, &epos, eloc, etype, elen, | 255 | extent_trunc(inode, &epos, eloc, etype, elen, 0); |
277 | 0); | ||
278 | epos.offset += adsize; | 256 | epos.offset += adsize; |
279 | } | 257 | } |
280 | } | 258 | } |
@@ -292,16 +270,13 @@ void udf_truncate_extents(struct inode *inode) | |||
292 | struct allocExtDesc *aed = | 270 | struct allocExtDesc *aed = |
293 | (struct allocExtDesc *)(epos.bh->b_data); | 271 | (struct allocExtDesc *)(epos.bh->b_data); |
294 | aed->lengthAllocDescs = cpu_to_le32(lenalloc); | 272 | aed->lengthAllocDescs = cpu_to_le32(lenalloc); |
295 | if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) | 273 | if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) || |
296 | || UDF_SB_UDFREV(sb) >= 0x0201) | 274 | UDF_SB_UDFREV(sb) >= 0x0201) |
297 | udf_update_tag(epos.bh->b_data, | 275 | udf_update_tag(epos.bh->b_data, |
298 | lenalloc + | 276 | lenalloc + sizeof(struct allocExtDesc)); |
299 | sizeof(struct | ||
300 | allocExtDesc)); | ||
301 | else | 277 | else |
302 | udf_update_tag(epos.bh->b_data, | 278 | udf_update_tag(epos.bh->b_data, |
303 | sizeof(struct | 279 | sizeof(struct allocExtDesc)); |
304 | allocExtDesc)); | ||
305 | mark_buffer_dirty_inode(epos.bh, inode); | 280 | mark_buffer_dirty_inode(epos.bh, inode); |
306 | } | 281 | } |
307 | } | 282 | } |
@@ -314,21 +289,14 @@ void udf_truncate_extents(struct inode *inode) | |||
314 | * no extent above inode->i_size => truncate is | 289 | * no extent above inode->i_size => truncate is |
315 | * extending the file by 'offset' blocks. | 290 | * extending the file by 'offset' blocks. |
316 | */ | 291 | */ |
317 | if ((!epos.bh | 292 | if ((!epos.bh && |
318 | && epos.offset == | 293 | epos.offset == udf_file_entry_alloc_offset(inode)) || |
319 | udf_file_entry_alloc_offset(inode)) || (epos.bh | 294 | (epos.bh && epos.offset == sizeof(struct allocExtDesc))) { |
320 | && epos. | ||
321 | offset == | ||
322 | sizeof | ||
323 | (struct | ||
324 | allocExtDesc))) | ||
325 | { | ||
326 | /* File has no extents at all or has empty last | 295 | /* File has no extents at all or has empty last |
327 | * indirect extent! Create a fake extent... */ | 296 | * indirect extent! Create a fake extent... */ |
328 | extent.extLocation.logicalBlockNum = 0; | 297 | extent.extLocation.logicalBlockNum = 0; |
329 | extent.extLocation.partitionReferenceNum = 0; | 298 | extent.extLocation.partitionReferenceNum = 0; |
330 | extent.extLength = | 299 | extent.extLength = EXT_NOT_RECORDED_NOT_ALLOCATED; |
331 | EXT_NOT_RECORDED_NOT_ALLOCATED; | ||
332 | } else { | 300 | } else { |
333 | epos.offset -= adsize; | 301 | epos.offset -= adsize; |
334 | etype = udf_next_aext(inode, &epos, | 302 | etype = udf_next_aext(inode, &epos, |
@@ -337,10 +305,7 @@ void udf_truncate_extents(struct inode *inode) | |||
337 | extent.extLength |= etype << 30; | 305 | extent.extLength |= etype << 30; |
338 | } | 306 | } |
339 | udf_extend_file(inode, &epos, &extent, | 307 | udf_extend_file(inode, &epos, &extent, |
340 | offset + | 308 | offset + ((inode->i_size & (sb->s_blocksize - 1)) != 0)); |
341 | ((inode-> | ||
342 | i_size & (sb->s_blocksize - 1)) != | ||
343 | 0)); | ||
344 | } | 309 | } |
345 | } | 310 | } |
346 | UDF_I_LENEXTENTS(inode) = inode->i_size; | 311 | UDF_I_LENEXTENTS(inode) = inode->i_size; |
diff --git a/fs/udf/udf_i.h b/fs/udf/udf_i.h index bee4308a8113..d7dbe6f3ba0c 100644 --- a/fs/udf/udf_i.h +++ b/fs/udf/udf_i.h | |||
@@ -23,4 +23,4 @@ static inline struct udf_inode_info *UDF_I(struct inode *inode) | |||
23 | #define UDF_I_LAD(X) ( UDF_I(X)->i_ext.i_lad ) | 23 | #define UDF_I_LAD(X) ( UDF_I(X)->i_ext.i_lad ) |
24 | #define UDF_I_DATA(X) ( UDF_I(X)->i_ext.i_data ) | 24 | #define UDF_I_DATA(X) ( UDF_I(X)->i_ext.i_data ) |
25 | 25 | ||
26 | #endif /* !defined(_LINUX_UDF_I_H) */ | 26 | #endif /* !defined(_LINUX_UDF_I_H) */ |
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h index 60f31d8cebee..3e937d3fb8f9 100644 --- a/fs/udf/udf_sb.h +++ b/fs/udf/udf_sb.h | |||
@@ -20,8 +20,8 @@ | |||
20 | #define UDF_FLAG_VARCONV 8 | 20 | #define UDF_FLAG_VARCONV 8 |
21 | #define UDF_FLAG_NLS_MAP 9 | 21 | #define UDF_FLAG_NLS_MAP 9 |
22 | #define UDF_FLAG_UTF8 10 | 22 | #define UDF_FLAG_UTF8 10 |
23 | #define UDF_FLAG_UID_FORGET 11 /* save -1 for uid to disk */ | 23 | #define UDF_FLAG_UID_FORGET 11 /* save -1 for uid to disk */ |
24 | #define UDF_FLAG_UID_IGNORE 12 /* use sb uid instead of on disk uid */ | 24 | #define UDF_FLAG_UID_IGNORE 12 /* use sb uid instead of on disk uid */ |
25 | #define UDF_FLAG_GID_FORGET 13 | 25 | #define UDF_FLAG_GID_FORGET 13 |
26 | #define UDF_FLAG_GID_IGNORE 14 | 26 | #define UDF_FLAG_GID_IGNORE 14 |
27 | 27 | ||
@@ -41,8 +41,7 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb) | |||
41 | 41 | ||
42 | #define UDF_SB_FREE(X)\ | 42 | #define UDF_SB_FREE(X)\ |
43 | {\ | 43 | {\ |
44 | if (UDF_SB(X))\ | 44 | if (UDF_SB(X)) {\ |
45 | {\ | ||
46 | kfree(UDF_SB_PARTMAPS(X));\ | 45 | kfree(UDF_SB_PARTMAPS(X));\ |
47 | UDF_SB_PARTMAPS(X) = NULL;\ | 46 | UDF_SB_PARTMAPS(X) = NULL;\ |
48 | }\ | 47 | }\ |
@@ -51,13 +50,10 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb) | |||
51 | #define UDF_SB_ALLOC_PARTMAPS(X,Y)\ | 50 | #define UDF_SB_ALLOC_PARTMAPS(X,Y)\ |
52 | {\ | 51 | {\ |
53 | UDF_SB_PARTMAPS(X) = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\ | 52 | UDF_SB_PARTMAPS(X) = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\ |
54 | if (UDF_SB_PARTMAPS(X) != NULL)\ | 53 | if (UDF_SB_PARTMAPS(X) != NULL) {\ |
55 | {\ | ||
56 | UDF_SB_NUMPARTS(X) = Y;\ | 54 | UDF_SB_NUMPARTS(X) = Y;\ |
57 | memset(UDF_SB_PARTMAPS(X), 0x00, sizeof(struct udf_part_map) * Y);\ | 55 | memset(UDF_SB_PARTMAPS(X), 0x00, sizeof(struct udf_part_map) * Y);\ |
58 | }\ | 56 | } else {\ |
59 | else\ | ||
60 | {\ | ||
61 | UDF_SB_NUMPARTS(X) = 0;\ | 57 | UDF_SB_NUMPARTS(X) = 0;\ |
62 | udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\ | 58 | udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\ |
63 | }\ | 59 | }\ |
@@ -72,15 +68,12 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb) | |||
72 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = kmalloc(size, GFP_KERNEL);\ | 68 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = kmalloc(size, GFP_KERNEL);\ |
73 | else\ | 69 | else\ |
74 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = vmalloc(size);\ | 70 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = vmalloc(size);\ |
75 | if (UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap != NULL)\ | 71 | if (UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap != NULL) {\ |
76 | {\ | ||
77 | memset(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap, 0x00, size);\ | 72 | memset(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap, 0x00, size);\ |
78 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_block_bitmap =\ | 73 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_block_bitmap =\ |
79 | (struct buffer_head **)(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap + 1);\ | 74 | (struct buffer_head **)(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap + 1);\ |
80 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_nr_groups = nr_groups;\ | 75 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_nr_groups = nr_groups;\ |
81 | }\ | 76 | } else {\ |
82 | else\ | ||
83 | {\ | ||
84 | udf_error(X, __FUNCTION__, "Unable to allocate space for bitmap and %d buffer_head pointers", nr_groups);\ | 77 | udf_error(X, __FUNCTION__, "Unable to allocate space for bitmap and %d buffer_head pointers", nr_groups);\ |
85 | }\ | 78 | }\ |
86 | } | 79 | } |
@@ -90,8 +83,7 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb) | |||
90 | int i;\ | 83 | int i;\ |
91 | int nr_groups = UDF_SB_BITMAP_NR_GROUPS(X,Y,Z);\ | 84 | int nr_groups = UDF_SB_BITMAP_NR_GROUPS(X,Y,Z);\ |
92 | int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);\ | 85 | int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);\ |
93 | for (i=0; i<nr_groups; i++)\ | 86 | for (i = 0; i < nr_groups; i++) {\ |
94 | {\ | ||
95 | if (UDF_SB_BITMAP(X,Y,Z,i))\ | 87 | if (UDF_SB_BITMAP(X,Y,Z,i))\ |
96 | brelse(UDF_SB_BITMAP(X,Y,Z,i));\ | 88 | brelse(UDF_SB_BITMAP(X,Y,Z,i));\ |
97 | }\ | 89 | }\ |
@@ -139,4 +131,4 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb) | |||
139 | #define UDF_SB_FLAGS(X) ( UDF_SB(X)->s_flags ) | 131 | #define UDF_SB_FLAGS(X) ( UDF_SB(X)->s_flags ) |
140 | #define UDF_SB_VAT(X) ( UDF_SB(X)->s_vat ) | 132 | #define UDF_SB_VAT(X) ( UDF_SB(X)->s_vat ) |
141 | 133 | ||
142 | #endif /* __LINUX_UDF_SB_H */ | 134 | #endif /* __LINUX_UDF_SB_H */ |
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index 76f2b82a39dc..c8016cc9e7e6 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h | |||
@@ -63,8 +63,8 @@ struct udf_vds_record { | |||
63 | }; | 63 | }; |
64 | 64 | ||
65 | struct generic_desc { | 65 | struct generic_desc { |
66 | tag descTag; | 66 | tag descTag; |
67 | __le32 volDescSeqNum; | 67 | __le32 volDescSeqNum; |
68 | }; | 68 | }; |
69 | 69 | ||
70 | struct ustr { | 70 | struct ustr { |
diff --git a/fs/udf/udfend.h b/fs/udf/udfend.h index 450daab35a13..c4bd1203f857 100644 --- a/fs/udf/udfend.h +++ b/fs/udf/udfend.h | |||
@@ -7,75 +7,93 @@ | |||
7 | static inline kernel_lb_addr lelb_to_cpu(lb_addr in) | 7 | static inline kernel_lb_addr lelb_to_cpu(lb_addr in) |
8 | { | 8 | { |
9 | kernel_lb_addr out; | 9 | kernel_lb_addr out; |
10 | |||
10 | out.logicalBlockNum = le32_to_cpu(in.logicalBlockNum); | 11 | out.logicalBlockNum = le32_to_cpu(in.logicalBlockNum); |
11 | out.partitionReferenceNum = le16_to_cpu(in.partitionReferenceNum); | 12 | out.partitionReferenceNum = le16_to_cpu(in.partitionReferenceNum); |
13 | |||
12 | return out; | 14 | return out; |
13 | } | 15 | } |
14 | 16 | ||
15 | static inline lb_addr cpu_to_lelb(kernel_lb_addr in) | 17 | static inline lb_addr cpu_to_lelb(kernel_lb_addr in) |
16 | { | 18 | { |
17 | lb_addr out; | 19 | lb_addr out; |
20 | |||
18 | out.logicalBlockNum = cpu_to_le32(in.logicalBlockNum); | 21 | out.logicalBlockNum = cpu_to_le32(in.logicalBlockNum); |
19 | out.partitionReferenceNum = cpu_to_le16(in.partitionReferenceNum); | 22 | out.partitionReferenceNum = cpu_to_le16(in.partitionReferenceNum); |
23 | |||
20 | return out; | 24 | return out; |
21 | } | 25 | } |
22 | 26 | ||
23 | static inline kernel_timestamp lets_to_cpu(timestamp in) | 27 | static inline kernel_timestamp lets_to_cpu(timestamp in) |
24 | { | 28 | { |
25 | kernel_timestamp out; | 29 | kernel_timestamp out; |
30 | |||
26 | memcpy(&out, &in, sizeof(timestamp)); | 31 | memcpy(&out, &in, sizeof(timestamp)); |
27 | out.typeAndTimezone = le16_to_cpu(in.typeAndTimezone); | 32 | out.typeAndTimezone = le16_to_cpu(in.typeAndTimezone); |
28 | out.year = le16_to_cpu(in.year); | 33 | out.year = le16_to_cpu(in.year); |
34 | |||
29 | return out; | 35 | return out; |
30 | } | 36 | } |
31 | 37 | ||
32 | static inline short_ad lesa_to_cpu(short_ad in) | 38 | static inline short_ad lesa_to_cpu(short_ad in) |
33 | { | 39 | { |
34 | short_ad out; | 40 | short_ad out; |
41 | |||
35 | out.extLength = le32_to_cpu(in.extLength); | 42 | out.extLength = le32_to_cpu(in.extLength); |
36 | out.extPosition = le32_to_cpu(in.extPosition); | 43 | out.extPosition = le32_to_cpu(in.extPosition); |
44 | |||
37 | return out; | 45 | return out; |
38 | } | 46 | } |
39 | 47 | ||
40 | static inline short_ad cpu_to_lesa(short_ad in) | 48 | static inline short_ad cpu_to_lesa(short_ad in) |
41 | { | 49 | { |
42 | short_ad out; | 50 | short_ad out; |
51 | |||
43 | out.extLength = cpu_to_le32(in.extLength); | 52 | out.extLength = cpu_to_le32(in.extLength); |
44 | out.extPosition = cpu_to_le32(in.extPosition); | 53 | out.extPosition = cpu_to_le32(in.extPosition); |
54 | |||
45 | return out; | 55 | return out; |
46 | } | 56 | } |
47 | 57 | ||
48 | static inline kernel_long_ad lela_to_cpu(long_ad in) | 58 | static inline kernel_long_ad lela_to_cpu(long_ad in) |
49 | { | 59 | { |
50 | kernel_long_ad out; | 60 | kernel_long_ad out; |
61 | |||
51 | out.extLength = le32_to_cpu(in.extLength); | 62 | out.extLength = le32_to_cpu(in.extLength); |
52 | out.extLocation = lelb_to_cpu(in.extLocation); | 63 | out.extLocation = lelb_to_cpu(in.extLocation); |
64 | |||
53 | return out; | 65 | return out; |
54 | } | 66 | } |
55 | 67 | ||
56 | static inline long_ad cpu_to_lela(kernel_long_ad in) | 68 | static inline long_ad cpu_to_lela(kernel_long_ad in) |
57 | { | 69 | { |
58 | long_ad out; | 70 | long_ad out; |
71 | |||
59 | out.extLength = cpu_to_le32(in.extLength); | 72 | out.extLength = cpu_to_le32(in.extLength); |
60 | out.extLocation = cpu_to_lelb(in.extLocation); | 73 | out.extLocation = cpu_to_lelb(in.extLocation); |
74 | |||
61 | return out; | 75 | return out; |
62 | } | 76 | } |
63 | 77 | ||
64 | static inline kernel_extent_ad leea_to_cpu(extent_ad in) | 78 | static inline kernel_extent_ad leea_to_cpu(extent_ad in) |
65 | { | 79 | { |
66 | kernel_extent_ad out; | 80 | kernel_extent_ad out; |
81 | |||
67 | out.extLength = le32_to_cpu(in.extLength); | 82 | out.extLength = le32_to_cpu(in.extLength); |
68 | out.extLocation = le32_to_cpu(in.extLocation); | 83 | out.extLocation = le32_to_cpu(in.extLocation); |
84 | |||
69 | return out; | 85 | return out; |
70 | } | 86 | } |
71 | 87 | ||
72 | static inline timestamp cpu_to_lets(kernel_timestamp in) | 88 | static inline timestamp cpu_to_lets(kernel_timestamp in) |
73 | { | 89 | { |
74 | timestamp out; | 90 | timestamp out; |
91 | |||
75 | memcpy(&out, &in, sizeof(timestamp)); | 92 | memcpy(&out, &in, sizeof(timestamp)); |
76 | out.typeAndTimezone = cpu_to_le16(in.typeAndTimezone); | 93 | out.typeAndTimezone = cpu_to_le16(in.typeAndTimezone); |
77 | out.year = cpu_to_le16(in.year); | 94 | out.year = cpu_to_le16(in.year); |
95 | |||
78 | return out; | 96 | return out; |
79 | } | 97 | } |
80 | 98 | ||
81 | #endif /* __UDF_ENDIAN_H */ | 99 | #endif /* __UDF_ENDIAN_H */ |
diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c index b9f3198080e9..3fd80eb66af3 100644 --- a/fs/udf/udftime.c +++ b/fs/udf/udftime.c | |||
@@ -18,18 +18,18 @@ | |||
18 | Boston, MA 02111-1307, USA. */ | 18 | Boston, MA 02111-1307, USA. */ |
19 | 19 | ||
20 | /* | 20 | /* |
21 | * dgb 10/02/98: ripped this from glibc source to help convert timestamps to unix time | 21 | * dgb 10/02/98: ripped this from glibc source to help convert timestamps to unix time |
22 | * 10/04/98: added new table-based lookup after seeing how ugly the gnu code is | 22 | * 10/04/98: added new table-based lookup after seeing how ugly the gnu code is |
23 | * blf 09/27/99: ripped out all the old code and inserted new table from | 23 | * blf 09/27/99: ripped out all the old code and inserted new table from |
24 | * John Brockmeyer (without leap second corrections) | 24 | * John Brockmeyer (without leap second corrections) |
25 | * rewrote udf_stamp_to_time and fixed timezone accounting in | 25 | * rewrote udf_stamp_to_time and fixed timezone accounting in |
26 | udf_time_to_stamp. | 26 | * udf_time_to_stamp. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | /* | 29 | /* |
30 | * We don't take into account leap seconds. This may be correct or incorrect. | 30 | * We don't take into account leap seconds. This may be correct or incorrect. |
31 | * For more NIST information (especially dealing with leap seconds), see: | 31 | * For more NIST information (especially dealing with leap seconds), see: |
32 | * http://www.boulder.nist.gov/timefreq/pubs/bulletin/leapsecond.htm | 32 | * http://www.boulder.nist.gov/timefreq/pubs/bulletin/leapsecond.htm |
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <linux/types.h> | 35 | #include <linux/types.h> |
@@ -54,28 +54,28 @@ static const unsigned short int __mon_yday[2][13] = { | |||
54 | }; | 54 | }; |
55 | 55 | ||
56 | #define MAX_YEAR_SECONDS 69 | 56 | #define MAX_YEAR_SECONDS 69 |
57 | #define SPD 0x15180 /*3600*24 */ | 57 | #define SPD 0x15180 /*3600*24 */ |
58 | #define SPY(y,l,s) (SPD * (365*y+l)+s) | 58 | #define SPY(y,l,s) (SPD * (365*y+l)+s) |
59 | 59 | ||
60 | static time_t year_seconds[MAX_YEAR_SECONDS] = { | 60 | static time_t year_seconds[MAX_YEAR_SECONDS]= { |
61 | /*1970*/ SPY(0, 0, 0), SPY(1, 0, 0), SPY(2, 0, 0), SPY(3, 1, 0), | 61 | /*1970*/ SPY( 0, 0,0), SPY( 1, 0,0), SPY( 2, 0,0), SPY( 3, 1,0), |
62 | /*1974*/ SPY(4, 1, 0), SPY(5, 1, 0), SPY(6, 1, 0), SPY(7, 2, 0), | 62 | /*1974*/ SPY( 4, 1,0), SPY( 5, 1,0), SPY( 6, 1,0), SPY( 7, 2,0), |
63 | /*1978*/ SPY(8, 2, 0), SPY(9, 2, 0), SPY(10, 2, 0), SPY(11, 3, 0), | 63 | /*1978*/ SPY( 8, 2,0), SPY( 9, 2,0), SPY(10, 2,0), SPY(11, 3,0), |
64 | /*1982*/ SPY(12, 3, 0), SPY(13, 3, 0), SPY(14, 3, 0), SPY(15, 4, 0), | 64 | /*1982*/ SPY(12, 3,0), SPY(13, 3,0), SPY(14, 3,0), SPY(15, 4,0), |
65 | /*1986*/ SPY(16, 4, 0), SPY(17, 4, 0), SPY(18, 4, 0), SPY(19, 5, 0), | 65 | /*1986*/ SPY(16, 4,0), SPY(17, 4,0), SPY(18, 4,0), SPY(19, 5,0), |
66 | /*1990*/ SPY(20, 5, 0), SPY(21, 5, 0), SPY(22, 5, 0), SPY(23, 6, 0), | 66 | /*1990*/ SPY(20, 5,0), SPY(21, 5,0), SPY(22, 5,0), SPY(23, 6,0), |
67 | /*1994*/ SPY(24, 6, 0), SPY(25, 6, 0), SPY(26, 6, 0), SPY(27, 7, 0), | 67 | /*1994*/ SPY(24, 6,0), SPY(25, 6,0), SPY(26, 6,0), SPY(27, 7,0), |
68 | /*1998*/ SPY(28, 7, 0), SPY(29, 7, 0), SPY(30, 7, 0), SPY(31, 8, 0), | 68 | /*1998*/ SPY(28, 7,0), SPY(29, 7,0), SPY(30, 7,0), SPY(31, 8,0), |
69 | /*2002*/ SPY(32, 8, 0), SPY(33, 8, 0), SPY(34, 8, 0), SPY(35, 9, 0), | 69 | /*2002*/ SPY(32, 8,0), SPY(33, 8,0), SPY(34, 8,0), SPY(35, 9,0), |
70 | /*2006*/ SPY(36, 9, 0), SPY(37, 9, 0), SPY(38, 9, 0), SPY(39, 10, 0), | 70 | /*2006*/ SPY(36, 9,0), SPY(37, 9,0), SPY(38, 9,0), SPY(39,10,0), |
71 | /*2010*/ SPY(40, 10, 0), SPY(41, 10, 0), SPY(42, 10, 0), SPY(43, 11, 0), | 71 | /*2010*/ SPY(40,10,0), SPY(41,10,0), SPY(42,10,0), SPY(43,11,0), |
72 | /*2014*/ SPY(44, 11, 0), SPY(45, 11, 0), SPY(46, 11, 0), SPY(47, 12, 0), | 72 | /*2014*/ SPY(44,11,0), SPY(45,11,0), SPY(46,11,0), SPY(47,12,0), |
73 | /*2018*/ SPY(48, 12, 0), SPY(49, 12, 0), SPY(50, 12, 0), SPY(51, 13, 0), | 73 | /*2018*/ SPY(48,12,0), SPY(49,12,0), SPY(50,12,0), SPY(51,13,0), |
74 | /*2022*/ SPY(52, 13, 0), SPY(53, 13, 0), SPY(54, 13, 0), SPY(55, 14, 0), | 74 | /*2022*/ SPY(52,13,0), SPY(53,13,0), SPY(54,13,0), SPY(55,14,0), |
75 | /*2026*/ SPY(56, 14, 0), SPY(57, 14, 0), SPY(58, 14, 0), SPY(59, 15, 0), | 75 | /*2026*/ SPY(56,14,0), SPY(57,14,0), SPY(58,14,0), SPY(59,15,0), |
76 | /*2030*/ SPY(60, 15, 0), SPY(61, 15, 0), SPY(62, 15, 0), SPY(63, 16, 0), | 76 | /*2030*/ SPY(60,15,0), SPY(61,15,0), SPY(62,15,0), SPY(63,16,0), |
77 | /*2034*/ SPY(64, 16, 0), SPY(65, 16, 0), SPY(66, 16, 0), SPY(67, 17, 0), | 77 | /*2034*/ SPY(64,16,0), SPY(65,16,0), SPY(66,16,0), SPY(67,17,0), |
78 | /*2038*/ SPY(68, 17, 0) | 78 | /*2038*/ SPY(68,17,0) |
79 | }; | 79 | }; |
80 | 80 | ||
81 | extern struct timezone sys_tz; | 81 | extern struct timezone sys_tz; |
@@ -83,7 +83,7 @@ extern struct timezone sys_tz; | |||
83 | #define SECS_PER_HOUR (60 * 60) | 83 | #define SECS_PER_HOUR (60 * 60) |
84 | #define SECS_PER_DAY (SECS_PER_HOUR * 24) | 84 | #define SECS_PER_DAY (SECS_PER_HOUR * 24) |
85 | 85 | ||
86 | time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src) | 86 | time_t *udf_stamp_to_time(time_t *dest, long *dest_usec, kernel_timestamp src) |
87 | { | 87 | { |
88 | int yday; | 88 | int yday; |
89 | uint8_t type = src.typeAndTimezone >> 12; | 89 | uint8_t type = src.typeAndTimezone >> 12; |
@@ -93,10 +93,11 @@ time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src) | |||
93 | offset = src.typeAndTimezone << 4; | 93 | offset = src.typeAndTimezone << 4; |
94 | /* sign extent offset */ | 94 | /* sign extent offset */ |
95 | offset = (offset >> 4); | 95 | offset = (offset >> 4); |
96 | if (offset == -2047) /* unspecified offset */ | 96 | if (offset == -2047) /* unspecified offset */ |
97 | offset = 0; | 97 | offset = 0; |
98 | } else | 98 | } else { |
99 | offset = 0; | 99 | offset = 0; |
100 | } | ||
100 | 101 | ||
101 | if ((src.year < EPOCH_YEAR) || | 102 | if ((src.year < EPOCH_YEAR) || |
102 | (src.year >= EPOCH_YEAR + MAX_YEAR_SECONDS)) { | 103 | (src.year >= EPOCH_YEAR + MAX_YEAR_SECONDS)) { |
@@ -107,12 +108,10 @@ time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src) | |||
107 | *dest = year_seconds[src.year - EPOCH_YEAR]; | 108 | *dest = year_seconds[src.year - EPOCH_YEAR]; |
108 | *dest -= offset * 60; | 109 | *dest -= offset * 60; |
109 | 110 | ||
110 | yday = ((__mon_yday[__isleap(src.year)] | 111 | yday = ((__mon_yday[__isleap (src.year)] |
111 | [src.month - 1]) + (src.day - 1)); | 112 | [src.month - 1]) + (src.day - 1)); |
112 | *dest += (((yday * 24) + src.hour) * 60 + src.minute) * 60 + src.second; | 113 | *dest += ( ( (yday * 24) + src.hour ) * 60 + src.minute ) * 60 + src.second; |
113 | *dest_usec = | 114 | *dest_usec = src.centiseconds * 10000 + src.hundredsOfMicroseconds * 100 + src.microseconds; |
114 | src.centiseconds * 10000 + src.hundredsOfMicroseconds * 100 + | ||
115 | src.microseconds; | ||
116 | return dest; | 115 | return dest; |
117 | } | 116 | } |
118 | 117 | ||
@@ -145,8 +144,9 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts) | |||
145 | long int yg = y + days / 365 - (days % 365 < 0); | 144 | long int yg = y + days / 365 - (days % 365 < 0); |
146 | 145 | ||
147 | /* Adjust DAYS and Y to match the guessed year. */ | 146 | /* Adjust DAYS and Y to match the guessed year. */ |
148 | days -= ((yg - y) * 365 + LEAPS_THRU_END_OF(yg - 1) | 147 | days -= ((yg - y) * 365 |
149 | - LEAPS_THRU_END_OF(y - 1)); | 148 | + LEAPS_THRU_END_OF (yg - 1) |
149 | - LEAPS_THRU_END_OF (y - 1)); | ||
150 | y = yg; | 150 | y = yg; |
151 | } | 151 | } |
152 | dest->year = y; | 152 | dest->year = y; |
@@ -158,11 +158,9 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts) | |||
158 | dest->day = days + 1; | 158 | dest->day = days + 1; |
159 | 159 | ||
160 | dest->centiseconds = ts.tv_nsec / 10000000; | 160 | dest->centiseconds = ts.tv_nsec / 10000000; |
161 | dest->hundredsOfMicroseconds = | 161 | dest->hundredsOfMicroseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000) / 100; |
162 | (ts.tv_nsec / 1000 - dest->centiseconds * 10000) / 100; | 162 | dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 - |
163 | dest->microseconds = | 163 | dest->hundredsOfMicroseconds * 100); |
164 | (ts.tv_nsec / 1000 - dest->centiseconds * 10000 - | ||
165 | dest->hundredsOfMicroseconds * 100); | ||
166 | return dest; | 164 | return dest; |
167 | } | 165 | } |
168 | 166 | ||
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c index 46835240275c..9e6099c26c27 100644 --- a/fs/udf/unicode.c +++ b/fs/udf/unicode.c | |||
@@ -29,21 +29,23 @@ | |||
29 | 29 | ||
30 | static int udf_translate_to_linux(uint8_t *, uint8_t *, int, uint8_t *, int); | 30 | static int udf_translate_to_linux(uint8_t *, uint8_t *, int, uint8_t *, int); |
31 | 31 | ||
32 | static int udf_char_to_ustr(struct ustr *dest, const uint8_t * src, int strlen) | 32 | static int udf_char_to_ustr(struct ustr *dest, const uint8_t *src, int strlen) |
33 | { | 33 | { |
34 | if ((!dest) || (!src) || (!strlen) || (strlen > UDF_NAME_LEN - 2)) | 34 | if ((!dest) || (!src) || (!strlen) || (strlen > UDF_NAME_LEN - 2)) |
35 | return 0; | 35 | return 0; |
36 | |||
36 | memset(dest, 0, sizeof(struct ustr)); | 37 | memset(dest, 0, sizeof(struct ustr)); |
37 | memcpy(dest->u_name, src, strlen); | 38 | memcpy(dest->u_name, src, strlen); |
38 | dest->u_cmpID = 0x08; | 39 | dest->u_cmpID = 0x08; |
39 | dest->u_len = strlen; | 40 | dest->u_len = strlen; |
41 | |||
40 | return strlen; | 42 | return strlen; |
41 | } | 43 | } |
42 | 44 | ||
43 | /* | 45 | /* |
44 | * udf_build_ustr | 46 | * udf_build_ustr |
45 | */ | 47 | */ |
46 | int udf_build_ustr(struct ustr *dest, dstring * ptr, int size) | 48 | int udf_build_ustr(struct ustr *dest, dstring *ptr, int size) |
47 | { | 49 | { |
48 | int usesize; | 50 | int usesize; |
49 | 51 | ||
@@ -55,13 +57,14 @@ int udf_build_ustr(struct ustr *dest, dstring * ptr, int size) | |||
55 | dest->u_cmpID = ptr[0]; | 57 | dest->u_cmpID = ptr[0]; |
56 | dest->u_len = ptr[size - 1]; | 58 | dest->u_len = ptr[size - 1]; |
57 | memcpy(dest->u_name, ptr + 1, usesize - 1); | 59 | memcpy(dest->u_name, ptr + 1, usesize - 1); |
60 | |||
58 | return 0; | 61 | return 0; |
59 | } | 62 | } |
60 | 63 | ||
61 | /* | 64 | /* |
62 | * udf_build_ustr_exact | 65 | * udf_build_ustr_exact |
63 | */ | 66 | */ |
64 | static int udf_build_ustr_exact(struct ustr *dest, dstring * ptr, int exactsize) | 67 | static int udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize) |
65 | { | 68 | { |
66 | if ((!dest) || (!ptr) || (!exactsize)) | 69 | if ((!dest) || (!ptr) || (!exactsize)) |
67 | return -1; | 70 | return -1; |
@@ -70,6 +73,7 @@ static int udf_build_ustr_exact(struct ustr *dest, dstring * ptr, int exactsize) | |||
70 | dest->u_cmpID = ptr[0]; | 73 | dest->u_cmpID = ptr[0]; |
71 | dest->u_len = exactsize - 1; | 74 | dest->u_len = exactsize - 1; |
72 | memcpy(dest->u_name, ptr + 1, exactsize - 1); | 75 | memcpy(dest->u_name, ptr + 1, exactsize - 1); |
76 | |||
73 | return 0; | 77 | return 0; |
74 | } | 78 | } |
75 | 79 | ||
@@ -129,20 +133,15 @@ int udf_CS0toUTF8(struct ustr *utf_o, struct ustr *ocu_i) | |||
129 | c = (c << 8) | ocu[i++]; | 133 | c = (c << 8) | ocu[i++]; |
130 | 134 | ||
131 | /* Compress Unicode to UTF-8 */ | 135 | /* Compress Unicode to UTF-8 */ |
132 | if (c < 0x80U) | 136 | if (c < 0x80U) { |
133 | utf_o->u_name[utf_o->u_len++] = (uint8_t) c; | 137 | utf_o->u_name[utf_o->u_len++] = (uint8_t)c; |
134 | else if (c < 0x800U) { | 138 | } else if (c < 0x800U) { |
135 | utf_o->u_name[utf_o->u_len++] = | 139 | utf_o->u_name[utf_o->u_len++] = (uint8_t)(0xc0 | (c >> 6)); |
136 | (uint8_t) (0xc0 | (c >> 6)); | 140 | utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | (c & 0x3f)); |
137 | utf_o->u_name[utf_o->u_len++] = | ||
138 | (uint8_t) (0x80 | (c & 0x3f)); | ||
139 | } else { | 141 | } else { |
140 | utf_o->u_name[utf_o->u_len++] = | 142 | utf_o->u_name[utf_o->u_len++] = (uint8_t)(0xe0 | (c >> 12)); |
141 | (uint8_t) (0xe0 | (c >> 12)); | 143 | utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | ((c >> 6) & 0x3f)); |
142 | utf_o->u_name[utf_o->u_len++] = | 144 | utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | (c & 0x3f)); |
143 | (uint8_t) (0x80 | ((c >> 6) & 0x3f)); | ||
144 | utf_o->u_name[utf_o->u_len++] = | ||
145 | (uint8_t) (0x80 | (c & 0x3f)); | ||
146 | } | 145 | } |
147 | } | 146 | } |
148 | utf_o->u_cmpID = 8; | 147 | utf_o->u_cmpID = 8; |
@@ -173,7 +172,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, struct ustr *ocu_i) | |||
173 | * November 12, 1997 - Andrew E. Mileski | 172 | * November 12, 1997 - Andrew E. Mileski |
174 | * Written, tested, and released. | 173 | * Written, tested, and released. |
175 | */ | 174 | */ |
176 | static int udf_UTF8toCS0(dstring * ocu, struct ustr *utf, int length) | 175 | static int udf_UTF8toCS0(dstring *ocu, struct ustr *utf, int length) |
177 | { | 176 | { |
178 | unsigned c, i, max_val, utf_char; | 177 | unsigned c, i, max_val, utf_char; |
179 | int utf_cnt, u_len; | 178 | int utf_cnt, u_len; |
@@ -182,12 +181,12 @@ static int udf_UTF8toCS0(dstring * ocu, struct ustr *utf, int length) | |||
182 | ocu[0] = 8; | 181 | ocu[0] = 8; |
183 | max_val = 0xffU; | 182 | max_val = 0xffU; |
184 | 183 | ||
185 | try_again: | 184 | try_again: |
186 | u_len = 0U; | 185 | u_len = 0U; |
187 | utf_char = 0U; | 186 | utf_char = 0U; |
188 | utf_cnt = 0U; | 187 | utf_cnt = 0U; |
189 | for (i = 0U; i < utf->u_len; i++) { | 188 | for (i = 0U; i < utf->u_len; i++) { |
190 | c = (uint8_t) utf->u_name[i]; | 189 | c = (uint8_t)utf->u_name[i]; |
191 | 190 | ||
192 | /* Complete a multi-byte UTF-8 character */ | 191 | /* Complete a multi-byte UTF-8 character */ |
193 | if (utf_cnt) { | 192 | if (utf_cnt) { |
@@ -213,37 +212,40 @@ static int udf_UTF8toCS0(dstring * ocu, struct ustr *utf, int length) | |||
213 | } else if ((c & 0xfeU) == 0xfcU) { | 212 | } else if ((c & 0xfeU) == 0xfcU) { |
214 | utf_char = c & 0x01U; | 213 | utf_char = c & 0x01U; |
215 | utf_cnt = 5; | 214 | utf_cnt = 5; |
216 | } else | 215 | } else { |
217 | goto error_out; | 216 | goto error_out; |
217 | } | ||
218 | continue; | 218 | continue; |
219 | } else | 219 | } else { |
220 | /* Single byte UTF-8 character (most common) */ | 220 | /* Single byte UTF-8 character (most common) */ |
221 | utf_char = c; | 221 | utf_char = c; |
222 | } | ||
222 | } | 223 | } |
223 | 224 | ||
224 | /* Choose no compression if necessary */ | 225 | /* Choose no compression if necessary */ |
225 | if (utf_char > max_val) { | 226 | if (utf_char > max_val) { |
226 | if (0xffU == max_val) { | 227 | if (max_val == 0xffU) { |
227 | max_val = 0xffffU; | 228 | max_val = 0xffffU; |
228 | ocu[0] = (uint8_t) 0x10U; | 229 | ocu[0] = (uint8_t)0x10U; |
229 | goto try_again; | 230 | goto try_again; |
230 | } | 231 | } |
231 | goto error_out; | 232 | goto error_out; |
232 | } | 233 | } |
233 | 234 | ||
234 | if (max_val == 0xffffU) { | 235 | if (max_val == 0xffffU) { |
235 | ocu[++u_len] = (uint8_t) (utf_char >> 8); | 236 | ocu[++u_len] = (uint8_t)(utf_char >> 8); |
236 | } | 237 | } |
237 | ocu[++u_len] = (uint8_t) (utf_char & 0xffU); | 238 | ocu[++u_len] = (uint8_t)(utf_char & 0xffU); |
238 | } | 239 | } |
239 | 240 | ||
240 | if (utf_cnt) { | 241 | if (utf_cnt) { |
241 | error_out: | 242 | error_out: |
242 | ocu[++u_len] = '?'; | 243 | ocu[++u_len] = '?'; |
243 | printk(KERN_DEBUG "udf: bad UTF-8 character\n"); | 244 | printk(KERN_DEBUG "udf: bad UTF-8 character\n"); |
244 | } | 245 | } |
245 | 246 | ||
246 | ocu[length - 1] = (uint8_t) u_len + 1; | 247 | ocu[length - 1] = (uint8_t)u_len + 1; |
248 | |||
247 | return u_len + 1; | 249 | return u_len + 1; |
248 | } | 250 | } |
249 | 251 | ||
@@ -288,7 +290,7 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, | |||
288 | return utf_o->u_len; | 290 | return utf_o->u_len; |
289 | } | 291 | } |
290 | 292 | ||
291 | static int udf_NLStoCS0(struct nls_table *nls, dstring * ocu, struct ustr *uni, | 293 | static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni, |
292 | int length) | 294 | int length) |
293 | { | 295 | { |
294 | unsigned len, i, max_val; | 296 | unsigned len, i, max_val; |
@@ -299,7 +301,7 @@ static int udf_NLStoCS0(struct nls_table *nls, dstring * ocu, struct ustr *uni, | |||
299 | ocu[0] = 8; | 301 | ocu[0] = 8; |
300 | max_val = 0xffU; | 302 | max_val = 0xffU; |
301 | 303 | ||
302 | try_again: | 304 | try_again: |
303 | u_len = 0U; | 305 | u_len = 0U; |
304 | for (i = 0U; i < uni->u_len; i++) { | 306 | for (i = 0U; i < uni->u_len; i++) { |
305 | len = nls->char2uni(&uni->u_name[i], uni->u_len - i, &uni_char); | 307 | len = nls->char2uni(&uni->u_name[i], uni->u_len - i, &uni_char); |
@@ -308,21 +310,21 @@ static int udf_NLStoCS0(struct nls_table *nls, dstring * ocu, struct ustr *uni, | |||
308 | 310 | ||
309 | if (uni_char > max_val) { | 311 | if (uni_char > max_val) { |
310 | max_val = 0xffffU; | 312 | max_val = 0xffffU; |
311 | ocu[0] = (uint8_t) 0x10U; | 313 | ocu[0] = (uint8_t)0x10U; |
312 | goto try_again; | 314 | goto try_again; |
313 | } | 315 | } |
314 | 316 | ||
315 | if (max_val == 0xffffU) | 317 | if (max_val == 0xffffU) |
316 | ocu[++u_len] = (uint8_t) (uni_char >> 8); | 318 | ocu[++u_len] = (uint8_t)(uni_char >> 8); |
317 | ocu[++u_len] = (uint8_t) (uni_char & 0xffU); | 319 | ocu[++u_len] = (uint8_t)(uni_char & 0xffU); |
318 | i += len - 1; | 320 | i += len - 1; |
319 | } | 321 | } |
320 | 322 | ||
321 | ocu[length - 1] = (uint8_t) u_len + 1; | 323 | ocu[length - 1] = (uint8_t)u_len + 1; |
322 | return u_len + 1; | 324 | return u_len + 1; |
323 | } | 325 | } |
324 | 326 | ||
325 | int udf_get_filename(struct super_block *sb, uint8_t * sname, uint8_t * dname, | 327 | int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname, |
326 | int flen) | 328 | int flen) |
327 | { | 329 | { |
328 | struct ustr filename, unifilename; | 330 | struct ustr filename, unifilename; |
@@ -334,30 +336,29 @@ int udf_get_filename(struct super_block *sb, uint8_t * sname, uint8_t * dname, | |||
334 | 336 | ||
335 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { | 337 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { |
336 | if (!udf_CS0toUTF8(&filename, &unifilename)) { | 338 | if (!udf_CS0toUTF8(&filename, &unifilename)) { |
337 | udf_debug("Failed in udf_get_filename: sname = %s\n", | 339 | udf_debug("Failed in udf_get_filename: sname = %s\n", sname); |
338 | sname); | ||
339 | return 0; | 340 | return 0; |
340 | } | 341 | } |
341 | } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { | 342 | } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { |
342 | if (!udf_CS0toNLS | 343 | if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, &filename, &unifilename)) { |
343 | (UDF_SB(sb)->s_nls_map, &filename, &unifilename)) { | 344 | udf_debug("Failed in udf_get_filename: sname = %s\n", sname); |
344 | udf_debug("Failed in udf_get_filename: sname = %s\n", | ||
345 | sname); | ||
346 | return 0; | 345 | return 0; |
347 | } | 346 | } |
348 | } else | 347 | } else { |
349 | return 0; | 348 | return 0; |
349 | } | ||
350 | 350 | ||
351 | if ((len = | 351 | len = udf_translate_to_linux(dname, filename.u_name, filename.u_len, |
352 | udf_translate_to_linux(dname, filename.u_name, filename.u_len, | 352 | unifilename.u_name, unifilename.u_len); |
353 | unifilename.u_name, unifilename.u_len))) { | 353 | if (len) { |
354 | return len; | 354 | return len; |
355 | } | 355 | } |
356 | |||
356 | return 0; | 357 | return 0; |
357 | } | 358 | } |
358 | 359 | ||
359 | int udf_put_filename(struct super_block *sb, const uint8_t * sname, | 360 | int udf_put_filename(struct super_block *sb, const uint8_t *sname, |
360 | uint8_t * dname, int flen) | 361 | uint8_t *dname, int flen) |
361 | { | 362 | { |
362 | struct ustr unifilename; | 363 | struct ustr unifilename; |
363 | int namelen; | 364 | int namelen; |
@@ -367,31 +368,29 @@ int udf_put_filename(struct super_block *sb, const uint8_t * sname, | |||
367 | } | 368 | } |
368 | 369 | ||
369 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { | 370 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { |
370 | if (! | 371 | namelen = udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN); |
371 | (namelen = | 372 | if (!namelen) { |
372 | udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN))) { | ||
373 | return 0; | 373 | return 0; |
374 | } | 374 | } |
375 | } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { | 375 | } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { |
376 | if (! | 376 | namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, &unifilename, UDF_NAME_LEN); |
377 | (namelen = | 377 | if (!namelen) { |
378 | udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, &unifilename, | ||
379 | UDF_NAME_LEN))) { | ||
380 | return 0; | 378 | return 0; |
381 | } | 379 | } |
382 | } else | 380 | } else { |
383 | return 0; | 381 | return 0; |
382 | } | ||
384 | 383 | ||
385 | return namelen; | 384 | return namelen; |
386 | } | 385 | } |
387 | 386 | ||
388 | #define ILLEGAL_CHAR_MARK '_' | 387 | #define ILLEGAL_CHAR_MARK '_' |
389 | #define EXT_MARK '.' | 388 | #define EXT_MARK '.' |
390 | #define CRC_MARK '#' | 389 | #define CRC_MARK '#' |
391 | #define EXT_SIZE 5 | 390 | #define EXT_SIZE 5 |
392 | 391 | ||
393 | static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName, | 392 | static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen, |
394 | int udfLen, uint8_t * fidName, int fidNameLen) | 393 | uint8_t *fidName, int fidNameLen) |
395 | { | 394 | { |
396 | int index, newIndex = 0, needsCRC = 0; | 395 | int index, newIndex = 0, needsCRC = 0; |
397 | int extIndex = 0, newExtIndex = 0, hasExt = 0; | 396 | int extIndex = 0, newExtIndex = 0, hasExt = 0; |
@@ -399,8 +398,8 @@ static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName, | |||
399 | uint8_t curr; | 398 | uint8_t curr; |
400 | const uint8_t hexChar[] = "0123456789ABCDEF"; | 399 | const uint8_t hexChar[] = "0123456789ABCDEF"; |
401 | 400 | ||
402 | if (udfName[0] == '.' && (udfLen == 1 || | 401 | if (udfName[0] == '.' && |
403 | (udfLen == 2 && udfName[1] == '.'))) { | 402 | (udfLen == 1 || (udfLen == 2 && udfName[1] == '.'))) { |
404 | needsCRC = 1; | 403 | needsCRC = 1; |
405 | newIndex = udfLen; | 404 | newIndex = udfLen; |
406 | memcpy(newName, udfName, udfLen); | 405 | memcpy(newName, udfName, udfLen); |
@@ -410,16 +409,13 @@ static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName, | |||
410 | if (curr == '/' || curr == 0) { | 409 | if (curr == '/' || curr == 0) { |
411 | needsCRC = 1; | 410 | needsCRC = 1; |
412 | curr = ILLEGAL_CHAR_MARK; | 411 | curr = ILLEGAL_CHAR_MARK; |
413 | while (index + 1 < udfLen | 412 | while (index + 1 < udfLen && (udfName[index + 1] == '/' || |
414 | && (udfName[index + 1] == '/' | 413 | udfName[index + 1] == 0)) |
415 | || udfName[index + 1] == 0)) | ||
416 | index++; | 414 | index++; |
417 | } | 415 | } if (curr == EXT_MARK && (udfLen - index - 1) <= EXT_SIZE) { |
418 | if (curr == EXT_MARK | 416 | if (udfLen == index + 1) { |
419 | && (udfLen - index - 1) <= EXT_SIZE) { | ||
420 | if (udfLen == index + 1) | ||
421 | hasExt = 0; | 417 | hasExt = 0; |
422 | else { | 418 | } else { |
423 | hasExt = 1; | 419 | hasExt = 1; |
424 | extIndex = index; | 420 | extIndex = index; |
425 | newExtIndex = newIndex; | 421 | newExtIndex = newIndex; |
@@ -437,23 +433,16 @@ static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName, | |||
437 | 433 | ||
438 | if (hasExt) { | 434 | if (hasExt) { |
439 | int maxFilenameLen; | 435 | int maxFilenameLen; |
440 | for (index = 0; | 436 | for(index = 0; index < EXT_SIZE && extIndex + index + 1 < udfLen; index++) { |
441 | index < EXT_SIZE && extIndex + index + 1 < udfLen; | ||
442 | index++) { | ||
443 | curr = udfName[extIndex + index + 1]; | 437 | curr = udfName[extIndex + index + 1]; |
444 | 438 | ||
445 | if (curr == '/' || curr == 0) { | 439 | if (curr == '/' || curr == 0) { |
446 | needsCRC = 1; | 440 | needsCRC = 1; |
447 | curr = ILLEGAL_CHAR_MARK; | 441 | curr = ILLEGAL_CHAR_MARK; |
448 | while (extIndex + index + 2 < udfLen | 442 | while(extIndex + index + 2 < udfLen && |
449 | && (index + 1 < EXT_SIZE | 443 | (index + 1 < EXT_SIZE |
450 | && | 444 | && (udfName[extIndex + index + 2] == '/' || |
451 | (udfName | 445 | udfName[extIndex + index + 2] == 0))) |
452 | [extIndex + index + 2] == | ||
453 | '/' | ||
454 | || udfName[extIndex + | ||
455 | index + 2] == | ||
456 | 0))) | ||
457 | index++; | 446 | index++; |
458 | } | 447 | } |
459 | ext[localExtIndex++] = curr; | 448 | ext[localExtIndex++] = curr; |
@@ -463,8 +452,9 @@ static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName, | |||
463 | newIndex = maxFilenameLen; | 452 | newIndex = maxFilenameLen; |
464 | else | 453 | else |
465 | newIndex = newExtIndex; | 454 | newIndex = newExtIndex; |
466 | } else if (newIndex > 250) | 455 | } else if (newIndex > 250) { |
467 | newIndex = 250; | 456 | newIndex = 250; |
457 | } | ||
468 | newName[newIndex++] = CRC_MARK; | 458 | newName[newIndex++] = CRC_MARK; |
469 | valueCRC = udf_crc(fidName, fidNameLen, 0); | 459 | valueCRC = udf_crc(fidName, fidNameLen, 0); |
470 | newName[newIndex++] = hexChar[(valueCRC & 0xf000) >> 12]; | 460 | newName[newIndex++] = hexChar[(valueCRC & 0xf000) >> 12]; |
@@ -478,5 +468,6 @@ static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName, | |||
478 | newName[newIndex++] = ext[index]; | 468 | newName[newIndex++] = ext[index]; |
479 | } | 469 | } |
480 | } | 470 | } |
471 | |||
481 | return newIndex; | 472 | return newIndex; |
482 | } | 473 | } |