diff options
author | Marcin Slusarz <marcin.slusarz@gmail.com> | 2008-02-08 07:20:30 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-08 12:22:34 -0500 |
commit | 6c79e987d629cb0f8f7e2983725f4434a2dec66b (patch) | |
tree | ea2e17a12a0bdc5d68d2fe49941bfdf249e0f647 /fs | |
parent | 3a71fc5de56338076fe99f24f50bccfebabefe18 (diff) |
udf: remove some ugly macros
remove macros:
- UDF_SB_PARTMAPS
- UDF_SB_PARTTYPE
- UDF_SB_PARTROOT
- UDF_SB_PARTLEN
- UDF_SB_PARTVSN
- UDF_SB_PARTNUM
- UDF_SB_TYPESPAR
- UDF_SB_TYPEVIRT
- UDF_SB_PARTFUNC
- UDF_SB_PARTFLAGS
- UDF_SB_VOLIDENT
- UDF_SB_NUMPARTS
- UDF_SB_PARTITION
- UDF_SB_SESSION
- UDF_SB_ANCHOR
- UDF_SB_LASTBLOCK
- UDF_SB_LVIDBH
- UDF_SB_LVID
- UDF_SB_UMASK
- UDF_SB_GID
- UDF_SB_UID
- UDF_SB_RECORDTIME
- UDF_SB_SERIALNUM
- UDF_SB_UDFREV
- UDF_SB_FLAGS
- UDF_SB_VAT
- UDF_UPDATE_UDFREV
- UDF_SB_FREE
and open code them
convert UDF_SB_LVIDIU macro to udf_sb_lvidiu function
rename some struct udf_sb_info fields:
- s_volident to s_volume_ident
- s_lastblock to s_last_block
- s_lvidbh to s_lvid_bh
- s_recordtime to s_record_time
- s_serialnum to s_serial_number;
- s_vat to s_vat_inode;
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Ben Fennema <bfennema@falcon.csc.calpoly.edu>
Cc: Jan Kara <jack@suse.cz>
Acked-by: Christoph Hellwig <hch@infradead.org>
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 | 136 | ||||
-rw-r--r-- | fs/udf/file.c | 2 | ||||
-rw-r--r-- | fs/udf/ialloc.c | 33 | ||||
-rw-r--r-- | fs/udf/inode.c | 34 | ||||
-rw-r--r-- | fs/udf/misc.c | 15 | ||||
-rw-r--r-- | fs/udf/namei.c | 24 | ||||
-rw-r--r-- | fs/udf/partition.c | 67 | ||||
-rw-r--r-- | fs/udf/super.c | 546 | ||||
-rw-r--r-- | fs/udf/truncate.c | 7 | ||||
-rw-r--r-- | fs/udf/udf_sb.h | 75 |
10 files changed, 503 insertions, 436 deletions
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c index ab26176f6b91..8c0c27912278 100644 --- a/fs/udf/balloc.c +++ b/fs/udf/balloc.c | |||
@@ -88,7 +88,7 @@ static int read_block_bitmap(struct super_block *sb, | |||
88 | kernel_lb_addr loc; | 88 | kernel_lb_addr loc; |
89 | 89 | ||
90 | loc.logicalBlockNum = bitmap->s_extPosition; | 90 | loc.logicalBlockNum = bitmap->s_extPosition; |
91 | loc.partitionReferenceNum = UDF_SB_PARTITION(sb); | 91 | loc.partitionReferenceNum = UDF_SB(sb)->s_partition; |
92 | 92 | ||
93 | bh = udf_tread(sb, udf_get_lb_pblock(sb, loc, block)); | 93 | bh = udf_tread(sb, udf_get_lb_pblock(sb, loc, block)); |
94 | if (!bh) { | 94 | if (!bh) { |
@@ -155,10 +155,10 @@ 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, bloc.partitionReferenceNum)) { | 158 | (bloc.logicalBlockNum + count) > sbi->s_partmaps[bloc.partitionReferenceNum].s_partition_len) { |
159 | udf_debug("%d < %d || %d + %d > %d\n", | 159 | udf_debug("%d < %d || %d + %d > %d\n", |
160 | bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, | 160 | bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, |
161 | UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)); | 161 | sbi->s_partmaps[bloc.partitionReferenceNum].s_partition_len); |
162 | goto error_return; | 162 | goto error_return; |
163 | } | 163 | } |
164 | 164 | ||
@@ -188,9 +188,10 @@ do_more: | |||
188 | } else { | 188 | } else { |
189 | if (inode) | 189 | if (inode) |
190 | DQUOT_FREE_BLOCK(inode, 1); | 190 | DQUOT_FREE_BLOCK(inode, 1); |
191 | if (UDF_SB_LVIDBH(sb)) { | 191 | if (sbi->s_lvid_bh) { |
192 | UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)] = | 192 | struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; |
193 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]) + 1); | 193 | lvid->freeSpaceTable[sbi->s_partition] = |
194 | cpu_to_le32(le32_to_cpu(lvid->freeSpaceTable[sbi->s_partition]) + 1); | ||
194 | } | 195 | } |
195 | } | 196 | } |
196 | } | 197 | } |
@@ -202,8 +203,8 @@ do_more: | |||
202 | } | 203 | } |
203 | error_return: | 204 | error_return: |
204 | sb->s_dirt = 1; | 205 | sb->s_dirt = 1; |
205 | if (UDF_SB_LVIDBH(sb)) | 206 | if (sbi->s_lvid_bh) |
206 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 207 | mark_buffer_dirty(sbi->s_lvid_bh); |
207 | mutex_unlock(&sbi->s_alloc_mutex); | 208 | mutex_unlock(&sbi->s_alloc_mutex); |
208 | return; | 209 | return; |
209 | } | 210 | } |
@@ -219,16 +220,18 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb, | |||
219 | int bit, block, block_group, group_start; | 220 | int bit, block, block_group, group_start; |
220 | int nr_groups, bitmap_nr; | 221 | int nr_groups, bitmap_nr; |
221 | struct buffer_head *bh; | 222 | struct buffer_head *bh; |
223 | __u32 part_len; | ||
222 | 224 | ||
223 | mutex_lock(&sbi->s_alloc_mutex); | 225 | mutex_lock(&sbi->s_alloc_mutex); |
224 | if (first_block < 0 || first_block >= UDF_SB_PARTLEN(sb, partition)) | 226 | part_len = sbi->s_partmaps[partition].s_partition_len; |
227 | if (first_block < 0 || first_block >= part_len) | ||
225 | goto out; | 228 | goto out; |
226 | 229 | ||
227 | if (first_block + block_count > UDF_SB_PARTLEN(sb, partition)) | 230 | if (first_block + block_count > part_len) |
228 | block_count = UDF_SB_PARTLEN(sb, partition) - first_block; | 231 | block_count = part_len - first_block; |
229 | 232 | ||
230 | repeat: | 233 | repeat: |
231 | nr_groups = (UDF_SB_PARTLEN(sb, partition) + | 234 | nr_groups = (sbi->s_partmaps[partition].s_partition_len + |
232 | (sizeof(struct spaceBitmapDesc) << 3) + | 235 | (sizeof(struct spaceBitmapDesc) << 3) + |
233 | (sb->s_blocksize * 8) - 1) / (sb->s_blocksize * 8); | 236 | (sb->s_blocksize * 8) - 1) / (sb->s_blocksize * 8); |
234 | block = first_block + (sizeof(struct spaceBitmapDesc) << 3); | 237 | block = first_block + (sizeof(struct spaceBitmapDesc) << 3); |
@@ -261,10 +264,11 @@ repeat: | |||
261 | if (block_count > 0) | 264 | if (block_count > 0) |
262 | goto repeat; | 265 | goto repeat; |
263 | out: | 266 | out: |
264 | if (UDF_SB_LVIDBH(sb)) { | 267 | if (sbi->s_lvid_bh) { |
265 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = | 268 | struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; |
266 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - alloc_count); | 269 | lvid->freeSpaceTable[partition] = |
267 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 270 | cpu_to_le32(le32_to_cpu(lvid->freeSpaceTable[partition]) - alloc_count); |
271 | mark_buffer_dirty(sbi->s_lvid_bh); | ||
268 | } | 272 | } |
269 | sb->s_dirt = 1; | 273 | sb->s_dirt = 1; |
270 | mutex_unlock(&sbi->s_alloc_mutex); | 274 | mutex_unlock(&sbi->s_alloc_mutex); |
@@ -287,7 +291,7 @@ static int udf_bitmap_new_block(struct super_block *sb, | |||
287 | mutex_lock(&sbi->s_alloc_mutex); | 291 | mutex_lock(&sbi->s_alloc_mutex); |
288 | 292 | ||
289 | repeat: | 293 | repeat: |
290 | if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition)) | 294 | if (goal < 0 || goal >= sbi->s_partmaps[partition].s_partition_len) |
291 | goal = 0; | 295 | goal = 0; |
292 | 296 | ||
293 | nr_groups = bitmap->s_nr_groups; | 297 | nr_groups = bitmap->s_nr_groups; |
@@ -389,10 +393,11 @@ got_block: | |||
389 | 393 | ||
390 | mark_buffer_dirty(bh); | 394 | mark_buffer_dirty(bh); |
391 | 395 | ||
392 | if (UDF_SB_LVIDBH(sb)) { | 396 | if (sbi->s_lvid_bh) { |
393 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = | 397 | struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; |
394 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - 1); | 398 | lvid->freeSpaceTable[partition] = |
395 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 399 | cpu_to_le32(le32_to_cpu(lvid->freeSpaceTable[partition]) - 1); |
400 | mark_buffer_dirty(sbi->s_lvid_bh); | ||
396 | } | 401 | } |
397 | sb->s_dirt = 1; | 402 | sb->s_dirt = 1; |
398 | mutex_unlock(&sbi->s_alloc_mutex); | 403 | mutex_unlock(&sbi->s_alloc_mutex); |
@@ -421,10 +426,10 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
421 | 426 | ||
422 | mutex_lock(&sbi->s_alloc_mutex); | 427 | mutex_lock(&sbi->s_alloc_mutex); |
423 | if (bloc.logicalBlockNum < 0 || | 428 | if (bloc.logicalBlockNum < 0 || |
424 | (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)) { | 429 | (bloc.logicalBlockNum + count) > sbi->s_partmaps[bloc.partitionReferenceNum].s_partition_len) { |
425 | udf_debug("%d < %d || %d + %d > %d\n", | 430 | udf_debug("%d < %d || %d + %d > %d\n", |
426 | bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, | 431 | bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, |
427 | UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)); | 432 | sbi->s_partmaps[bloc.partitionReferenceNum]->s_partition_len); |
428 | goto error_return; | 433 | goto error_return; |
429 | } | 434 | } |
430 | 435 | ||
@@ -432,10 +437,11 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
432 | but.. oh well */ | 437 | but.. oh well */ |
433 | if (inode) | 438 | if (inode) |
434 | DQUOT_FREE_BLOCK(inode, count); | 439 | DQUOT_FREE_BLOCK(inode, count); |
435 | if (UDF_SB_LVIDBH(sb)) { | 440 | if (sbi->s_lvid_bh) { |
436 | UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)] = | 441 | struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; |
437 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]) + count); | 442 | lvid->freeSpaceTable[sbi->s_partition] = |
438 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 443 | cpu_to_le32(le32_to_cpu(lvid->freeSpaceTable[sbi->s_partition]) + count); |
444 | mark_buffer_dirty(sbi->s_lvid_bh); | ||
439 | } | 445 | } |
440 | 446 | ||
441 | start = bloc.logicalBlockNum + offset; | 447 | start = bloc.logicalBlockNum + offset; |
@@ -559,7 +565,7 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
559 | } | 565 | } |
560 | epos.offset = sizeof(struct allocExtDesc); | 566 | epos.offset = sizeof(struct allocExtDesc); |
561 | } | 567 | } |
562 | if (UDF_SB_UDFREV(sb) >= 0x0200) | 568 | if (sbi->s_udfrev >= 0x0200) |
563 | udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 3, 1, | 569 | udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 3, 1, |
564 | epos.block.logicalBlockNum, sizeof(tag)); | 570 | epos.block.logicalBlockNum, sizeof(tag)); |
565 | else | 571 | else |
@@ -627,7 +633,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb, | |||
627 | struct extent_position epos; | 633 | struct extent_position epos; |
628 | int8_t etype = -1; | 634 | int8_t etype = -1; |
629 | 635 | ||
630 | if (first_block < 0 || first_block >= UDF_SB_PARTLEN(sb, partition)) | 636 | if (first_block < 0 || first_block >= sbi->s_partmaps[partition].s_partition_len) |
631 | return 0; | 637 | return 0; |
632 | 638 | ||
633 | if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT) | 639 | if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT) |
@@ -670,10 +676,11 @@ static int udf_table_prealloc_blocks(struct super_block *sb, | |||
670 | 676 | ||
671 | brelse(epos.bh); | 677 | brelse(epos.bh); |
672 | 678 | ||
673 | if (alloc_count && UDF_SB_LVIDBH(sb)) { | 679 | if (alloc_count && sbi->s_lvid_bh) { |
674 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = | 680 | struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; |
675 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - alloc_count); | 681 | lvid->freeSpaceTable[partition] = |
676 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 682 | cpu_to_le32(le32_to_cpu(lvid->freeSpaceTable[partition]) - alloc_count); |
683 | mark_buffer_dirty(sbi->s_lvid_bh); | ||
677 | sb->s_dirt = 1; | 684 | sb->s_dirt = 1; |
678 | } | 685 | } |
679 | mutex_unlock(&sbi->s_alloc_mutex); | 686 | mutex_unlock(&sbi->s_alloc_mutex); |
@@ -703,7 +710,7 @@ static int udf_table_new_block(struct super_block *sb, | |||
703 | return newblock; | 710 | return newblock; |
704 | 711 | ||
705 | mutex_lock(&sbi->s_alloc_mutex); | 712 | mutex_lock(&sbi->s_alloc_mutex); |
706 | if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition)) | 713 | if (goal < 0 || goal >= sbi->s_partmaps[partition].s_partition_len) |
707 | goal = 0; | 714 | goal = 0; |
708 | 715 | ||
709 | /* We search for the closest matching block to goal. If we find a exact hit, | 716 | /* We search for the closest matching block to goal. If we find a exact hit, |
@@ -771,10 +778,11 @@ static int udf_table_new_block(struct super_block *sb, | |||
771 | udf_delete_aext(table, goal_epos, goal_eloc, goal_elen); | 778 | udf_delete_aext(table, goal_epos, goal_eloc, goal_elen); |
772 | brelse(goal_epos.bh); | 779 | brelse(goal_epos.bh); |
773 | 780 | ||
774 | if (UDF_SB_LVIDBH(sb)) { | 781 | if (sbi->s_lvid_bh) { |
775 | UDF_SB_LVID(sb)->freeSpaceTable[partition] = | 782 | struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; |
776 | cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - 1); | 783 | lvid->freeSpaceTable[partition] = |
777 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 784 | cpu_to_le32(le32_to_cpu(lvid->freeSpaceTable[partition]) - 1); |
785 | mark_buffer_dirty(sbi->s_lvid_bh); | ||
778 | } | 786 | } |
779 | 787 | ||
780 | sb->s_dirt = 1; | 788 | sb->s_dirt = 1; |
@@ -789,22 +797,23 @@ inline void udf_free_blocks(struct super_block *sb, | |||
789 | uint32_t count) | 797 | uint32_t count) |
790 | { | 798 | { |
791 | uint16_t partition = bloc.partitionReferenceNum; | 799 | uint16_t partition = bloc.partitionReferenceNum; |
800 | struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; | ||
792 | 801 | ||
793 | if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) { | 802 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) { |
794 | return udf_bitmap_free_blocks(sb, inode, | 803 | return udf_bitmap_free_blocks(sb, inode, |
795 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap, | 804 | map->s_uspace.s_bitmap, |
796 | bloc, offset, count); | 805 | bloc, offset, count); |
797 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) { | 806 | } else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) { |
798 | return udf_table_free_blocks(sb, inode, | 807 | return udf_table_free_blocks(sb, inode, |
799 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table, | 808 | map->s_uspace.s_table, |
800 | bloc, offset, count); | 809 | bloc, offset, count); |
801 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) { | 810 | } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) { |
802 | return udf_bitmap_free_blocks(sb, inode, | 811 | return udf_bitmap_free_blocks(sb, inode, |
803 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap, | 812 | map->s_fspace.s_bitmap, |
804 | bloc, offset, count); | 813 | bloc, offset, count); |
805 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) { | 814 | } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) { |
806 | return udf_table_free_blocks(sb, inode, | 815 | return udf_table_free_blocks(sb, inode, |
807 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table, | 816 | map->s_fspace.s_table, |
808 | bloc, offset, count); | 817 | bloc, offset, count); |
809 | } else { | 818 | } else { |
810 | return; | 819 | return; |
@@ -816,21 +825,23 @@ inline int udf_prealloc_blocks(struct super_block *sb, | |||
816 | uint16_t partition, uint32_t first_block, | 825 | uint16_t partition, uint32_t first_block, |
817 | uint32_t block_count) | 826 | uint32_t block_count) |
818 | { | 827 | { |
819 | if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) { | 828 | struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; |
829 | |||
830 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) { | ||
820 | return udf_bitmap_prealloc_blocks(sb, inode, | 831 | return udf_bitmap_prealloc_blocks(sb, inode, |
821 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap, | 832 | map->s_uspace.s_bitmap, |
822 | partition, first_block, block_count); | 833 | partition, first_block, block_count); |
823 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) { | 834 | } else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) { |
824 | return udf_table_prealloc_blocks(sb, inode, | 835 | return udf_table_prealloc_blocks(sb, inode, |
825 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table, | 836 | map->s_uspace.s_table, |
826 | partition, first_block, block_count); | 837 | partition, first_block, block_count); |
827 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) { | 838 | } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) { |
828 | return udf_bitmap_prealloc_blocks(sb, inode, | 839 | return udf_bitmap_prealloc_blocks(sb, inode, |
829 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap, | 840 | map->s_fspace.s_bitmap, |
830 | partition, first_block, block_count); | 841 | partition, first_block, block_count); |
831 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) { | 842 | } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) { |
832 | return udf_table_prealloc_blocks(sb, inode, | 843 | return udf_table_prealloc_blocks(sb, inode, |
833 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table, | 844 | map->s_fspace.s_table, |
834 | partition, first_block, block_count); | 845 | partition, first_block, block_count); |
835 | } else { | 846 | } else { |
836 | return 0; | 847 | return 0; |
@@ -842,23 +853,24 @@ inline int udf_new_block(struct super_block *sb, | |||
842 | uint16_t partition, uint32_t goal, int *err) | 853 | uint16_t partition, uint32_t goal, int *err) |
843 | { | 854 | { |
844 | int ret; | 855 | int ret; |
856 | struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; | ||
845 | 857 | ||
846 | if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) { | 858 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) { |
847 | ret = udf_bitmap_new_block(sb, inode, | 859 | ret = udf_bitmap_new_block(sb, inode, |
848 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap, | 860 | map->s_uspace.s_bitmap, |
849 | partition, goal, err); | 861 | partition, goal, err); |
850 | return ret; | 862 | return ret; |
851 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) { | 863 | } else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) { |
852 | return udf_table_new_block(sb, inode, | 864 | return udf_table_new_block(sb, inode, |
853 | UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table, | 865 | map->s_uspace.s_table, |
854 | partition, goal, err); | 866 | partition, goal, err); |
855 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) { | 867 | } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) { |
856 | return udf_bitmap_new_block(sb, inode, | 868 | return udf_bitmap_new_block(sb, inode, |
857 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap, | 869 | map->s_fspace.s_bitmap, |
858 | partition, goal, err); | 870 | partition, goal, err); |
859 | } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) { | 871 | } else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) { |
860 | return udf_table_new_block(sb, inode, | 872 | return udf_table_new_block(sb, inode, |
861 | UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table, | 873 | map->s_fspace.s_table, |
862 | partition, goal, err); | 874 | partition, goal, err); |
863 | } else { | 875 | } else { |
864 | *err = -EIO; | 876 | *err = -EIO; |
diff --git a/fs/udf/file.c b/fs/udf/file.c index 7c7a1b39d56c..3bd5068877fa 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c | |||
@@ -192,7 +192,7 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | |||
192 | switch (cmd) { | 192 | switch (cmd) { |
193 | case UDF_GETVOLIDENT: | 193 | case UDF_GETVOLIDENT: |
194 | return copy_to_user((char __user *)arg, | 194 | return copy_to_user((char __user *)arg, |
195 | UDF_SB_VOLIDENT(inode->i_sb), 32) ? -EFAULT : 0; | 195 | UDF_SB(inode->i_sb)->s_volume_ident, 32) ? -EFAULT : 0; |
196 | case UDF_RELOCATE_BLOCKS: | 196 | case UDF_RELOCATE_BLOCKS: |
197 | if (!capable(CAP_SYS_ADMIN)) | 197 | if (!capable(CAP_SYS_ADMIN)) |
198 | return -EACCES; | 198 | return -EACCES; |
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c index 636d8f613929..8145e943be61 100644 --- a/fs/udf/ialloc.c +++ b/fs/udf/ialloc.c | |||
@@ -43,15 +43,17 @@ void udf_free_inode(struct inode *inode) | |||
43 | clear_inode(inode); | 43 | clear_inode(inode); |
44 | 44 | ||
45 | mutex_lock(&sbi->s_alloc_mutex); | 45 | mutex_lock(&sbi->s_alloc_mutex); |
46 | if (sbi->s_lvidbh) { | 46 | if (sbi->s_lvid_bh) { |
47 | struct logicalVolIntegrityDescImpUse *lvidiu = | ||
48 | udf_sb_lvidiu(sbi); | ||
47 | if (S_ISDIR(inode->i_mode)) | 49 | if (S_ISDIR(inode->i_mode)) |
48 | UDF_SB_LVIDIU(sb)->numDirs = | 50 | lvidiu->numDirs = |
49 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) - 1); | 51 | cpu_to_le32(le32_to_cpu(lvidiu->numDirs) - 1); |
50 | else | 52 | else |
51 | UDF_SB_LVIDIU(sb)->numFiles = | 53 | lvidiu->numFiles = |
52 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1); | 54 | cpu_to_le32(le32_to_cpu(lvidiu->numFiles) - 1); |
53 | 55 | ||
54 | mark_buffer_dirty(sbi->s_lvidbh); | 56 | mark_buffer_dirty(sbi->s_lvid_bh); |
55 | } | 57 | } |
56 | mutex_unlock(&sbi->s_alloc_mutex); | 58 | mutex_unlock(&sbi->s_alloc_mutex); |
57 | 59 | ||
@@ -88,21 +90,23 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) | |||
88 | } | 90 | } |
89 | 91 | ||
90 | mutex_lock(&sbi->s_alloc_mutex); | 92 | mutex_lock(&sbi->s_alloc_mutex); |
91 | if (UDF_SB_LVIDBH(sb)) { | 93 | if (sbi->s_lvid_bh) { |
94 | struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; | ||
95 | struct logicalVolIntegrityDescImpUse *lvidiu = udf_sb_lvidiu(sbi); | ||
92 | struct logicalVolHeaderDesc *lvhd; | 96 | struct logicalVolHeaderDesc *lvhd; |
93 | uint64_t uniqueID; | 97 | uint64_t uniqueID; |
94 | lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->logicalVolContentsUse); | 98 | lvhd = (struct logicalVolHeaderDesc *)(lvid->logicalVolContentsUse); |
95 | if (S_ISDIR(mode)) | 99 | if (S_ISDIR(mode)) |
96 | UDF_SB_LVIDIU(sb)->numDirs = | 100 | lvidiu->numDirs = |
97 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) + 1); | 101 | cpu_to_le32(le32_to_cpu(lvidiu->numDirs) + 1); |
98 | else | 102 | else |
99 | UDF_SB_LVIDIU(sb)->numFiles = | 103 | lvidiu->numFiles = |
100 | cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + 1); | 104 | cpu_to_le32(le32_to_cpu(lvidiu->numFiles) + 1); |
101 | UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID); | 105 | UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID); |
102 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) | 106 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) |
103 | uniqueID += 16; | 107 | uniqueID += 16; |
104 | lvhd->uniqueID = cpu_to_le64(uniqueID); | 108 | lvhd->uniqueID = cpu_to_le64(uniqueID); |
105 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 109 | mark_buffer_dirty(sbi->s_lvid_bh); |
106 | } | 110 | } |
107 | inode->i_mode = mode; | 111 | inode->i_mode = mode; |
108 | inode->i_uid = current->fsuid; | 112 | inode->i_uid = current->fsuid; |
@@ -123,7 +127,8 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) | |||
123 | UDF_I_USE(inode) = 0; | 127 | UDF_I_USE(inode) = 0; |
124 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) { | 128 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) { |
125 | UDF_I_EFE(inode) = 1; | 129 | UDF_I_EFE(inode) = 1; |
126 | UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE); | 130 | if (UDF_VERS_USE_EXTENDED_FE > sbi->s_udfrev) |
131 | sbi->s_udfrev = UDF_VERS_USE_EXTENDED_FE; | ||
127 | UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL); | 132 | UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL); |
128 | } else { | 133 | } else { |
129 | UDF_I_EFE(inode) = 0; | 134 | UDF_I_EFE(inode) = 0; |
diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 6ff8151984cf..2eb1220e4236 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c | |||
@@ -1081,6 +1081,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1081 | time_t convtime; | 1081 | time_t convtime; |
1082 | long convtime_usec; | 1082 | long convtime_usec; |
1083 | int offset; | 1083 | int offset; |
1084 | struct udf_sb_info *sbi = UDF_SB(inode->i_sb); | ||
1084 | 1085 | ||
1085 | fe = (struct fileEntry *)bh->b_data; | 1086 | fe = (struct fileEntry *)bh->b_data; |
1086 | efe = (struct extendedFileEntry *)bh->b_data; | 1087 | efe = (struct extendedFileEntry *)bh->b_data; |
@@ -1160,7 +1161,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1160 | inode->i_atime.tv_sec = convtime; | 1161 | inode->i_atime.tv_sec = convtime; |
1161 | inode->i_atime.tv_nsec = convtime_usec * 1000; | 1162 | inode->i_atime.tv_nsec = convtime_usec * 1000; |
1162 | } else { | 1163 | } else { |
1163 | inode->i_atime = UDF_SB_RECORDTIME(inode->i_sb); | 1164 | inode->i_atime = sbi->s_record_time; |
1164 | } | 1165 | } |
1165 | 1166 | ||
1166 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1167 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
@@ -1168,7 +1169,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1168 | inode->i_mtime.tv_sec = convtime; | 1169 | inode->i_mtime.tv_sec = convtime; |
1169 | inode->i_mtime.tv_nsec = convtime_usec * 1000; | 1170 | inode->i_mtime.tv_nsec = convtime_usec * 1000; |
1170 | } else { | 1171 | } else { |
1171 | inode->i_mtime = UDF_SB_RECORDTIME(inode->i_sb); | 1172 | inode->i_mtime = sbi->s_record_time; |
1172 | } | 1173 | } |
1173 | 1174 | ||
1174 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1175 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
@@ -1176,7 +1177,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1176 | inode->i_ctime.tv_sec = convtime; | 1177 | inode->i_ctime.tv_sec = convtime; |
1177 | inode->i_ctime.tv_nsec = convtime_usec * 1000; | 1178 | inode->i_ctime.tv_nsec = convtime_usec * 1000; |
1178 | } else { | 1179 | } else { |
1179 | inode->i_ctime = UDF_SB_RECORDTIME(inode->i_sb); | 1180 | inode->i_ctime = sbi->s_record_time; |
1180 | } | 1181 | } |
1181 | 1182 | ||
1182 | UDF_I_UNIQUE(inode) = le64_to_cpu(fe->uniqueID); | 1183 | UDF_I_UNIQUE(inode) = le64_to_cpu(fe->uniqueID); |
@@ -1192,7 +1193,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1192 | inode->i_atime.tv_sec = convtime; | 1193 | inode->i_atime.tv_sec = convtime; |
1193 | inode->i_atime.tv_nsec = convtime_usec * 1000; | 1194 | inode->i_atime.tv_nsec = convtime_usec * 1000; |
1194 | } else { | 1195 | } else { |
1195 | inode->i_atime = UDF_SB_RECORDTIME(inode->i_sb); | 1196 | inode->i_atime = sbi->s_record_time; |
1196 | } | 1197 | } |
1197 | 1198 | ||
1198 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1199 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
@@ -1200,7 +1201,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1200 | inode->i_mtime.tv_sec = convtime; | 1201 | inode->i_mtime.tv_sec = convtime; |
1201 | inode->i_mtime.tv_nsec = convtime_usec * 1000; | 1202 | inode->i_mtime.tv_nsec = convtime_usec * 1000; |
1202 | } else { | 1203 | } else { |
1203 | inode->i_mtime = UDF_SB_RECORDTIME(inode->i_sb); | 1204 | inode->i_mtime = sbi->s_record_time; |
1204 | } | 1205 | } |
1205 | 1206 | ||
1206 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1207 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
@@ -1208,7 +1209,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1208 | UDF_I_CRTIME(inode).tv_sec = convtime; | 1209 | UDF_I_CRTIME(inode).tv_sec = convtime; |
1209 | UDF_I_CRTIME(inode).tv_nsec = convtime_usec * 1000; | 1210 | UDF_I_CRTIME(inode).tv_nsec = convtime_usec * 1000; |
1210 | } else { | 1211 | } else { |
1211 | UDF_I_CRTIME(inode) = UDF_SB_RECORDTIME(inode->i_sb); | 1212 | UDF_I_CRTIME(inode) = sbi->s_record_time; |
1212 | } | 1213 | } |
1213 | 1214 | ||
1214 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1215 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
@@ -1216,7 +1217,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1216 | inode->i_ctime.tv_sec = convtime; | 1217 | inode->i_ctime.tv_sec = convtime; |
1217 | inode->i_ctime.tv_nsec = convtime_usec * 1000; | 1218 | inode->i_ctime.tv_nsec = convtime_usec * 1000; |
1218 | } else { | 1219 | } else { |
1219 | inode->i_ctime = UDF_SB_RECORDTIME(inode->i_sb); | 1220 | inode->i_ctime = sbi->s_record_time; |
1220 | } | 1221 | } |
1221 | 1222 | ||
1222 | UDF_I_UNIQUE(inode) = le64_to_cpu(efe->uniqueID); | 1223 | UDF_I_UNIQUE(inode) = le64_to_cpu(efe->uniqueID); |
@@ -1353,6 +1354,7 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1353 | int i; | 1354 | int i; |
1354 | kernel_timestamp cpu_time; | 1355 | kernel_timestamp cpu_time; |
1355 | int err = 0; | 1356 | int err = 0; |
1357 | struct udf_sb_info *sbi = UDF_SB(inode->i_sb); | ||
1356 | 1358 | ||
1357 | bh = udf_tread(inode->i_sb, udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode), 0)); | 1359 | bh = udf_tread(inode->i_sb, udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode), 0)); |
1358 | if (!bh) { | 1360 | if (!bh) { |
@@ -1537,11 +1539,11 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1537 | ICBTAG_FLAG_SETGID | ICBTAG_FLAG_STICKY)); | 1539 | ICBTAG_FLAG_SETGID | ICBTAG_FLAG_STICKY)); |
1538 | 1540 | ||
1539 | fe->icbTag.flags = cpu_to_le16(icbflags); | 1541 | fe->icbTag.flags = cpu_to_le16(icbflags); |
1540 | if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) | 1542 | if (sbi->s_udfrev >= 0x0200) |
1541 | fe->descTag.descVersion = cpu_to_le16(3); | 1543 | fe->descTag.descVersion = cpu_to_le16(3); |
1542 | else | 1544 | else |
1543 | fe->descTag.descVersion = cpu_to_le16(2); | 1545 | fe->descTag.descVersion = cpu_to_le16(2); |
1544 | fe->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb)); | 1546 | fe->descTag.tagSerialNum = cpu_to_le16(sbi->s_serial_number); |
1545 | fe->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); | 1547 | fe->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); |
1546 | crclen += UDF_I_LENEATTR(inode) + UDF_I_LENALLOC(inode) - sizeof(tag); | 1548 | crclen += UDF_I_LENEATTR(inode) + UDF_I_LENALLOC(inode) - sizeof(tag); |
1547 | fe->descTag.descCRCLength = cpu_to_le16(crclen); | 1549 | fe->descTag.descCRCLength = cpu_to_le16(crclen); |
@@ -1585,7 +1587,7 @@ struct inode *udf_iget(struct super_block *sb, kernel_lb_addr ino) | |||
1585 | if (is_bad_inode(inode)) | 1587 | if (is_bad_inode(inode)) |
1586 | goto out_iput; | 1588 | goto out_iput; |
1587 | 1589 | ||
1588 | if (ino.logicalBlockNum >= UDF_SB_PARTLEN(sb, ino.partitionReferenceNum)) { | 1590 | if (ino.logicalBlockNum >= UDF_SB(sb)->s_partmaps[ino.partitionReferenceNum].s_partition_len) { |
1589 | udf_debug("block=%d, partition=%d out of range\n", | 1591 | udf_debug("block=%d, partition=%d out of range\n", |
1590 | ino.logicalBlockNum, ino.partitionReferenceNum); | 1592 | ino.logicalBlockNum, ino.partitionReferenceNum); |
1591 | make_bad_inode(inode); | 1593 | make_bad_inode(inode); |
@@ -1667,7 +1669,7 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1667 | mark_inode_dirty(inode); | 1669 | mark_inode_dirty(inode); |
1668 | } | 1670 | } |
1669 | } | 1671 | } |
1670 | if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) | 1672 | if (UDF_SB(inode->i_sb)->s_udfrev >= 0x0200) |
1671 | udf_new_tag(nbh->b_data, TAG_IDENT_AED, 3, 1, | 1673 | udf_new_tag(nbh->b_data, TAG_IDENT_AED, 3, 1, |
1672 | epos->block.logicalBlockNum, sizeof(tag)); | 1674 | epos->block.logicalBlockNum, sizeof(tag)); |
1673 | else | 1675 | else |
@@ -1690,7 +1692,7 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1690 | } | 1692 | } |
1691 | if (epos->bh) { | 1693 | if (epos->bh) { |
1692 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 1694 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1693 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 1695 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) |
1694 | udf_update_tag(epos->bh->b_data, loffset); | 1696 | udf_update_tag(epos->bh->b_data, loffset); |
1695 | else | 1697 | else |
1696 | udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc)); | 1698 | udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc)); |
@@ -1711,7 +1713,7 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1711 | aed = (struct allocExtDesc *)epos->bh->b_data; | 1713 | aed = (struct allocExtDesc *)epos->bh->b_data; |
1712 | aed->lengthAllocDescs = | 1714 | aed->lengthAllocDescs = |
1713 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); | 1715 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); |
1714 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 1716 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) |
1715 | udf_update_tag(epos->bh->b_data, epos->offset + (inc ? 0 : adsize)); | 1717 | udf_update_tag(epos->bh->b_data, epos->offset + (inc ? 0 : adsize)); |
1716 | else | 1718 | else |
1717 | udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc)); | 1719 | udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc)); |
@@ -1754,7 +1756,7 @@ int8_t udf_write_aext(struct inode * inode, struct extent_position * epos, | |||
1754 | 1756 | ||
1755 | if (epos->bh) { | 1757 | if (epos->bh) { |
1756 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 1758 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1757 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) { | 1759 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) { |
1758 | struct allocExtDesc *aed = (struct allocExtDesc *)epos->bh->b_data; | 1760 | struct allocExtDesc *aed = (struct allocExtDesc *)epos->bh->b_data; |
1759 | udf_update_tag(epos->bh->b_data, | 1761 | udf_update_tag(epos->bh->b_data, |
1760 | le32_to_cpu(aed->lengthAllocDescs) + sizeof(struct allocExtDesc)); | 1762 | le32_to_cpu(aed->lengthAllocDescs) + sizeof(struct allocExtDesc)); |
@@ -1907,7 +1909,7 @@ int8_t udf_delete_aext(struct inode * inode, struct extent_position epos, | |||
1907 | aed->lengthAllocDescs = | 1909 | aed->lengthAllocDescs = |
1908 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - (2 * adsize)); | 1910 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - (2 * adsize)); |
1909 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 1911 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1910 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 1912 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) |
1911 | udf_update_tag(oepos.bh->b_data, oepos.offset - (2 * adsize)); | 1913 | udf_update_tag(oepos.bh->b_data, oepos.offset - (2 * adsize)); |
1912 | else | 1914 | else |
1913 | udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc)); | 1915 | udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc)); |
@@ -1923,7 +1925,7 @@ int8_t udf_delete_aext(struct inode * inode, struct extent_position epos, | |||
1923 | aed->lengthAllocDescs = | 1925 | aed->lengthAllocDescs = |
1924 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - adsize); | 1926 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - adsize); |
1925 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 1927 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1926 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 1928 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) |
1927 | udf_update_tag(oepos.bh->b_data, epos.offset - adsize); | 1929 | udf_update_tag(oepos.bh->b_data, epos.offset - adsize); |
1928 | else | 1930 | else |
1929 | udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc)); | 1931 | udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc)); |
diff --git a/fs/udf/misc.c b/fs/udf/misc.c index 15297deb5051..7cecb3098061 100644 --- a/fs/udf/misc.c +++ b/fs/udf/misc.c | |||
@@ -81,14 +81,16 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, | |||
81 | return NULL; | 81 | return NULL; |
82 | } | 82 | } |
83 | } else { | 83 | } else { |
84 | struct udf_sb_info *sbi = UDF_SB(inode->i_sb); | ||
85 | |||
84 | size -= sizeof(struct extendedAttrHeaderDesc); | 86 | size -= sizeof(struct extendedAttrHeaderDesc); |
85 | UDF_I_LENEATTR(inode) += sizeof(struct extendedAttrHeaderDesc); | 87 | UDF_I_LENEATTR(inode) += sizeof(struct extendedAttrHeaderDesc); |
86 | eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD); | 88 | eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD); |
87 | if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) | 89 | if (sbi->s_udfrev >= 0x0200) |
88 | eahd->descTag.descVersion = cpu_to_le16(3); | 90 | eahd->descTag.descVersion = cpu_to_le16(3); |
89 | else | 91 | else |
90 | eahd->descTag.descVersion = cpu_to_le16(2); | 92 | eahd->descTag.descVersion = cpu_to_le16(2); |
91 | eahd->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb)); | 93 | eahd->descTag.tagSerialNum = cpu_to_le16(sbi->s_serial_number); |
92 | eahd->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); | 94 | eahd->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); |
93 | eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF); | 95 | eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF); |
94 | eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF); | 96 | eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF); |
@@ -192,15 +194,16 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, | |||
192 | struct buffer_head *bh = NULL; | 194 | struct buffer_head *bh = NULL; |
193 | register uint8_t checksum; | 195 | register uint8_t checksum; |
194 | register int i; | 196 | register int i; |
197 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
195 | 198 | ||
196 | /* Read the block */ | 199 | /* Read the block */ |
197 | if (block == 0xFFFFFFFF) | 200 | if (block == 0xFFFFFFFF) |
198 | return NULL; | 201 | return NULL; |
199 | 202 | ||
200 | bh = udf_tread(sb, block + UDF_SB_SESSION(sb)); | 203 | bh = udf_tread(sb, block + sbi->s_session); |
201 | if (!bh) { | 204 | if (!bh) { |
202 | udf_debug("block=%d, location=%d: read failed\n", | 205 | udf_debug("block=%d, location=%d: read failed\n", |
203 | block + UDF_SB_SESSION(sb), location); | 206 | block + sbi->s_session, location); |
204 | return NULL; | 207 | return NULL; |
205 | } | 208 | } |
206 | 209 | ||
@@ -210,7 +213,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, | |||
210 | 213 | ||
211 | if (location != le32_to_cpu(tag_p->tagLocation)) { | 214 | if (location != le32_to_cpu(tag_p->tagLocation)) { |
212 | udf_debug("location mismatch block %u, tag %u != %u\n", | 215 | udf_debug("location mismatch block %u, tag %u != %u\n", |
213 | block + UDF_SB_SESSION(sb), le32_to_cpu(tag_p->tagLocation), location); | 216 | block + sbi->s_session, le32_to_cpu(tag_p->tagLocation), location); |
214 | goto error_out; | 217 | goto error_out; |
215 | } | 218 | } |
216 | 219 | ||
@@ -240,7 +243,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, | |||
240 | return bh; | 243 | return bh; |
241 | } | 244 | } |
242 | udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", | 245 | udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", |
243 | block + UDF_SB_SESSION(sb), le16_to_cpu(tag_p->descCRC), | 246 | block + sbi->s_session, le16_to_cpu(tag_p->descCRC), |
244 | le16_to_cpu(tag_p->descCRCLength)); | 247 | le16_to_cpu(tag_p->descCRCLength)); |
245 | 248 | ||
246 | error_out: | 249 | error_out: |
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index bec96a6b3343..86033d92824c 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c | |||
@@ -325,7 +325,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
325 | struct udf_fileident_bh *fibh, | 325 | struct udf_fileident_bh *fibh, |
326 | struct fileIdentDesc *cfi, int *err) | 326 | struct fileIdentDesc *cfi, int *err) |
327 | { | 327 | { |
328 | struct super_block *sb; | 328 | struct super_block *sb = dir->i_sb; |
329 | struct fileIdentDesc *fi = NULL; | 329 | struct fileIdentDesc *fi = NULL; |
330 | char name[UDF_NAME_LEN], fname[UDF_NAME_LEN]; | 330 | char name[UDF_NAME_LEN], fname[UDF_NAME_LEN]; |
331 | int namelen; | 331 | int namelen; |
@@ -342,8 +342,6 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
342 | sector_t offset; | 342 | sector_t offset; |
343 | struct extent_position epos = {}; | 343 | struct extent_position epos = {}; |
344 | 344 | ||
345 | sb = dir->i_sb; | ||
346 | |||
347 | if (dentry) { | 345 | if (dentry) { |
348 | if (!dentry->d_name.len) { | 346 | if (!dentry->d_name.len) { |
349 | *err = -EINVAL; | 347 | *err = -EINVAL; |
@@ -535,7 +533,7 @@ add: | |||
535 | } | 533 | } |
536 | 534 | ||
537 | memset(cfi, 0, sizeof(struct fileIdentDesc)); | 535 | memset(cfi, 0, sizeof(struct fileIdentDesc)); |
538 | if (UDF_SB_UDFREV(sb) >= 0x0200) | 536 | if (UDF_SB(sb)->s_udfrev >= 0x0200) |
539 | udf_new_tag((char *)cfi, TAG_IDENT_FID, 3, 1, block, sizeof(tag)); | 537 | udf_new_tag((char *)cfi, TAG_IDENT_FID, 3, 1, block, sizeof(tag)); |
540 | else | 538 | else |
541 | udf_new_tag((char *)cfi, TAG_IDENT_FID, 2, 1, block, sizeof(tag)); | 539 | udf_new_tag((char *)cfi, TAG_IDENT_FID, 2, 1, block, sizeof(tag)); |
@@ -901,6 +899,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
901 | int block; | 899 | int block; |
902 | char name[UDF_NAME_LEN]; | 900 | char name[UDF_NAME_LEN]; |
903 | int namelen; | 901 | int namelen; |
902 | struct buffer_head *bh; | ||
904 | 903 | ||
905 | lock_kernel(); | 904 | lock_kernel(); |
906 | if (!(inode = udf_new_inode(dir, S_IFLNK, &err))) | 905 | if (!(inode = udf_new_inode(dir, S_IFLNK, &err))) |
@@ -1014,17 +1013,19 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
1014 | goto out_no_entry; | 1013 | goto out_no_entry; |
1015 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 1014 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
1016 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); | 1015 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); |
1017 | if (UDF_SB_LVIDBH(inode->i_sb)) { | 1016 | bh = UDF_SB(inode->i_sb)->s_lvid_bh; |
1017 | if (bh) { | ||
1018 | struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)bh->b_data; | ||
1018 | struct logicalVolHeaderDesc *lvhd; | 1019 | struct logicalVolHeaderDesc *lvhd; |
1019 | uint64_t uniqueID; | 1020 | uint64_t uniqueID; |
1020 | lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse); | 1021 | lvhd = (struct logicalVolHeaderDesc *)(lvid->logicalVolContentsUse); |
1021 | uniqueID = le64_to_cpu(lvhd->uniqueID); | 1022 | uniqueID = le64_to_cpu(lvhd->uniqueID); |
1022 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 1023 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
1023 | cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); | 1024 | cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); |
1024 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) | 1025 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) |
1025 | uniqueID += 16; | 1026 | uniqueID += 16; |
1026 | lvhd->uniqueID = cpu_to_le64(uniqueID); | 1027 | lvhd->uniqueID = cpu_to_le64(uniqueID); |
1027 | mark_buffer_dirty(UDF_SB_LVIDBH(inode->i_sb)); | 1028 | mark_buffer_dirty(bh); |
1028 | } | 1029 | } |
1029 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); | 1030 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
1030 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | 1031 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { |
@@ -1053,6 +1054,7 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir, | |||
1053 | struct udf_fileident_bh fibh; | 1054 | struct udf_fileident_bh fibh; |
1054 | struct fileIdentDesc cfi, *fi; | 1055 | struct fileIdentDesc cfi, *fi; |
1055 | int err; | 1056 | int err; |
1057 | struct buffer_head *bh; | ||
1056 | 1058 | ||
1057 | lock_kernel(); | 1059 | lock_kernel(); |
1058 | if (inode->i_nlink >= (256 << sizeof(inode->i_nlink)) - 1) { | 1060 | if (inode->i_nlink >= (256 << sizeof(inode->i_nlink)) - 1) { |
@@ -1066,17 +1068,19 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir, | |||
1066 | } | 1068 | } |
1067 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 1069 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
1068 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); | 1070 | cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); |
1069 | if (UDF_SB_LVIDBH(inode->i_sb)) { | 1071 | bh = UDF_SB(inode->i_sb)->s_lvid_bh; |
1072 | if (bh) { | ||
1073 | struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)bh->b_data; | ||
1070 | struct logicalVolHeaderDesc *lvhd; | 1074 | struct logicalVolHeaderDesc *lvhd; |
1071 | uint64_t uniqueID; | 1075 | uint64_t uniqueID; |
1072 | lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse); | 1076 | lvhd = (struct logicalVolHeaderDesc *)(lvid->logicalVolContentsUse); |
1073 | uniqueID = le64_to_cpu(lvhd->uniqueID); | 1077 | uniqueID = le64_to_cpu(lvhd->uniqueID); |
1074 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 1078 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
1075 | cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); | 1079 | cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); |
1076 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) | 1080 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) |
1077 | uniqueID += 16; | 1081 | uniqueID += 16; |
1078 | lvhd->uniqueID = cpu_to_le64(uniqueID); | 1082 | lvhd->uniqueID = cpu_to_le64(uniqueID); |
1079 | mark_buffer_dirty(UDF_SB_LVIDBH(inode->i_sb)); | 1083 | mark_buffer_dirty(bh); |
1080 | } | 1084 | } |
1081 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); | 1085 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
1082 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { | 1086 | if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { |
diff --git a/fs/udf/partition.c b/fs/udf/partition.c index aaab24c8c498..eeb4714b3641 100644 --- a/fs/udf/partition.c +++ b/fs/udf/partition.c | |||
@@ -31,15 +31,18 @@ | |||
31 | inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block, | 31 | 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 | struct udf_sb_info *sbi = UDF_SB(sb); |
35 | struct udf_part_map *map; | ||
36 | if (partition >= sbi->s_partitions) { | ||
35 | udf_debug("block=%d, partition=%d, offset=%d: invalid partition\n", | 37 | udf_debug("block=%d, partition=%d, offset=%d: invalid partition\n", |
36 | block, partition, offset); | 38 | block, partition, offset); |
37 | return 0xFFFFFFFF; | 39 | return 0xFFFFFFFF; |
38 | } | 40 | } |
39 | if (UDF_SB_PARTFUNC(sb, partition)) | 41 | map = &sbi->s_partmaps[partition]; |
40 | return UDF_SB_PARTFUNC(sb, partition)(sb, block, partition, offset); | 42 | if (map->s_partition_func) |
43 | return map->s_partition_func(sb, block, partition, offset); | ||
41 | else | 44 | else |
42 | return UDF_SB_PARTROOT(sb, partition) + block + offset; | 45 | return map->s_partition_root + block + offset; |
43 | } | 46 | } |
44 | 47 | ||
45 | uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block, | 48 | uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block, |
@@ -49,12 +52,15 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block, | |||
49 | uint32_t newblock; | 52 | uint32_t newblock; |
50 | uint32_t index; | 53 | uint32_t index; |
51 | uint32_t loc; | 54 | uint32_t loc; |
55 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
56 | struct udf_part_map *map; | ||
52 | 57 | ||
53 | index = (sb->s_blocksize - UDF_SB_TYPEVIRT(sb,partition).s_start_offset) / sizeof(uint32_t); | 58 | map = &sbi->s_partmaps[partition]; |
59 | index = (sb->s_blocksize - map->s_type_specific.s_virtual.s_start_offset) / sizeof(uint32_t); | ||
54 | 60 | ||
55 | if (block > UDF_SB_TYPEVIRT(sb,partition).s_num_entries) { | 61 | if (block > map->s_type_specific.s_virtual.s_num_entries) { |
56 | udf_debug("Trying to access block beyond end of VAT (%d max %d)\n", | 62 | udf_debug("Trying to access block beyond end of VAT (%d max %d)\n", |
57 | block, UDF_SB_TYPEVIRT(sb,partition).s_num_entries); | 63 | block, map->s_type_specific.s_virtual.s_num_entries); |
58 | return 0xFFFFFFFF; | 64 | return 0xFFFFFFFF; |
59 | } | 65 | } |
60 | 66 | ||
@@ -64,10 +70,10 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block, | |||
64 | index = block % (sb->s_blocksize / sizeof(uint32_t)); | 70 | index = block % (sb->s_blocksize / sizeof(uint32_t)); |
65 | } else { | 71 | } else { |
66 | newblock = 0; | 72 | newblock = 0; |
67 | index = UDF_SB_TYPEVIRT(sb,partition).s_start_offset / sizeof(uint32_t) + block; | 73 | index = map->s_type_specific.s_virtual.s_start_offset / sizeof(uint32_t) + block; |
68 | } | 74 | } |
69 | 75 | ||
70 | loc = udf_block_map(UDF_SB_VAT(sb), newblock); | 76 | loc = udf_block_map(sbi->s_vat_inode, newblock); |
71 | 77 | ||
72 | if (!(bh = sb_bread(sb, loc))) { | 78 | if (!(bh = sb_bread(sb, loc))) { |
73 | udf_debug("get_pblock(UDF_VIRTUAL_MAP:%p,%d,%d) VAT: %d[%d]\n", | 79 | udf_debug("get_pblock(UDF_VIRTUAL_MAP:%p,%d,%d) VAT: %d[%d]\n", |
@@ -79,13 +85,13 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block, | |||
79 | 85 | ||
80 | brelse(bh); | 86 | brelse(bh); |
81 | 87 | ||
82 | if (UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum == partition) { | 88 | if (UDF_I_LOCATION(sbi->s_vat_inode).partitionReferenceNum == partition) { |
83 | udf_debug("recursive call to udf_get_pblock!\n"); | 89 | udf_debug("recursive call to udf_get_pblock!\n"); |
84 | return 0xFFFFFFFF; | 90 | return 0xFFFFFFFF; |
85 | } | 91 | } |
86 | 92 | ||
87 | return udf_get_pblock(sb, loc, | 93 | return udf_get_pblock(sb, loc, |
88 | UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum, | 94 | UDF_I_LOCATION(sbi->s_vat_inode).partitionReferenceNum, |
89 | offset); | 95 | offset); |
90 | } | 96 | } |
91 | 97 | ||
@@ -95,16 +101,21 @@ inline uint32_t udf_get_pblock_virt20(struct super_block * sb, uint32_t block, | |||
95 | return udf_get_pblock_virt15(sb, block, partition, offset); | 101 | return udf_get_pblock_virt15(sb, block, partition, offset); |
96 | } | 102 | } |
97 | 103 | ||
98 | uint32_t udf_get_pblock_spar15(struct super_block * sb, uint32_t block, | 104 | uint32_t udf_get_pblock_spar15(struct super_block *sb, uint32_t block, |
99 | uint16_t partition, uint32_t offset) | 105 | uint16_t partition, uint32_t offset) |
100 | { | 106 | { |
101 | int i; | 107 | int i; |
102 | struct sparingTable *st = NULL; | 108 | struct sparingTable *st = NULL; |
103 | uint32_t packet = (block + offset) & ~(UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1); | 109 | struct udf_sb_info *sbi = UDF_SB(sb); |
110 | struct udf_part_map *map; | ||
111 | uint32_t packet; | ||
112 | |||
113 | map = &sbi->s_partmaps[partition]; | ||
114 | packet = (block + offset) & ~(map->s_type_specific.s_sparing.s_packet_len - 1); | ||
104 | 115 | ||
105 | for (i = 0; i < 4; i++) { | 116 | for (i = 0; i < 4; i++) { |
106 | if (UDF_SB_TYPESPAR(sb,partition).s_spar_map[i] != NULL) { | 117 | if (map->s_type_specific.s_sparing.s_spar_map[i] != NULL) { |
107 | st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,partition).s_spar_map[i]->b_data; | 118 | st = (struct sparingTable *)map->s_type_specific.s_sparing.s_spar_map[i]->b_data; |
108 | break; | 119 | break; |
109 | } | 120 | } |
110 | } | 121 | } |
@@ -115,14 +126,14 @@ uint32_t udf_get_pblock_spar15(struct super_block * sb, uint32_t block, | |||
115 | break; | 126 | break; |
116 | } else if (le32_to_cpu(st->mapEntry[i].origLocation) == packet) { | 127 | } else if (le32_to_cpu(st->mapEntry[i].origLocation) == packet) { |
117 | return le32_to_cpu(st->mapEntry[i].mappedLocation) + | 128 | return le32_to_cpu(st->mapEntry[i].mappedLocation) + |
118 | ((block + offset) & (UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1)); | 129 | ((block + offset) & (map->s_type_specific.s_sparing.s_packet_len - 1)); |
119 | } else if (le32_to_cpu(st->mapEntry[i].origLocation) > packet) { | 130 | } else if (le32_to_cpu(st->mapEntry[i].origLocation) > packet) { |
120 | break; | 131 | break; |
121 | } | 132 | } |
122 | } | 133 | } |
123 | } | 134 | } |
124 | 135 | ||
125 | return UDF_SB_PARTROOT(sb,partition) + block + offset; | 136 | return map->s_partition_root + block + offset; |
126 | } | 137 | } |
127 | 138 | ||
128 | int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) | 139 | int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) |
@@ -132,15 +143,17 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) | |||
132 | struct sparingEntry mapEntry; | 143 | struct sparingEntry mapEntry; |
133 | uint32_t packet; | 144 | uint32_t packet; |
134 | int i, j, k, l; | 145 | int i, j, k, l; |
146 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
135 | 147 | ||
136 | for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { | 148 | for (i = 0; i < sbi->s_partitions; i++) { |
137 | if (old_block > UDF_SB_PARTROOT(sb,i) && | 149 | struct udf_part_map *map = &sbi->s_partmaps[i]; |
138 | old_block < UDF_SB_PARTROOT(sb,i) + UDF_SB_PARTLEN(sb,i)) { | 150 | if (old_block > map->s_partition_root && |
139 | sdata = &UDF_SB_TYPESPAR(sb,i); | 151 | old_block < map->s_partition_root + map->s_partition_len) { |
140 | packet = (old_block - UDF_SB_PARTROOT(sb,i)) & ~(sdata->s_packet_len - 1); | 152 | sdata = &map->s_type_specific.s_sparing; |
153 | packet = (old_block - map->s_partition_root) & ~(sdata->s_packet_len - 1); | ||
141 | 154 | ||
142 | for (j = 0; j < 4; j++) { | 155 | for (j = 0; j < 4; j++) { |
143 | if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) { | 156 | if (map->s_type_specific.s_sparing.s_spar_map[j] != NULL) { |
144 | st = (struct sparingTable *)sdata->s_spar_map[j]->b_data; | 157 | st = (struct sparingTable *)sdata->s_spar_map[j]->b_data; |
145 | break; | 158 | break; |
146 | } | 159 | } |
@@ -160,11 +173,11 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) | |||
160 | } | 173 | } |
161 | } | 174 | } |
162 | *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) + | 175 | *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) + |
163 | ((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1)); | 176 | ((old_block - map->s_partition_root) & (sdata->s_packet_len - 1)); |
164 | return 0; | 177 | return 0; |
165 | } else if (le32_to_cpu(st->mapEntry[k].origLocation) == packet) { | 178 | } else if (le32_to_cpu(st->mapEntry[k].origLocation) == packet) { |
166 | *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) + | 179 | *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) + |
167 | ((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1)); | 180 | ((old_block - map->s_partition_root) & (sdata->s_packet_len - 1)); |
168 | return 0; | 181 | return 0; |
169 | } else if (le32_to_cpu(st->mapEntry[k].origLocation) > packet) { | 182 | } else if (le32_to_cpu(st->mapEntry[k].origLocation) > packet) { |
170 | break; | 183 | break; |
@@ -185,7 +198,7 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) | |||
185 | } | 198 | } |
186 | } | 199 | } |
187 | *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) + | 200 | *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) + |
188 | ((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1)); | 201 | ((old_block - map->s_partition_root) & (sdata->s_packet_len - 1)); |
189 | return 0; | 202 | return 0; |
190 | } | 203 | } |
191 | } | 204 | } |
@@ -194,7 +207,7 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) | |||
194 | } /* if old_block */ | 207 | } /* if old_block */ |
195 | } | 208 | } |
196 | 209 | ||
197 | if (i == UDF_SB_NUMPARTS(sb)) { | 210 | if (i == sbi->s_partitions) { |
198 | /* outside of partitions */ | 211 | /* outside of partitions */ |
199 | /* for now, fail =) */ | 212 | /* for now, fail =) */ |
200 | return 1; | 213 | return 1; |
diff --git a/fs/udf/super.c b/fs/udf/super.c index 57788f1ba2da..0ca2deb5b992 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -95,6 +95,14 @@ static void udf_close_lvid(struct super_block *); | |||
95 | static unsigned int udf_count_free(struct super_block *); | 95 | static unsigned int udf_count_free(struct super_block *); |
96 | static int udf_statfs(struct dentry *, struct kstatfs *); | 96 | static int udf_statfs(struct dentry *, struct kstatfs *); |
97 | 97 | ||
98 | struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi) | ||
99 | { | ||
100 | struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; | ||
101 | __u32 number_of_partitions = le32_to_cpu(lvid->numOfPartitions); | ||
102 | __u32 offset = number_of_partitions * 2 * sizeof(uint32_t)/sizeof(uint8_t); | ||
103 | return (struct logicalVolIntegrityDescImpUse *)&(lvid->impUse[offset]); | ||
104 | } | ||
105 | |||
98 | /* UDF filesystem type */ | 106 | /* UDF filesystem type */ |
99 | static int udf_get_sb(struct file_system_type *fs_type, | 107 | static int udf_get_sb(struct file_system_type *fs_type, |
100 | int flags, const char *dev_name, void *data, | 108 | int flags, const char *dev_name, void *data, |
@@ -461,22 +469,23 @@ void udf_write_super(struct super_block *sb) | |||
461 | static int udf_remount_fs(struct super_block *sb, int *flags, char *options) | 469 | static int udf_remount_fs(struct super_block *sb, int *flags, char *options) |
462 | { | 470 | { |
463 | struct udf_options uopt; | 471 | struct udf_options uopt; |
472 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
464 | 473 | ||
465 | uopt.flags = UDF_SB(sb)->s_flags; | 474 | uopt.flags = sbi->s_flags; |
466 | uopt.uid = UDF_SB(sb)->s_uid; | 475 | uopt.uid = sbi->s_uid; |
467 | uopt.gid = UDF_SB(sb)->s_gid; | 476 | uopt.gid = sbi->s_gid; |
468 | uopt.umask = UDF_SB(sb)->s_umask; | 477 | uopt.umask = sbi->s_umask; |
469 | 478 | ||
470 | if (!udf_parse_options(options, &uopt)) | 479 | if (!udf_parse_options(options, &uopt)) |
471 | return -EINVAL; | 480 | return -EINVAL; |
472 | 481 | ||
473 | UDF_SB(sb)->s_flags = uopt.flags; | 482 | sbi->s_flags = uopt.flags; |
474 | UDF_SB(sb)->s_uid = uopt.uid; | 483 | sbi->s_uid = uopt.uid; |
475 | UDF_SB(sb)->s_gid = uopt.gid; | 484 | sbi->s_gid = uopt.gid; |
476 | UDF_SB(sb)->s_umask = uopt.umask; | 485 | sbi->s_umask = uopt.umask; |
477 | 486 | ||
478 | if (UDF_SB_LVIDBH(sb)) { | 487 | if (sbi->s_lvid_bh) { |
479 | int write_rev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev); | 488 | int write_rev = le16_to_cpu(udf_sb_lvidiu(sbi)->minUDFWriteRev); |
480 | if (write_rev > UDF_MAX_WRITE_VERSION) | 489 | if (write_rev > UDF_MAX_WRITE_VERSION) |
481 | *flags |= MS_RDONLY; | 490 | *flags |= MS_RDONLY; |
482 | } | 491 | } |
@@ -538,17 +547,19 @@ static int udf_vrs(struct super_block *sb, int silent) | |||
538 | int iso9660 = 0; | 547 | int iso9660 = 0; |
539 | int nsr02 = 0; | 548 | int nsr02 = 0; |
540 | int nsr03 = 0; | 549 | int nsr03 = 0; |
550 | struct udf_sb_info *sbi; | ||
541 | 551 | ||
542 | /* Block size must be a multiple of 512 */ | 552 | /* Block size must be a multiple of 512 */ |
543 | if (sb->s_blocksize & 511) | 553 | if (sb->s_blocksize & 511) |
544 | return 0; | 554 | return 0; |
555 | sbi = UDF_SB(sb); | ||
545 | 556 | ||
546 | if (sb->s_blocksize < sizeof(struct volStructDesc)) | 557 | if (sb->s_blocksize < sizeof(struct volStructDesc)) |
547 | sectorsize = sizeof(struct volStructDesc); | 558 | sectorsize = sizeof(struct volStructDesc); |
548 | else | 559 | else |
549 | sectorsize = sb->s_blocksize; | 560 | sectorsize = sb->s_blocksize; |
550 | 561 | ||
551 | sector += (UDF_SB_SESSION(sb) << sb->s_blocksize_bits); | 562 | sector += (sbi->s_session << sb->s_blocksize_bits); |
552 | 563 | ||
553 | udf_debug("Starting at sector %u (%ld byte sectors)\n", | 564 | udf_debug("Starting at sector %u (%ld byte sectors)\n", |
554 | (sector >> sb->s_blocksize_bits), sb->s_blocksize); | 565 | (sector >> sb->s_blocksize_bits), sb->s_blocksize); |
@@ -614,7 +625,7 @@ static int udf_vrs(struct super_block *sb, int silent) | |||
614 | return nsr03; | 625 | return nsr03; |
615 | else if (nsr02) | 626 | else if (nsr02) |
616 | return nsr02; | 627 | return nsr02; |
617 | else if (sector - (UDF_SB_SESSION(sb) << sb->s_blocksize_bits) == 32768) | 628 | else if (sector - (sbi->s_session << sb->s_blocksize_bits) == 32768) |
618 | return -1; | 629 | return -1; |
619 | else | 630 | else |
620 | return 0; | 631 | return 0; |
@@ -639,11 +650,15 @@ static int udf_vrs(struct super_block *sb, int silent) | |||
639 | */ | 650 | */ |
640 | static void udf_find_anchor(struct super_block *sb) | 651 | static void udf_find_anchor(struct super_block *sb) |
641 | { | 652 | { |
642 | int lastblock = UDF_SB_LASTBLOCK(sb); | 653 | int lastblock; |
643 | struct buffer_head *bh = NULL; | 654 | struct buffer_head *bh = NULL; |
644 | uint16_t ident; | 655 | uint16_t ident; |
645 | uint32_t location; | 656 | uint32_t location; |
646 | int i; | 657 | int i; |
658 | struct udf_sb_info *sbi; | ||
659 | |||
660 | sbi = UDF_SB(sb); | ||
661 | lastblock = sbi->s_last_block; | ||
647 | 662 | ||
648 | if (lastblock) { | 663 | if (lastblock) { |
649 | int varlastblock = udf_variable_to_fixed(lastblock); | 664 | int varlastblock = udf_variable_to_fixed(lastblock); |
@@ -675,22 +690,22 @@ static void udf_find_anchor(struct super_block *sb) | |||
675 | } | 690 | } |
676 | 691 | ||
677 | if (ident == TAG_IDENT_AVDP) { | 692 | if (ident == TAG_IDENT_AVDP) { |
678 | if (location == last[i] - UDF_SB_SESSION(sb)) { | 693 | if (location == last[i] - sbi->s_session) { |
679 | lastblock = last[i] - UDF_SB_SESSION(sb); | 694 | lastblock = last[i] - sbi->s_session; |
680 | UDF_SB_ANCHOR(sb)[0] = lastblock; | 695 | sbi->s_anchor[0] = lastblock; |
681 | UDF_SB_ANCHOR(sb)[1] = lastblock - 256; | 696 | sbi->s_anchor[1] = lastblock - 256; |
682 | } else if (location == udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb)) { | 697 | } else if (location == udf_variable_to_fixed(last[i]) - sbi->s_session) { |
683 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); | 698 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); |
684 | lastblock = udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb); | 699 | lastblock = udf_variable_to_fixed(last[i]) - sbi->s_session; |
685 | UDF_SB_ANCHOR(sb)[0] = lastblock; | 700 | sbi->s_anchor[0] = lastblock; |
686 | UDF_SB_ANCHOR(sb)[1] = lastblock - 256 - UDF_SB_SESSION(sb); | 701 | sbi->s_anchor[1] = lastblock - 256 - sbi->s_session; |
687 | } else { | 702 | } else { |
688 | udf_debug("Anchor found at block %d, location mismatch %d.\n", | 703 | udf_debug("Anchor found at block %d, location mismatch %d.\n", |
689 | last[i], location); | 704 | last[i], location); |
690 | } | 705 | } |
691 | } else if (ident == TAG_IDENT_FE || ident == TAG_IDENT_EFE) { | 706 | } else if (ident == TAG_IDENT_FE || ident == TAG_IDENT_EFE) { |
692 | lastblock = last[i]; | 707 | lastblock = last[i]; |
693 | UDF_SB_ANCHOR(sb)[3] = 512; | 708 | sbi->s_anchor[3] = 512; |
694 | } else { | 709 | } else { |
695 | ident = location = 0; | 710 | ident = location = 0; |
696 | if (last[i] >= 256) { | 711 | if (last[i] >= 256) { |
@@ -704,13 +719,13 @@ static void udf_find_anchor(struct super_block *sb) | |||
704 | } | 719 | } |
705 | 720 | ||
706 | if (ident == TAG_IDENT_AVDP && | 721 | if (ident == TAG_IDENT_AVDP && |
707 | location == last[i] - 256 - UDF_SB_SESSION(sb)) { | 722 | location == last[i] - 256 - sbi->s_session) { |
708 | lastblock = last[i]; | 723 | lastblock = last[i]; |
709 | UDF_SB_ANCHOR(sb)[1] = last[i] - 256; | 724 | sbi->s_anchor[1] = last[i] - 256; |
710 | } else { | 725 | } else { |
711 | ident = location = 0; | 726 | ident = location = 0; |
712 | if (last[i] >= 312 + UDF_SB_SESSION(sb)) { | 727 | if (last[i] >= 312 + sbi->s_session) { |
713 | bh = sb_bread(sb, last[i] - 312 - UDF_SB_SESSION(sb)); | 728 | bh = sb_bread(sb, last[i] - 312 - sbi->s_session); |
714 | if (bh) { | 729 | if (bh) { |
715 | tag *t = (tag *)bh->b_data; | 730 | tag *t = (tag *)bh->b_data; |
716 | ident = le16_to_cpu(t->tagIdent); | 731 | ident = le16_to_cpu(t->tagIdent); |
@@ -723,7 +738,7 @@ static void udf_find_anchor(struct super_block *sb) | |||
723 | location == udf_variable_to_fixed(last[i]) - 256) { | 738 | location == udf_variable_to_fixed(last[i]) - 256) { |
724 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); | 739 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); |
725 | lastblock = udf_variable_to_fixed(last[i]); | 740 | lastblock = udf_variable_to_fixed(last[i]); |
726 | UDF_SB_ANCHOR(sb)[1] = lastblock - 256; | 741 | sbi->s_anchor[1] = lastblock - 256; |
727 | } | 742 | } |
728 | } | 743 | } |
729 | } | 744 | } |
@@ -732,7 +747,7 @@ static void udf_find_anchor(struct super_block *sb) | |||
732 | 747 | ||
733 | if (!lastblock) { | 748 | if (!lastblock) { |
734 | /* We haven't found the lastblock. check 312 */ | 749 | /* We haven't found the lastblock. check 312 */ |
735 | bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb)); | 750 | bh = sb_bread(sb, 312 + sbi->s_session); |
736 | if (bh) { | 751 | if (bh) { |
737 | tag *t = (tag *)bh->b_data; | 752 | tag *t = (tag *)bh->b_data; |
738 | ident = le16_to_cpu(t->tagIdent); | 753 | ident = le16_to_cpu(t->tagIdent); |
@@ -744,22 +759,22 @@ static void udf_find_anchor(struct super_block *sb) | |||
744 | } | 759 | } |
745 | } | 760 | } |
746 | 761 | ||
747 | for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { | 762 | for (i = 0; i < ARRAY_SIZE(sbi->s_anchor); i++) { |
748 | if (UDF_SB_ANCHOR(sb)[i]) { | 763 | if (sbi->s_anchor[i]) { |
749 | bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i], | 764 | bh = udf_read_tagged(sb, sbi->s_anchor[i], |
750 | UDF_SB_ANCHOR(sb)[i], &ident); | 765 | sbi->s_anchor[i], &ident); |
751 | if (!bh) | 766 | if (!bh) |
752 | UDF_SB_ANCHOR(sb)[i] = 0; | 767 | sbi->s_anchor[i] = 0; |
753 | else { | 768 | else { |
754 | brelse(bh); | 769 | brelse(bh); |
755 | if ((ident != TAG_IDENT_AVDP) && | 770 | if ((ident != TAG_IDENT_AVDP) && |
756 | (i || (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE))) | 771 | (i || (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE))) |
757 | UDF_SB_ANCHOR(sb)[i] = 0; | 772 | sbi->s_anchor[i] = 0; |
758 | } | 773 | } |
759 | } | 774 | } |
760 | } | 775 | } |
761 | 776 | ||
762 | UDF_SB_LASTBLOCK(sb) = lastblock; | 777 | sbi->s_last_block = lastblock; |
763 | } | 778 | } |
764 | 779 | ||
765 | static int udf_find_fileset(struct super_block *sb, | 780 | static int udf_find_fileset(struct super_block *sb, |
@@ -769,6 +784,7 @@ static int udf_find_fileset(struct super_block *sb, | |||
769 | struct buffer_head *bh = NULL; | 784 | struct buffer_head *bh = NULL; |
770 | long lastblock; | 785 | long lastblock; |
771 | uint16_t ident; | 786 | uint16_t ident; |
787 | struct udf_sb_info *sbi; | ||
772 | 788 | ||
773 | if (fileset->logicalBlockNum != 0xFFFFFFFF || | 789 | if (fileset->logicalBlockNum != 0xFFFFFFFF || |
774 | fileset->partitionReferenceNum != 0xFFFF) { | 790 | fileset->partitionReferenceNum != 0xFFFF) { |
@@ -783,6 +799,7 @@ static int udf_find_fileset(struct super_block *sb, | |||
783 | 799 | ||
784 | } | 800 | } |
785 | 801 | ||
802 | sbi = UDF_SB(sb); | ||
786 | if (!bh) { | 803 | if (!bh) { |
787 | /* Search backwards through the partitions */ | 804 | /* Search backwards through the partitions */ |
788 | kernel_lb_addr newfileset; | 805 | kernel_lb_addr newfileset; |
@@ -790,13 +807,14 @@ static int udf_find_fileset(struct super_block *sb, | |||
790 | /* --> cvg: FIXME - is it reasonable? */ | 807 | /* --> cvg: FIXME - is it reasonable? */ |
791 | return 1; | 808 | return 1; |
792 | 809 | ||
793 | for (newfileset.partitionReferenceNum = UDF_SB_NUMPARTS(sb) - 1; | 810 | for (newfileset.partitionReferenceNum = sbi->s_partitions - 1; |
794 | (newfileset.partitionReferenceNum != 0xFFFF && | 811 | (newfileset.partitionReferenceNum != 0xFFFF && |
795 | fileset->logicalBlockNum == 0xFFFFFFFF && | 812 | fileset->logicalBlockNum == 0xFFFFFFFF && |
796 | fileset->partitionReferenceNum == 0xFFFF); | 813 | fileset->partitionReferenceNum == 0xFFFF); |
797 | newfileset.partitionReferenceNum--) { | 814 | newfileset.partitionReferenceNum--) { |
798 | lastblock = UDF_SB_PARTLEN(sb, | 815 | lastblock = sbi->s_partmaps |
799 | newfileset.partitionReferenceNum); | 816 | [newfileset.partitionReferenceNum] |
817 | .s_partition_len; | ||
800 | newfileset.logicalBlockNum = 0; | 818 | newfileset.logicalBlockNum = 0; |
801 | 819 | ||
802 | do { | 820 | do { |
@@ -840,7 +858,7 @@ static int udf_find_fileset(struct super_block *sb, | |||
840 | fileset->logicalBlockNum, | 858 | fileset->logicalBlockNum, |
841 | fileset->partitionReferenceNum); | 859 | fileset->partitionReferenceNum); |
842 | 860 | ||
843 | UDF_SB_PARTITION(sb) = fileset->partitionReferenceNum; | 861 | sbi->s_partition = fileset->partitionReferenceNum; |
844 | udf_load_fileset(sb, bh, root); | 862 | udf_load_fileset(sb, bh, root); |
845 | brelse(bh); | 863 | brelse(bh); |
846 | return 0; | 864 | return 0; |
@@ -867,15 +885,15 @@ static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh) | |||
867 | recording, recording_usec, | 885 | recording, recording_usec, |
868 | ts.year, ts.month, ts.day, ts.hour, | 886 | ts.year, ts.month, ts.day, ts.hour, |
869 | ts.minute, ts.typeAndTimezone); | 887 | ts.minute, ts.typeAndTimezone); |
870 | UDF_SB_RECORDTIME(sb).tv_sec = recording; | 888 | UDF_SB(sb)->s_record_time.tv_sec = recording; |
871 | UDF_SB_RECORDTIME(sb).tv_nsec = recording_usec * 1000; | 889 | UDF_SB(sb)->s_record_time.tv_nsec = recording_usec * 1000; |
872 | } | 890 | } |
873 | 891 | ||
874 | if (!udf_build_ustr(&instr, pvoldesc->volIdent, 32)) { | 892 | if (!udf_build_ustr(&instr, pvoldesc->volIdent, 32)) { |
875 | if (udf_CS0toUTF8(&outstr, &instr)) { | 893 | if (udf_CS0toUTF8(&outstr, &instr)) { |
876 | strncpy(UDF_SB_VOLIDENT(sb), outstr.u_name, | 894 | strncpy(UDF_SB(sb)->s_volume_ident, outstr.u_name, |
877 | outstr.u_len > 31 ? 31 : outstr.u_len); | 895 | outstr.u_len > 31 ? 31 : outstr.u_len); |
878 | udf_debug("volIdent[] = '%s'\n", UDF_SB_VOLIDENT(sb)); | 896 | udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident); |
879 | } | 897 | } |
880 | } | 898 | } |
881 | 899 | ||
@@ -894,7 +912,7 @@ static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh, | |||
894 | 912 | ||
895 | *root = lelb_to_cpu(fset->rootDirectoryICB.extLocation); | 913 | *root = lelb_to_cpu(fset->rootDirectoryICB.extLocation); |
896 | 914 | ||
897 | UDF_SB_SERIALNUM(sb) = le16_to_cpu(fset->descTag.tagSerialNum); | 915 | UDF_SB(sb)->s_serial_number = le16_to_cpu(fset->descTag.tagSerialNum); |
898 | 916 | ||
899 | udf_debug("Rootdir at block=%d, partition=%d\n", | 917 | udf_debug("Rootdir at block=%d, partition=%d\n", |
900 | root->logicalBlockNum, root->partitionReferenceNum); | 918 | root->logicalBlockNum, root->partitionReferenceNum); |
@@ -904,23 +922,27 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh) | |||
904 | { | 922 | { |
905 | struct partitionDesc *p; | 923 | struct partitionDesc *p; |
906 | int i; | 924 | int i; |
925 | struct udf_part_map *map; | ||
926 | struct udf_sb_info *sbi; | ||
907 | 927 | ||
908 | p = (struct partitionDesc *)bh->b_data; | 928 | p = (struct partitionDesc *)bh->b_data; |
929 | sbi = UDF_SB(sb); | ||
909 | 930 | ||
910 | for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { | 931 | for (i = 0; i < sbi->s_partitions; i++) { |
932 | map = &sbi->s_partmaps[i]; | ||
911 | udf_debug("Searching map: (%d == %d)\n", | 933 | udf_debug("Searching map: (%d == %d)\n", |
912 | UDF_SB_PARTMAPS(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber)); | 934 | map->s_partition_num, le16_to_cpu(p->partitionNumber)); |
913 | if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber)) { | 935 | if (map->s_partition_num == le16_to_cpu(p->partitionNumber)) { |
914 | UDF_SB_PARTLEN(sb, i) = le32_to_cpu(p->partitionLength); /* blocks */ | 936 | map->s_partition_len = le32_to_cpu(p->partitionLength); /* blocks */ |
915 | UDF_SB_PARTROOT(sb, i) = le32_to_cpu(p->partitionStartingLocation); | 937 | map->s_partition_root = le32_to_cpu(p->partitionStartingLocation); |
916 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_READ_ONLY) | 938 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_READ_ONLY) |
917 | UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_READ_ONLY; | 939 | map->s_partition_flags |= UDF_PART_FLAG_READ_ONLY; |
918 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_WRITE_ONCE) | 940 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_WRITE_ONCE) |
919 | UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_WRITE_ONCE; | 941 | map->s_partition_flags |= UDF_PART_FLAG_WRITE_ONCE; |
920 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_REWRITABLE) | 942 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_REWRITABLE) |
921 | UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_REWRITABLE; | 943 | map->s_partition_flags |= UDF_PART_FLAG_REWRITABLE; |
922 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_OVERWRITABLE) | 944 | if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_OVERWRITABLE) |
923 | UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_OVERWRITABLE; | 945 | map->s_partition_flags |= UDF_PART_FLAG_OVERWRITABLE; |
924 | 946 | ||
925 | if (!strcmp(p->partitionContents.ident, | 947 | if (!strcmp(p->partitionContents.ident, |
926 | PD_PARTITION_CONTENTS_NSR02) || | 948 | PD_PARTITION_CONTENTS_NSR02) || |
@@ -935,26 +957,26 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh) | |||
935 | .partitionReferenceNum = i, | 957 | .partitionReferenceNum = i, |
936 | }; | 958 | }; |
937 | 959 | ||
938 | UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table = | 960 | map->s_uspace.s_table = |
939 | udf_iget(sb, loc); | 961 | udf_iget(sb, loc); |
940 | if (!UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table) { | 962 | if (!map->s_uspace.s_table) { |
941 | udf_debug("cannot load unallocSpaceTable (part %d)\n", i); | 963 | udf_debug("cannot load unallocSpaceTable (part %d)\n", i); |
942 | return 1; | 964 | return 1; |
943 | } | 965 | } |
944 | UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_UNALLOC_TABLE; | 966 | map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE; |
945 | udf_debug("unallocSpaceTable (part %d) @ %ld\n", | 967 | udf_debug("unallocSpaceTable (part %d) @ %ld\n", |
946 | i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table->i_ino); | 968 | i, map->s_uspace.s_table->i_ino); |
947 | } | 969 | } |
948 | if (phd->unallocSpaceBitmap.extLength) { | 970 | if (phd->unallocSpaceBitmap.extLength) { |
949 | UDF_SB_ALLOC_BITMAP(sb, i, s_uspace); | 971 | UDF_SB_ALLOC_BITMAP(sb, i, s_uspace); |
950 | if (UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap != NULL) { | 972 | if (map->s_uspace.s_bitmap != NULL) { |
951 | UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extLength = | 973 | map->s_uspace.s_bitmap->s_extLength = |
952 | le32_to_cpu(phd->unallocSpaceBitmap.extLength); | 974 | le32_to_cpu(phd->unallocSpaceBitmap.extLength); |
953 | UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition = | 975 | map->s_uspace.s_bitmap->s_extPosition = |
954 | le32_to_cpu(phd->unallocSpaceBitmap.extPosition); | 976 | le32_to_cpu(phd->unallocSpaceBitmap.extPosition); |
955 | UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_UNALLOC_BITMAP; | 977 | map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP; |
956 | udf_debug("unallocSpaceBitmap (part %d) @ %d\n", | 978 | udf_debug("unallocSpaceBitmap (part %d) @ %d\n", |
957 | i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition); | 979 | i, map->s_uspace.s_bitmap->s_extPosition); |
958 | } | 980 | } |
959 | } | 981 | } |
960 | if (phd->partitionIntegrityTable.extLength) | 982 | if (phd->partitionIntegrityTable.extLength) |
@@ -965,41 +987,42 @@ static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh) | |||
965 | .partitionReferenceNum = i, | 987 | .partitionReferenceNum = i, |
966 | }; | 988 | }; |
967 | 989 | ||
968 | UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table = | 990 | map->s_fspace.s_table = |
969 | udf_iget(sb, loc); | 991 | udf_iget(sb, loc); |
970 | if (!UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table) { | 992 | if (!map->s_fspace.s_table) { |
971 | udf_debug("cannot load freedSpaceTable (part %d)\n", i); | 993 | udf_debug("cannot load freedSpaceTable (part %d)\n", i); |
972 | return 1; | 994 | return 1; |
973 | } | 995 | } |
974 | UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_FREED_TABLE; | 996 | map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE; |
975 | udf_debug("freedSpaceTable (part %d) @ %ld\n", | 997 | udf_debug("freedSpaceTable (part %d) @ %ld\n", |
976 | i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table->i_ino); | 998 | i, map->s_fspace.s_table->i_ino); |
977 | } | 999 | } |
978 | if (phd->freedSpaceBitmap.extLength) { | 1000 | if (phd->freedSpaceBitmap.extLength) { |
979 | UDF_SB_ALLOC_BITMAP(sb, i, s_fspace); | 1001 | UDF_SB_ALLOC_BITMAP(sb, i, s_fspace); |
980 | if (UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap != NULL) { | 1002 | if (map->s_fspace.s_bitmap != NULL) { |
981 | UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extLength = | 1003 | map->s_fspace.s_bitmap->s_extLength = |
982 | le32_to_cpu(phd->freedSpaceBitmap.extLength); | 1004 | le32_to_cpu(phd->freedSpaceBitmap.extLength); |
983 | UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition = | 1005 | map->s_fspace.s_bitmap->s_extPosition = |
984 | le32_to_cpu(phd->freedSpaceBitmap.extPosition); | 1006 | le32_to_cpu(phd->freedSpaceBitmap.extPosition); |
985 | UDF_SB_PARTFLAGS(sb, i) |= UDF_PART_FLAG_FREED_BITMAP; | 1007 | map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP; |
986 | udf_debug("freedSpaceBitmap (part %d) @ %d\n", | 1008 | udf_debug("freedSpaceBitmap (part %d) @ %d\n", |
987 | i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition); | 1009 | i, map->s_fspace.s_bitmap->s_extPosition); |
988 | } | 1010 | } |
989 | } | 1011 | } |
990 | } | 1012 | } |
991 | break; | 1013 | break; |
992 | } | 1014 | } |
993 | } | 1015 | } |
994 | if (i == UDF_SB_NUMPARTS(sb)) { | 1016 | if (i == sbi->s_partitions) { |
995 | udf_debug("Partition (%d) not found in partition map\n", | 1017 | udf_debug("Partition (%d) not found in partition map\n", |
996 | le16_to_cpu(p->partitionNumber)); | 1018 | le16_to_cpu(p->partitionNumber)); |
997 | } else { | 1019 | } else { |
998 | udf_debug("Partition (%d:%d type %x) starts at physical %d, " | 1020 | udf_debug("Partition (%d:%d type %x) starts at physical %d, " |
999 | "block length %d\n", | 1021 | "block length %d\n", |
1000 | le16_to_cpu(p->partitionNumber), i, | 1022 | le16_to_cpu(p->partitionNumber), i, |
1001 | UDF_SB_PARTTYPE(sb, i), UDF_SB_PARTROOT(sb, i), | 1023 | map->s_partition_type, |
1002 | UDF_SB_PARTLEN(sb, i)); | 1024 | map->s_partition_root, |
1025 | map->s_partition_len); | ||
1003 | } | 1026 | } |
1004 | return 0; | 1027 | return 0; |
1005 | } | 1028 | } |
@@ -1010,30 +1033,32 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh, | |||
1010 | struct logicalVolDesc *lvd; | 1033 | struct logicalVolDesc *lvd; |
1011 | int i, j, offset; | 1034 | int i, j, offset; |
1012 | uint8_t type; | 1035 | uint8_t type; |
1036 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
1013 | 1037 | ||
1014 | lvd = (struct logicalVolDesc *)bh->b_data; | 1038 | lvd = (struct logicalVolDesc *)bh->b_data; |
1015 | 1039 | ||
1016 | UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps)); | 1040 | UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps)); |
1017 | 1041 | ||
1018 | for (i = 0, offset = 0; | 1042 | for (i = 0, offset = 0; |
1019 | i < UDF_SB_NUMPARTS(sb) && offset < le32_to_cpu(lvd->mapTableLength); | 1043 | i < sbi->s_partitions && offset < le32_to_cpu(lvd->mapTableLength); |
1020 | i++, offset += ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapLength) { | 1044 | i++, offset += ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapLength) { |
1045 | struct udf_part_map *map = &sbi->s_partmaps[i]; | ||
1021 | type = ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapType; | 1046 | type = ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapType; |
1022 | if (type == 1) { | 1047 | if (type == 1) { |
1023 | struct genericPartitionMap1 *gpm1 = (struct genericPartitionMap1 *)&(lvd->partitionMaps[offset]); | 1048 | struct genericPartitionMap1 *gpm1 = (struct genericPartitionMap1 *)&(lvd->partitionMaps[offset]); |
1024 | UDF_SB_PARTTYPE(sb, i) = UDF_TYPE1_MAP15; | 1049 | map->s_partition_type = UDF_TYPE1_MAP15; |
1025 | UDF_SB_PARTVSN(sb, i) = le16_to_cpu(gpm1->volSeqNum); | 1050 | map->s_volumeseqnum = le16_to_cpu(gpm1->volSeqNum); |
1026 | UDF_SB_PARTNUM(sb, i) = le16_to_cpu(gpm1->partitionNum); | 1051 | map->s_partition_num = le16_to_cpu(gpm1->partitionNum); |
1027 | UDF_SB_PARTFUNC(sb, i) = NULL; | 1052 | map->s_partition_func = NULL; |
1028 | } else if (type == 2) { | 1053 | } else if (type == 2) { |
1029 | struct udfPartitionMap2 *upm2 = (struct udfPartitionMap2 *)&(lvd->partitionMaps[offset]); | 1054 | struct udfPartitionMap2 *upm2 = (struct udfPartitionMap2 *)&(lvd->partitionMaps[offset]); |
1030 | if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL))) { | 1055 | if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL))) { |
1031 | if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0150) { | 1056 | if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0150) { |
1032 | UDF_SB_PARTTYPE(sb, i) = UDF_VIRTUAL_MAP15; | 1057 | map->s_partition_type = UDF_VIRTUAL_MAP15; |
1033 | UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_virt15; | 1058 | map->s_partition_func = udf_get_pblock_virt15; |
1034 | } else if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0200) { | 1059 | } else if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0200) { |
1035 | UDF_SB_PARTTYPE(sb, i) = UDF_VIRTUAL_MAP20; | 1060 | map->s_partition_type = UDF_VIRTUAL_MAP20; |
1036 | UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_virt20; | 1061 | map->s_partition_func = udf_get_pblock_virt20; |
1037 | } | 1062 | } |
1038 | } else if (!strncmp(upm2->partIdent.ident, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE))) { | 1063 | } else if (!strncmp(upm2->partIdent.ident, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE))) { |
1039 | uint32_t loc; | 1064 | uint32_t loc; |
@@ -1041,33 +1066,33 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh, | |||
1041 | struct sparingTable *st; | 1066 | struct sparingTable *st; |
1042 | struct sparablePartitionMap *spm = (struct sparablePartitionMap *)&(lvd->partitionMaps[offset]); | 1067 | struct sparablePartitionMap *spm = (struct sparablePartitionMap *)&(lvd->partitionMaps[offset]); |
1043 | 1068 | ||
1044 | UDF_SB_PARTTYPE(sb, i) = UDF_SPARABLE_MAP15; | 1069 | map->s_partition_type = UDF_SPARABLE_MAP15; |
1045 | UDF_SB_TYPESPAR(sb, i).s_packet_len = le16_to_cpu(spm->packetLength); | 1070 | map->s_type_specific.s_sparing.s_packet_len = le16_to_cpu(spm->packetLength); |
1046 | for (j = 0; j < spm->numSparingTables; j++) { | 1071 | for (j = 0; j < spm->numSparingTables; j++) { |
1047 | loc = le32_to_cpu(spm->locSparingTable[j]); | 1072 | loc = le32_to_cpu(spm->locSparingTable[j]); |
1048 | UDF_SB_TYPESPAR(sb, i).s_spar_map[j] = | 1073 | map->s_type_specific.s_sparing.s_spar_map[j] = |
1049 | udf_read_tagged(sb, loc, loc, &ident); | 1074 | udf_read_tagged(sb, loc, loc, &ident); |
1050 | if (UDF_SB_TYPESPAR(sb, i).s_spar_map[j] != NULL) { | 1075 | if (map->s_type_specific.s_sparing.s_spar_map[j] != NULL) { |
1051 | st = (struct sparingTable *)UDF_SB_TYPESPAR(sb, i).s_spar_map[j]->b_data; | 1076 | st = (struct sparingTable *)map->s_type_specific.s_sparing.s_spar_map[j]->b_data; |
1052 | if (ident != 0 || | 1077 | if (ident != 0 || |
1053 | strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING))) { | 1078 | strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING))) { |
1054 | brelse(UDF_SB_TYPESPAR(sb, i).s_spar_map[j]); | 1079 | brelse(map->s_type_specific.s_sparing.s_spar_map[j]); |
1055 | UDF_SB_TYPESPAR(sb, i).s_spar_map[j] = NULL; | 1080 | map->s_type_specific.s_sparing.s_spar_map[j] = NULL; |
1056 | } | 1081 | } |
1057 | } | 1082 | } |
1058 | } | 1083 | } |
1059 | UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_spar15; | 1084 | map->s_partition_func = udf_get_pblock_spar15; |
1060 | } else { | 1085 | } else { |
1061 | udf_debug("Unknown ident: %s\n", | 1086 | udf_debug("Unknown ident: %s\n", |
1062 | upm2->partIdent.ident); | 1087 | upm2->partIdent.ident); |
1063 | continue; | 1088 | continue; |
1064 | } | 1089 | } |
1065 | UDF_SB_PARTVSN(sb, i) = le16_to_cpu(upm2->volSeqNum); | 1090 | map->s_volumeseqnum = le16_to_cpu(upm2->volSeqNum); |
1066 | UDF_SB_PARTNUM(sb, i) = le16_to_cpu(upm2->partitionNum); | 1091 | map->s_partition_num = le16_to_cpu(upm2->partitionNum); |
1067 | } | 1092 | } |
1068 | udf_debug("Partition (%d:%d) type %d on volume %d\n", | 1093 | udf_debug("Partition (%d:%d) type %d on volume %d\n", |
1069 | i, UDF_SB_PARTNUM(sb, i), type, | 1094 | i, map->s_partition_num, type, |
1070 | UDF_SB_PARTVSN(sb, i)); | 1095 | map->s_volumeseqnum); |
1071 | } | 1096 | } |
1072 | 1097 | ||
1073 | if (fileset) { | 1098 | if (fileset) { |
@@ -1092,23 +1117,26 @@ static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc) | |||
1092 | { | 1117 | { |
1093 | struct buffer_head *bh = NULL; | 1118 | struct buffer_head *bh = NULL; |
1094 | uint16_t ident; | 1119 | uint16_t ident; |
1120 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
1121 | struct logicalVolIntegrityDesc *lvid; | ||
1095 | 1122 | ||
1096 | while (loc.extLength > 0 && | 1123 | while (loc.extLength > 0 && |
1097 | (bh = udf_read_tagged(sb, loc.extLocation, | 1124 | (bh = udf_read_tagged(sb, loc.extLocation, |
1098 | loc.extLocation, &ident)) && | 1125 | loc.extLocation, &ident)) && |
1099 | ident == TAG_IDENT_LVID) { | 1126 | ident == TAG_IDENT_LVID) { |
1100 | UDF_SB_LVIDBH(sb) = bh; | 1127 | sbi->s_lvid_bh = bh; |
1128 | lvid = (struct logicalVolIntegrityDesc *)bh->b_data; | ||
1101 | 1129 | ||
1102 | if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength) | 1130 | if (lvid->nextIntegrityExt.extLength) |
1103 | udf_load_logicalvolint(sb, | 1131 | udf_load_logicalvolint(sb, |
1104 | leea_to_cpu(UDF_SB_LVID(sb)->nextIntegrityExt)); | 1132 | leea_to_cpu(lvid->nextIntegrityExt)); |
1105 | 1133 | ||
1106 | if (UDF_SB_LVIDBH(sb) != bh) | 1134 | if (sbi->s_lvid_bh != bh) |
1107 | brelse(bh); | 1135 | brelse(bh); |
1108 | loc.extLength -= sb->s_blocksize; | 1136 | loc.extLength -= sb->s_blocksize; |
1109 | loc.extLocation++; | 1137 | loc.extLocation++; |
1110 | } | 1138 | } |
1111 | if (UDF_SB_LVIDBH(sb) != bh) | 1139 | if (sbi->s_lvid_bh != bh) |
1112 | brelse(bh); | 1140 | brelse(bh); |
1113 | } | 1141 | } |
1114 | 1142 | ||
@@ -1259,10 +1287,11 @@ static int udf_check_valid(struct super_block *sb, int novrs, int silent) | |||
1259 | else { | 1287 | else { |
1260 | block = udf_vrs(sb, silent); | 1288 | block = udf_vrs(sb, silent); |
1261 | if (block == -1) { | 1289 | if (block == -1) { |
1290 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
1262 | udf_debug("Failed to read byte 32768. Assuming open " | 1291 | udf_debug("Failed to read byte 32768. Assuming open " |
1263 | "disc. Skipping validity check\n"); | 1292 | "disc. Skipping validity check\n"); |
1264 | if (!UDF_SB_LASTBLOCK(sb)) | 1293 | if (!sbi->s_last_block) |
1265 | UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb); | 1294 | sbi->s_last_block = udf_get_last_block(sb); |
1266 | return 0; | 1295 | return 0; |
1267 | } else | 1296 | } else |
1268 | return !block; | 1297 | return !block; |
@@ -1276,14 +1305,16 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) | |||
1276 | struct buffer_head *bh; | 1305 | struct buffer_head *bh; |
1277 | long main_s, main_e, reserve_s, reserve_e; | 1306 | long main_s, main_e, reserve_s, reserve_e; |
1278 | int i, j; | 1307 | int i, j; |
1308 | struct udf_sb_info *sbi; | ||
1279 | 1309 | ||
1280 | if (!sb) | 1310 | if (!sb) |
1281 | return 1; | 1311 | return 1; |
1312 | sbi = UDF_SB(sb); | ||
1282 | 1313 | ||
1283 | for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { | 1314 | for (i = 0; i < ARRAY_SIZE(sbi->s_anchor); i++) { |
1284 | if (UDF_SB_ANCHOR(sb)[i] && | 1315 | if (sbi->s_anchor[i] && |
1285 | (bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i], | 1316 | (bh = udf_read_tagged(sb, sbi->s_anchor[i], |
1286 | UDF_SB_ANCHOR(sb)[i], &ident))) { | 1317 | sbi->s_anchor[i], &ident))) { |
1287 | anchor = (struct anchorVolDescPtr *)bh->b_data; | 1318 | anchor = (struct anchorVolDescPtr *)bh->b_data; |
1288 | 1319 | ||
1289 | /* Locate the main sequence */ | 1320 | /* Locate the main sequence */ |
@@ -1308,68 +1339,72 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) | |||
1308 | } | 1339 | } |
1309 | } | 1340 | } |
1310 | 1341 | ||
1311 | if (i == ARRAY_SIZE(UDF_SB_ANCHOR(sb))) { | 1342 | if (i == ARRAY_SIZE(sbi->s_anchor)) { |
1312 | udf_debug("No Anchor block found\n"); | 1343 | udf_debug("No Anchor block found\n"); |
1313 | return 1; | 1344 | return 1; |
1314 | } else | 1345 | } else |
1315 | udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]); | 1346 | udf_debug("Using anchor in block %d\n", sbi->s_anchor[i]); |
1316 | 1347 | ||
1317 | for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { | 1348 | for (i = 0; i < sbi->s_partitions; i++) { |
1318 | kernel_lb_addr uninitialized_var(ino); | 1349 | kernel_lb_addr uninitialized_var(ino); |
1319 | switch (UDF_SB_PARTTYPE(sb, i)) { | 1350 | struct udf_part_map *map = &sbi->s_partmaps[i]; |
1351 | switch (map->s_partition_type) { | ||
1320 | case UDF_VIRTUAL_MAP15: | 1352 | case UDF_VIRTUAL_MAP15: |
1321 | case UDF_VIRTUAL_MAP20: | 1353 | case UDF_VIRTUAL_MAP20: |
1322 | if (!UDF_SB_LASTBLOCK(sb)) { | 1354 | if (!sbi->s_last_block) { |
1323 | UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb); | 1355 | sbi->s_last_block = udf_get_last_block(sb); |
1324 | udf_find_anchor(sb); | 1356 | udf_find_anchor(sb); |
1325 | } | 1357 | } |
1326 | 1358 | ||
1327 | if (!UDF_SB_LASTBLOCK(sb)) { | 1359 | if (!sbi->s_last_block) { |
1328 | udf_debug("Unable to determine Lastblock (For " | 1360 | udf_debug("Unable to determine Lastblock (For " |
1329 | "Virtual Partition)\n"); | 1361 | "Virtual Partition)\n"); |
1330 | return 1; | 1362 | return 1; |
1331 | } | 1363 | } |
1332 | 1364 | ||
1333 | for (j = 0; j < UDF_SB_NUMPARTS(sb); j++) { | 1365 | for (j = 0; j < sbi->s_partitions; j++) { |
1366 | struct udf_part_map *map2 = &sbi->s_partmaps[j]; | ||
1334 | if (j != i && | 1367 | if (j != i && |
1335 | UDF_SB_PARTVSN(sb, i) == UDF_SB_PARTVSN(sb, j) && | 1368 | map->s_volumeseqnum == map2->s_volumeseqnum && |
1336 | UDF_SB_PARTNUM(sb, i) == UDF_SB_PARTNUM(sb, j)) { | 1369 | map->s_partition_num == map2->s_partition_num) { |
1337 | ino.partitionReferenceNum = j; | 1370 | ino.partitionReferenceNum = j; |
1338 | ino.logicalBlockNum = UDF_SB_LASTBLOCK(sb) - UDF_SB_PARTROOT(sb, j); | 1371 | ino.logicalBlockNum = sbi->s_last_block - map2->s_partition_root; |
1339 | break; | 1372 | break; |
1340 | } | 1373 | } |
1341 | } | 1374 | } |
1342 | 1375 | ||
1343 | if (j == UDF_SB_NUMPARTS(sb)) | 1376 | if (j == sbi->s_partitions) |
1344 | return 1; | 1377 | return 1; |
1345 | 1378 | ||
1346 | UDF_SB_VAT(sb) = udf_iget(sb, ino); | 1379 | sbi->s_vat_inode = udf_iget(sb, ino); |
1347 | if (!UDF_SB_VAT(sb)) | 1380 | if (!sbi->s_vat_inode) |
1348 | return 1; | 1381 | return 1; |
1349 | 1382 | ||
1350 | if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) { | 1383 | if (map->s_partition_type == UDF_VIRTUAL_MAP15) { |
1351 | UDF_SB_TYPEVIRT(sb, i).s_start_offset = | 1384 | map->s_type_specific.s_virtual.s_start_offset = |
1352 | udf_ext0_offset(UDF_SB_VAT(sb)); | 1385 | udf_ext0_offset(sbi->s_vat_inode); |
1353 | UDF_SB_TYPEVIRT(sb, i).s_num_entries = | 1386 | map->s_type_specific.s_virtual.s_num_entries = |
1354 | (UDF_SB_VAT(sb)->i_size - 36) >> 2; | 1387 | (sbi->s_vat_inode->i_size - 36) >> 2; |
1355 | } else if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP20) { | 1388 | } else if (map->s_partition_type == UDF_VIRTUAL_MAP20) { |
1356 | struct buffer_head *bh = NULL; | 1389 | struct buffer_head *bh = NULL; |
1357 | uint32_t pos; | 1390 | uint32_t pos; |
1358 | 1391 | ||
1359 | pos = udf_block_map(UDF_SB_VAT(sb), 0); | 1392 | pos = udf_block_map(sbi->s_vat_inode, 0); |
1360 | bh = sb_bread(sb, pos); | 1393 | bh = sb_bread(sb, pos); |
1361 | if (!bh) | 1394 | if (!bh) |
1362 | return 1; | 1395 | return 1; |
1363 | UDF_SB_TYPEVIRT(sb, i).s_start_offset = | 1396 | map->s_type_specific.s_virtual.s_start_offset = |
1364 | le16_to_cpu(((struct virtualAllocationTable20 *)bh->b_data + | 1397 | le16_to_cpu(((struct virtualAllocationTable20 *)bh->b_data + |
1365 | udf_ext0_offset(UDF_SB_VAT(sb)))->lengthHeader) + | 1398 | udf_ext0_offset(sbi->s_vat_inode))->lengthHeader) + |
1366 | udf_ext0_offset(UDF_SB_VAT(sb)); | 1399 | udf_ext0_offset(sbi->s_vat_inode); |
1367 | UDF_SB_TYPEVIRT(sb, i).s_num_entries = (UDF_SB_VAT(sb)->i_size - | 1400 | map->s_type_specific.s_virtual.s_num_entries = (sbi->s_vat_inode->i_size - |
1368 | UDF_SB_TYPEVIRT(sb, i).s_start_offset) >> 2; | 1401 | map->s_type_specific.s_virtual.s_start_offset) >> 2; |
1369 | brelse(bh); | 1402 | brelse(bh); |
1370 | } | 1403 | } |
1371 | UDF_SB_PARTROOT(sb, i) = udf_get_pblock(sb, 0, i, 0); | 1404 | map->s_partition_root = udf_get_pblock(sb, 0, i, 0); |
1372 | UDF_SB_PARTLEN(sb, i) = UDF_SB_PARTLEN(sb, ino.partitionReferenceNum); | 1405 | map->s_partition_len = |
1406 | sbi->s_partmaps[ino.partitionReferenceNum]. | ||
1407 | s_partition_len; | ||
1373 | } | 1408 | } |
1374 | } | 1409 | } |
1375 | return 0; | 1410 | return 0; |
@@ -1377,26 +1412,30 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) | |||
1377 | 1412 | ||
1378 | static void udf_open_lvid(struct super_block *sb) | 1413 | static void udf_open_lvid(struct super_block *sb) |
1379 | { | 1414 | { |
1380 | if (UDF_SB_LVIDBH(sb)) { | 1415 | struct udf_sb_info *sbi = UDF_SB(sb); |
1416 | struct buffer_head *bh = sbi->s_lvid_bh; | ||
1417 | if (bh) { | ||
1381 | int i; | 1418 | int i; |
1382 | kernel_timestamp cpu_time; | 1419 | kernel_timestamp cpu_time; |
1420 | struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)bh->b_data; | ||
1421 | struct logicalVolIntegrityDescImpUse *lvidiu = udf_sb_lvidiu(sbi); | ||
1383 | 1422 | ||
1384 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | 1423 | lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; |
1385 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | 1424 | lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; |
1386 | if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) | 1425 | if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) |
1387 | UDF_SB_LVID(sb)->recordingDateAndTime = cpu_to_lets(cpu_time); | 1426 | lvid->recordingDateAndTime = cpu_to_lets(cpu_time); |
1388 | UDF_SB_LVID(sb)->integrityType = LVID_INTEGRITY_TYPE_OPEN; | 1427 | lvid->integrityType = LVID_INTEGRITY_TYPE_OPEN; |
1389 | 1428 | ||
1390 | UDF_SB_LVID(sb)->descTag.descCRC = cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag), | 1429 | lvid->descTag.descCRC = cpu_to_le16(udf_crc((char *)lvid + sizeof(tag), |
1391 | le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0)); | 1430 | le16_to_cpu(lvid->descTag.descCRCLength), 0)); |
1392 | 1431 | ||
1393 | UDF_SB_LVID(sb)->descTag.tagChecksum = 0; | 1432 | lvid->descTag.tagChecksum = 0; |
1394 | for (i = 0; i < 16; i++) | 1433 | for (i = 0; i < 16; i++) |
1395 | if (i != 4) | 1434 | if (i != 4) |
1396 | UDF_SB_LVID(sb)->descTag.tagChecksum += | 1435 | lvid->descTag.tagChecksum += |
1397 | ((uint8_t *) &(UDF_SB_LVID(sb)->descTag))[i]; | 1436 | ((uint8_t *) &(lvid->descTag))[i]; |
1398 | 1437 | ||
1399 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 1438 | mark_buffer_dirty(bh); |
1400 | } | 1439 | } |
1401 | } | 1440 | } |
1402 | 1441 | ||
@@ -1404,32 +1443,40 @@ static void udf_close_lvid(struct super_block *sb) | |||
1404 | { | 1443 | { |
1405 | kernel_timestamp cpu_time; | 1444 | kernel_timestamp cpu_time; |
1406 | int i; | 1445 | int i; |
1446 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
1447 | struct buffer_head *bh = sbi->s_lvid_bh; | ||
1448 | struct logicalVolIntegrityDesc *lvid; | ||
1407 | 1449 | ||
1408 | if (UDF_SB_LVIDBH(sb) && | 1450 | if (!bh) |
1409 | UDF_SB_LVID(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN) { | 1451 | return; |
1410 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | 1452 | |
1411 | UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | 1453 | lvid = (struct logicalVolIntegrityDesc *)bh->b_data; |
1454 | |||
1455 | if (lvid->integrityType == LVID_INTEGRITY_TYPE_OPEN) { | ||
1456 | struct logicalVolIntegrityDescImpUse *lvidiu = udf_sb_lvidiu(sbi); | ||
1457 | lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | ||
1458 | lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | ||
1412 | if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) | 1459 | if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) |
1413 | UDF_SB_LVID(sb)->recordingDateAndTime = cpu_to_lets(cpu_time); | 1460 | lvid->recordingDateAndTime = cpu_to_lets(cpu_time); |
1414 | if (UDF_MAX_WRITE_VERSION > le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev)) | 1461 | if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev)) |
1415 | UDF_SB_LVIDIU(sb)->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION); | 1462 | lvidiu->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION); |
1416 | if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev)) | 1463 | if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev)) |
1417 | UDF_SB_LVIDIU(sb)->minUDFReadRev = cpu_to_le16(UDF_SB_UDFREV(sb)); | 1464 | lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev); |
1418 | if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev)) | 1465 | if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev)) |
1419 | UDF_SB_LVIDIU(sb)->minUDFWriteRev = cpu_to_le16(UDF_SB_UDFREV(sb)); | 1466 | lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev); |
1420 | UDF_SB_LVID(sb)->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); | 1467 | lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); |
1421 | 1468 | ||
1422 | UDF_SB_LVID(sb)->descTag.descCRC = | 1469 | lvid->descTag.descCRC = |
1423 | cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag), | 1470 | cpu_to_le16(udf_crc((char *)lvid + sizeof(tag), |
1424 | le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0)); | 1471 | le16_to_cpu(lvid->descTag.descCRCLength), 0)); |
1425 | 1472 | ||
1426 | UDF_SB_LVID(sb)->descTag.tagChecksum = 0; | 1473 | lvid->descTag.tagChecksum = 0; |
1427 | for (i = 0; i < 16; i++) | 1474 | for (i = 0; i < 16; i++) |
1428 | if (i != 4) | 1475 | if (i != 4) |
1429 | UDF_SB_LVID(sb)->descTag.tagChecksum += | 1476 | lvid->descTag.tagChecksum += |
1430 | ((uint8_t *)&(UDF_SB_LVID(sb)->descTag))[i]; | 1477 | ((uint8_t *)&(lvid->descTag))[i]; |
1431 | 1478 | ||
1432 | mark_buffer_dirty(UDF_SB_LVIDBH(sb)); | 1479 | mark_buffer_dirty(bh); |
1433 | } | 1480 | } |
1434 | } | 1481 | } |
1435 | 1482 | ||
@@ -1462,12 +1509,11 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1462 | uopt.gid = -1; | 1509 | uopt.gid = -1; |
1463 | uopt.umask = 0; | 1510 | uopt.umask = 0; |
1464 | 1511 | ||
1465 | sbi = kmalloc(sizeof(struct udf_sb_info), GFP_KERNEL); | 1512 | sbi = kzalloc(sizeof(struct udf_sb_info), GFP_KERNEL); |
1466 | if (!sbi) | 1513 | if (!sbi) |
1467 | return -ENOMEM; | 1514 | return -ENOMEM; |
1468 | 1515 | ||
1469 | sb->s_fs_info = sbi; | 1516 | sb->s_fs_info = sbi; |
1470 | memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info)); | ||
1471 | 1517 | ||
1472 | mutex_init(&sbi->s_alloc_mutex); | 1518 | mutex_init(&sbi->s_alloc_mutex); |
1473 | 1519 | ||
@@ -1495,27 +1541,27 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1495 | fileset.logicalBlockNum = 0xFFFFFFFF; | 1541 | fileset.logicalBlockNum = 0xFFFFFFFF; |
1496 | fileset.partitionReferenceNum = 0xFFFF; | 1542 | fileset.partitionReferenceNum = 0xFFFF; |
1497 | 1543 | ||
1498 | UDF_SB(sb)->s_flags = uopt.flags; | 1544 | sbi->s_flags = uopt.flags; |
1499 | UDF_SB(sb)->s_uid = uopt.uid; | 1545 | sbi->s_uid = uopt.uid; |
1500 | UDF_SB(sb)->s_gid = uopt.gid; | 1546 | sbi->s_gid = uopt.gid; |
1501 | UDF_SB(sb)->s_umask = uopt.umask; | 1547 | sbi->s_umask = uopt.umask; |
1502 | UDF_SB(sb)->s_nls_map = uopt.nls_map; | 1548 | sbi->s_nls_map = uopt.nls_map; |
1503 | 1549 | ||
1504 | /* Set the block size for all transfers */ | 1550 | /* Set the block size for all transfers */ |
1505 | if (!udf_set_blocksize(sb, uopt.blocksize)) | 1551 | if (!udf_set_blocksize(sb, uopt.blocksize)) |
1506 | goto error_out; | 1552 | goto error_out; |
1507 | 1553 | ||
1508 | if (uopt.session == 0xFFFFFFFF) | 1554 | if (uopt.session == 0xFFFFFFFF) |
1509 | UDF_SB_SESSION(sb) = udf_get_last_session(sb); | 1555 | sbi->s_session = udf_get_last_session(sb); |
1510 | else | 1556 | else |
1511 | UDF_SB_SESSION(sb) = uopt.session; | 1557 | sbi->s_session = uopt.session; |
1512 | 1558 | ||
1513 | udf_debug("Multi-session=%d\n", UDF_SB_SESSION(sb)); | 1559 | udf_debug("Multi-session=%d\n", sbi->s_session); |
1514 | 1560 | ||
1515 | UDF_SB_LASTBLOCK(sb) = uopt.lastblock; | 1561 | sbi->s_last_block = uopt.lastblock; |
1516 | UDF_SB_ANCHOR(sb)[0] = UDF_SB_ANCHOR(sb)[1] = 0; | 1562 | sbi->s_anchor[0] = sbi->s_anchor[1] = 0; |
1517 | UDF_SB_ANCHOR(sb)[2] = uopt.anchor; | 1563 | sbi->s_anchor[2] = uopt.anchor; |
1518 | UDF_SB_ANCHOR(sb)[3] = 256; | 1564 | sbi->s_anchor[3] = 256; |
1519 | 1565 | ||
1520 | if (udf_check_valid(sb, uopt.novrs, silent)) { | 1566 | if (udf_check_valid(sb, uopt.novrs, silent)) { |
1521 | /* read volume recognition sequences */ | 1567 | /* read volume recognition sequences */ |
@@ -1537,23 +1583,24 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1537 | goto error_out; | 1583 | goto error_out; |
1538 | } | 1584 | } |
1539 | 1585 | ||
1540 | udf_debug("Lastblock=%d\n", UDF_SB_LASTBLOCK(sb)); | 1586 | udf_debug("Lastblock=%d\n", sbi->s_last_block); |
1541 | 1587 | ||
1542 | if (UDF_SB_LVIDBH(sb)) { | 1588 | if (sbi->s_lvid_bh) { |
1543 | uint16_t minUDFReadRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev); | 1589 | struct logicalVolIntegrityDescImpUse *lvidiu = udf_sb_lvidiu(sbi); |
1544 | uint16_t minUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev); | 1590 | uint16_t minUDFReadRev = le16_to_cpu(lvidiu->minUDFReadRev); |
1545 | /* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */ | 1591 | uint16_t minUDFWriteRev = le16_to_cpu(lvidiu->minUDFWriteRev); |
1592 | /* uint16_t maxUDFWriteRev = le16_to_cpu(lvidiu->maxUDFWriteRev); */ | ||
1546 | 1593 | ||
1547 | if (minUDFReadRev > UDF_MAX_READ_VERSION) { | 1594 | if (minUDFReadRev > UDF_MAX_READ_VERSION) { |
1548 | printk(KERN_ERR "UDF-fs: minUDFReadRev=%x (max is %x)\n", | 1595 | printk(KERN_ERR "UDF-fs: minUDFReadRev=%x (max is %x)\n", |
1549 | le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev), | 1596 | le16_to_cpu(lvidiu->minUDFReadRev), |
1550 | UDF_MAX_READ_VERSION); | 1597 | UDF_MAX_READ_VERSION); |
1551 | goto error_out; | 1598 | goto error_out; |
1552 | } else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION) { | 1599 | } else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION) { |
1553 | sb->s_flags |= MS_RDONLY; | 1600 | sb->s_flags |= MS_RDONLY; |
1554 | } | 1601 | } |
1555 | 1602 | ||
1556 | UDF_SB_UDFREV(sb) = minUDFWriteRev; | 1603 | sbi->s_udfrev = minUDFWriteRev; |
1557 | 1604 | ||
1558 | if (minUDFReadRev >= UDF_VERS_USE_EXTENDED_FE) | 1605 | if (minUDFReadRev >= UDF_VERS_USE_EXTENDED_FE) |
1559 | UDF_SET_FLAG(sb, UDF_FLAG_USE_EXTENDED_FE); | 1606 | UDF_SET_FLAG(sb, UDF_FLAG_USE_EXTENDED_FE); |
@@ -1561,12 +1608,12 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1561 | UDF_SET_FLAG(sb, UDF_FLAG_USE_STREAMS); | 1608 | UDF_SET_FLAG(sb, UDF_FLAG_USE_STREAMS); |
1562 | } | 1609 | } |
1563 | 1610 | ||
1564 | if (!UDF_SB_NUMPARTS(sb)) { | 1611 | if (!sbi->s_partitions) { |
1565 | printk(KERN_WARNING "UDF-fs: No partition found (2)\n"); | 1612 | printk(KERN_WARNING "UDF-fs: No partition found (2)\n"); |
1566 | goto error_out; | 1613 | goto error_out; |
1567 | } | 1614 | } |
1568 | 1615 | ||
1569 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_READ_ONLY) { | 1616 | if (sbi->s_partmaps[sbi->s_partition].s_partition_flags & UDF_PART_FLAG_READ_ONLY) { |
1570 | printk(KERN_NOTICE "UDF-fs: Partition marked readonly; forcing readonly mount\n"); | 1617 | printk(KERN_NOTICE "UDF-fs: Partition marked readonly; forcing readonly mount\n"); |
1571 | sb->s_flags |= MS_RDONLY; | 1618 | sb->s_flags |= MS_RDONLY; |
1572 | } | 1619 | } |
@@ -1578,12 +1625,12 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1578 | 1625 | ||
1579 | if (!silent) { | 1626 | if (!silent) { |
1580 | kernel_timestamp ts; | 1627 | kernel_timestamp ts; |
1581 | udf_time_to_stamp(&ts, UDF_SB_RECORDTIME(sb)); | 1628 | udf_time_to_stamp(&ts, sbi->s_record_time); |
1582 | udf_info("UDF %s (%s) Mounting volume '%s', " | 1629 | udf_info("UDF %s (%s) Mounting volume '%s', " |
1583 | "timestamp %04u/%02u/%02u %02u:%02u (%x)\n", | 1630 | "timestamp %04u/%02u/%02u %02u:%02u (%x)\n", |
1584 | UDFFS_VERSION, UDFFS_DATE, | 1631 | UDFFS_VERSION, UDFFS_DATE, |
1585 | UDF_SB_VOLIDENT(sb), ts.year, ts.month, ts.day, ts.hour, ts.minute, | 1632 | sbi->s_volume_ident, ts.year, ts.month, ts.day, |
1586 | ts.typeAndTimezone); | 1633 | ts.hour, ts.minute, ts.typeAndTimezone); |
1587 | } | 1634 | } |
1588 | if (!(sb->s_flags & MS_RDONLY)) | 1635 | if (!(sb->s_flags & MS_RDONLY)) |
1589 | udf_open_lvid(sb); | 1636 | udf_open_lvid(sb); |
@@ -1609,30 +1656,31 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1609 | return 0; | 1656 | return 0; |
1610 | 1657 | ||
1611 | error_out: | 1658 | error_out: |
1612 | if (UDF_SB_VAT(sb)) | 1659 | if (sbi->s_vat_inode) |
1613 | iput(UDF_SB_VAT(sb)); | 1660 | iput(sbi->s_vat_inode); |
1614 | if (UDF_SB_NUMPARTS(sb)) { | 1661 | if (sbi->s_partitions) { |
1615 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) | 1662 | struct udf_part_map *map = &sbi->s_partmaps[sbi->s_partition]; |
1616 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table); | 1663 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) |
1617 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) | 1664 | iput(map->s_uspace.s_table); |
1618 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table); | 1665 | if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) |
1619 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) | 1666 | iput(map->s_fspace.s_table); |
1620 | UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace); | 1667 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) |
1621 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) | 1668 | UDF_SB_FREE_BITMAP(sb, sbi->s_partition, s_uspace); |
1622 | UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_fspace); | 1669 | if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) |
1623 | if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) { | 1670 | UDF_SB_FREE_BITMAP(sb, sbi->s_partition, s_fspace); |
1671 | if (map->s_partition_type == UDF_SPARABLE_MAP15) | ||
1624 | for (i = 0; i < 4; i++) | 1672 | for (i = 0; i < 4; i++) |
1625 | brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]); | 1673 | brelse(map->s_type_specific.s_sparing.s_spar_map[i]); |
1626 | } | ||
1627 | } | 1674 | } |
1628 | #ifdef CONFIG_UDF_NLS | 1675 | #ifdef CONFIG_UDF_NLS |
1629 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) | 1676 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) |
1630 | unload_nls(UDF_SB(sb)->s_nls_map); | 1677 | unload_nls(sbi->s_nls_map); |
1631 | #endif | 1678 | #endif |
1632 | if (!(sb->s_flags & MS_RDONLY)) | 1679 | if (!(sb->s_flags & MS_RDONLY)) |
1633 | udf_close_lvid(sb); | 1680 | udf_close_lvid(sb); |
1634 | brelse(UDF_SB_LVIDBH(sb)); | 1681 | brelse(sbi->s_lvid_bh); |
1635 | UDF_SB_FREE(sb); | 1682 | |
1683 | kfree(sbi->s_partmaps); | ||
1636 | kfree(sbi); | 1684 | kfree(sbi); |
1637 | sb->s_fs_info = NULL; | 1685 | sb->s_fs_info = NULL; |
1638 | 1686 | ||
@@ -1683,31 +1731,33 @@ void udf_warning(struct super_block *sb, const char *function, | |||
1683 | static void udf_put_super(struct super_block *sb) | 1731 | static void udf_put_super(struct super_block *sb) |
1684 | { | 1732 | { |
1685 | int i; | 1733 | int i; |
1734 | struct udf_sb_info *sbi; | ||
1686 | 1735 | ||
1687 | if (UDF_SB_VAT(sb)) | 1736 | sbi = UDF_SB(sb); |
1688 | iput(UDF_SB_VAT(sb)); | 1737 | if (sbi->s_vat_inode) |
1689 | if (UDF_SB_NUMPARTS(sb)) { | 1738 | iput(sbi->s_vat_inode); |
1690 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) | 1739 | if (sbi->s_partitions) { |
1691 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table); | 1740 | struct udf_part_map *map = &sbi->s_partmaps[sbi->s_partition]; |
1692 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) | 1741 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) |
1693 | iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table); | 1742 | iput(map->s_uspace.s_table); |
1694 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) | 1743 | if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) |
1695 | UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace); | 1744 | iput(map->s_fspace.s_table); |
1696 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) | 1745 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) |
1697 | UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_fspace); | 1746 | UDF_SB_FREE_BITMAP(sb, sbi->s_partition, s_uspace); |
1698 | if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) { | 1747 | if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) |
1748 | UDF_SB_FREE_BITMAP(sb, sbi->s_partition, s_fspace); | ||
1749 | if (map->s_partition_type == UDF_SPARABLE_MAP15) | ||
1699 | for (i = 0; i < 4; i++) | 1750 | for (i = 0; i < 4; i++) |
1700 | brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]); | 1751 | brelse(map->s_type_specific.s_sparing.s_spar_map[i]); |
1701 | } | ||
1702 | } | 1752 | } |
1703 | #ifdef CONFIG_UDF_NLS | 1753 | #ifdef CONFIG_UDF_NLS |
1704 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) | 1754 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) |
1705 | unload_nls(UDF_SB(sb)->s_nls_map); | 1755 | unload_nls(sbi->s_nls_map); |
1706 | #endif | 1756 | #endif |
1707 | if (!(sb->s_flags & MS_RDONLY)) | 1757 | if (!(sb->s_flags & MS_RDONLY)) |
1708 | udf_close_lvid(sb); | 1758 | udf_close_lvid(sb); |
1709 | brelse(UDF_SB_LVIDBH(sb)); | 1759 | brelse(sbi->s_lvid_bh); |
1710 | UDF_SB_FREE(sb); | 1760 | kfree(sbi->s_partmaps); |
1711 | kfree(sb->s_fs_info); | 1761 | kfree(sb->s_fs_info); |
1712 | sb->s_fs_info = NULL; | 1762 | sb->s_fs_info = NULL; |
1713 | } | 1763 | } |
@@ -1728,15 +1778,22 @@ static void udf_put_super(struct super_block *sb) | |||
1728 | static int udf_statfs(struct dentry *dentry, struct kstatfs *buf) | 1778 | static int udf_statfs(struct dentry *dentry, struct kstatfs *buf) |
1729 | { | 1779 | { |
1730 | struct super_block *sb = dentry->d_sb; | 1780 | struct super_block *sb = dentry->d_sb; |
1781 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
1782 | struct logicalVolIntegrityDescImpUse *lvidiu; | ||
1783 | |||
1784 | if (sbi->s_lvid_bh != NULL) | ||
1785 | lvidiu = udf_sb_lvidiu(sbi); | ||
1786 | else | ||
1787 | lvidiu = NULL; | ||
1731 | 1788 | ||
1732 | buf->f_type = UDF_SUPER_MAGIC; | 1789 | buf->f_type = UDF_SUPER_MAGIC; |
1733 | buf->f_bsize = sb->s_blocksize; | 1790 | buf->f_bsize = sb->s_blocksize; |
1734 | buf->f_blocks = UDF_SB_PARTLEN(sb, UDF_SB_PARTITION(sb)); | 1791 | buf->f_blocks = sbi->s_partmaps[sbi->s_partition].s_partition_len; |
1735 | buf->f_bfree = udf_count_free(sb); | 1792 | buf->f_bfree = udf_count_free(sb); |
1736 | buf->f_bavail = buf->f_bfree; | 1793 | buf->f_bavail = buf->f_bfree; |
1737 | buf->f_files = (UDF_SB_LVIDBH(sb) ? | 1794 | buf->f_files = (lvidiu != NULL ? (le32_to_cpu(lvidiu->numFiles) + |
1738 | (le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + | 1795 | le32_to_cpu(lvidiu->numDirs)) : 0) |
1739 | le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)) : 0) + buf->f_bfree; | 1796 | + buf->f_bfree; |
1740 | buf->f_ffree = buf->f_bfree; | 1797 | buf->f_ffree = buf->f_bfree; |
1741 | /* __kernel_fsid_t f_fsid */ | 1798 | /* __kernel_fsid_t f_fsid */ |
1742 | buf->f_namelen = UDF_NAME_LEN - 2; | 1799 | buf->f_namelen = UDF_NAME_LEN - 2; |
@@ -1764,7 +1821,7 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb, struct udf_bit | |||
1764 | lock_kernel(); | 1821 | lock_kernel(); |
1765 | 1822 | ||
1766 | loc.logicalBlockNum = bitmap->s_extPosition; | 1823 | loc.logicalBlockNum = bitmap->s_extPosition; |
1767 | loc.partitionReferenceNum = UDF_SB_PARTITION(sb); | 1824 | loc.partitionReferenceNum = UDF_SB(sb)->s_partition; |
1768 | bh = udf_read_ptagged(sb, loc, 0, &ident); | 1825 | bh = udf_read_ptagged(sb, loc, 0, &ident); |
1769 | 1826 | ||
1770 | if (!bh) { | 1827 | if (!bh) { |
@@ -1836,10 +1893,14 @@ static unsigned int udf_count_free_table(struct super_block *sb, struct inode *t | |||
1836 | static unsigned int udf_count_free(struct super_block *sb) | 1893 | static unsigned int udf_count_free(struct super_block *sb) |
1837 | { | 1894 | { |
1838 | unsigned int accum = 0; | 1895 | unsigned int accum = 0; |
1896 | struct udf_sb_info *sbi; | ||
1897 | struct udf_part_map *map; | ||
1839 | 1898 | ||
1840 | if (UDF_SB_LVIDBH(sb)) { | 1899 | sbi = UDF_SB(sb); |
1841 | if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > UDF_SB_PARTITION(sb)) { | 1900 | if (sbi->s_lvid_bh) { |
1842 | accum = le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]); | 1901 | struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data; |
1902 | if (le32_to_cpu(lvid->numOfPartitions) > sbi->s_partition) { | ||
1903 | accum = le32_to_cpu(lvid->freeSpaceTable[sbi->s_partition]); | ||
1843 | if (accum == 0xFFFFFFFF) | 1904 | if (accum == 0xFFFFFFFF) |
1844 | accum = 0; | 1905 | accum = 0; |
1845 | } | 1906 | } |
@@ -1848,24 +1909,25 @@ static unsigned int udf_count_free(struct super_block *sb) | |||
1848 | if (accum) | 1909 | if (accum) |
1849 | return accum; | 1910 | return accum; |
1850 | 1911 | ||
1851 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) { | 1912 | map = &sbi->s_partmaps[sbi->s_partition]; |
1913 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) { | ||
1852 | accum += udf_count_free_bitmap(sb, | 1914 | accum += udf_count_free_bitmap(sb, |
1853 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_bitmap); | 1915 | map->s_uspace.s_bitmap); |
1854 | } | 1916 | } |
1855 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) { | 1917 | if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) { |
1856 | accum += udf_count_free_bitmap(sb, | 1918 | accum += udf_count_free_bitmap(sb, |
1857 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_bitmap); | 1919 | map->s_fspace.s_bitmap); |
1858 | } | 1920 | } |
1859 | if (accum) | 1921 | if (accum) |
1860 | return accum; | 1922 | return accum; |
1861 | 1923 | ||
1862 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) { | 1924 | if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) { |
1863 | accum += udf_count_free_table(sb, | 1925 | accum += udf_count_free_table(sb, |
1864 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table); | 1926 | map->s_uspace.s_table); |
1865 | } | 1927 | } |
1866 | if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) { | 1928 | if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) { |
1867 | accum += udf_count_free_table(sb, | 1929 | accum += udf_count_free_table(sb, |
1868 | UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table); | 1930 | map->s_fspace.s_table); |
1869 | } | 1931 | } |
1870 | 1932 | ||
1871 | return accum; | 1933 | return accum; |
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c index 7fc3912885a5..6931f6bfa1ae 100644 --- a/fs/udf/truncate.c +++ b/fs/udf/truncate.c | |||
@@ -163,7 +163,7 @@ void udf_discard_prealloc(struct inode *inode) | |||
163 | cpu_to_le32(epos.offset - | 163 | cpu_to_le32(epos.offset - |
164 | sizeof(struct allocExtDesc)); | 164 | sizeof(struct allocExtDesc)); |
165 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 165 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
166 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 166 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) |
167 | udf_update_tag(epos.bh->b_data, epos.offset); | 167 | udf_update_tag(epos.bh->b_data, epos.offset); |
168 | else | 168 | else |
169 | udf_update_tag(epos.bh->b_data, | 169 | udf_update_tag(epos.bh->b_data, |
@@ -184,6 +184,7 @@ void udf_truncate_extents(struct inode *inode) | |||
184 | uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc; | 184 | uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc; |
185 | int8_t etype; | 185 | int8_t etype; |
186 | struct super_block *sb = inode->i_sb; | 186 | struct super_block *sb = inode->i_sb; |
187 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
187 | sector_t first_block = inode->i_size >> sb->s_blocksize_bits, offset; | 188 | sector_t first_block = inode->i_size >> sb->s_blocksize_bits, offset; |
188 | loff_t byte_offset; | 189 | loff_t byte_offset; |
189 | int adsize; | 190 | int adsize; |
@@ -232,7 +233,7 @@ void udf_truncate_extents(struct inode *inode) | |||
232 | aed->lengthAllocDescs = | 233 | aed->lengthAllocDescs = |
233 | cpu_to_le32(lenalloc); | 234 | cpu_to_le32(lenalloc); |
234 | if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) || | 235 | if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) || |
235 | UDF_SB_UDFREV(sb) >= 0x0201) | 236 | sbi->s_udfrev >= 0x0201) |
236 | udf_update_tag(epos.bh->b_data, | 237 | udf_update_tag(epos.bh->b_data, |
237 | lenalloc + | 238 | lenalloc + |
238 | sizeof(struct allocExtDesc)); | 239 | sizeof(struct allocExtDesc)); |
@@ -271,7 +272,7 @@ void udf_truncate_extents(struct inode *inode) | |||
271 | (struct allocExtDesc *)(epos.bh->b_data); | 272 | (struct allocExtDesc *)(epos.bh->b_data); |
272 | aed->lengthAllocDescs = cpu_to_le32(lenalloc); | 273 | aed->lengthAllocDescs = cpu_to_le32(lenalloc); |
273 | if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) || | 274 | if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) || |
274 | UDF_SB_UDFREV(sb) >= 0x0201) | 275 | sbi->s_udfrev >= 0x0201) |
275 | udf_update_tag(epos.bh->b_data, | 276 | udf_update_tag(epos.bh->b_data, |
276 | lenalloc + sizeof(struct allocExtDesc)); | 277 | lenalloc + sizeof(struct allocExtDesc)); |
277 | else | 278 | else |
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h index 3c2982017c6d..92e6d75b0163 100644 --- a/fs/udf/udf_sb.h +++ b/fs/udf/udf_sb.h | |||
@@ -41,40 +41,36 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb) | |||
41 | return sb->s_fs_info; | 41 | return sb->s_fs_info; |
42 | } | 42 | } |
43 | 43 | ||
44 | #define UDF_SB_FREE(X)\ | 44 | struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi); |
45 | {\ | ||
46 | if (UDF_SB(X)) {\ | ||
47 | kfree(UDF_SB_PARTMAPS(X));\ | ||
48 | UDF_SB_PARTMAPS(X) = NULL;\ | ||
49 | }\ | ||
50 | } | ||
51 | 45 | ||
52 | #define UDF_SB_ALLOC_PARTMAPS(X,Y)\ | 46 | #define UDF_SB_ALLOC_PARTMAPS(X,Y)\ |
53 | {\ | 47 | {\ |
54 | UDF_SB_PARTMAPS(X) = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\ | 48 | struct udf_sb_info *sbi = UDF_SB(X);\ |
55 | if (UDF_SB_PARTMAPS(X) != NULL) {\ | 49 | sbi->s_partmaps = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\ |
56 | UDF_SB_NUMPARTS(X) = Y;\ | 50 | if (sbi->s_partmaps != NULL) {\ |
57 | memset(UDF_SB_PARTMAPS(X), 0x00, sizeof(struct udf_part_map) * Y);\ | 51 | sbi->s_partitions = Y;\ |
52 | memset(sbi->s_partmaps, 0x00, sizeof(struct udf_part_map) * Y);\ | ||
58 | } else {\ | 53 | } else {\ |
59 | UDF_SB_NUMPARTS(X) = 0;\ | 54 | sbi->s_partitions = 0;\ |
60 | udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\ | 55 | udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\ |
61 | }\ | 56 | }\ |
62 | } | 57 | } |
63 | 58 | ||
64 | #define UDF_SB_ALLOC_BITMAP(X,Y,Z)\ | 59 | #define UDF_SB_ALLOC_BITMAP(X,Y,Z)\ |
65 | {\ | 60 | {\ |
66 | int nr_groups = ((UDF_SB_PARTLEN((X),(Y)) + (sizeof(struct spaceBitmapDesc) << 3) +\ | 61 | struct udf_sb_info *sbi = UDF_SB(X);\ |
62 | int nr_groups = ((sbi->s_partmaps[(Y)].s_partition_len + (sizeof(struct spaceBitmapDesc) << 3) +\ | ||
67 | ((X)->s_blocksize * 8) - 1) / ((X)->s_blocksize * 8));\ | 63 | ((X)->s_blocksize * 8) - 1) / ((X)->s_blocksize * 8));\ |
68 | int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);\ | 64 | int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);\ |
69 | if (size <= PAGE_SIZE)\ | 65 | if (size <= PAGE_SIZE)\ |
70 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = kmalloc(size, GFP_KERNEL);\ | 66 | sbi->s_partmaps[(Y)].Z.s_bitmap = kmalloc(size, GFP_KERNEL);\ |
71 | else\ | 67 | else\ |
72 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = vmalloc(size);\ | 68 | sbi->s_partmaps[(Y)].Z.s_bitmap = vmalloc(size);\ |
73 | if (UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap != NULL) {\ | 69 | if (sbi->s_partmaps[(Y)].Z.s_bitmap != NULL) {\ |
74 | memset(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap, 0x00, size);\ | 70 | memset(sbi->s_partmaps[(Y)].Z.s_bitmap, 0x00, size);\ |
75 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_block_bitmap =\ | 71 | sbi->s_partmaps[(Y)].Z.s_bitmap->s_block_bitmap =\ |
76 | (struct buffer_head **)(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap + 1);\ | 72 | (struct buffer_head **)(sbi->s_partmaps[(Y)].Z.s_bitmap + 1);\ |
77 | UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_nr_groups = nr_groups;\ | 73 | sbi->s_partmaps[(Y)].Z.s_bitmap->s_nr_groups = nr_groups;\ |
78 | } else {\ | 74 | } else {\ |
79 | udf_error(X, __FUNCTION__, "Unable to allocate space for bitmap and %d buffer_head pointers", nr_groups);\ | 75 | udf_error(X, __FUNCTION__, "Unable to allocate space for bitmap and %d buffer_head pointers", nr_groups);\ |
80 | }\ | 76 | }\ |
@@ -90,47 +86,16 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb) | |||
90 | brelse(UDF_SB_BITMAP(X,Y,Z,i));\ | 86 | brelse(UDF_SB_BITMAP(X,Y,Z,i));\ |
91 | }\ | 87 | }\ |
92 | if (size <= PAGE_SIZE)\ | 88 | if (size <= PAGE_SIZE)\ |
93 | kfree(UDF_SB_PARTMAPS(X)[Y].Z.s_bitmap);\ | 89 | kfree(UDF_SB(X)->s_partmaps[Y].Z.s_bitmap);\ |
94 | else\ | 90 | else\ |
95 | vfree(UDF_SB_PARTMAPS(X)[Y].Z.s_bitmap);\ | 91 | vfree(UDF_SB(X)->s_partmaps[Y].Z.s_bitmap);\ |
96 | } | 92 | } |
97 | 93 | ||
98 | #define UDF_QUERY_FLAG(X,Y) ( UDF_SB(X)->s_flags & ( 1 << (Y) ) ) | 94 | #define UDF_QUERY_FLAG(X,Y) ( UDF_SB(X)->s_flags & ( 1 << (Y) ) ) |
99 | #define UDF_SET_FLAG(X,Y) ( UDF_SB(X)->s_flags |= ( 1 << (Y) ) ) | 95 | #define UDF_SET_FLAG(X,Y) ( UDF_SB(X)->s_flags |= ( 1 << (Y) ) ) |
100 | #define UDF_CLEAR_FLAG(X,Y) ( UDF_SB(X)->s_flags &= ~( 1 << (Y) ) ) | 96 | #define UDF_CLEAR_FLAG(X,Y) ( UDF_SB(X)->s_flags &= ~( 1 << (Y) ) ) |
101 | 97 | ||
102 | #define UDF_UPDATE_UDFREV(X,Y) ( ((Y) > UDF_SB_UDFREV(X)) ? UDF_SB_UDFREV(X) = (Y) : UDF_SB_UDFREV(X) ) | 98 | #define UDF_SB_BITMAP(X,Y,Z,I) ( UDF_SB(X)->s_partmaps[(Y)].Z.s_bitmap->s_block_bitmap[I] ) |
103 | 99 | #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z) ( UDF_SB(X)->s_partmaps[(Y)].Z.s_bitmap->s_nr_groups ) | |
104 | #define UDF_SB_PARTMAPS(X) ( UDF_SB(X)->s_partmaps ) | ||
105 | #define UDF_SB_PARTTYPE(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_partition_type ) | ||
106 | #define UDF_SB_PARTROOT(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_partition_root ) | ||
107 | #define UDF_SB_PARTLEN(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_partition_len ) | ||
108 | #define UDF_SB_PARTVSN(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_volumeseqnum ) | ||
109 | #define UDF_SB_PARTNUM(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_partition_num ) | ||
110 | #define UDF_SB_TYPESPAR(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_type_specific.s_sparing ) | ||
111 | #define UDF_SB_TYPEVIRT(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_type_specific.s_virtual ) | ||
112 | #define UDF_SB_PARTFUNC(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_partition_func ) | ||
113 | #define UDF_SB_PARTFLAGS(X,Y) ( UDF_SB_PARTMAPS(X)[(Y)].s_partition_flags ) | ||
114 | #define UDF_SB_BITMAP(X,Y,Z,I) ( UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_block_bitmap[I] ) | ||
115 | #define UDF_SB_BITMAP_NR_GROUPS(X,Y,Z) ( UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_nr_groups ) | ||
116 | |||
117 | #define UDF_SB_VOLIDENT(X) ( UDF_SB(X)->s_volident ) | ||
118 | #define UDF_SB_NUMPARTS(X) ( UDF_SB(X)->s_partitions ) | ||
119 | #define UDF_SB_PARTITION(X) ( UDF_SB(X)->s_partition ) | ||
120 | #define UDF_SB_SESSION(X) ( UDF_SB(X)->s_session ) | ||
121 | #define UDF_SB_ANCHOR(X) ( UDF_SB(X)->s_anchor ) | ||
122 | #define UDF_SB_LASTBLOCK(X) ( UDF_SB(X)->s_lastblock ) | ||
123 | #define UDF_SB_LVIDBH(X) ( UDF_SB(X)->s_lvidbh ) | ||
124 | #define UDF_SB_LVID(X) ( (struct logicalVolIntegrityDesc *)UDF_SB_LVIDBH(X)->b_data ) | ||
125 | #define UDF_SB_LVIDIU(X) ( (struct logicalVolIntegrityDescImpUse *)&(UDF_SB_LVID(X)->impUse[le32_to_cpu(UDF_SB_LVID(X)->numOfPartitions) * 2 * sizeof(uint32_t)/sizeof(uint8_t)]) ) | ||
126 | |||
127 | #define UDF_SB_UMASK(X) ( UDF_SB(X)->s_umask ) | ||
128 | #define UDF_SB_GID(X) ( UDF_SB(X)->s_gid ) | ||
129 | #define UDF_SB_UID(X) ( UDF_SB(X)->s_uid ) | ||
130 | #define UDF_SB_RECORDTIME(X) ( UDF_SB(X)->s_recordtime ) | ||
131 | #define UDF_SB_SERIALNUM(X) ( UDF_SB(X)->s_serialnum ) | ||
132 | #define UDF_SB_UDFREV(X) ( UDF_SB(X)->s_udfrev ) | ||
133 | #define UDF_SB_FLAGS(X) ( UDF_SB(X)->s_flags ) | ||
134 | #define UDF_SB_VAT(X) ( UDF_SB(X)->s_vat ) | ||
135 | 100 | ||
136 | #endif /* __LINUX_UDF_SB_H */ | 101 | #endif /* __LINUX_UDF_SB_H */ |