diff options
author | Marcin Slusarz <marcin.slusarz@gmail.com> | 2008-02-10 05:33:08 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2008-04-17 08:22:45 -0400 |
commit | 165923fa4590b0eb77bec31af383ea16b2d5868f (patch) | |
tree | 10b05d436c73e5392efc85eb918138d863ad3f28 | |
parent | af15a298a49c9b5844cdaf70e10eb808e54ead2c (diff) |
udf: super.c reorganization
reorganize few code blocks in super.c which
were needlessly indented (and hard to read):
so change from:
rettype fun()
{
init;
if (sth) {
long block of code;
}
}
to:
rettype fun()
{
init;
if (!sth)
return;
long block of code;
}
or
from:
rettype fun2()
{
init;
while (sth) {
init2();
if (sth2) {
long block of code;
}
}
}
to:
rettype fun2()
{
init;
while (sth) {
init2();
if (!sth2)
continue;
long block of code;
}
}
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r-- | fs/udf/super.c | 552 |
1 files changed, 270 insertions, 282 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c index 829ddfa5a148..17ba054faaa4 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -827,18 +827,18 @@ static void udf_find_anchor(struct super_block *sb) | |||
827 | } | 827 | } |
828 | 828 | ||
829 | for (i = 0; i < ARRAY_SIZE(sbi->s_anchor); i++) { | 829 | for (i = 0; i < ARRAY_SIZE(sbi->s_anchor); i++) { |
830 | if (sbi->s_anchor[i]) { | 830 | if (!sbi->s_anchor[i]) |
831 | bh = udf_read_tagged(sb, sbi->s_anchor[i], | 831 | continue; |
832 | sbi->s_anchor[i], &ident); | 832 | bh = udf_read_tagged(sb, sbi->s_anchor[i], |
833 | if (!bh) | 833 | sbi->s_anchor[i], &ident); |
834 | if (!bh) | ||
835 | sbi->s_anchor[i] = 0; | ||
836 | else { | ||
837 | brelse(bh); | ||
838 | if ((ident != TAG_IDENT_AVDP) && | ||
839 | (i || (ident != TAG_IDENT_FE && | ||
840 | ident != TAG_IDENT_EFE))) | ||
834 | sbi->s_anchor[i] = 0; | 841 | sbi->s_anchor[i] = 0; |
835 | else { | ||
836 | brelse(bh); | ||
837 | if ((ident != TAG_IDENT_AVDP) && | ||
838 | (i || (ident != TAG_IDENT_FE && | ||
839 | ident != TAG_IDENT_EFE))) | ||
840 | sbi->s_anchor[i] = 0; | ||
841 | } | ||
842 | } | 842 | } |
843 | } | 843 | } |
844 | 844 | ||
@@ -1020,128 +1020,118 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index) | |||
1020 | 1020 | ||
1021 | static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh) | 1021 | static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh) |
1022 | { | 1022 | { |
1023 | struct partitionDesc *p; | 1023 | struct partitionHeaderDesc *phd; |
1024 | int i; | 1024 | struct partitionDesc *p = (struct partitionDesc *)bh->b_data; |
1025 | struct udf_part_map *map; | 1025 | struct udf_part_map *map; |
1026 | struct udf_sb_info *sbi; | 1026 | struct udf_sb_info *sbi = UDF_SB(sb); |
1027 | 1027 | bool found = false; | |
1028 | p = (struct partitionDesc *)bh->b_data; | 1028 | int i; |
1029 | sbi = UDF_SB(sb); | 1029 | u16 partitionNumber = le16_to_cpu(p->partitionNumber); |
1030 | 1030 | ||
1031 | for (i = 0; i < sbi->s_partitions; i++) { | 1031 | for (i = 0; i < sbi->s_partitions; i++) { |
1032 | map = &sbi->s_partmaps[i]; | 1032 | map = &sbi->s_partmaps[i]; |
1033 | udf_debug("Searching map: (%d == %d)\n", | 1033 | udf_debug("Searching map: (%d == %d)\n", |
1034 | map->s_partition_num, | 1034 | map->s_partition_num, partitionNumber); |
1035 | le16_to_cpu(p->partitionNumber)); | 1035 | found = map->s_partition_num == partitionNumber; |
1036 | if (map->s_partition_num == | 1036 | if (found) |
1037 | le16_to_cpu(p->partitionNumber)) { | ||
1038 | map->s_partition_len = | ||
1039 | le32_to_cpu(p->partitionLength); /* blocks */ | ||
1040 | map->s_partition_root = | ||
1041 | le32_to_cpu(p->partitionStartingLocation); | ||
1042 | if (p->accessType == | ||
1043 | cpu_to_le32(PD_ACCESS_TYPE_READ_ONLY)) | ||
1044 | map->s_partition_flags |= | ||
1045 | UDF_PART_FLAG_READ_ONLY; | ||
1046 | if (p->accessType == | ||
1047 | cpu_to_le32(PD_ACCESS_TYPE_WRITE_ONCE)) | ||
1048 | map->s_partition_flags |= | ||
1049 | UDF_PART_FLAG_WRITE_ONCE; | ||
1050 | if (p->accessType == | ||
1051 | cpu_to_le32(PD_ACCESS_TYPE_REWRITABLE)) | ||
1052 | map->s_partition_flags |= | ||
1053 | UDF_PART_FLAG_REWRITABLE; | ||
1054 | if (p->accessType == | ||
1055 | cpu_to_le32(PD_ACCESS_TYPE_OVERWRITABLE)) | ||
1056 | map->s_partition_flags |= | ||
1057 | UDF_PART_FLAG_OVERWRITABLE; | ||
1058 | |||
1059 | if (!strcmp(p->partitionContents.ident, | ||
1060 | PD_PARTITION_CONTENTS_NSR02) || | ||
1061 | !strcmp(p->partitionContents.ident, | ||
1062 | PD_PARTITION_CONTENTS_NSR03)) { | ||
1063 | struct partitionHeaderDesc *phd; | ||
1064 | |||
1065 | phd = (struct partitionHeaderDesc *) | ||
1066 | (p->partitionContentsUse); | ||
1067 | if (phd->unallocSpaceTable.extLength) { | ||
1068 | kernel_lb_addr loc = { | ||
1069 | .logicalBlockNum = le32_to_cpu(phd->unallocSpaceTable.extPosition), | ||
1070 | .partitionReferenceNum = i, | ||
1071 | }; | ||
1072 | |||
1073 | map->s_uspace.s_table = | ||
1074 | udf_iget(sb, loc); | ||
1075 | if (!map->s_uspace.s_table) { | ||
1076 | udf_debug("cannot load unallocSpaceTable (part %d)\n", i); | ||
1077 | return 1; | ||
1078 | } | ||
1079 | map->s_partition_flags |= | ||
1080 | UDF_PART_FLAG_UNALLOC_TABLE; | ||
1081 | udf_debug("unallocSpaceTable (part %d) @ %ld\n", | ||
1082 | i, map->s_uspace.s_table->i_ino); | ||
1083 | } | ||
1084 | if (phd->unallocSpaceBitmap.extLength) { | ||
1085 | struct udf_bitmap *bitmap = | ||
1086 | udf_sb_alloc_bitmap(sb, i); | ||
1087 | map->s_uspace.s_bitmap = bitmap; | ||
1088 | if (bitmap != NULL) { | ||
1089 | bitmap->s_extLength = | ||
1090 | le32_to_cpu(phd->unallocSpaceBitmap.extLength); | ||
1091 | bitmap->s_extPosition = | ||
1092 | le32_to_cpu(phd->unallocSpaceBitmap.extPosition); | ||
1093 | map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP; | ||
1094 | udf_debug("unallocSpaceBitmap (part %d) @ %d\n", | ||
1095 | i, bitmap->s_extPosition); | ||
1096 | } | ||
1097 | } | ||
1098 | if (phd->partitionIntegrityTable.extLength) | ||
1099 | udf_debug("partitionIntegrityTable (part %d)\n", i); | ||
1100 | if (phd->freedSpaceTable.extLength) { | ||
1101 | kernel_lb_addr loc = { | ||
1102 | .logicalBlockNum = le32_to_cpu(phd->freedSpaceTable.extPosition), | ||
1103 | .partitionReferenceNum = i, | ||
1104 | }; | ||
1105 | |||
1106 | map->s_fspace.s_table = | ||
1107 | udf_iget(sb, loc); | ||
1108 | if (!map->s_fspace.s_table) { | ||
1109 | udf_debug("cannot load freedSpaceTable (part %d)\n", i); | ||
1110 | return 1; | ||
1111 | } | ||
1112 | map->s_partition_flags |= | ||
1113 | UDF_PART_FLAG_FREED_TABLE; | ||
1114 | udf_debug("freedSpaceTable (part %d) @ %ld\n", | ||
1115 | i, map->s_fspace.s_table->i_ino); | ||
1116 | } | ||
1117 | if (phd->freedSpaceBitmap.extLength) { | ||
1118 | struct udf_bitmap *bitmap = | ||
1119 | udf_sb_alloc_bitmap(sb, i); | ||
1120 | map->s_fspace.s_bitmap = bitmap; | ||
1121 | if (bitmap != NULL) { | ||
1122 | bitmap->s_extLength = | ||
1123 | le32_to_cpu(phd->freedSpaceBitmap.extLength); | ||
1124 | bitmap->s_extPosition = | ||
1125 | le32_to_cpu(phd->freedSpaceBitmap.extPosition); | ||
1126 | map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP; | ||
1127 | udf_debug("freedSpaceBitmap (part %d) @ %d\n", | ||
1128 | i, bitmap->s_extPosition); | ||
1129 | } | ||
1130 | } | ||
1131 | } | ||
1132 | break; | 1037 | break; |
1133 | } | ||
1134 | } | 1038 | } |
1135 | if (i == sbi->s_partitions) | 1039 | |
1040 | if (!found) { | ||
1136 | udf_debug("Partition (%d) not found in partition map\n", | 1041 | udf_debug("Partition (%d) not found in partition map\n", |
1137 | le16_to_cpu(p->partitionNumber)); | 1042 | partitionNumber); |
1138 | else | 1043 | return 0; |
1139 | udf_debug("Partition (%d:%d type %x) starts at physical %d, " | 1044 | } |
1140 | "block length %d\n", | 1045 | |
1141 | le16_to_cpu(p->partitionNumber), i, | 1046 | map->s_partition_len = le32_to_cpu(p->partitionLength); /* blocks */ |
1142 | map->s_partition_type, | 1047 | map->s_partition_root = le32_to_cpu(p->partitionStartingLocation); |
1143 | map->s_partition_root, | 1048 | |
1144 | map->s_partition_len); | 1049 | if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_READ_ONLY)) |
1050 | map->s_partition_flags |= UDF_PART_FLAG_READ_ONLY; | ||
1051 | if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_WRITE_ONCE)) | ||
1052 | map->s_partition_flags |= UDF_PART_FLAG_WRITE_ONCE; | ||
1053 | if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_REWRITABLE)) | ||
1054 | map->s_partition_flags |= UDF_PART_FLAG_REWRITABLE; | ||
1055 | if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_OVERWRITABLE)) | ||
1056 | map->s_partition_flags |= UDF_PART_FLAG_OVERWRITABLE; | ||
1057 | |||
1058 | udf_debug("Partition (%d:%d type %x) starts at physical %d, " | ||
1059 | "block length %d\n", partitionNumber, i, | ||
1060 | map->s_partition_type, map->s_partition_root, | ||
1061 | map->s_partition_len); | ||
1062 | |||
1063 | if (strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) && | ||
1064 | strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03)) | ||
1065 | return 0; | ||
1066 | |||
1067 | phd = (struct partitionHeaderDesc *)p->partitionContentsUse; | ||
1068 | if (phd->unallocSpaceTable.extLength) { | ||
1069 | kernel_lb_addr loc = { | ||
1070 | .logicalBlockNum = le32_to_cpu( | ||
1071 | phd->unallocSpaceTable.extPosition), | ||
1072 | .partitionReferenceNum = i, | ||
1073 | }; | ||
1074 | |||
1075 | map->s_uspace.s_table = udf_iget(sb, loc); | ||
1076 | if (!map->s_uspace.s_table) { | ||
1077 | udf_debug("cannot load unallocSpaceTable (part %d)\n", | ||
1078 | i); | ||
1079 | return 1; | ||
1080 | } | ||
1081 | map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE; | ||
1082 | udf_debug("unallocSpaceTable (part %d) @ %ld\n", | ||
1083 | i, map->s_uspace.s_table->i_ino); | ||
1084 | } | ||
1085 | |||
1086 | if (phd->unallocSpaceBitmap.extLength) { | ||
1087 | struct udf_bitmap *bitmap = udf_sb_alloc_bitmap(sb, i); | ||
1088 | map->s_uspace.s_bitmap = bitmap; | ||
1089 | if (bitmap != NULL) { | ||
1090 | bitmap->s_extLength = le32_to_cpu( | ||
1091 | phd->unallocSpaceBitmap.extLength); | ||
1092 | bitmap->s_extPosition = le32_to_cpu( | ||
1093 | phd->unallocSpaceBitmap.extPosition); | ||
1094 | map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP; | ||
1095 | udf_debug("unallocSpaceBitmap (part %d) @ %d\n", | ||
1096 | i, bitmap->s_extPosition); | ||
1097 | } | ||
1098 | } | ||
1099 | |||
1100 | if (phd->partitionIntegrityTable.extLength) | ||
1101 | udf_debug("partitionIntegrityTable (part %d)\n", i); | ||
1102 | |||
1103 | if (phd->freedSpaceTable.extLength) { | ||
1104 | kernel_lb_addr loc = { | ||
1105 | .logicalBlockNum = le32_to_cpu( | ||
1106 | phd->freedSpaceTable.extPosition), | ||
1107 | .partitionReferenceNum = i, | ||
1108 | }; | ||
1109 | |||
1110 | map->s_fspace.s_table = udf_iget(sb, loc); | ||
1111 | if (!map->s_fspace.s_table) { | ||
1112 | udf_debug("cannot load freedSpaceTable (part %d)\n", i); | ||
1113 | return 1; | ||
1114 | } | ||
1115 | |||
1116 | map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE; | ||
1117 | udf_debug("freedSpaceTable (part %d) @ %ld\n", | ||
1118 | i, map->s_fspace.s_table->i_ino); | ||
1119 | } | ||
1120 | |||
1121 | if (phd->freedSpaceBitmap.extLength) { | ||
1122 | struct udf_bitmap *bitmap = udf_sb_alloc_bitmap(sb, i); | ||
1123 | map->s_fspace.s_bitmap = bitmap; | ||
1124 | if (bitmap != NULL) { | ||
1125 | bitmap->s_extLength = le32_to_cpu( | ||
1126 | phd->freedSpaceBitmap.extLength); | ||
1127 | bitmap->s_extPosition = le32_to_cpu( | ||
1128 | phd->freedSpaceBitmap.extPosition); | ||
1129 | map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP; | ||
1130 | udf_debug("freedSpaceBitmap (part %d) @ %d\n", | ||
1131 | i, bitmap->s_extPosition); | ||
1132 | } | ||
1133 | } | ||
1134 | |||
1145 | return 0; | 1135 | return 0; |
1146 | } | 1136 | } |
1147 | 1137 | ||
@@ -1215,19 +1205,17 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh, | |||
1215 | map->s_type_specific.s_sparing. | 1205 | map->s_type_specific.s_sparing. |
1216 | s_spar_map[j] = bh2; | 1206 | s_spar_map[j] = bh2; |
1217 | 1207 | ||
1218 | if (bh2 != NULL) { | 1208 | if (bh2 == NULL) |
1219 | st = (struct sparingTable *) | 1209 | continue; |
1220 | bh2->b_data; | 1210 | |
1221 | if (ident != 0 || strncmp( | 1211 | st = (struct sparingTable *)bh2->b_data; |
1222 | st->sparingIdent.ident, | 1212 | if (ident != 0 || strncmp( |
1223 | UDF_ID_SPARING, | 1213 | st->sparingIdent.ident, |
1224 | strlen(UDF_ID_SPARING))) { | 1214 | UDF_ID_SPARING, |
1225 | brelse(bh2); | 1215 | strlen(UDF_ID_SPARING))) { |
1226 | map->s_type_specific. | 1216 | brelse(bh2); |
1227 | s_sparing. | 1217 | map->s_type_specific.s_sparing. |
1228 | s_spar_map[j] = | 1218 | s_spar_map[j] = NULL; |
1229 | NULL; | ||
1230 | } | ||
1231 | } | 1219 | } |
1232 | } | 1220 | } |
1233 | map->s_partition_func = udf_get_pblock_spar15; | 1221 | map->s_partition_func = udf_get_pblock_spar15; |
@@ -1392,40 +1380,40 @@ static int udf_process_sequence(struct super_block *sb, long block, | |||
1392 | brelse(bh); | 1380 | brelse(bh); |
1393 | } | 1381 | } |
1394 | for (i = 0; i < VDS_POS_LENGTH; i++) { | 1382 | for (i = 0; i < VDS_POS_LENGTH; i++) { |
1395 | if (vds[i].block) { | 1383 | if (!vds[i].block) |
1396 | bh = udf_read_tagged(sb, vds[i].block, vds[i].block, | 1384 | continue; |
1397 | &ident); | 1385 | |
1398 | 1386 | bh = udf_read_tagged(sb, vds[i].block, vds[i].block, | |
1399 | if (i == VDS_POS_PRIMARY_VOL_DESC) { | 1387 | &ident); |
1400 | udf_load_pvoldesc(sb, bh); | 1388 | |
1401 | } else if (i == VDS_POS_LOGICAL_VOL_DESC) { | 1389 | if (i == VDS_POS_PRIMARY_VOL_DESC) |
1402 | if (udf_load_logicalvol(sb, bh, fileset)) { | 1390 | udf_load_pvoldesc(sb, bh); |
1403 | brelse(bh); | 1391 | else if (i == VDS_POS_LOGICAL_VOL_DESC) { |
1404 | return 1; | 1392 | if (udf_load_logicalvol(sb, bh, fileset)) { |
1405 | } | 1393 | brelse(bh); |
1406 | } else if (i == VDS_POS_PARTITION_DESC) { | 1394 | return 1; |
1407 | struct buffer_head *bh2 = NULL; | 1395 | } |
1408 | if (udf_load_partdesc(sb, bh)) { | 1396 | } else if (i == VDS_POS_PARTITION_DESC) { |
1409 | brelse(bh); | 1397 | struct buffer_head *bh2 = NULL; |
1410 | return 1; | 1398 | if (udf_load_partdesc(sb, bh)) { |
1411 | } | 1399 | brelse(bh); |
1412 | for (j = vds[i].block + 1; | 1400 | return 1; |
1413 | j < vds[VDS_POS_TERMINATING_DESC].block; | 1401 | } |
1414 | j++) { | 1402 | for (j = vds[i].block + 1; |
1415 | bh2 = udf_read_tagged(sb, j, j, &ident); | 1403 | j < vds[VDS_POS_TERMINATING_DESC].block; |
1416 | gd = (struct generic_desc *)bh2->b_data; | 1404 | j++) { |
1417 | if (ident == TAG_IDENT_PD) | 1405 | bh2 = udf_read_tagged(sb, j, j, &ident); |
1418 | if (udf_load_partdesc(sb, | 1406 | gd = (struct generic_desc *)bh2->b_data; |
1419 | bh2)) { | 1407 | if (ident == TAG_IDENT_PD) |
1420 | brelse(bh); | 1408 | if (udf_load_partdesc(sb, bh2)) { |
1421 | brelse(bh2); | 1409 | brelse(bh); |
1422 | return 1; | 1410 | brelse(bh2); |
1423 | } | 1411 | return 1; |
1424 | brelse(bh2); | 1412 | } |
1425 | } | 1413 | brelse(bh2); |
1426 | } | 1414 | } |
1427 | brelse(bh); | ||
1428 | } | 1415 | } |
1416 | brelse(bh); | ||
1429 | } | 1417 | } |
1430 | 1418 | ||
1431 | return 0; | 1419 | return 0; |
@@ -1437,6 +1425,7 @@ static int udf_process_sequence(struct super_block *sb, long block, | |||
1437 | static int udf_check_valid(struct super_block *sb, int novrs, int silent) | 1425 | static int udf_check_valid(struct super_block *sb, int novrs, int silent) |
1438 | { | 1426 | { |
1439 | long block; | 1427 | long block; |
1428 | struct udf_sb_info *sbi; | ||
1440 | 1429 | ||
1441 | if (novrs) { | 1430 | if (novrs) { |
1442 | udf_debug("Validity check skipped because of novrs option\n"); | 1431 | udf_debug("Validity check skipped because of novrs option\n"); |
@@ -1444,18 +1433,16 @@ static int udf_check_valid(struct super_block *sb, int novrs, int silent) | |||
1444 | } | 1433 | } |
1445 | /* Check that it is NSR02 compliant */ | 1434 | /* Check that it is NSR02 compliant */ |
1446 | /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */ | 1435 | /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */ |
1447 | else { | 1436 | block = udf_vrs(sb, silent); |
1448 | block = udf_vrs(sb, silent); | 1437 | if (block != -1) |
1449 | if (block == -1) { | 1438 | return !block; |
1450 | struct udf_sb_info *sbi = UDF_SB(sb); | 1439 | |
1451 | udf_debug("Failed to read byte 32768. Assuming open " | 1440 | sbi = UDF_SB(sb); |
1452 | "disc. Skipping validity check\n"); | 1441 | udf_debug("Failed to read byte 32768. Assuming open " |
1453 | if (!sbi->s_last_block) | 1442 | "disc. Skipping validity check\n"); |
1454 | sbi->s_last_block = udf_get_last_block(sb); | 1443 | if (!sbi->s_last_block) |
1455 | return 0; | 1444 | sbi->s_last_block = udf_get_last_block(sb); |
1456 | } else | 1445 | return 0; |
1457 | return !block; | ||
1458 | } | ||
1459 | } | 1446 | } |
1460 | 1447 | ||
1461 | static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) | 1448 | static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) |
@@ -1474,6 +1461,7 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) | |||
1474 | for (i = 0; i < ARRAY_SIZE(sbi->s_anchor); i++) { | 1461 | for (i = 0; i < ARRAY_SIZE(sbi->s_anchor); i++) { |
1475 | if (!sbi->s_anchor[i]) | 1462 | if (!sbi->s_anchor[i]) |
1476 | continue; | 1463 | continue; |
1464 | |||
1477 | bh = udf_read_tagged(sb, sbi->s_anchor[i], sbi->s_anchor[i], | 1465 | bh = udf_read_tagged(sb, sbi->s_anchor[i], sbi->s_anchor[i], |
1478 | &ident); | 1466 | &ident); |
1479 | if (!bh) | 1467 | if (!bh) |
@@ -1515,72 +1503,73 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) | |||
1515 | for (i = 0; i < sbi->s_partitions; i++) { | 1503 | for (i = 0; i < sbi->s_partitions; i++) { |
1516 | kernel_lb_addr uninitialized_var(ino); | 1504 | kernel_lb_addr uninitialized_var(ino); |
1517 | struct udf_part_map *map = &sbi->s_partmaps[i]; | 1505 | struct udf_part_map *map = &sbi->s_partmaps[i]; |
1518 | switch (map->s_partition_type) { | ||
1519 | case UDF_VIRTUAL_MAP15: | ||
1520 | case UDF_VIRTUAL_MAP20: | ||
1521 | if (!sbi->s_last_block) { | ||
1522 | sbi->s_last_block = udf_get_last_block(sb); | ||
1523 | udf_find_anchor(sb); | ||
1524 | } | ||
1525 | 1506 | ||
1526 | if (!sbi->s_last_block) { | 1507 | if (map->s_partition_type != UDF_VIRTUAL_MAP15 && |
1527 | udf_debug("Unable to determine Lastblock (For " | 1508 | map->s_partition_type != UDF_VIRTUAL_MAP20) |
1528 | "Virtual Partition)\n"); | 1509 | continue; |
1529 | return 1; | ||
1530 | } | ||
1531 | 1510 | ||
1532 | for (j = 0; j < sbi->s_partitions; j++) { | 1511 | if (!sbi->s_last_block) { |
1533 | struct udf_part_map *map2 = &sbi->s_partmaps[j]; | 1512 | sbi->s_last_block = udf_get_last_block(sb); |
1534 | if (j != i && | 1513 | udf_find_anchor(sb); |
1535 | map->s_volumeseqnum == | 1514 | } |
1536 | map2->s_volumeseqnum && | 1515 | |
1537 | map->s_partition_num == | 1516 | if (!sbi->s_last_block) { |
1538 | map2->s_partition_num) { | 1517 | udf_debug("Unable to determine Lastblock (For " |
1539 | ino.partitionReferenceNum = j; | 1518 | "Virtual Partition)\n"); |
1540 | ino.logicalBlockNum = | 1519 | return 1; |
1541 | sbi->s_last_block - | 1520 | } |
1542 | map2->s_partition_root; | 1521 | |
1543 | break; | 1522 | for (j = 0; j < sbi->s_partitions; j++) { |
1544 | } | 1523 | struct udf_part_map *map2 = &sbi->s_partmaps[j]; |
1524 | if (j != i && | ||
1525 | map->s_volumeseqnum == | ||
1526 | map2->s_volumeseqnum && | ||
1527 | map->s_partition_num == | ||
1528 | map2->s_partition_num) { | ||
1529 | ino.partitionReferenceNum = j; | ||
1530 | ino.logicalBlockNum = | ||
1531 | sbi->s_last_block - | ||
1532 | map2->s_partition_root; | ||
1533 | break; | ||
1545 | } | 1534 | } |
1535 | } | ||
1546 | 1536 | ||
1547 | if (j == sbi->s_partitions) | 1537 | if (j == sbi->s_partitions) |
1548 | return 1; | 1538 | return 1; |
1549 | 1539 | ||
1550 | sbi->s_vat_inode = udf_iget(sb, ino); | 1540 | sbi->s_vat_inode = udf_iget(sb, ino); |
1551 | if (!sbi->s_vat_inode) | 1541 | if (!sbi->s_vat_inode) |
1552 | return 1; | 1542 | return 1; |
1553 | 1543 | ||
1554 | if (map->s_partition_type == UDF_VIRTUAL_MAP15) { | 1544 | if (map->s_partition_type == UDF_VIRTUAL_MAP15) { |
1555 | map->s_type_specific.s_virtual.s_start_offset = | 1545 | map->s_type_specific.s_virtual.s_start_offset = |
1556 | udf_ext0_offset(sbi->s_vat_inode); | 1546 | udf_ext0_offset(sbi->s_vat_inode); |
1557 | map->s_type_specific.s_virtual.s_num_entries = | 1547 | map->s_type_specific.s_virtual.s_num_entries = |
1558 | (sbi->s_vat_inode->i_size - 36) >> 2; | 1548 | (sbi->s_vat_inode->i_size - 36) >> 2; |
1559 | } else if (map->s_partition_type == UDF_VIRTUAL_MAP20) { | 1549 | } else if (map->s_partition_type == UDF_VIRTUAL_MAP20) { |
1560 | uint32_t pos; | 1550 | uint32_t pos; |
1561 | struct virtualAllocationTable20 *vat20; | 1551 | struct virtualAllocationTable20 *vat20; |
1562 | 1552 | ||
1563 | pos = udf_block_map(sbi->s_vat_inode, 0); | 1553 | pos = udf_block_map(sbi->s_vat_inode, 0); |
1564 | bh = sb_bread(sb, pos); | 1554 | bh = sb_bread(sb, pos); |
1565 | if (!bh) | 1555 | if (!bh) |
1566 | return 1; | 1556 | return 1; |
1567 | vat20 = (struct virtualAllocationTable20 *) | 1557 | vat20 = (struct virtualAllocationTable20 *) |
1568 | bh->b_data + | 1558 | bh->b_data + |
1569 | udf_ext0_offset(sbi->s_vat_inode); | 1559 | udf_ext0_offset(sbi->s_vat_inode); |
1570 | map->s_type_specific.s_virtual.s_start_offset = | 1560 | map->s_type_specific.s_virtual.s_start_offset = |
1571 | le16_to_cpu(vat20->lengthHeader) + | 1561 | le16_to_cpu(vat20->lengthHeader) + |
1572 | udf_ext0_offset(sbi->s_vat_inode); | 1562 | udf_ext0_offset(sbi->s_vat_inode); |
1573 | map->s_type_specific.s_virtual.s_num_entries = | 1563 | map->s_type_specific.s_virtual.s_num_entries = |
1574 | (sbi->s_vat_inode->i_size - | 1564 | (sbi->s_vat_inode->i_size - |
1575 | map->s_type_specific.s_virtual. | 1565 | map->s_type_specific.s_virtual. |
1576 | s_start_offset) >> 2; | 1566 | s_start_offset) >> 2; |
1577 | brelse(bh); | 1567 | brelse(bh); |
1578 | } | ||
1579 | map->s_partition_root = udf_get_pblock(sb, 0, i, 0); | ||
1580 | map->s_partition_len = | ||
1581 | sbi->s_partmaps[ino.partitionReferenceNum]. | ||
1582 | s_partition_len; | ||
1583 | } | 1568 | } |
1569 | map->s_partition_root = udf_get_pblock(sb, 0, i, 0); | ||
1570 | map->s_partition_len = | ||
1571 | sbi->s_partmaps[ino.partitionReferenceNum]. | ||
1572 | s_partition_len; | ||
1584 | } | 1573 | } |
1585 | return 0; | 1574 | return 0; |
1586 | } | 1575 | } |
@@ -1589,26 +1578,26 @@ static void udf_open_lvid(struct super_block *sb) | |||
1589 | { | 1578 | { |
1590 | struct udf_sb_info *sbi = UDF_SB(sb); | 1579 | struct udf_sb_info *sbi = UDF_SB(sb); |
1591 | struct buffer_head *bh = sbi->s_lvid_bh; | 1580 | struct buffer_head *bh = sbi->s_lvid_bh; |
1592 | if (bh) { | 1581 | struct logicalVolIntegrityDesc *lvid; |
1593 | struct logicalVolIntegrityDesc *lvid = | 1582 | struct logicalVolIntegrityDescImpUse *lvidiu; |
1594 | (struct logicalVolIntegrityDesc *)bh->b_data; | 1583 | if (!bh) |
1595 | struct logicalVolIntegrityDescImpUse *lvidiu = | 1584 | return; |
1596 | udf_sb_lvidiu(sbi); | ||
1597 | 1585 | ||
1598 | lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | 1586 | lvid = (struct logicalVolIntegrityDesc *)bh->b_data; |
1599 | lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | 1587 | lvidiu = udf_sb_lvidiu(sbi); |
1600 | udf_time_to_disk_stamp(&lvid->recordingDateAndTime, | ||
1601 | CURRENT_TIME); | ||
1602 | lvid->integrityType = LVID_INTEGRITY_TYPE_OPEN; | ||
1603 | 1588 | ||
1604 | lvid->descTag.descCRC = cpu_to_le16( | 1589 | lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; |
1605 | udf_crc((char *)lvid + sizeof(tag), | 1590 | lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; |
1606 | le16_to_cpu(lvid->descTag.descCRCLength), | 1591 | udf_time_to_disk_stamp(&lvid->recordingDateAndTime, |
1607 | 0)); | 1592 | CURRENT_TIME); |
1593 | lvid->integrityType = LVID_INTEGRITY_TYPE_OPEN; | ||
1608 | 1594 | ||
1609 | lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag); | 1595 | lvid->descTag.descCRC = cpu_to_le16( |
1610 | mark_buffer_dirty(bh); | 1596 | udf_crc((char *)lvid + sizeof(tag), |
1611 | } | 1597 | le16_to_cpu(lvid->descTag.descCRCLength), 0)); |
1598 | |||
1599 | lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag); | ||
1600 | mark_buffer_dirty(bh); | ||
1612 | } | 1601 | } |
1613 | 1602 | ||
1614 | static void udf_close_lvid(struct super_block *sb) | 1603 | static void udf_close_lvid(struct super_block *sb) |
@@ -1616,36 +1605,35 @@ static void udf_close_lvid(struct super_block *sb) | |||
1616 | struct udf_sb_info *sbi = UDF_SB(sb); | 1605 | struct udf_sb_info *sbi = UDF_SB(sb); |
1617 | struct buffer_head *bh = sbi->s_lvid_bh; | 1606 | struct buffer_head *bh = sbi->s_lvid_bh; |
1618 | struct logicalVolIntegrityDesc *lvid; | 1607 | struct logicalVolIntegrityDesc *lvid; |
1608 | struct logicalVolIntegrityDescImpUse *lvidiu; | ||
1619 | 1609 | ||
1620 | if (!bh) | 1610 | if (!bh) |
1621 | return; | 1611 | return; |
1622 | 1612 | ||
1623 | lvid = (struct logicalVolIntegrityDesc *)bh->b_data; | 1613 | lvid = (struct logicalVolIntegrityDesc *)bh->b_data; |
1624 | 1614 | ||
1625 | if (lvid->integrityType == LVID_INTEGRITY_TYPE_OPEN) { | 1615 | if (lvid->integrityType != LVID_INTEGRITY_TYPE_OPEN) |
1626 | struct logicalVolIntegrityDescImpUse *lvidiu = | 1616 | return; |
1627 | udf_sb_lvidiu(sbi); | 1617 | |
1628 | lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | 1618 | lvidiu = udf_sb_lvidiu(sbi); |
1629 | lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | 1619 | lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; |
1630 | udf_time_to_disk_stamp(&lvid->recordingDateAndTime, | 1620 | lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; |
1631 | CURRENT_TIME); | 1621 | udf_time_to_disk_stamp(&lvid->recordingDateAndTime, CURRENT_TIME); |
1632 | if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev)) | 1622 | if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev)) |
1633 | lvidiu->maxUDFWriteRev = | 1623 | lvidiu->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION); |
1634 | cpu_to_le16(UDF_MAX_WRITE_VERSION); | 1624 | if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev)) |
1635 | if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev)) | 1625 | lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev); |
1636 | lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev); | 1626 | if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev)) |
1637 | if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev)) | 1627 | lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev); |
1638 | lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev); | 1628 | lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); |
1639 | lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); | 1629 | |
1640 | 1630 | lvid->descTag.descCRC = cpu_to_le16( | |
1641 | lvid->descTag.descCRC = cpu_to_le16( | 1631 | udf_crc((char *)lvid + sizeof(tag), |
1642 | udf_crc((char *)lvid + sizeof(tag), | 1632 | le16_to_cpu(lvid->descTag.descCRCLength), |
1643 | le16_to_cpu(lvid->descTag.descCRCLength), | 1633 | 0)); |
1644 | 0)); | 1634 | |
1645 | 1635 | lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag); | |
1646 | lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag); | 1636 | mark_buffer_dirty(bh); |
1647 | mark_buffer_dirty(bh); | ||
1648 | } | ||
1649 | } | 1637 | } |
1650 | 1638 | ||
1651 | static void udf_sb_free_bitmap(struct udf_bitmap *bitmap) | 1639 | static void udf_sb_free_bitmap(struct udf_bitmap *bitmap) |