udf: Move filling of partition descriptor info into a separate function
Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
2e0838fd0c
commit
3fb38dfa0e
198
fs/udf/super.c
198
fs/udf/super.c
|
@ -1024,10 +1024,110 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
|
|||
return bitmap;
|
||||
}
|
||||
|
||||
static int udf_fill_partdesc_info(struct super_block *sb,
|
||||
struct partitionDesc *p, int p_index)
|
||||
{
|
||||
struct udf_part_map *map;
|
||||
struct udf_sb_info *sbi = UDF_SB(sb);
|
||||
struct partitionHeaderDesc *phd;
|
||||
|
||||
map = &sbi->s_partmaps[p_index];
|
||||
|
||||
map->s_partition_len = le32_to_cpu(p->partitionLength); /* blocks */
|
||||
map->s_partition_root = le32_to_cpu(p->partitionStartingLocation);
|
||||
|
||||
if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_READ_ONLY))
|
||||
map->s_partition_flags |= UDF_PART_FLAG_READ_ONLY;
|
||||
if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_WRITE_ONCE))
|
||||
map->s_partition_flags |= UDF_PART_FLAG_WRITE_ONCE;
|
||||
if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_REWRITABLE))
|
||||
map->s_partition_flags |= UDF_PART_FLAG_REWRITABLE;
|
||||
if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_OVERWRITABLE))
|
||||
map->s_partition_flags |= UDF_PART_FLAG_OVERWRITABLE;
|
||||
|
||||
udf_debug("Partition (%d:%d type %x) starts at physical %d, "
|
||||
"block length %d\n", partitionNumber, p_index,
|
||||
map->s_partition_type, map->s_partition_root,
|
||||
map->s_partition_len);
|
||||
|
||||
if (strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) &&
|
||||
strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03))
|
||||
return 0;
|
||||
|
||||
phd = (struct partitionHeaderDesc *)p->partitionContentsUse;
|
||||
if (phd->unallocSpaceTable.extLength) {
|
||||
kernel_lb_addr loc = {
|
||||
.logicalBlockNum = le32_to_cpu(
|
||||
phd->unallocSpaceTable.extPosition),
|
||||
.partitionReferenceNum = p_index,
|
||||
};
|
||||
|
||||
map->s_uspace.s_table = udf_iget(sb, loc);
|
||||
if (!map->s_uspace.s_table) {
|
||||
udf_debug("cannot load unallocSpaceTable (part %d)\n",
|
||||
p_index);
|
||||
return 1;
|
||||
}
|
||||
map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE;
|
||||
udf_debug("unallocSpaceTable (part %d) @ %ld\n",
|
||||
p_index, map->s_uspace.s_table->i_ino);
|
||||
}
|
||||
|
||||
if (phd->unallocSpaceBitmap.extLength) {
|
||||
struct udf_bitmap *bitmap = udf_sb_alloc_bitmap(sb, p_index);
|
||||
if (!bitmap)
|
||||
return 1;
|
||||
map->s_uspace.s_bitmap = bitmap;
|
||||
bitmap->s_extLength = le32_to_cpu(
|
||||
phd->unallocSpaceBitmap.extLength);
|
||||
bitmap->s_extPosition = le32_to_cpu(
|
||||
phd->unallocSpaceBitmap.extPosition);
|
||||
map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP;
|
||||
udf_debug("unallocSpaceBitmap (part %d) @ %d\n", p_index,
|
||||
bitmap->s_extPosition);
|
||||
}
|
||||
|
||||
if (phd->partitionIntegrityTable.extLength)
|
||||
udf_debug("partitionIntegrityTable (part %d)\n", p_index);
|
||||
|
||||
if (phd->freedSpaceTable.extLength) {
|
||||
kernel_lb_addr loc = {
|
||||
.logicalBlockNum = le32_to_cpu(
|
||||
phd->freedSpaceTable.extPosition),
|
||||
.partitionReferenceNum = p_index,
|
||||
};
|
||||
|
||||
map->s_fspace.s_table = udf_iget(sb, loc);
|
||||
if (!map->s_fspace.s_table) {
|
||||
udf_debug("cannot load freedSpaceTable (part %d)\n",
|
||||
p_index);
|
||||
return 1;
|
||||
}
|
||||
|
||||
map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE;
|
||||
udf_debug("freedSpaceTable (part %d) @ %ld\n",
|
||||
p_index, map->s_fspace.s_table->i_ino);
|
||||
}
|
||||
|
||||
if (phd->freedSpaceBitmap.extLength) {
|
||||
struct udf_bitmap *bitmap = udf_sb_alloc_bitmap(sb, p_index);
|
||||
if (!bitmap)
|
||||
return 1;
|
||||
map->s_fspace.s_bitmap = bitmap;
|
||||
bitmap->s_extLength = le32_to_cpu(
|
||||
phd->freedSpaceBitmap.extLength);
|
||||
bitmap->s_extPosition = le32_to_cpu(
|
||||
phd->freedSpaceBitmap.extPosition);
|
||||
map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP;
|
||||
udf_debug("freedSpaceBitmap (part %d) @ %d\n", p_index,
|
||||
bitmap->s_extPosition);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int udf_load_partdesc(struct super_block *sb, sector_t block)
|
||||
{
|
||||
struct buffer_head *bh;
|
||||
struct partitionHeaderDesc *phd;
|
||||
struct partitionDesc *p;
|
||||
struct udf_part_map *map;
|
||||
struct udf_sb_info *sbi = UDF_SB(sb);
|
||||
|
@ -1060,101 +1160,7 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block)
|
|||
goto out_bh;
|
||||
}
|
||||
|
||||
map->s_partition_len = le32_to_cpu(p->partitionLength); /* blocks */
|
||||
map->s_partition_root = le32_to_cpu(p->partitionStartingLocation);
|
||||
|
||||
if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_READ_ONLY))
|
||||
map->s_partition_flags |= UDF_PART_FLAG_READ_ONLY;
|
||||
if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_WRITE_ONCE))
|
||||
map->s_partition_flags |= UDF_PART_FLAG_WRITE_ONCE;
|
||||
if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_REWRITABLE))
|
||||
map->s_partition_flags |= UDF_PART_FLAG_REWRITABLE;
|
||||
if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_OVERWRITABLE))
|
||||
map->s_partition_flags |= UDF_PART_FLAG_OVERWRITABLE;
|
||||
|
||||
udf_debug("Partition (%d:%d type %x) starts at physical %d, "
|
||||
"block length %d\n", partitionNumber, i,
|
||||
map->s_partition_type, map->s_partition_root,
|
||||
map->s_partition_len);
|
||||
|
||||
if (strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) &&
|
||||
strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03))
|
||||
goto out_bh;
|
||||
|
||||
phd = (struct partitionHeaderDesc *)p->partitionContentsUse;
|
||||
if (phd->unallocSpaceTable.extLength) {
|
||||
kernel_lb_addr loc = {
|
||||
.logicalBlockNum = le32_to_cpu(
|
||||
phd->unallocSpaceTable.extPosition),
|
||||
.partitionReferenceNum = i,
|
||||
};
|
||||
|
||||
map->s_uspace.s_table = udf_iget(sb, loc);
|
||||
if (!map->s_uspace.s_table) {
|
||||
udf_debug("cannot load unallocSpaceTable (part %d)\n",
|
||||
i);
|
||||
ret = 1;
|
||||
goto out_bh;
|
||||
}
|
||||
map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE;
|
||||
udf_debug("unallocSpaceTable (part %d) @ %ld\n",
|
||||
i, map->s_uspace.s_table->i_ino);
|
||||
}
|
||||
|
||||
if (phd->unallocSpaceBitmap.extLength) {
|
||||
struct udf_bitmap *bitmap = udf_sb_alloc_bitmap(sb, i);
|
||||
if (!bitmap) {
|
||||
ret = 1;
|
||||
goto out_bh;
|
||||
}
|
||||
map->s_uspace.s_bitmap = bitmap;
|
||||
bitmap->s_extLength = le32_to_cpu(
|
||||
phd->unallocSpaceBitmap.extLength);
|
||||
bitmap->s_extPosition = le32_to_cpu(
|
||||
phd->unallocSpaceBitmap.extPosition);
|
||||
map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP;
|
||||
udf_debug("unallocSpaceBitmap (part %d) @ %d\n", i,
|
||||
bitmap->s_extPosition);
|
||||
}
|
||||
|
||||
if (phd->partitionIntegrityTable.extLength)
|
||||
udf_debug("partitionIntegrityTable (part %d)\n", i);
|
||||
|
||||
if (phd->freedSpaceTable.extLength) {
|
||||
kernel_lb_addr loc = {
|
||||
.logicalBlockNum = le32_to_cpu(
|
||||
phd->freedSpaceTable.extPosition),
|
||||
.partitionReferenceNum = i,
|
||||
};
|
||||
|
||||
map->s_fspace.s_table = udf_iget(sb, loc);
|
||||
if (!map->s_fspace.s_table) {
|
||||
udf_debug("cannot load freedSpaceTable (part %d)\n", i);
|
||||
ret = 1;
|
||||
goto out_bh;
|
||||
}
|
||||
|
||||
map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE;
|
||||
udf_debug("freedSpaceTable (part %d) @ %ld\n",
|
||||
i, map->s_fspace.s_table->i_ino);
|
||||
}
|
||||
|
||||
if (phd->freedSpaceBitmap.extLength) {
|
||||
struct udf_bitmap *bitmap = udf_sb_alloc_bitmap(sb, i);
|
||||
if (!bitmap) {
|
||||
ret = 1;
|
||||
goto out_bh;
|
||||
}
|
||||
map->s_fspace.s_bitmap = bitmap;
|
||||
bitmap->s_extLength = le32_to_cpu(
|
||||
phd->freedSpaceBitmap.extLength);
|
||||
bitmap->s_extPosition = le32_to_cpu(
|
||||
phd->freedSpaceBitmap.extPosition);
|
||||
map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP;
|
||||
udf_debug("freedSpaceBitmap (part %d) @ %d\n", i,
|
||||
bitmap->s_extPosition);
|
||||
}
|
||||
|
||||
ret = udf_fill_partdesc_info(sb, p, i);
|
||||
out_bh:
|
||||
/* In case loading failed, we handle cleanup in udf_fill_super */
|
||||
brelse(bh);
|
||||
|
|
Loading…
Reference in New Issue