diff options
Diffstat (limited to 'fs/udf/super.c')
-rw-r--r-- | fs/udf/super.c | 546 |
1 files changed, 304 insertions, 242 deletions
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; |