diff options
author | Marcin Slusarz <marcin.slusarz@gmail.com> | 2008-02-08 07:20:36 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-08 12:22:35 -0500 |
commit | 4b11111aba6c80cc2969fd1806d2a869bfc9f357 (patch) | |
tree | 57b72a1ca58859dc6a9e47d647f29cebb9bcf7e0 /fs/udf/inode.c | |
parent | bd45a420f93d18c91115f3f0568dd6a2555aa15a (diff) |
udf: fix coding style
fix coding style errors found by checkpatch:
- assignments in if conditions
- braces {} around single statement blocks
- no spaces after commas
- printks without KERN_*
- lines longer than 80 characters
- spaces between "type *" and variable name
before: 192 errors, 561 warnings, 8987 lines checked
after: 1 errors, 38 warnings, 9468 lines checked
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/udf/inode.c')
-rw-r--r-- | fs/udf/inode.c | 665 |
1 files changed, 401 insertions, 264 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 2eb1220e4236..3ce2f6d1aafa 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c | |||
@@ -19,7 +19,8 @@ | |||
19 | * 10/04/98 dgb Added rudimentary directory functions | 19 | * 10/04/98 dgb Added rudimentary directory functions |
20 | * 10/07/98 Fully working udf_block_map! It works! | 20 | * 10/07/98 Fully working udf_block_map! It works! |
21 | * 11/25/98 bmap altered to better support extents | 21 | * 11/25/98 bmap altered to better support extents |
22 | * 12/06/98 blf partition support in udf_iget, udf_block_map and udf_read_inode | 22 | * 12/06/98 blf partition support in udf_iget, udf_block_map |
23 | * and udf_read_inode | ||
23 | * 12/12/98 rewrote udf_block_map to handle next extents and descs across | 24 | * 12/12/98 rewrote udf_block_map to handle next extents and descs across |
24 | * block boundaries (which is not actually allowed) | 25 | * block boundaries (which is not actually allowed) |
25 | * 12/20/98 added support for strategy 4096 | 26 | * 12/20/98 added support for strategy 4096 |
@@ -237,7 +238,8 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
237 | if (!(*block)) | 238 | if (!(*block)) |
238 | return NULL; | 239 | return NULL; |
239 | newblock = udf_get_pblock(inode->i_sb, *block, | 240 | newblock = udf_get_pblock(inode->i_sb, *block, |
240 | UDF_I_LOCATION(inode).partitionReferenceNum, 0); | 241 | UDF_I_LOCATION(inode).partitionReferenceNum, |
242 | 0); | ||
241 | if (!newblock) | 243 | if (!newblock) |
242 | return NULL; | 244 | return NULL; |
243 | dbh = udf_tgetblk(inode->i_sb, newblock); | 245 | dbh = udf_tgetblk(inode->i_sb, newblock); |
@@ -249,13 +251,15 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
249 | unlock_buffer(dbh); | 251 | unlock_buffer(dbh); |
250 | mark_buffer_dirty_inode(dbh, inode); | 252 | mark_buffer_dirty_inode(dbh, inode); |
251 | 253 | ||
252 | sfibh.soffset = sfibh.eoffset = (f_pos & ((inode->i_sb->s_blocksize - 1) >> 2)) << 2; | 254 | sfibh.soffset = sfibh.eoffset = |
255 | (f_pos & ((inode->i_sb->s_blocksize - 1) >> 2)) << 2; | ||
253 | sfibh.sbh = sfibh.ebh = NULL; | 256 | sfibh.sbh = sfibh.ebh = NULL; |
254 | dfibh.soffset = dfibh.eoffset = 0; | 257 | dfibh.soffset = dfibh.eoffset = 0; |
255 | dfibh.sbh = dfibh.ebh = dbh; | 258 | dfibh.sbh = dfibh.ebh = dbh; |
256 | while ((f_pos < size)) { | 259 | while ((f_pos < size)) { |
257 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; | 260 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; |
258 | sfi = udf_fileident_read(inode, &f_pos, &sfibh, &cfi, NULL, NULL, NULL, NULL); | 261 | sfi = udf_fileident_read(inode, &f_pos, &sfibh, &cfi, NULL, |
262 | NULL, NULL, NULL); | ||
259 | if (!sfi) { | 263 | if (!sfi) { |
260 | brelse(dbh); | 264 | brelse(dbh); |
261 | return NULL; | 265 | return NULL; |
@@ -266,7 +270,8 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
266 | dfibh.eoffset += (sfibh.eoffset - sfibh.soffset); | 270 | dfibh.eoffset += (sfibh.eoffset - sfibh.soffset); |
267 | dfi = (struct fileIdentDesc *)(dbh->b_data + dfibh.soffset); | 271 | dfi = (struct fileIdentDesc *)(dbh->b_data + dfibh.soffset); |
268 | if (udf_write_fi(inode, sfi, dfi, &dfibh, sfi->impUse, | 272 | if (udf_write_fi(inode, sfi, dfi, &dfibh, sfi->impUse, |
269 | sfi->fileIdent + le16_to_cpu(sfi->lengthOfImpUse))) { | 273 | sfi->fileIdent + |
274 | le16_to_cpu(sfi->lengthOfImpUse))) { | ||
270 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; | 275 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; |
271 | brelse(dbh); | 276 | brelse(dbh); |
272 | return NULL; | 277 | return NULL; |
@@ -274,10 +279,12 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
274 | } | 279 | } |
275 | mark_buffer_dirty_inode(dbh, inode); | 280 | mark_buffer_dirty_inode(dbh, inode); |
276 | 281 | ||
277 | memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), 0, UDF_I_LENALLOC(inode)); | 282 | memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), 0, |
283 | UDF_I_LENALLOC(inode)); | ||
278 | UDF_I_LENALLOC(inode) = 0; | 284 | UDF_I_LENALLOC(inode) = 0; |
279 | eloc.logicalBlockNum = *block; | 285 | eloc.logicalBlockNum = *block; |
280 | eloc.partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum; | 286 | eloc.partitionReferenceNum = |
287 | UDF_I_LOCATION(inode).partitionReferenceNum; | ||
281 | elen = inode->i_size; | 288 | elen = inode->i_size; |
282 | UDF_I_LENEXTENTS(inode) = elen; | 289 | UDF_I_LENEXTENTS(inode) = elen; |
283 | epos.bh = NULL; | 290 | epos.bh = NULL; |
@@ -366,7 +373,7 @@ static struct buffer_head *udf_getblk(struct inode *inode, long block, | |||
366 | 373 | ||
367 | /* Extend the file by 'blocks' blocks, return the number of extents added */ | 374 | /* Extend the file by 'blocks' blocks, return the number of extents added */ |
368 | int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | 375 | int udf_extend_file(struct inode *inode, struct extent_position *last_pos, |
369 | kernel_long_ad * last_ext, sector_t blocks) | 376 | kernel_long_ad *last_ext, sector_t blocks) |
370 | { | 377 | { |
371 | sector_t add; | 378 | sector_t add; |
372 | int count = 0, fake = !(last_ext->extLength & UDF_EXTENT_LENGTH_MASK); | 379 | int count = 0, fake = !(last_ext->extLength & UDF_EXTENT_LENGTH_MASK); |
@@ -391,7 +398,8 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
391 | } | 398 | } |
392 | 399 | ||
393 | /* Last extent are just preallocated blocks? */ | 400 | /* Last extent are just preallocated blocks? */ |
394 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == EXT_NOT_RECORDED_ALLOCATED) { | 401 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == |
402 | EXT_NOT_RECORDED_ALLOCATED) { | ||
395 | /* Save the extent so that we can reattach it to the end */ | 403 | /* Save the extent so that we can reattach it to the end */ |
396 | prealloc_loc = last_ext->extLocation; | 404 | prealloc_loc = last_ext->extLocation; |
397 | prealloc_len = last_ext->extLength; | 405 | prealloc_len = last_ext->extLength; |
@@ -399,13 +407,15 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
399 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | | 407 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | |
400 | (last_ext->extLength & UDF_EXTENT_LENGTH_MASK); | 408 | (last_ext->extLength & UDF_EXTENT_LENGTH_MASK); |
401 | last_ext->extLocation.logicalBlockNum = 0; | 409 | last_ext->extLocation.logicalBlockNum = 0; |
402 | last_ext->extLocation.partitionReferenceNum = 0; | 410 | last_ext->extLocation.partitionReferenceNum = 0; |
403 | } | 411 | } |
404 | 412 | ||
405 | /* Can we merge with the previous extent? */ | 413 | /* Can we merge with the previous extent? */ |
406 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == EXT_NOT_RECORDED_NOT_ALLOCATED) { | 414 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == |
407 | add = ((1 << 30) - sb->s_blocksize - (last_ext->extLength & | 415 | EXT_NOT_RECORDED_NOT_ALLOCATED) { |
408 | UDF_EXTENT_LENGTH_MASK)) >> sb->s_blocksize_bits; | 416 | add = ((1 << 30) - sb->s_blocksize - |
417 | (last_ext->extLength & UDF_EXTENT_LENGTH_MASK)) >> | ||
418 | sb->s_blocksize_bits; | ||
409 | if (add > blocks) | 419 | if (add > blocks) |
410 | add = blocks; | 420 | add = blocks; |
411 | blocks -= add; | 421 | blocks -= add; |
@@ -416,9 +426,9 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
416 | udf_add_aext(inode, last_pos, last_ext->extLocation, | 426 | udf_add_aext(inode, last_pos, last_ext->extLocation, |
417 | last_ext->extLength, 1); | 427 | last_ext->extLength, 1); |
418 | count++; | 428 | count++; |
419 | } else { | 429 | } else |
420 | udf_write_aext(inode, last_pos, last_ext->extLocation, last_ext->extLength, 1); | 430 | udf_write_aext(inode, last_pos, last_ext->extLocation, |
421 | } | 431 | last_ext->extLength, 1); |
422 | 432 | ||
423 | /* Managed to do everything necessary? */ | 433 | /* Managed to do everything necessary? */ |
424 | if (!blocks) | 434 | if (!blocks) |
@@ -426,9 +436,10 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
426 | 436 | ||
427 | /* All further extents will be NOT_RECORDED_NOT_ALLOCATED */ | 437 | /* All further extents will be NOT_RECORDED_NOT_ALLOCATED */ |
428 | last_ext->extLocation.logicalBlockNum = 0; | 438 | last_ext->extLocation.logicalBlockNum = 0; |
429 | last_ext->extLocation.partitionReferenceNum = 0; | 439 | last_ext->extLocation.partitionReferenceNum = 0; |
430 | add = (1 << (30-sb->s_blocksize_bits)) - 1; | 440 | add = (1 << (30-sb->s_blocksize_bits)) - 1; |
431 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | (add << sb->s_blocksize_bits); | 441 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | |
442 | (add << sb->s_blocksize_bits); | ||
432 | 443 | ||
433 | /* Create enough extents to cover the whole hole */ | 444 | /* Create enough extents to cover the whole hole */ |
434 | while (blocks > add) { | 445 | while (blocks > add) { |
@@ -450,7 +461,8 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
450 | out: | 461 | out: |
451 | /* Do we have some preallocated blocks saved? */ | 462 | /* Do we have some preallocated blocks saved? */ |
452 | if (prealloc_len) { | 463 | if (prealloc_len) { |
453 | if (udf_add_aext(inode, last_pos, prealloc_loc, prealloc_len, 1) == -1) | 464 | if (udf_add_aext(inode, last_pos, prealloc_loc, |
465 | prealloc_len, 1) == -1) | ||
454 | return -1; | 466 | return -1; |
455 | last_ext->extLocation = prealloc_loc; | 467 | last_ext->extLocation = prealloc_loc; |
456 | last_ext->extLength = prealloc_len; | 468 | last_ext->extLength = prealloc_len; |
@@ -515,7 +527,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
515 | prev_epos.offset = cur_epos.offset; | 527 | prev_epos.offset = cur_epos.offset; |
516 | cur_epos.offset = next_epos.offset; | 528 | cur_epos.offset = next_epos.offset; |
517 | 529 | ||
518 | if ((etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 1)) == -1) | 530 | etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 1); |
531 | if (etype == -1) | ||
519 | break; | 532 | break; |
520 | 533 | ||
521 | c = !c; | 534 | c = !c; |
@@ -569,9 +582,11 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
569 | startnum = 1; | 582 | startnum = 1; |
570 | } else { | 583 | } else { |
571 | /* Create a fake extent when there's not one */ | 584 | /* Create a fake extent when there's not one */ |
572 | memset(&laarr[0].extLocation, 0x00, sizeof(kernel_lb_addr)); | 585 | memset(&laarr[0].extLocation, 0x00, |
586 | sizeof(kernel_lb_addr)); | ||
573 | laarr[0].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED; | 587 | laarr[0].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED; |
574 | /* Will udf_extend_file() create real extent from a fake one? */ | 588 | /* Will udf_extend_file() create real extent from |
589 | a fake one? */ | ||
575 | startnum = (offset > 0); | 590 | startnum = (offset > 0); |
576 | } | 591 | } |
577 | /* Create extents for the hole between EOF and offset */ | 592 | /* Create extents for the hole between EOF and offset */ |
@@ -589,14 +604,16 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
589 | offset = 0; | 604 | offset = 0; |
590 | count += ret; | 605 | count += ret; |
591 | /* We are not covered by a preallocated extent? */ | 606 | /* We are not covered by a preallocated extent? */ |
592 | if ((laarr[0].extLength & UDF_EXTENT_FLAG_MASK) != EXT_NOT_RECORDED_ALLOCATED) { | 607 | if ((laarr[0].extLength & UDF_EXTENT_FLAG_MASK) != |
608 | EXT_NOT_RECORDED_ALLOCATED) { | ||
593 | /* Is there any real extent? - otherwise we overwrite | 609 | /* Is there any real extent? - otherwise we overwrite |
594 | * the fake one... */ | 610 | * the fake one... */ |
595 | if (count) | 611 | if (count) |
596 | c = !c; | 612 | c = !c; |
597 | laarr[c].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | | 613 | laarr[c].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | |
598 | inode->i_sb->s_blocksize; | 614 | inode->i_sb->s_blocksize; |
599 | memset(&laarr[c].extLocation, 0x00, sizeof(kernel_lb_addr)); | 615 | memset(&laarr[c].extLocation, 0x00, |
616 | sizeof(kernel_lb_addr)); | ||
600 | count++; | 617 | count++; |
601 | endnum++; | 618 | endnum++; |
602 | } | 619 | } |
@@ -605,7 +622,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
605 | } else { | 622 | } else { |
606 | endnum = startnum = ((count > 2) ? 2 : count); | 623 | endnum = startnum = ((count > 2) ? 2 : count); |
607 | 624 | ||
608 | /* if the current extent is in position 0, swap it with the previous */ | 625 | /* if the current extent is in position 0, |
626 | swap it with the previous */ | ||
609 | if (!c && count != 1) { | 627 | if (!c && count != 1) { |
610 | laarr[2] = laarr[0]; | 628 | laarr[2] = laarr[0]; |
611 | laarr[0] = laarr[1]; | 629 | laarr[0] = laarr[1]; |
@@ -613,34 +631,36 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
613 | c = 1; | 631 | c = 1; |
614 | } | 632 | } |
615 | 633 | ||
616 | /* if the current block is located in an extent, read the next extent */ | 634 | /* if the current block is located in an extent, |
617 | if ((etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 0)) != -1) { | 635 | read the next extent */ |
636 | etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 0); | ||
637 | if (etype != -1) { | ||
618 | laarr[c + 1].extLength = (etype << 30) | elen; | 638 | laarr[c + 1].extLength = (etype << 30) | elen; |
619 | laarr[c + 1].extLocation = eloc; | 639 | laarr[c + 1].extLocation = eloc; |
620 | count++; | 640 | count++; |
621 | startnum++; | 641 | startnum++; |
622 | endnum++; | 642 | endnum++; |
623 | } else { | 643 | } else |
624 | lastblock = 1; | 644 | lastblock = 1; |
625 | } | ||
626 | } | 645 | } |
627 | 646 | ||
628 | /* if the current extent is not recorded but allocated, get the | 647 | /* if the current extent is not recorded but allocated, get the |
629 | * block in the extent corresponding to the requested block */ | 648 | * block in the extent corresponding to the requested block */ |
630 | if ((laarr[c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | 649 | if ((laarr[c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) |
631 | newblocknum = laarr[c].extLocation.logicalBlockNum + offset; | 650 | newblocknum = laarr[c].extLocation.logicalBlockNum + offset; |
632 | } else { /* otherwise, allocate a new block */ | 651 | else { /* otherwise, allocate a new block */ |
633 | if (UDF_I_NEXT_ALLOC_BLOCK(inode) == block) | 652 | if (UDF_I_NEXT_ALLOC_BLOCK(inode) == block) |
634 | goal = UDF_I_NEXT_ALLOC_GOAL(inode); | 653 | goal = UDF_I_NEXT_ALLOC_GOAL(inode); |
635 | 654 | ||
636 | if (!goal) { | 655 | if (!goal) { |
637 | if (!(goal = pgoal)) | 656 | if (!(goal = pgoal)) /* XXX: what was intended here? */ |
638 | goal = UDF_I_LOCATION(inode).logicalBlockNum + 1; | 657 | goal = UDF_I_LOCATION(inode).logicalBlockNum+1; |
639 | } | 658 | } |
640 | 659 | ||
641 | if (!(newblocknum = udf_new_block(inode->i_sb, inode, | 660 | newblocknum = udf_new_block(inode->i_sb, inode, |
642 | UDF_I_LOCATION(inode).partitionReferenceNum, | 661 | UDF_I_LOCATION(inode).partitionReferenceNum, |
643 | goal, err))) { | 662 | goal, err); |
663 | if (!newblocknum) { | ||
644 | brelse(prev_epos.bh); | 664 | brelse(prev_epos.bh); |
645 | *err = -ENOSPC; | 665 | *err = -ENOSPC; |
646 | return NULL; | 666 | return NULL; |
@@ -648,9 +668,10 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
648 | UDF_I_LENEXTENTS(inode) += inode->i_sb->s_blocksize; | 668 | UDF_I_LENEXTENTS(inode) += inode->i_sb->s_blocksize; |
649 | } | 669 | } |
650 | 670 | ||
651 | /* if the extent the requsted block is located in contains multiple blocks, | 671 | /* if the extent the requsted block is located in contains multiple |
652 | * split the extent into at most three extents. blocks prior to requested | 672 | * blocks, split the extent into at most three extents. blocks prior |
653 | * block, requested block, and blocks after requested block */ | 673 | * to requested block, requested block, and blocks after requested |
674 | * block */ | ||
654 | udf_split_extents(inode, &c, offset, newblocknum, laarr, &endnum); | 675 | udf_split_extents(inode, &c, offset, newblocknum, laarr, &endnum); |
655 | 676 | ||
656 | #ifdef UDF_PREALLOCATE | 677 | #ifdef UDF_PREALLOCATE |
@@ -668,10 +689,10 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
668 | 689 | ||
669 | brelse(prev_epos.bh); | 690 | brelse(prev_epos.bh); |
670 | 691 | ||
671 | if (!(newblock = udf_get_pblock(inode->i_sb, newblocknum, | 692 | newblock = udf_get_pblock(inode->i_sb, newblocknum, |
672 | UDF_I_LOCATION(inode).partitionReferenceNum, 0))) { | 693 | UDF_I_LOCATION(inode).partitionReferenceNum, 0); |
694 | if (!newblock) | ||
673 | return NULL; | 695 | return NULL; |
674 | } | ||
675 | *phys = newblock; | 696 | *phys = newblock; |
676 | *err = 0; | 697 | *err = 0; |
677 | *new = 1; | 698 | *new = 1; |
@@ -692,16 +713,20 @@ static void udf_split_extents(struct inode *inode, int *c, int offset, | |||
692 | kernel_long_ad laarr[EXTENT_MERGE_SIZE], | 713 | kernel_long_ad laarr[EXTENT_MERGE_SIZE], |
693 | int *endnum) | 714 | int *endnum) |
694 | { | 715 | { |
716 | unsigned long blocksize = inode->i_sb->s_blocksize; | ||
717 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; | ||
718 | |||
695 | if ((laarr[*c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30) || | 719 | if ((laarr[*c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30) || |
696 | (laarr[*c].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) { | 720 | (laarr[*c].extLength >> 30) == |
721 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) { | ||
697 | int curr = *c; | 722 | int curr = *c; |
698 | int blen = ((laarr[curr].extLength & UDF_EXTENT_LENGTH_MASK) + | 723 | int blen = ((laarr[curr].extLength & UDF_EXTENT_LENGTH_MASK) + |
699 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits; | 724 | blocksize - 1) >> blocksize_bits; |
700 | int8_t etype = (laarr[curr].extLength >> 30); | 725 | int8_t etype = (laarr[curr].extLength >> 30); |
701 | 726 | ||
702 | if (blen == 1) { | 727 | if (blen == 1) |
703 | ; | 728 | ; |
704 | } else if (!offset || blen == offset + 1) { | 729 | else if (!offset || blen == offset + 1) { |
705 | laarr[curr + 2] = laarr[curr + 1]; | 730 | laarr[curr + 2] = laarr[curr + 1]; |
706 | laarr[curr + 1] = laarr[curr]; | 731 | laarr[curr + 1] = laarr[curr]; |
707 | } else { | 732 | } else { |
@@ -711,15 +736,18 @@ static void udf_split_extents(struct inode *inode, int *c, int offset, | |||
711 | 736 | ||
712 | if (offset) { | 737 | if (offset) { |
713 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | 738 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { |
714 | udf_free_blocks(inode->i_sb, inode, laarr[curr].extLocation, 0, offset); | 739 | udf_free_blocks(inode->i_sb, inode, |
715 | laarr[curr].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | | 740 | laarr[curr].extLocation, |
716 | (offset << inode->i_sb->s_blocksize_bits); | 741 | 0, offset); |
742 | laarr[curr].extLength = | ||
743 | EXT_NOT_RECORDED_NOT_ALLOCATED | | ||
744 | (offset << blocksize_bits); | ||
717 | laarr[curr].extLocation.logicalBlockNum = 0; | 745 | laarr[curr].extLocation.logicalBlockNum = 0; |
718 | laarr[curr].extLocation.partitionReferenceNum = 0; | 746 | laarr[curr].extLocation. |
719 | } else { | 747 | partitionReferenceNum = 0; |
748 | } else | ||
720 | laarr[curr].extLength = (etype << 30) | | 749 | laarr[curr].extLength = (etype << 30) | |
721 | (offset << inode->i_sb->s_blocksize_bits); | 750 | (offset << blocksize_bits); |
722 | } | ||
723 | curr++; | 751 | curr++; |
724 | (*c)++; | 752 | (*c)++; |
725 | (*endnum)++; | 753 | (*endnum)++; |
@@ -730,14 +758,15 @@ static void udf_split_extents(struct inode *inode, int *c, int offset, | |||
730 | laarr[curr].extLocation.partitionReferenceNum = | 758 | laarr[curr].extLocation.partitionReferenceNum = |
731 | UDF_I_LOCATION(inode).partitionReferenceNum; | 759 | UDF_I_LOCATION(inode).partitionReferenceNum; |
732 | laarr[curr].extLength = EXT_RECORDED_ALLOCATED | | 760 | laarr[curr].extLength = EXT_RECORDED_ALLOCATED | |
733 | inode->i_sb->s_blocksize; | 761 | blocksize; |
734 | curr++; | 762 | curr++; |
735 | 763 | ||
736 | if (blen != offset + 1) { | 764 | if (blen != offset + 1) { |
737 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) | 765 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) |
738 | laarr[curr].extLocation.logicalBlockNum += (offset + 1); | 766 | laarr[curr].extLocation.logicalBlockNum += |
767 | offset + 1; | ||
739 | laarr[curr].extLength = (etype << 30) | | 768 | laarr[curr].extLength = (etype << 30) | |
740 | ((blen - (offset + 1)) << inode->i_sb->s_blocksize_bits); | 769 | ((blen - (offset + 1)) << blocksize_bits); |
741 | curr++; | 770 | curr++; |
742 | (*endnum)++; | 771 | (*endnum)++; |
743 | } | 772 | } |
@@ -756,69 +785,86 @@ static void udf_prealloc_extents(struct inode *inode, int c, int lastblock, | |||
756 | else | 785 | else |
757 | start = c; | 786 | start = c; |
758 | } else { | 787 | } else { |
759 | if ((laarr[c + 1].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | 788 | if ((laarr[c + 1].extLength >> 30) == |
789 | (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | ||
760 | start = c + 1; | 790 | start = c + 1; |
761 | length = currlength = (((laarr[c + 1].extLength & UDF_EXTENT_LENGTH_MASK) + | 791 | length = currlength = |
762 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); | 792 | (((laarr[c + 1].extLength & |
763 | } else { | 793 | UDF_EXTENT_LENGTH_MASK) + |
794 | inode->i_sb->s_blocksize - 1) >> | ||
795 | inode->i_sb->s_blocksize_bits); | ||
796 | } else | ||
764 | start = c; | 797 | start = c; |
765 | } | ||
766 | } | 798 | } |
767 | 799 | ||
768 | for (i = start + 1; i <= *endnum; i++) { | 800 | for (i = start + 1; i <= *endnum; i++) { |
769 | if (i == *endnum) { | 801 | if (i == *endnum) { |
770 | if (lastblock) | 802 | if (lastblock) |
771 | length += UDF_DEFAULT_PREALLOC_BLOCKS; | 803 | length += UDF_DEFAULT_PREALLOC_BLOCKS; |
772 | } else if ((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) { | 804 | } else if ((laarr[i].extLength >> 30) == |
773 | length += (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 805 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) { |
774 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); | 806 | length += (((laarr[i].extLength & |
775 | } else { | 807 | UDF_EXTENT_LENGTH_MASK) + |
808 | inode->i_sb->s_blocksize - 1) >> | ||
809 | inode->i_sb->s_blocksize_bits); | ||
810 | } else | ||
776 | break; | 811 | break; |
777 | } | ||
778 | } | 812 | } |
779 | 813 | ||
780 | if (length) { | 814 | if (length) { |
781 | int next = laarr[start].extLocation.logicalBlockNum + | 815 | int next = laarr[start].extLocation.logicalBlockNum + |
782 | (((laarr[start].extLength & UDF_EXTENT_LENGTH_MASK) + | 816 | (((laarr[start].extLength & UDF_EXTENT_LENGTH_MASK) + |
783 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); | 817 | inode->i_sb->s_blocksize - 1) >> |
818 | inode->i_sb->s_blocksize_bits); | ||
784 | int numalloc = udf_prealloc_blocks(inode->i_sb, inode, | 819 | int numalloc = udf_prealloc_blocks(inode->i_sb, inode, |
785 | laarr[start].extLocation.partitionReferenceNum, | 820 | laarr[start].extLocation.partitionReferenceNum, |
786 | next, (UDF_DEFAULT_PREALLOC_BLOCKS > length ? length : | 821 | next, (UDF_DEFAULT_PREALLOC_BLOCKS > length ? |
787 | UDF_DEFAULT_PREALLOC_BLOCKS) - currlength); | 822 | length : UDF_DEFAULT_PREALLOC_BLOCKS) - |
823 | currlength); | ||
788 | if (numalloc) { | 824 | if (numalloc) { |
789 | if (start == (c + 1)) { | 825 | if (start == (c + 1)) |
790 | laarr[start].extLength += | 826 | laarr[start].extLength += |
791 | (numalloc << inode->i_sb->s_blocksize_bits); | 827 | (numalloc << |
792 | } else { | 828 | inode->i_sb->s_blocksize_bits); |
829 | else { | ||
793 | memmove(&laarr[c + 2], &laarr[c + 1], | 830 | memmove(&laarr[c + 2], &laarr[c + 1], |
794 | sizeof(long_ad) * (*endnum - (c + 1))); | 831 | sizeof(long_ad) * (*endnum - (c + 1))); |
795 | (*endnum)++; | 832 | (*endnum)++; |
796 | laarr[c + 1].extLocation.logicalBlockNum = next; | 833 | laarr[c + 1].extLocation.logicalBlockNum = next; |
797 | laarr[c + 1].extLocation.partitionReferenceNum = | 834 | laarr[c + 1].extLocation.partitionReferenceNum = |
798 | laarr[c].extLocation.partitionReferenceNum; | 835 | laarr[c].extLocation. |
799 | laarr[c + 1].extLength = EXT_NOT_RECORDED_ALLOCATED | | 836 | partitionReferenceNum; |
800 | (numalloc << inode->i_sb->s_blocksize_bits); | 837 | laarr[c + 1].extLength = |
838 | EXT_NOT_RECORDED_ALLOCATED | | ||
839 | (numalloc << | ||
840 | inode->i_sb->s_blocksize_bits); | ||
801 | start = c + 1; | 841 | start = c + 1; |
802 | } | 842 | } |
803 | 843 | ||
804 | for (i = start + 1; numalloc && i < *endnum; i++) { | 844 | for (i = start + 1; numalloc && i < *endnum; i++) { |
805 | int elen = ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 845 | int elen = ((laarr[i].extLength & |
806 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits; | 846 | UDF_EXTENT_LENGTH_MASK) + |
847 | inode->i_sb->s_blocksize - 1) >> | ||
848 | inode->i_sb->s_blocksize_bits; | ||
807 | 849 | ||
808 | if (elen > numalloc) { | 850 | if (elen > numalloc) { |
809 | laarr[i].extLength -= | 851 | laarr[i].extLength -= |
810 | (numalloc << inode->i_sb->s_blocksize_bits); | 852 | (numalloc << |
853 | inode->i_sb->s_blocksize_bits); | ||
811 | numalloc = 0; | 854 | numalloc = 0; |
812 | } else { | 855 | } else { |
813 | numalloc -= elen; | 856 | numalloc -= elen; |
814 | if (*endnum > (i + 1)) | 857 | if (*endnum > (i + 1)) |
815 | memmove(&laarr[i], &laarr[i + 1], | 858 | memmove(&laarr[i], |
816 | sizeof(long_ad) * (*endnum - (i + 1))); | 859 | &laarr[i + 1], |
860 | sizeof(long_ad) * | ||
861 | (*endnum - (i + 1))); | ||
817 | i--; | 862 | i--; |
818 | (*endnum)--; | 863 | (*endnum)--; |
819 | } | 864 | } |
820 | } | 865 | } |
821 | UDF_I_LENEXTENTS(inode) += numalloc << inode->i_sb->s_blocksize_bits; | 866 | UDF_I_LENEXTENTS(inode) += |
867 | numalloc << inode->i_sb->s_blocksize_bits; | ||
822 | } | 868 | } |
823 | } | 869 | } |
824 | } | 870 | } |
@@ -828,70 +874,97 @@ static void udf_merge_extents(struct inode *inode, | |||
828 | int *endnum) | 874 | int *endnum) |
829 | { | 875 | { |
830 | int i; | 876 | int i; |
877 | unsigned long blocksize = inode->i_sb->s_blocksize; | ||
878 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; | ||
831 | 879 | ||
832 | for (i = 0; i < (*endnum - 1); i++) { | 880 | for (i = 0; i < (*endnum - 1); i++) { |
833 | if ((laarr[i].extLength >> 30) == (laarr[i + 1].extLength >> 30)) { | 881 | kernel_long_ad *li /*l[i]*/ = &laarr[i]; |
834 | if (((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) || | 882 | kernel_long_ad *lip1 /*l[i plus 1]*/ = &laarr[i + 1]; |
835 | ((laarr[i + 1].extLocation.logicalBlockNum - laarr[i].extLocation.logicalBlockNum) == | 883 | |
836 | (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 884 | if (((li->extLength >> 30) == (lip1->extLength >> 30)) && |
837 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits))) { | 885 | (((li->extLength >> 30) == |
838 | if (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 886 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) || |
839 | (laarr[i + 1].extLength & UDF_EXTENT_LENGTH_MASK) + | 887 | ((lip1->extLocation.logicalBlockNum - |
840 | inode->i_sb->s_blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) { | 888 | li->extLocation.logicalBlockNum) == |
841 | laarr[i + 1].extLength = (laarr[i + 1].extLength - | 889 | (((li->extLength & UDF_EXTENT_LENGTH_MASK) + |
842 | (laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 890 | blocksize - 1) >> blocksize_bits)))) { |
843 | UDF_EXTENT_LENGTH_MASK) & ~(inode->i_sb->s_blocksize - 1); | 891 | |
844 | laarr[i].extLength = (laarr[i].extLength & UDF_EXTENT_FLAG_MASK) + | 892 | if (((li->extLength & UDF_EXTENT_LENGTH_MASK) + |
845 | (UDF_EXTENT_LENGTH_MASK + 1) - inode->i_sb->s_blocksize; | 893 | (lip1->extLength & UDF_EXTENT_LENGTH_MASK) + |
846 | laarr[i + 1].extLocation.logicalBlockNum = | 894 | blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) { |
847 | laarr[i].extLocation.logicalBlockNum + | 895 | lip1->extLength = (lip1->extLength - |
848 | ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) >> | 896 | (li->extLength & |
849 | inode->i_sb->s_blocksize_bits); | 897 | UDF_EXTENT_LENGTH_MASK) + |
850 | } else { | 898 | UDF_EXTENT_LENGTH_MASK) & |
851 | laarr[i].extLength = laarr[i + 1].extLength + | 899 | ~(blocksize - 1); |
852 | (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 900 | li->extLength = (li->extLength & |
853 | inode->i_sb->s_blocksize - 1) & ~(inode->i_sb->s_blocksize - 1)); | 901 | UDF_EXTENT_FLAG_MASK) + |
854 | if (*endnum > (i + 2)) | 902 | (UDF_EXTENT_LENGTH_MASK + 1) - |
855 | memmove(&laarr[i + 1], &laarr[i + 2], | 903 | blocksize; |
856 | sizeof(long_ad) * (*endnum - (i + 2))); | 904 | lip1->extLocation.logicalBlockNum = |
857 | i--; | 905 | li->extLocation.logicalBlockNum + |
858 | (*endnum)--; | 906 | ((li->extLength & |
859 | } | 907 | UDF_EXTENT_LENGTH_MASK) >> |
908 | blocksize_bits); | ||
909 | } else { | ||
910 | li->extLength = lip1->extLength + | ||
911 | (((li->extLength & | ||
912 | UDF_EXTENT_LENGTH_MASK) + | ||
913 | blocksize - 1) & ~(blocksize - 1)); | ||
914 | if (*endnum > (i + 2)) | ||
915 | memmove(&laarr[i + 1], &laarr[i + 2], | ||
916 | sizeof(long_ad) * | ||
917 | (*endnum - (i + 2))); | ||
918 | i--; | ||
919 | (*endnum)--; | ||
860 | } | 920 | } |
861 | } else if (((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) && | 921 | } else if (((li->extLength >> 30) == |
862 | ((laarr[i + 1].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))) { | 922 | (EXT_NOT_RECORDED_ALLOCATED >> 30)) && |
863 | udf_free_blocks(inode->i_sb, inode, laarr[i].extLocation, 0, | 923 | ((lip1->extLength >> 30) == |
864 | ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 924 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))) { |
865 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); | 925 | udf_free_blocks(inode->i_sb, inode, li->extLocation, 0, |
866 | laarr[i].extLocation.logicalBlockNum = 0; | 926 | ((li->extLength & |
867 | laarr[i].extLocation.partitionReferenceNum = 0; | 927 | UDF_EXTENT_LENGTH_MASK) + |
868 | 928 | blocksize - 1) >> blocksize_bits); | |
869 | if (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 929 | li->extLocation.logicalBlockNum = 0; |
870 | (laarr[i + 1].extLength & UDF_EXTENT_LENGTH_MASK) + | 930 | li->extLocation.partitionReferenceNum = 0; |
871 | inode->i_sb->s_blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) { | 931 | |
872 | laarr[i + 1].extLength = (laarr[i + 1].extLength - | 932 | if (((li->extLength & UDF_EXTENT_LENGTH_MASK) + |
873 | (laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 933 | (lip1->extLength & UDF_EXTENT_LENGTH_MASK) + |
874 | UDF_EXTENT_LENGTH_MASK) & ~(inode->i_sb->s_blocksize - 1); | 934 | blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) { |
875 | laarr[i].extLength = (laarr[i].extLength & UDF_EXTENT_FLAG_MASK) + | 935 | lip1->extLength = (lip1->extLength - |
876 | (UDF_EXTENT_LENGTH_MASK + 1) - inode->i_sb->s_blocksize; | 936 | (li->extLength & |
937 | UDF_EXTENT_LENGTH_MASK) + | ||
938 | UDF_EXTENT_LENGTH_MASK) & | ||
939 | ~(blocksize - 1); | ||
940 | li->extLength = (li->extLength & | ||
941 | UDF_EXTENT_FLAG_MASK) + | ||
942 | (UDF_EXTENT_LENGTH_MASK + 1) - | ||
943 | blocksize; | ||
877 | } else { | 944 | } else { |
878 | laarr[i].extLength = laarr[i + 1].extLength + | 945 | li->extLength = lip1->extLength + |
879 | (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 946 | (((li->extLength & |
880 | inode->i_sb->s_blocksize - 1) & ~(inode->i_sb->s_blocksize - 1)); | 947 | UDF_EXTENT_LENGTH_MASK) + |
948 | blocksize - 1) & ~(blocksize - 1)); | ||
881 | if (*endnum > (i + 2)) | 949 | if (*endnum > (i + 2)) |
882 | memmove(&laarr[i + 1], &laarr[i + 2], | 950 | memmove(&laarr[i + 1], &laarr[i + 2], |
883 | sizeof(long_ad) * (*endnum - (i + 2))); | 951 | sizeof(long_ad) * |
952 | (*endnum - (i + 2))); | ||
884 | i--; | 953 | i--; |
885 | (*endnum)--; | 954 | (*endnum)--; |
886 | } | 955 | } |
887 | } else if ((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | 956 | } else if ((li->extLength >> 30) == |
888 | udf_free_blocks(inode->i_sb, inode, laarr[i].extLocation, 0, | 957 | (EXT_NOT_RECORDED_ALLOCATED >> 30)) { |
889 | ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 958 | udf_free_blocks(inode->i_sb, inode, |
890 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); | 959 | li->extLocation, 0, |
891 | laarr[i].extLocation.logicalBlockNum = 0; | 960 | ((li->extLength & |
892 | laarr[i].extLocation.partitionReferenceNum = 0; | 961 | UDF_EXTENT_LENGTH_MASK) + |
893 | laarr[i].extLength = (laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) | | 962 | blocksize - 1) >> blocksize_bits); |
894 | EXT_NOT_RECORDED_NOT_ALLOCATED; | 963 | li->extLocation.logicalBlockNum = 0; |
964 | li->extLocation.partitionReferenceNum = 0; | ||
965 | li->extLength = (li->extLength & | ||
966 | UDF_EXTENT_LENGTH_MASK) | | ||
967 | EXT_NOT_RECORDED_NOT_ALLOCATED; | ||
895 | } | 968 | } |
896 | } | 969 | } |
897 | } | 970 | } |
@@ -962,24 +1035,26 @@ void udf_truncate(struct inode *inode) | |||
962 | 1035 | ||
963 | lock_kernel(); | 1036 | lock_kernel(); |
964 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { | 1037 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { |
965 | if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) + | 1038 | if (inode->i_sb->s_blocksize < |
966 | inode->i_size)) { | 1039 | (udf_file_entry_alloc_offset(inode) + |
1040 | inode->i_size)) { | ||
967 | udf_expand_file_adinicb(inode, inode->i_size, &err); | 1041 | udf_expand_file_adinicb(inode, inode->i_size, &err); |
968 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { | 1042 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { |
969 | inode->i_size = UDF_I_LENALLOC(inode); | 1043 | inode->i_size = UDF_I_LENALLOC(inode); |
970 | unlock_kernel(); | 1044 | unlock_kernel(); |
971 | return; | 1045 | return; |
972 | } else { | 1046 | } else |
973 | udf_truncate_extents(inode); | 1047 | udf_truncate_extents(inode); |
974 | } | ||
975 | } else { | 1048 | } else { |
976 | offset = inode->i_size & (inode->i_sb->s_blocksize - 1); | 1049 | offset = inode->i_size & (inode->i_sb->s_blocksize - 1); |
977 | memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode) + offset, 0x00, | 1050 | memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode) + |
978 | inode->i_sb->s_blocksize - offset - udf_file_entry_alloc_offset(inode)); | 1051 | offset, 0x00, inode->i_sb->s_blocksize - |
1052 | offset - udf_file_entry_alloc_offset(inode)); | ||
979 | UDF_I_LENALLOC(inode) = inode->i_size; | 1053 | UDF_I_LENALLOC(inode) = inode->i_size; |
980 | } | 1054 | } |
981 | } else { | 1055 | } else { |
982 | block_truncate_page(inode->i_mapping, inode->i_size, udf_get_block); | 1056 | block_truncate_page(inode->i_mapping, inode->i_size, |
1057 | udf_get_block); | ||
983 | udf_truncate_extents(inode); | 1058 | udf_truncate_extents(inode); |
984 | } | 1059 | } |
985 | 1060 | ||
@@ -1019,8 +1094,8 @@ static void __udf_read_inode(struct inode *inode) | |||
1019 | 1094 | ||
1020 | if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && | 1095 | if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && |
1021 | ident != TAG_IDENT_USE) { | 1096 | ident != TAG_IDENT_USE) { |
1022 | printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed ident=%d\n", | 1097 | printk(KERN_ERR "udf: udf_read_inode(ino %ld) " |
1023 | inode->i_ino, ident); | 1098 | "failed ident=%d\n", inode->i_ino, ident); |
1024 | brelse(bh); | 1099 | brelse(bh); |
1025 | make_bad_inode(inode); | 1100 | make_bad_inode(inode); |
1026 | return; | 1101 | return; |
@@ -1032,7 +1107,8 @@ static void __udf_read_inode(struct inode *inode) | |||
1032 | struct buffer_head *ibh = NULL, *nbh = NULL; | 1107 | struct buffer_head *ibh = NULL, *nbh = NULL; |
1033 | struct indirectEntry *ie; | 1108 | struct indirectEntry *ie; |
1034 | 1109 | ||
1035 | ibh = udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 1, &ident); | 1110 | ibh = udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 1, |
1111 | &ident); | ||
1036 | if (ident == TAG_IDENT_IE) { | 1112 | if (ident == TAG_IDENT_IE) { |
1037 | if (ibh) { | 1113 | if (ibh) { |
1038 | kernel_lb_addr loc; | 1114 | kernel_lb_addr loc; |
@@ -1041,10 +1117,12 @@ static void __udf_read_inode(struct inode *inode) | |||
1041 | loc = lelb_to_cpu(ie->indirectICB.extLocation); | 1117 | loc = lelb_to_cpu(ie->indirectICB.extLocation); |
1042 | 1118 | ||
1043 | if (ie->indirectICB.extLength && | 1119 | if (ie->indirectICB.extLength && |
1044 | (nbh = udf_read_ptagged(inode->i_sb, loc, 0, &ident))) { | 1120 | (nbh = udf_read_ptagged(inode->i_sb, loc, 0, |
1121 | &ident))) { | ||
1045 | if (ident == TAG_IDENT_FE || | 1122 | if (ident == TAG_IDENT_FE || |
1046 | ident == TAG_IDENT_EFE) { | 1123 | ident == TAG_IDENT_EFE) { |
1047 | memcpy(&UDF_I_LOCATION(inode), &loc, | 1124 | memcpy(&UDF_I_LOCATION(inode), |
1125 | &loc, | ||
1048 | sizeof(kernel_lb_addr)); | 1126 | sizeof(kernel_lb_addr)); |
1049 | brelse(bh); | 1127 | brelse(bh); |
1050 | brelse(ibh); | 1128 | brelse(ibh); |
@@ -1091,7 +1169,8 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1091 | else /* if (le16_to_cpu(fe->icbTag.strategyType) == 4096) */ | 1169 | else /* if (le16_to_cpu(fe->icbTag.strategyType) == 4096) */ |
1092 | UDF_I_STRAT4096(inode) = 1; | 1170 | UDF_I_STRAT4096(inode) = 1; |
1093 | 1171 | ||
1094 | UDF_I_ALLOCTYPE(inode) = le16_to_cpu(fe->icbTag.flags) & ICBTAG_FLAG_AD_MASK; | 1172 | UDF_I_ALLOCTYPE(inode) = le16_to_cpu(fe->icbTag.flags) & |
1173 | ICBTAG_FLAG_AD_MASK; | ||
1095 | UDF_I_UNIQUE(inode) = 0; | 1174 | UDF_I_UNIQUE(inode) = 0; |
1096 | UDF_I_LENEATTR(inode) = 0; | 1175 | UDF_I_LENEATTR(inode) = 0; |
1097 | UDF_I_LENEXTENTS(inode) = 0; | 1176 | UDF_I_LENEXTENTS(inode) = 0; |
@@ -1101,16 +1180,20 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1101 | if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_EFE) { | 1180 | if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_EFE) { |
1102 | UDF_I_EFE(inode) = 1; | 1181 | UDF_I_EFE(inode) = 1; |
1103 | UDF_I_USE(inode) = 0; | 1182 | UDF_I_USE(inode) = 0; |
1104 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry))) { | 1183 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - |
1184 | sizeof(struct extendedFileEntry))) { | ||
1105 | make_bad_inode(inode); | 1185 | make_bad_inode(inode); |
1106 | return; | 1186 | return; |
1107 | } | 1187 | } |
1108 | memcpy(UDF_I_DATA(inode), bh->b_data + sizeof(struct extendedFileEntry), | 1188 | memcpy(UDF_I_DATA(inode), |
1109 | inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry)); | 1189 | bh->b_data + sizeof(struct extendedFileEntry), |
1190 | inode->i_sb->s_blocksize - | ||
1191 | sizeof(struct extendedFileEntry)); | ||
1110 | } else if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_FE) { | 1192 | } else if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_FE) { |
1111 | UDF_I_EFE(inode) = 0; | 1193 | UDF_I_EFE(inode) = 0; |
1112 | UDF_I_USE(inode) = 0; | 1194 | UDF_I_USE(inode) = 0; |
1113 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - sizeof(struct fileEntry))) { | 1195 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - |
1196 | sizeof(struct fileEntry))) { | ||
1114 | make_bad_inode(inode); | 1197 | make_bad_inode(inode); |
1115 | return; | 1198 | return; |
1116 | } | 1199 | } |
@@ -1119,14 +1202,18 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1119 | } else if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_USE) { | 1202 | } else if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_USE) { |
1120 | UDF_I_EFE(inode) = 0; | 1203 | UDF_I_EFE(inode) = 0; |
1121 | UDF_I_USE(inode) = 1; | 1204 | UDF_I_USE(inode) = 1; |
1122 | UDF_I_LENALLOC(inode) = | 1205 | UDF_I_LENALLOC(inode) = le32_to_cpu( |
1123 | le32_to_cpu(((struct unallocSpaceEntry *)bh->b_data)->lengthAllocDescs); | 1206 | ((struct unallocSpaceEntry *)bh->b_data)-> |
1124 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - sizeof(struct unallocSpaceEntry))) { | 1207 | lengthAllocDescs); |
1208 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - | ||
1209 | sizeof(struct unallocSpaceEntry))) { | ||
1125 | make_bad_inode(inode); | 1210 | make_bad_inode(inode); |
1126 | return; | 1211 | return; |
1127 | } | 1212 | } |
1128 | memcpy(UDF_I_DATA(inode), bh->b_data + sizeof(struct unallocSpaceEntry), | 1213 | memcpy(UDF_I_DATA(inode), |
1129 | inode->i_sb->s_blocksize - sizeof(struct unallocSpaceEntry)); | 1214 | bh->b_data + sizeof(struct unallocSpaceEntry), |
1215 | inode->i_sb->s_blocksize - | ||
1216 | sizeof(struct unallocSpaceEntry)); | ||
1130 | return; | 1217 | return; |
1131 | } | 1218 | } |
1132 | 1219 | ||
@@ -1223,7 +1310,8 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1223 | UDF_I_UNIQUE(inode) = le64_to_cpu(efe->uniqueID); | 1310 | UDF_I_UNIQUE(inode) = le64_to_cpu(efe->uniqueID); |
1224 | UDF_I_LENEATTR(inode) = le32_to_cpu(efe->lengthExtendedAttr); | 1311 | UDF_I_LENEATTR(inode) = le32_to_cpu(efe->lengthExtendedAttr); |
1225 | UDF_I_LENALLOC(inode) = le32_to_cpu(efe->lengthAllocDescs); | 1312 | UDF_I_LENALLOC(inode) = le32_to_cpu(efe->lengthAllocDescs); |
1226 | offset = sizeof(struct extendedFileEntry) + UDF_I_LENEATTR(inode); | 1313 | offset = sizeof(struct extendedFileEntry) + |
1314 | UDF_I_LENEATTR(inode); | ||
1227 | } | 1315 | } |
1228 | 1316 | ||
1229 | switch (fe->icbTag.fileType) { | 1317 | switch (fe->icbTag.fileType) { |
@@ -1262,21 +1350,22 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1262 | inode->i_mode = S_IFLNK | S_IRWXUGO; | 1350 | inode->i_mode = S_IFLNK | S_IRWXUGO; |
1263 | break; | 1351 | break; |
1264 | default: | 1352 | default: |
1265 | printk(KERN_ERR "udf: udf_fill_inode(ino %ld) failed unknown file type=%d\n", | 1353 | printk(KERN_ERR "udf: udf_fill_inode(ino %ld) failed unknown " |
1266 | inode->i_ino, fe->icbTag.fileType); | 1354 | "file type=%d\n", inode->i_ino, |
1355 | fe->icbTag.fileType); | ||
1267 | make_bad_inode(inode); | 1356 | make_bad_inode(inode); |
1268 | return; | 1357 | return; |
1269 | } | 1358 | } |
1270 | if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { | 1359 | if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { |
1271 | struct deviceSpec *dsea = (struct deviceSpec *)udf_get_extendedattr(inode, 12, 1); | 1360 | struct deviceSpec *dsea = |
1361 | (struct deviceSpec *)udf_get_extendedattr(inode, 12, 1); | ||
1272 | if (dsea) { | 1362 | if (dsea) { |
1273 | init_special_inode(inode, inode->i_mode, | 1363 | init_special_inode(inode, inode->i_mode, |
1274 | MKDEV(le32_to_cpu(dsea->majorDeviceIdent), | 1364 | MKDEV(le32_to_cpu(dsea->majorDeviceIdent), |
1275 | le32_to_cpu(dsea->minorDeviceIdent))); | 1365 | le32_to_cpu(dsea->minorDeviceIdent))); |
1276 | /* Developer ID ??? */ | 1366 | /* Developer ID ??? */ |
1277 | } else { | 1367 | } else |
1278 | make_bad_inode(inode); | 1368 | make_bad_inode(inode); |
1279 | } | ||
1280 | } | 1369 | } |
1281 | } | 1370 | } |
1282 | 1371 | ||
@@ -1285,8 +1374,8 @@ static int udf_alloc_i_data(struct inode *inode, size_t size) | |||
1285 | UDF_I_DATA(inode) = kmalloc(size, GFP_KERNEL); | 1374 | UDF_I_DATA(inode) = kmalloc(size, GFP_KERNEL); |
1286 | 1375 | ||
1287 | if (!UDF_I_DATA(inode)) { | 1376 | if (!UDF_I_DATA(inode)) { |
1288 | printk(KERN_ERR "udf:udf_alloc_i_data (ino %ld) no free memory\n", | 1377 | printk(KERN_ERR "udf:udf_alloc_i_data (ino %ld) " |
1289 | inode->i_ino); | 1378 | "no free memory\n", inode->i_ino); |
1290 | return -ENOMEM; | 1379 | return -ENOMEM; |
1291 | } | 1380 | } |
1292 | 1381 | ||
@@ -1302,12 +1391,12 @@ static mode_t udf_convert_permissions(struct fileEntry *fe) | |||
1302 | permissions = le32_to_cpu(fe->permissions); | 1391 | permissions = le32_to_cpu(fe->permissions); |
1303 | flags = le16_to_cpu(fe->icbTag.flags); | 1392 | flags = le16_to_cpu(fe->icbTag.flags); |
1304 | 1393 | ||
1305 | mode = (( permissions ) & S_IRWXO) | | 1394 | mode = ((permissions) & S_IRWXO) | |
1306 | (( permissions >> 2 ) & S_IRWXG) | | 1395 | ((permissions >> 2) & S_IRWXG) | |
1307 | (( permissions >> 4 ) & S_IRWXU) | | 1396 | ((permissions >> 4) & S_IRWXU) | |
1308 | (( flags & ICBTAG_FLAG_SETUID) ? S_ISUID : 0) | | 1397 | ((flags & ICBTAG_FLAG_SETUID) ? S_ISUID : 0) | |
1309 | (( flags & ICBTAG_FLAG_SETGID) ? S_ISGID : 0) | | 1398 | ((flags & ICBTAG_FLAG_SETGID) ? S_ISGID : 0) | |
1310 | (( flags & ICBTAG_FLAG_STICKY) ? S_ISVTX : 0); | 1399 | ((flags & ICBTAG_FLAG_STICKY) ? S_ISVTX : 0); |
1311 | 1400 | ||
1312 | return mode; | 1401 | return mode; |
1313 | } | 1402 | } |
@@ -1355,8 +1444,11 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1355 | kernel_timestamp cpu_time; | 1444 | kernel_timestamp cpu_time; |
1356 | int err = 0; | 1445 | int err = 0; |
1357 | struct udf_sb_info *sbi = UDF_SB(inode->i_sb); | 1446 | struct udf_sb_info *sbi = UDF_SB(inode->i_sb); |
1447 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; | ||
1358 | 1448 | ||
1359 | bh = udf_tread(inode->i_sb, udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode), 0)); | 1449 | bh = udf_tread(inode->i_sb, |
1450 | udf_get_lb_pblock(inode->i_sb, | ||
1451 | UDF_I_LOCATION(inode), 0)); | ||
1360 | if (!bh) { | 1452 | if (!bh) { |
1361 | udf_debug("bread failure\n"); | 1453 | udf_debug("bread failure\n"); |
1362 | return -EIO; | 1454 | return -EIO; |
@@ -1372,18 +1464,24 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1372 | (struct unallocSpaceEntry *)bh->b_data; | 1464 | (struct unallocSpaceEntry *)bh->b_data; |
1373 | 1465 | ||
1374 | use->lengthAllocDescs = cpu_to_le32(UDF_I_LENALLOC(inode)); | 1466 | use->lengthAllocDescs = cpu_to_le32(UDF_I_LENALLOC(inode)); |
1375 | memcpy(bh->b_data + sizeof(struct unallocSpaceEntry), UDF_I_DATA(inode), | 1467 | memcpy(bh->b_data + sizeof(struct unallocSpaceEntry), |
1376 | inode->i_sb->s_blocksize - sizeof(struct unallocSpaceEntry)); | 1468 | UDF_I_DATA(inode), inode->i_sb->s_blocksize - |
1377 | crclen = sizeof(struct unallocSpaceEntry) + UDF_I_LENALLOC(inode) - sizeof(tag); | 1469 | sizeof(struct unallocSpaceEntry)); |
1378 | use->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); | 1470 | crclen = sizeof(struct unallocSpaceEntry) + |
1471 | UDF_I_LENALLOC(inode) - sizeof(tag); | ||
1472 | use->descTag.tagLocation = cpu_to_le32( | ||
1473 | UDF_I_LOCATION(inode). | ||
1474 | logicalBlockNum); | ||
1379 | use->descTag.descCRCLength = cpu_to_le16(crclen); | 1475 | use->descTag.descCRCLength = cpu_to_le16(crclen); |
1380 | use->descTag.descCRC = cpu_to_le16(udf_crc((char *)use + sizeof(tag), crclen, 0)); | 1476 | use->descTag.descCRC = cpu_to_le16(udf_crc((char *)use + |
1477 | sizeof(tag), crclen, | ||
1478 | 0)); | ||
1381 | 1479 | ||
1382 | use->descTag.tagChecksum = 0; | 1480 | use->descTag.tagChecksum = 0; |
1383 | for (i = 0; i < 16; i++) { | 1481 | for (i = 0; i < 16; i++) |
1384 | if (i != 4) | 1482 | if (i != 4) |
1385 | use->descTag.tagChecksum += ((uint8_t *)&(use->descTag))[i]; | 1483 | use->descTag.tagChecksum += |
1386 | } | 1484 | ((uint8_t *)&(use->descTag))[i]; |
1387 | 1485 | ||
1388 | mark_buffer_dirty(bh); | 1486 | mark_buffer_dirty(bh); |
1389 | brelse(bh); | 1487 | brelse(bh); |
@@ -1400,14 +1498,14 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1400 | else | 1498 | else |
1401 | fe->gid = cpu_to_le32(inode->i_gid); | 1499 | fe->gid = cpu_to_le32(inode->i_gid); |
1402 | 1500 | ||
1403 | udfperms = ((inode->i_mode & S_IRWXO) ) | | 1501 | udfperms = ((inode->i_mode & S_IRWXO)) | |
1404 | ((inode->i_mode & S_IRWXG) << 2) | | 1502 | ((inode->i_mode & S_IRWXG) << 2) | |
1405 | ((inode->i_mode & S_IRWXU) << 4); | 1503 | ((inode->i_mode & S_IRWXU) << 4); |
1406 | 1504 | ||
1407 | udfperms |= (le32_to_cpu(fe->permissions) & | 1505 | udfperms |= (le32_to_cpu(fe->permissions) & |
1408 | (FE_PERM_O_DELETE | FE_PERM_O_CHATTR | | 1506 | (FE_PERM_O_DELETE | FE_PERM_O_CHATTR | |
1409 | FE_PERM_G_DELETE | FE_PERM_G_CHATTR | | 1507 | FE_PERM_G_DELETE | FE_PERM_G_CHATTR | |
1410 | FE_PERM_U_DELETE | FE_PERM_U_CHATTR)); | 1508 | FE_PERM_U_DELETE | FE_PERM_U_CHATTR)); |
1411 | fe->permissions = cpu_to_le32(udfperms); | 1509 | fe->permissions = cpu_to_le32(udfperms); |
1412 | 1510 | ||
1413 | if (S_ISDIR(inode->i_mode)) | 1511 | if (S_ISDIR(inode->i_mode)) |
@@ -1428,8 +1526,9 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1428 | sizeof(regid), 12, 0x3); | 1526 | sizeof(regid), 12, 0x3); |
1429 | dsea->attrType = cpu_to_le32(12); | 1527 | dsea->attrType = cpu_to_le32(12); |
1430 | dsea->attrSubtype = 1; | 1528 | dsea->attrSubtype = 1; |
1431 | dsea->attrLength = cpu_to_le32(sizeof(struct deviceSpec) + | 1529 | dsea->attrLength = cpu_to_le32( |
1432 | sizeof(regid)); | 1530 | sizeof(struct deviceSpec) + |
1531 | sizeof(regid)); | ||
1433 | dsea->impUseLength = cpu_to_le32(sizeof(regid)); | 1532 | dsea->impUseLength = cpu_to_le32(sizeof(regid)); |
1434 | } | 1533 | } |
1435 | eid = (regid *)dsea->impUse; | 1534 | eid = (regid *)dsea->impUse; |
@@ -1445,8 +1544,8 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1445 | memcpy(bh->b_data + sizeof(struct fileEntry), UDF_I_DATA(inode), | 1544 | memcpy(bh->b_data + sizeof(struct fileEntry), UDF_I_DATA(inode), |
1446 | inode->i_sb->s_blocksize - sizeof(struct fileEntry)); | 1545 | inode->i_sb->s_blocksize - sizeof(struct fileEntry)); |
1447 | fe->logicalBlocksRecorded = cpu_to_le64( | 1546 | fe->logicalBlocksRecorded = cpu_to_le64( |
1448 | (inode->i_blocks + (1 << (inode->i_sb->s_blocksize_bits - 9)) - 1) >> | 1547 | (inode->i_blocks + (1 << (blocksize_bits - 9)) - 1) >> |
1449 | (inode->i_sb->s_blocksize_bits - 9)); | 1548 | (blocksize_bits - 9)); |
1450 | 1549 | ||
1451 | if (udf_time_to_stamp(&cpu_time, inode->i_atime)) | 1550 | if (udf_time_to_stamp(&cpu_time, inode->i_atime)) |
1452 | fe->accessTime = cpu_to_lets(cpu_time); | 1551 | fe->accessTime = cpu_to_lets(cpu_time); |
@@ -1464,28 +1563,29 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1464 | fe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_FE); | 1563 | fe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_FE); |
1465 | crclen = sizeof(struct fileEntry); | 1564 | crclen = sizeof(struct fileEntry); |
1466 | } else { | 1565 | } else { |
1467 | memcpy(bh->b_data + sizeof(struct extendedFileEntry), UDF_I_DATA(inode), | 1566 | memcpy(bh->b_data + sizeof(struct extendedFileEntry), |
1468 | inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry)); | 1567 | UDF_I_DATA(inode), |
1568 | inode->i_sb->s_blocksize - | ||
1569 | sizeof(struct extendedFileEntry)); | ||
1469 | efe->objectSize = cpu_to_le64(inode->i_size); | 1570 | efe->objectSize = cpu_to_le64(inode->i_size); |
1470 | efe->logicalBlocksRecorded = cpu_to_le64( | 1571 | efe->logicalBlocksRecorded = cpu_to_le64( |
1471 | (inode->i_blocks + (1 << (inode->i_sb->s_blocksize_bits - 9)) - 1) >> | 1572 | (inode->i_blocks + (1 << (blocksize_bits - 9)) - 1) >> |
1472 | (inode->i_sb->s_blocksize_bits - 9)); | 1573 | (blocksize_bits - 9)); |
1473 | 1574 | ||
1474 | if (UDF_I_CRTIME(inode).tv_sec > inode->i_atime.tv_sec || | 1575 | if (UDF_I_CRTIME(inode).tv_sec > inode->i_atime.tv_sec || |
1475 | (UDF_I_CRTIME(inode).tv_sec == inode->i_atime.tv_sec && | 1576 | (UDF_I_CRTIME(inode).tv_sec == inode->i_atime.tv_sec && |
1476 | UDF_I_CRTIME(inode).tv_nsec > inode->i_atime.tv_nsec)) { | 1577 | UDF_I_CRTIME(inode).tv_nsec > inode->i_atime.tv_nsec)) |
1477 | UDF_I_CRTIME(inode) = inode->i_atime; | 1578 | UDF_I_CRTIME(inode) = inode->i_atime; |
1478 | } | 1579 | |
1479 | if (UDF_I_CRTIME(inode).tv_sec > inode->i_mtime.tv_sec || | 1580 | if (UDF_I_CRTIME(inode).tv_sec > inode->i_mtime.tv_sec || |
1480 | (UDF_I_CRTIME(inode).tv_sec == inode->i_mtime.tv_sec && | 1581 | (UDF_I_CRTIME(inode).tv_sec == inode->i_mtime.tv_sec && |
1481 | UDF_I_CRTIME(inode).tv_nsec > inode->i_mtime.tv_nsec)) { | 1582 | UDF_I_CRTIME(inode).tv_nsec > inode->i_mtime.tv_nsec)) |
1482 | UDF_I_CRTIME(inode) = inode->i_mtime; | 1583 | UDF_I_CRTIME(inode) = inode->i_mtime; |
1483 | } | 1584 | |
1484 | if (UDF_I_CRTIME(inode).tv_sec > inode->i_ctime.tv_sec || | 1585 | if (UDF_I_CRTIME(inode).tv_sec > inode->i_ctime.tv_sec || |
1485 | (UDF_I_CRTIME(inode).tv_sec == inode->i_ctime.tv_sec && | 1586 | (UDF_I_CRTIME(inode).tv_sec == inode->i_ctime.tv_sec && |
1486 | UDF_I_CRTIME(inode).tv_nsec > inode->i_ctime.tv_nsec)) { | 1587 | UDF_I_CRTIME(inode).tv_nsec > inode->i_ctime.tv_nsec)) |
1487 | UDF_I_CRTIME(inode) = inode->i_ctime; | 1588 | UDF_I_CRTIME(inode) = inode->i_ctime; |
1488 | } | ||
1489 | 1589 | ||
1490 | if (udf_time_to_stamp(&cpu_time, inode->i_atime)) | 1590 | if (udf_time_to_stamp(&cpu_time, inode->i_atime)) |
1491 | efe->accessTime = cpu_to_lets(cpu_time); | 1591 | efe->accessTime = cpu_to_lets(cpu_time); |
@@ -1544,24 +1644,27 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1544 | else | 1644 | else |
1545 | fe->descTag.descVersion = cpu_to_le16(2); | 1645 | fe->descTag.descVersion = cpu_to_le16(2); |
1546 | fe->descTag.tagSerialNum = cpu_to_le16(sbi->s_serial_number); | 1646 | fe->descTag.tagSerialNum = cpu_to_le16(sbi->s_serial_number); |
1547 | fe->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); | 1647 | fe->descTag.tagLocation = cpu_to_le32( |
1648 | UDF_I_LOCATION(inode).logicalBlockNum); | ||
1548 | crclen += UDF_I_LENEATTR(inode) + UDF_I_LENALLOC(inode) - sizeof(tag); | 1649 | crclen += UDF_I_LENEATTR(inode) + UDF_I_LENALLOC(inode) - sizeof(tag); |
1549 | fe->descTag.descCRCLength = cpu_to_le16(crclen); | 1650 | fe->descTag.descCRCLength = cpu_to_le16(crclen); |
1550 | fe->descTag.descCRC = cpu_to_le16(udf_crc((char *)fe + sizeof(tag), crclen, 0)); | 1651 | fe->descTag.descCRC = cpu_to_le16(udf_crc((char *)fe + sizeof(tag), |
1652 | crclen, 0)); | ||
1551 | 1653 | ||
1552 | fe->descTag.tagChecksum = 0; | 1654 | fe->descTag.tagChecksum = 0; |
1553 | for (i = 0; i < 16; i++) { | 1655 | for (i = 0; i < 16; i++) |
1554 | if (i != 4) | 1656 | if (i != 4) |
1555 | fe->descTag.tagChecksum += ((uint8_t *)&(fe->descTag))[i]; | 1657 | fe->descTag.tagChecksum += |
1556 | } | 1658 | ((uint8_t *)&(fe->descTag))[i]; |
1557 | 1659 | ||
1558 | /* write the data blocks */ | 1660 | /* write the data blocks */ |
1559 | mark_buffer_dirty(bh); | 1661 | mark_buffer_dirty(bh); |
1560 | if (do_sync) { | 1662 | if (do_sync) { |
1561 | sync_dirty_buffer(bh); | 1663 | sync_dirty_buffer(bh); |
1562 | if (buffer_req(bh) && !buffer_uptodate(bh)) { | 1664 | if (buffer_req(bh) && !buffer_uptodate(bh)) { |
1563 | printk("IO error syncing udf inode [%s:%08lx]\n", | 1665 | printk(KERN_WARNING "IO error syncing udf inode " |
1564 | inode->i_sb->s_id, inode->i_ino); | 1666 | "[%s:%08lx]\n", inode->i_sb->s_id, |
1667 | inode->i_ino); | ||
1565 | err = -EIO; | 1668 | err = -EIO; |
1566 | } | 1669 | } |
1567 | } | 1670 | } |
@@ -1587,7 +1690,8 @@ struct inode *udf_iget(struct super_block *sb, kernel_lb_addr ino) | |||
1587 | if (is_bad_inode(inode)) | 1690 | if (is_bad_inode(inode)) |
1588 | goto out_iput; | 1691 | goto out_iput; |
1589 | 1692 | ||
1590 | if (ino.logicalBlockNum >= UDF_SB(sb)->s_partmaps[ino.partitionReferenceNum].s_partition_len) { | 1693 | if (ino.logicalBlockNum >= UDF_SB(sb)-> |
1694 | s_partmaps[ino.partitionReferenceNum].s_partition_len) { | ||
1591 | udf_debug("block=%d, partition=%d out of range\n", | 1695 | udf_debug("block=%d, partition=%d out of range\n", |
1592 | ino.logicalBlockNum, ino.partitionReferenceNum); | 1696 | ino.logicalBlockNum, ino.partitionReferenceNum); |
1593 | make_bad_inode(inode); | 1697 | make_bad_inode(inode); |
@@ -1601,7 +1705,7 @@ struct inode *udf_iget(struct super_block *sb, kernel_lb_addr ino) | |||
1601 | return NULL; | 1705 | return NULL; |
1602 | } | 1706 | } |
1603 | 1707 | ||
1604 | int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | 1708 | int8_t udf_add_aext(struct inode *inode, struct extent_position *epos, |
1605 | kernel_lb_addr eloc, uint32_t elen, int inc) | 1709 | kernel_lb_addr eloc, uint32_t elen, int inc) |
1606 | { | 1710 | { |
1607 | int adsize; | 1711 | int adsize; |
@@ -1612,7 +1716,9 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1612 | uint8_t *ptr; | 1716 | uint8_t *ptr; |
1613 | 1717 | ||
1614 | if (!epos->bh) | 1718 | if (!epos->bh) |
1615 | ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); | 1719 | ptr = UDF_I_DATA(inode) + epos->offset - |
1720 | udf_file_entry_alloc_offset(inode) + | ||
1721 | UDF_I_LENEATTR(inode); | ||
1616 | else | 1722 | else |
1617 | ptr = epos->bh->b_data + epos->offset; | 1723 | ptr = epos->bh->b_data + epos->offset; |
1618 | 1724 | ||
@@ -1629,15 +1735,16 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1629 | int err, loffset; | 1735 | int err, loffset; |
1630 | kernel_lb_addr obloc = epos->block; | 1736 | kernel_lb_addr obloc = epos->block; |
1631 | 1737 | ||
1632 | if (!(epos->block.logicalBlockNum = udf_new_block(inode->i_sb, NULL, | 1738 | epos->block.logicalBlockNum = udf_new_block(inode->i_sb, NULL, |
1633 | obloc.partitionReferenceNum, | 1739 | obloc.partitionReferenceNum, |
1634 | obloc.logicalBlockNum, &err))) { | 1740 | obloc.logicalBlockNum, &err); |
1741 | if (!epos->block.logicalBlockNum) | ||
1635 | return -1; | 1742 | return -1; |
1636 | } | 1743 | nbh = udf_tgetblk(inode->i_sb, udf_get_lb_pblock(inode->i_sb, |
1637 | if (!(nbh = udf_tgetblk(inode->i_sb, udf_get_lb_pblock(inode->i_sb, | 1744 | epos->block, |
1638 | epos->block, 0)))) { | 1745 | 0)); |
1746 | if (!nbh) | ||
1639 | return -1; | 1747 | return -1; |
1640 | } | ||
1641 | lock_buffer(nbh); | 1748 | lock_buffer(nbh); |
1642 | memset(nbh->b_data, 0x00, inode->i_sb->s_blocksize); | 1749 | memset(nbh->b_data, 0x00, inode->i_sb->s_blocksize); |
1643 | set_buffer_uptodate(nbh); | 1750 | set_buffer_uptodate(nbh); |
@@ -1646,7 +1753,8 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1646 | 1753 | ||
1647 | aed = (struct allocExtDesc *)(nbh->b_data); | 1754 | aed = (struct allocExtDesc *)(nbh->b_data); |
1648 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)) | 1755 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)) |
1649 | aed->previousAllocExtLocation = cpu_to_le32(obloc.logicalBlockNum); | 1756 | aed->previousAllocExtLocation = |
1757 | cpu_to_le32(obloc.logicalBlockNum); | ||
1650 | if (epos->offset + adsize > inode->i_sb->s_blocksize) { | 1758 | if (epos->offset + adsize > inode->i_sb->s_blocksize) { |
1651 | loffset = epos->offset; | 1759 | loffset = epos->offset; |
1652 | aed->lengthAllocDescs = cpu_to_le32(adsize); | 1760 | aed->lengthAllocDescs = cpu_to_le32(adsize); |
@@ -1663,7 +1771,8 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1663 | if (epos->bh) { | 1771 | if (epos->bh) { |
1664 | aed = (struct allocExtDesc *)epos->bh->b_data; | 1772 | aed = (struct allocExtDesc *)epos->bh->b_data; |
1665 | aed->lengthAllocDescs = | 1773 | aed->lengthAllocDescs = |
1666 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); | 1774 | cpu_to_le32(le32_to_cpu( |
1775 | aed->lengthAllocDescs) + adsize); | ||
1667 | } else { | 1776 | } else { |
1668 | UDF_I_LENALLOC(inode) += adsize; | 1777 | UDF_I_LENALLOC(inode) += adsize; |
1669 | mark_inode_dirty(inode); | 1778 | mark_inode_dirty(inode); |
@@ -1680,7 +1789,8 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1680 | sad = (short_ad *)sptr; | 1789 | sad = (short_ad *)sptr; |
1681 | sad->extLength = cpu_to_le32(EXT_NEXT_EXTENT_ALLOCDECS | | 1790 | sad->extLength = cpu_to_le32(EXT_NEXT_EXTENT_ALLOCDECS | |
1682 | inode->i_sb->s_blocksize); | 1791 | inode->i_sb->s_blocksize); |
1683 | sad->extPosition = cpu_to_le32(epos->block.logicalBlockNum); | 1792 | sad->extPosition = |
1793 | cpu_to_le32(epos->block.logicalBlockNum); | ||
1684 | break; | 1794 | break; |
1685 | case ICBTAG_FLAG_AD_LONG: | 1795 | case ICBTAG_FLAG_AD_LONG: |
1686 | lad = (long_ad *)sptr; | 1796 | lad = (long_ad *)sptr; |
@@ -1695,7 +1805,8 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1695 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) | 1805 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) |
1696 | udf_update_tag(epos->bh->b_data, loffset); | 1806 | udf_update_tag(epos->bh->b_data, loffset); |
1697 | else | 1807 | else |
1698 | udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc)); | 1808 | udf_update_tag(epos->bh->b_data, |
1809 | sizeof(struct allocExtDesc)); | ||
1699 | mark_buffer_dirty_inode(epos->bh, inode); | 1810 | mark_buffer_dirty_inode(epos->bh, inode); |
1700 | brelse(epos->bh); | 1811 | brelse(epos->bh); |
1701 | } else { | 1812 | } else { |
@@ -1712,18 +1823,22 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1712 | } else { | 1823 | } else { |
1713 | aed = (struct allocExtDesc *)epos->bh->b_data; | 1824 | aed = (struct allocExtDesc *)epos->bh->b_data; |
1714 | aed->lengthAllocDescs = | 1825 | aed->lengthAllocDescs = |
1715 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); | 1826 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + |
1716 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) | 1827 | adsize); |
1717 | udf_update_tag(epos->bh->b_data, epos->offset + (inc ? 0 : adsize)); | 1828 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1829 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) | ||
1830 | udf_update_tag(epos->bh->b_data, | ||
1831 | epos->offset + (inc ? 0 : adsize)); | ||
1718 | else | 1832 | else |
1719 | udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc)); | 1833 | udf_update_tag(epos->bh->b_data, |
1834 | sizeof(struct allocExtDesc)); | ||
1720 | mark_buffer_dirty_inode(epos->bh, inode); | 1835 | mark_buffer_dirty_inode(epos->bh, inode); |
1721 | } | 1836 | } |
1722 | 1837 | ||
1723 | return etype; | 1838 | return etype; |
1724 | } | 1839 | } |
1725 | 1840 | ||
1726 | int8_t udf_write_aext(struct inode * inode, struct extent_position * epos, | 1841 | int8_t udf_write_aext(struct inode *inode, struct extent_position *epos, |
1727 | kernel_lb_addr eloc, uint32_t elen, int inc) | 1842 | kernel_lb_addr eloc, uint32_t elen, int inc) |
1728 | { | 1843 | { |
1729 | int adsize; | 1844 | int adsize; |
@@ -1732,7 +1847,9 @@ int8_t udf_write_aext(struct inode * inode, struct extent_position * epos, | |||
1732 | long_ad *lad; | 1847 | long_ad *lad; |
1733 | 1848 | ||
1734 | if (!epos->bh) | 1849 | if (!epos->bh) |
1735 | ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); | 1850 | ptr = UDF_I_DATA(inode) + epos->offset - |
1851 | udf_file_entry_alloc_offset(inode) + | ||
1852 | UDF_I_LENEATTR(inode); | ||
1736 | else | 1853 | else |
1737 | ptr = epos->bh->b_data + epos->offset; | 1854 | ptr = epos->bh->b_data + epos->offset; |
1738 | 1855 | ||
@@ -1757,9 +1874,11 @@ int8_t udf_write_aext(struct inode * inode, struct extent_position * epos, | |||
1757 | if (epos->bh) { | 1874 | if (epos->bh) { |
1758 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 1875 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1759 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) { | 1876 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) { |
1760 | struct allocExtDesc *aed = (struct allocExtDesc *)epos->bh->b_data; | 1877 | struct allocExtDesc *aed = |
1878 | (struct allocExtDesc *)epos->bh->b_data; | ||
1761 | udf_update_tag(epos->bh->b_data, | 1879 | udf_update_tag(epos->bh->b_data, |
1762 | le32_to_cpu(aed->lengthAllocDescs) + sizeof(struct allocExtDesc)); | 1880 | le32_to_cpu(aed->lengthAllocDescs) + |
1881 | sizeof(struct allocExtDesc)); | ||
1763 | } | 1882 | } |
1764 | mark_buffer_dirty_inode(epos->bh, inode); | 1883 | mark_buffer_dirty_inode(epos->bh, inode); |
1765 | } else { | 1884 | } else { |
@@ -1772,19 +1891,21 @@ int8_t udf_write_aext(struct inode * inode, struct extent_position * epos, | |||
1772 | return (elen >> 30); | 1891 | return (elen >> 30); |
1773 | } | 1892 | } |
1774 | 1893 | ||
1775 | int8_t udf_next_aext(struct inode * inode, struct extent_position * epos, | 1894 | int8_t udf_next_aext(struct inode *inode, struct extent_position *epos, |
1776 | kernel_lb_addr * eloc, uint32_t * elen, int inc) | 1895 | kernel_lb_addr *eloc, uint32_t *elen, int inc) |
1777 | { | 1896 | { |
1778 | int8_t etype; | 1897 | int8_t etype; |
1779 | 1898 | ||
1780 | while ((etype = udf_current_aext(inode, epos, eloc, elen, inc)) == | 1899 | while ((etype = udf_current_aext(inode, epos, eloc, elen, inc)) == |
1781 | (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) { | 1900 | (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) { |
1901 | int block; | ||
1782 | epos->block = *eloc; | 1902 | epos->block = *eloc; |
1783 | epos->offset = sizeof(struct allocExtDesc); | 1903 | epos->offset = sizeof(struct allocExtDesc); |
1784 | brelse(epos->bh); | 1904 | brelse(epos->bh); |
1785 | if (!(epos->bh = udf_tread(inode->i_sb, udf_get_lb_pblock(inode->i_sb, epos->block, 0)))) { | 1905 | block = udf_get_lb_pblock(inode->i_sb, epos->block, 0); |
1786 | udf_debug("reading block %d failed!\n", | 1906 | epos->bh = udf_tread(inode->i_sb, block); |
1787 | udf_get_lb_pblock(inode->i_sb, epos->block, 0)); | 1907 | if (!epos->bh) { |
1908 | udf_debug("reading block %d failed!\n", block); | ||
1788 | return -1; | 1909 | return -1; |
1789 | } | 1910 | } |
1790 | } | 1911 | } |
@@ -1792,8 +1913,8 @@ int8_t udf_next_aext(struct inode * inode, struct extent_position * epos, | |||
1792 | return etype; | 1913 | return etype; |
1793 | } | 1914 | } |
1794 | 1915 | ||
1795 | int8_t udf_current_aext(struct inode * inode, struct extent_position * epos, | 1916 | int8_t udf_current_aext(struct inode *inode, struct extent_position *epos, |
1796 | kernel_lb_addr * eloc, uint32_t * elen, int inc) | 1917 | kernel_lb_addr *eloc, uint32_t *elen, int inc) |
1797 | { | 1918 | { |
1798 | int alen; | 1919 | int alen; |
1799 | int8_t etype; | 1920 | int8_t etype; |
@@ -1801,38 +1922,45 @@ int8_t udf_current_aext(struct inode * inode, struct extent_position * epos, | |||
1801 | short_ad *sad; | 1922 | short_ad *sad; |
1802 | long_ad *lad; | 1923 | long_ad *lad; |
1803 | 1924 | ||
1804 | |||
1805 | if (!epos->bh) { | 1925 | if (!epos->bh) { |
1806 | if (!epos->offset) | 1926 | if (!epos->offset) |
1807 | epos->offset = udf_file_entry_alloc_offset(inode); | 1927 | epos->offset = udf_file_entry_alloc_offset(inode); |
1808 | ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); | 1928 | ptr = UDF_I_DATA(inode) + epos->offset - |
1809 | alen = udf_file_entry_alloc_offset(inode) + UDF_I_LENALLOC(inode); | 1929 | udf_file_entry_alloc_offset(inode) + |
1930 | UDF_I_LENEATTR(inode); | ||
1931 | alen = udf_file_entry_alloc_offset(inode) + | ||
1932 | UDF_I_LENALLOC(inode); | ||
1810 | } else { | 1933 | } else { |
1811 | if (!epos->offset) | 1934 | if (!epos->offset) |
1812 | epos->offset = sizeof(struct allocExtDesc); | 1935 | epos->offset = sizeof(struct allocExtDesc); |
1813 | ptr = epos->bh->b_data + epos->offset; | 1936 | ptr = epos->bh->b_data + epos->offset; |
1814 | alen = sizeof(struct allocExtDesc) + | 1937 | alen = sizeof(struct allocExtDesc) + |
1815 | le32_to_cpu(((struct allocExtDesc *)epos->bh->b_data)->lengthAllocDescs); | 1938 | le32_to_cpu(((struct allocExtDesc *)epos->bh->b_data)-> |
1939 | lengthAllocDescs); | ||
1816 | } | 1940 | } |
1817 | 1941 | ||
1818 | switch (UDF_I_ALLOCTYPE(inode)) { | 1942 | switch (UDF_I_ALLOCTYPE(inode)) { |
1819 | case ICBTAG_FLAG_AD_SHORT: | 1943 | case ICBTAG_FLAG_AD_SHORT: |
1820 | if (!(sad = udf_get_fileshortad(ptr, alen, &epos->offset, inc))) | 1944 | sad = udf_get_fileshortad(ptr, alen, &epos->offset, inc); |
1945 | if (!sad) | ||
1821 | return -1; | 1946 | return -1; |
1822 | etype = le32_to_cpu(sad->extLength) >> 30; | 1947 | etype = le32_to_cpu(sad->extLength) >> 30; |
1823 | eloc->logicalBlockNum = le32_to_cpu(sad->extPosition); | 1948 | eloc->logicalBlockNum = le32_to_cpu(sad->extPosition); |
1824 | eloc->partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum; | 1949 | eloc->partitionReferenceNum = |
1950 | UDF_I_LOCATION(inode).partitionReferenceNum; | ||
1825 | *elen = le32_to_cpu(sad->extLength) & UDF_EXTENT_LENGTH_MASK; | 1951 | *elen = le32_to_cpu(sad->extLength) & UDF_EXTENT_LENGTH_MASK; |
1826 | break; | 1952 | break; |
1827 | case ICBTAG_FLAG_AD_LONG: | 1953 | case ICBTAG_FLAG_AD_LONG: |
1828 | if (!(lad = udf_get_filelongad(ptr, alen, &epos->offset, inc))) | 1954 | lad = udf_get_filelongad(ptr, alen, &epos->offset, inc); |
1955 | if (!lad) | ||
1829 | return -1; | 1956 | return -1; |
1830 | etype = le32_to_cpu(lad->extLength) >> 30; | 1957 | etype = le32_to_cpu(lad->extLength) >> 30; |
1831 | *eloc = lelb_to_cpu(lad->extLocation); | 1958 | *eloc = lelb_to_cpu(lad->extLocation); |
1832 | *elen = le32_to_cpu(lad->extLength) & UDF_EXTENT_LENGTH_MASK; | 1959 | *elen = le32_to_cpu(lad->extLength) & UDF_EXTENT_LENGTH_MASK; |
1833 | break; | 1960 | break; |
1834 | default: | 1961 | default: |
1835 | udf_debug("alloc_type = %d unsupported\n", UDF_I_ALLOCTYPE(inode)); | 1962 | udf_debug("alloc_type = %d unsupported\n", |
1963 | UDF_I_ALLOCTYPE(inode)); | ||
1836 | return -1; | 1964 | return -1; |
1837 | } | 1965 | } |
1838 | 1966 | ||
@@ -1860,7 +1988,7 @@ static int8_t udf_insert_aext(struct inode *inode, struct extent_position epos, | |||
1860 | return (nelen >> 30); | 1988 | return (nelen >> 30); |
1861 | } | 1989 | } |
1862 | 1990 | ||
1863 | int8_t udf_delete_aext(struct inode * inode, struct extent_position epos, | 1991 | int8_t udf_delete_aext(struct inode *inode, struct extent_position epos, |
1864 | kernel_lb_addr eloc, uint32_t elen) | 1992 | kernel_lb_addr eloc, uint32_t elen) |
1865 | { | 1993 | { |
1866 | struct extent_position oepos; | 1994 | struct extent_position oepos; |
@@ -1907,12 +2035,15 @@ int8_t udf_delete_aext(struct inode * inode, struct extent_position epos, | |||
1907 | } else { | 2035 | } else { |
1908 | aed = (struct allocExtDesc *)oepos.bh->b_data; | 2036 | aed = (struct allocExtDesc *)oepos.bh->b_data; |
1909 | aed->lengthAllocDescs = | 2037 | aed->lengthAllocDescs = |
1910 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - (2 * adsize)); | 2038 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - |
2039 | (2 * adsize)); | ||
1911 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 2040 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1912 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) | 2041 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) |
1913 | udf_update_tag(oepos.bh->b_data, oepos.offset - (2 * adsize)); | 2042 | udf_update_tag(oepos.bh->b_data, |
2043 | oepos.offset - (2 * adsize)); | ||
1914 | else | 2044 | else |
1915 | udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc)); | 2045 | udf_update_tag(oepos.bh->b_data, |
2046 | sizeof(struct allocExtDesc)); | ||
1916 | mark_buffer_dirty_inode(oepos.bh, inode); | 2047 | mark_buffer_dirty_inode(oepos.bh, inode); |
1917 | } | 2048 | } |
1918 | } else { | 2049 | } else { |
@@ -1923,12 +2054,15 @@ int8_t udf_delete_aext(struct inode * inode, struct extent_position epos, | |||
1923 | } else { | 2054 | } else { |
1924 | aed = (struct allocExtDesc *)oepos.bh->b_data; | 2055 | aed = (struct allocExtDesc *)oepos.bh->b_data; |
1925 | aed->lengthAllocDescs = | 2056 | aed->lengthAllocDescs = |
1926 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - adsize); | 2057 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - |
2058 | adsize); | ||
1927 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 2059 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1928 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) | 2060 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) |
1929 | udf_update_tag(oepos.bh->b_data, epos.offset - adsize); | 2061 | udf_update_tag(oepos.bh->b_data, |
2062 | epos.offset - adsize); | ||
1930 | else | 2063 | else |
1931 | udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc)); | 2064 | udf_update_tag(oepos.bh->b_data, |
2065 | sizeof(struct allocExtDesc)); | ||
1932 | mark_buffer_dirty_inode(oepos.bh, inode); | 2066 | mark_buffer_dirty_inode(oepos.bh, inode); |
1933 | } | 2067 | } |
1934 | } | 2068 | } |
@@ -1939,12 +2073,13 @@ int8_t udf_delete_aext(struct inode * inode, struct extent_position epos, | |||
1939 | return (elen >> 30); | 2073 | return (elen >> 30); |
1940 | } | 2074 | } |
1941 | 2075 | ||
1942 | int8_t inode_bmap(struct inode * inode, sector_t block, | 2076 | int8_t inode_bmap(struct inode *inode, sector_t block, |
1943 | struct extent_position * pos, kernel_lb_addr * eloc, | 2077 | struct extent_position *pos, kernel_lb_addr *eloc, |
1944 | uint32_t * elen, sector_t * offset) | 2078 | uint32_t *elen, sector_t *offset) |
1945 | { | 2079 | { |
2080 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; | ||
1946 | loff_t lbcount = 0, bcount = | 2081 | loff_t lbcount = 0, bcount = |
1947 | (loff_t) block << inode->i_sb->s_blocksize_bits; | 2082 | (loff_t) block << blocksize_bits; |
1948 | int8_t etype; | 2083 | int8_t etype; |
1949 | 2084 | ||
1950 | if (block < 0) { | 2085 | if (block < 0) { |
@@ -1958,15 +2093,16 @@ int8_t inode_bmap(struct inode * inode, sector_t block, | |||
1958 | *elen = 0; | 2093 | *elen = 0; |
1959 | 2094 | ||
1960 | do { | 2095 | do { |
1961 | if ((etype = udf_next_aext(inode, pos, eloc, elen, 1)) == -1) { | 2096 | etype = udf_next_aext(inode, pos, eloc, elen, 1); |
1962 | *offset = (bcount - lbcount) >> inode->i_sb->s_blocksize_bits; | 2097 | if (etype == -1) { |
2098 | *offset = (bcount - lbcount) >> blocksize_bits; | ||
1963 | UDF_I_LENEXTENTS(inode) = lbcount; | 2099 | UDF_I_LENEXTENTS(inode) = lbcount; |
1964 | return -1; | 2100 | return -1; |
1965 | } | 2101 | } |
1966 | lbcount += *elen; | 2102 | lbcount += *elen; |
1967 | } while (lbcount <= bcount); | 2103 | } while (lbcount <= bcount); |
1968 | 2104 | ||
1969 | *offset = (bcount + *elen - lbcount) >> inode->i_sb->s_blocksize_bits; | 2105 | *offset = (bcount + *elen - lbcount) >> blocksize_bits; |
1970 | 2106 | ||
1971 | return etype; | 2107 | return etype; |
1972 | } | 2108 | } |
@@ -1981,7 +2117,8 @@ long udf_block_map(struct inode *inode, sector_t block) | |||
1981 | 2117 | ||
1982 | lock_kernel(); | 2118 | lock_kernel(); |
1983 | 2119 | ||
1984 | if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) | 2120 | if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) == |
2121 | (EXT_RECORDED_ALLOCATED >> 30)) | ||
1985 | ret = udf_get_lb_pblock(inode->i_sb, eloc, offset); | 2122 | ret = udf_get_lb_pblock(inode->i_sb, eloc, offset); |
1986 | else | 2123 | else |
1987 | ret = 0; | 2124 | ret = 0; |