1248
static int udf_load_sparable_map(struct super_block *sb,
1249
struct udf_part_map *map,
1250
struct sparablePartitionMap *spm)
1254
struct sparingTable *st;
1255
struct udf_sparing_data *sdata = &map->s_type_specific.s_sparing;
1257
struct buffer_head *bh;
1259
map->s_partition_type = UDF_SPARABLE_MAP15;
1260
sdata->s_packet_len = le16_to_cpu(spm->packetLength);
1261
if (!is_power_of_2(sdata->s_packet_len)) {
1262
udf_error(sb, __func__,
1263
"error loading logical volume descriptor: "
1264
"Invalid packet length %u\n",
1265
(unsigned)sdata->s_packet_len);
1268
if (spm->numSparingTables > 4) {
1269
udf_error(sb, __func__,
1270
"error loading logical volume descriptor: "
1271
"Too many sparing tables (%d)\n",
1272
(int)spm->numSparingTables);
1276
for (i = 0; i < spm->numSparingTables; i++) {
1277
loc = le32_to_cpu(spm->locSparingTable[i]);
1278
bh = udf_read_tagged(sb, loc, loc, &ident);
1282
st = (struct sparingTable *)bh->b_data;
1284
strncmp(st->sparingIdent.ident, UDF_ID_SPARING,
1285
strlen(UDF_ID_SPARING)) ||
1286
sizeof(*st) + le16_to_cpu(st->reallocationTableLen) >
1292
sdata->s_spar_map[i] = bh;
1294
map->s_partition_func = udf_get_pblock_spar15;
1247
1298
static int udf_load_logicalvol(struct super_block *sb, sector_t block,
1248
1299
struct kernel_lb_addr *fileset)
1250
1301
struct logicalVolDesc *lvd;
1253
1304
struct udf_sb_info *sbi = UDF_SB(sb);
1254
1305
struct genericPartitionMap *gpm;
1255
1306
uint16_t ident;
1256
1307
struct buffer_head *bh;
1308
unsigned int table_len;
1259
1311
bh = udf_read_tagged(sb, block, block, &ident);
1262
1314
BUG_ON(ident != TAG_IDENT_LVD);
1263
1315
lvd = (struct logicalVolDesc *)bh->b_data;
1316
table_len = le32_to_cpu(lvd->mapTableLength);
1317
if (sizeof(*lvd) + table_len > sb->s_blocksize) {
1318
udf_error(sb, __func__,
1319
"error loading logical volume descriptor: "
1320
"Partition table too long (%u > %lu)\n", table_len,
1321
sb->s_blocksize - sizeof(*lvd));
1265
1325
i = udf_sb_alloc_partition_maps(sb, le32_to_cpu(lvd->numPartitionMaps));
1271
1331
for (i = 0, offset = 0;
1272
i < sbi->s_partitions && offset < le32_to_cpu(lvd->mapTableLength);
1332
i < sbi->s_partitions && offset < table_len;
1273
1333
i++, offset += gpm->partitionMapLength) {
1274
1334
struct udf_part_map *map = &sbi->s_partmaps[i];
1275
1335
gpm = (struct genericPartitionMap *)
1304
1364
} else if (!strncmp(upm2->partIdent.ident,
1305
1365
UDF_ID_SPARABLE,
1306
1366
strlen(UDF_ID_SPARABLE))) {
1308
struct sparingTable *st;
1309
struct sparablePartitionMap *spm =
1310
(struct sparablePartitionMap *)gpm;
1312
map->s_partition_type = UDF_SPARABLE_MAP15;
1313
map->s_type_specific.s_sparing.s_packet_len =
1314
le16_to_cpu(spm->packetLength);
1315
for (j = 0; j < spm->numSparingTables; j++) {
1316
struct buffer_head *bh2;
1319
spm->locSparingTable[j]);
1320
bh2 = udf_read_tagged(sb, loc, loc,
1322
map->s_type_specific.s_sparing.
1323
s_spar_map[j] = bh2;
1328
st = (struct sparingTable *)bh2->b_data;
1329
if (ident != 0 || strncmp(
1330
st->sparingIdent.ident,
1332
strlen(UDF_ID_SPARING))) {
1334
map->s_type_specific.s_sparing.
1335
s_spar_map[j] = NULL;
1338
map->s_partition_func = udf_get_pblock_spar15;
1367
if (udf_load_sparable_map(sb, map,
1368
(struct sparablePartitionMap *)gpm) < 0)
1339
1370
} else if (!strncmp(upm2->partIdent.ident,
1340
1371
UDF_ID_METADATA,
1341
1372
strlen(UDF_ID_METADATA))) {