提交 165923fa 编写于 作者: M Marcin Slusarz 提交者: Jan Kara

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: NMarcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: NJan Kara <jack@suse.cz>
上级 af15a298
...@@ -827,7 +827,8 @@ static void udf_find_anchor(struct super_block *sb) ...@@ -827,7 +827,8 @@ static void udf_find_anchor(struct super_block *sb)
} }
for (i = 0; i < ARRAY_SIZE(sbi->s_anchor); i++) { for (i = 0; i < ARRAY_SIZE(sbi->s_anchor); i++) {
if (sbi->s_anchor[i]) { if (!sbi->s_anchor[i])
continue;
bh = udf_read_tagged(sb, sbi->s_anchor[i], bh = udf_read_tagged(sb, sbi->s_anchor[i],
sbi->s_anchor[i], &ident); sbi->s_anchor[i], &ident);
if (!bh) if (!bh)
...@@ -840,7 +841,6 @@ static void udf_find_anchor(struct super_block *sb) ...@@ -840,7 +841,6 @@ static void udf_find_anchor(struct super_block *sb)
sbi->s_anchor[i] = 0; sbi->s_anchor[i] = 0;
} }
} }
}
sbi->s_last_block = lastblock; sbi->s_last_block = lastblock;
} }
...@@ -1020,128 +1020,118 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index) ...@@ -1020,128 +1020,118 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh) static int udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
{ {
struct partitionDesc *p; struct partitionHeaderDesc *phd;
int i; struct partitionDesc *p = (struct partitionDesc *)bh->b_data;
struct udf_part_map *map; struct udf_part_map *map;
struct udf_sb_info *sbi; struct udf_sb_info *sbi = UDF_SB(sb);
bool found = false;
p = (struct partitionDesc *)bh->b_data; int i;
sbi = UDF_SB(sb); u16 partitionNumber = le16_to_cpu(p->partitionNumber);
for (i = 0; i < sbi->s_partitions; i++) { for (i = 0; i < sbi->s_partitions; i++) {
map = &sbi->s_partmaps[i]; map = &sbi->s_partmaps[i];
udf_debug("Searching map: (%d == %d)\n", udf_debug("Searching map: (%d == %d)\n",
map->s_partition_num, map->s_partition_num, partitionNumber);
le16_to_cpu(p->partitionNumber)); found = map->s_partition_num == partitionNumber;
if (map->s_partition_num == if (found)
le16_to_cpu(p->partitionNumber)) { break;
map->s_partition_len = }
le32_to_cpu(p->partitionLength); /* blocks */
map->s_partition_root = if (!found) {
le32_to_cpu(p->partitionStartingLocation); udf_debug("Partition (%d) not found in partition map\n",
if (p->accessType == partitionNumber);
cpu_to_le32(PD_ACCESS_TYPE_READ_ONLY)) return 0;
map->s_partition_flags |= }
UDF_PART_FLAG_READ_ONLY;
if (p->accessType == map->s_partition_len = le32_to_cpu(p->partitionLength); /* blocks */
cpu_to_le32(PD_ACCESS_TYPE_WRITE_ONCE)) map->s_partition_root = le32_to_cpu(p->partitionStartingLocation);
map->s_partition_flags |=
UDF_PART_FLAG_WRITE_ONCE; if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_READ_ONLY))
if (p->accessType == map->s_partition_flags |= UDF_PART_FLAG_READ_ONLY;
cpu_to_le32(PD_ACCESS_TYPE_REWRITABLE)) if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_WRITE_ONCE))
map->s_partition_flags |= map->s_partition_flags |= UDF_PART_FLAG_WRITE_ONCE;
UDF_PART_FLAG_REWRITABLE; if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_REWRITABLE))
if (p->accessType == map->s_partition_flags |= UDF_PART_FLAG_REWRITABLE;
cpu_to_le32(PD_ACCESS_TYPE_OVERWRITABLE)) if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_OVERWRITABLE))
map->s_partition_flags |= map->s_partition_flags |= UDF_PART_FLAG_OVERWRITABLE;
UDF_PART_FLAG_OVERWRITABLE;
udf_debug("Partition (%d:%d type %x) starts at physical %d, "
if (!strcmp(p->partitionContents.ident, "block length %d\n", partitionNumber, i,
PD_PARTITION_CONTENTS_NSR02) || map->s_partition_type, map->s_partition_root,
!strcmp(p->partitionContents.ident, map->s_partition_len);
PD_PARTITION_CONTENTS_NSR03)) {
struct partitionHeaderDesc *phd; if (strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) &&
strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03))
return 0;
phd = (struct partitionHeaderDesc *) phd = (struct partitionHeaderDesc *)p->partitionContentsUse;
(p->partitionContentsUse);
if (phd->unallocSpaceTable.extLength) { if (phd->unallocSpaceTable.extLength) {
kernel_lb_addr loc = { kernel_lb_addr loc = {
.logicalBlockNum = le32_to_cpu(phd->unallocSpaceTable.extPosition), .logicalBlockNum = le32_to_cpu(
phd->unallocSpaceTable.extPosition),
.partitionReferenceNum = i, .partitionReferenceNum = i,
}; };
map->s_uspace.s_table = map->s_uspace.s_table = udf_iget(sb, loc);
udf_iget(sb, loc);
if (!map->s_uspace.s_table) { if (!map->s_uspace.s_table) {
udf_debug("cannot load unallocSpaceTable (part %d)\n", i); udf_debug("cannot load unallocSpaceTable (part %d)\n",
i);
return 1; return 1;
} }
map->s_partition_flags |= map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE;
UDF_PART_FLAG_UNALLOC_TABLE;
udf_debug("unallocSpaceTable (part %d) @ %ld\n", udf_debug("unallocSpaceTable (part %d) @ %ld\n",
i, map->s_uspace.s_table->i_ino); i, map->s_uspace.s_table->i_ino);
} }
if (phd->unallocSpaceBitmap.extLength) { if (phd->unallocSpaceBitmap.extLength) {
struct udf_bitmap *bitmap = struct udf_bitmap *bitmap = udf_sb_alloc_bitmap(sb, i);
udf_sb_alloc_bitmap(sb, i);
map->s_uspace.s_bitmap = bitmap; map->s_uspace.s_bitmap = bitmap;
if (bitmap != NULL) { if (bitmap != NULL) {
bitmap->s_extLength = bitmap->s_extLength = le32_to_cpu(
le32_to_cpu(phd->unallocSpaceBitmap.extLength); phd->unallocSpaceBitmap.extLength);
bitmap->s_extPosition = bitmap->s_extPosition = le32_to_cpu(
le32_to_cpu(phd->unallocSpaceBitmap.extPosition); phd->unallocSpaceBitmap.extPosition);
map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP; map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP;
udf_debug("unallocSpaceBitmap (part %d) @ %d\n", udf_debug("unallocSpaceBitmap (part %d) @ %d\n",
i, bitmap->s_extPosition); i, bitmap->s_extPosition);
} }
} }
if (phd->partitionIntegrityTable.extLength) if (phd->partitionIntegrityTable.extLength)
udf_debug("partitionIntegrityTable (part %d)\n", i); udf_debug("partitionIntegrityTable (part %d)\n", i);
if (phd->freedSpaceTable.extLength) { if (phd->freedSpaceTable.extLength) {
kernel_lb_addr loc = { kernel_lb_addr loc = {
.logicalBlockNum = le32_to_cpu(phd->freedSpaceTable.extPosition), .logicalBlockNum = le32_to_cpu(
phd->freedSpaceTable.extPosition),
.partitionReferenceNum = i, .partitionReferenceNum = i,
}; };
map->s_fspace.s_table = map->s_fspace.s_table = udf_iget(sb, loc);
udf_iget(sb, loc);
if (!map->s_fspace.s_table) { if (!map->s_fspace.s_table) {
udf_debug("cannot load freedSpaceTable (part %d)\n", i); udf_debug("cannot load freedSpaceTable (part %d)\n", i);
return 1; return 1;
} }
map->s_partition_flags |=
UDF_PART_FLAG_FREED_TABLE; map->s_partition_flags |= UDF_PART_FLAG_FREED_TABLE;
udf_debug("freedSpaceTable (part %d) @ %ld\n", udf_debug("freedSpaceTable (part %d) @ %ld\n",
i, map->s_fspace.s_table->i_ino); i, map->s_fspace.s_table->i_ino);
} }
if (phd->freedSpaceBitmap.extLength) { if (phd->freedSpaceBitmap.extLength) {
struct udf_bitmap *bitmap = struct udf_bitmap *bitmap = udf_sb_alloc_bitmap(sb, i);
udf_sb_alloc_bitmap(sb, i);
map->s_fspace.s_bitmap = bitmap; map->s_fspace.s_bitmap = bitmap;
if (bitmap != NULL) { if (bitmap != NULL) {
bitmap->s_extLength = bitmap->s_extLength = le32_to_cpu(
le32_to_cpu(phd->freedSpaceBitmap.extLength); phd->freedSpaceBitmap.extLength);
bitmap->s_extPosition = bitmap->s_extPosition = le32_to_cpu(
le32_to_cpu(phd->freedSpaceBitmap.extPosition); phd->freedSpaceBitmap.extPosition);
map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP; map->s_partition_flags |= UDF_PART_FLAG_FREED_BITMAP;
udf_debug("freedSpaceBitmap (part %d) @ %d\n", udf_debug("freedSpaceBitmap (part %d) @ %d\n",
i, bitmap->s_extPosition); i, bitmap->s_extPosition);
} }
} }
}
break;
}
}
if (i == sbi->s_partitions)
udf_debug("Partition (%d) not found in partition map\n",
le16_to_cpu(p->partitionNumber));
else
udf_debug("Partition (%d:%d type %x) starts at physical %d, "
"block length %d\n",
le16_to_cpu(p->partitionNumber), i,
map->s_partition_type,
map->s_partition_root,
map->s_partition_len);
return 0; return 0;
} }
...@@ -1215,19 +1205,17 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh, ...@@ -1215,19 +1205,17 @@ static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
map->s_type_specific.s_sparing. map->s_type_specific.s_sparing.
s_spar_map[j] = bh2; s_spar_map[j] = bh2;
if (bh2 != NULL) { if (bh2 == NULL)
st = (struct sparingTable *) continue;
bh2->b_data;
st = (struct sparingTable *)bh2->b_data;
if (ident != 0 || strncmp( if (ident != 0 || strncmp(
st->sparingIdent.ident, st->sparingIdent.ident,
UDF_ID_SPARING, UDF_ID_SPARING,
strlen(UDF_ID_SPARING))) { strlen(UDF_ID_SPARING))) {
brelse(bh2); brelse(bh2);
map->s_type_specific. map->s_type_specific.s_sparing.
s_sparing. s_spar_map[j] = NULL;
s_spar_map[j] =
NULL;
}
} }
} }
map->s_partition_func = udf_get_pblock_spar15; map->s_partition_func = udf_get_pblock_spar15;
...@@ -1392,13 +1380,15 @@ static int udf_process_sequence(struct super_block *sb, long block, ...@@ -1392,13 +1380,15 @@ static int udf_process_sequence(struct super_block *sb, long block,
brelse(bh); brelse(bh);
} }
for (i = 0; i < VDS_POS_LENGTH; i++) { for (i = 0; i < VDS_POS_LENGTH; i++) {
if (vds[i].block) { if (!vds[i].block)
continue;
bh = udf_read_tagged(sb, vds[i].block, vds[i].block, bh = udf_read_tagged(sb, vds[i].block, vds[i].block,
&ident); &ident);
if (i == VDS_POS_PRIMARY_VOL_DESC) { if (i == VDS_POS_PRIMARY_VOL_DESC)
udf_load_pvoldesc(sb, bh); udf_load_pvoldesc(sb, bh);
} else if (i == VDS_POS_LOGICAL_VOL_DESC) { else if (i == VDS_POS_LOGICAL_VOL_DESC) {
if (udf_load_logicalvol(sb, bh, fileset)) { if (udf_load_logicalvol(sb, bh, fileset)) {
brelse(bh); brelse(bh);
return 1; return 1;
...@@ -1415,8 +1405,7 @@ static int udf_process_sequence(struct super_block *sb, long block, ...@@ -1415,8 +1405,7 @@ static int udf_process_sequence(struct super_block *sb, long block,
bh2 = udf_read_tagged(sb, j, j, &ident); bh2 = udf_read_tagged(sb, j, j, &ident);
gd = (struct generic_desc *)bh2->b_data; gd = (struct generic_desc *)bh2->b_data;
if (ident == TAG_IDENT_PD) if (ident == TAG_IDENT_PD)
if (udf_load_partdesc(sb, if (udf_load_partdesc(sb, bh2)) {
bh2)) {
brelse(bh); brelse(bh);
brelse(bh2); brelse(bh2);
return 1; return 1;
...@@ -1426,7 +1415,6 @@ static int udf_process_sequence(struct super_block *sb, long block, ...@@ -1426,7 +1415,6 @@ static int udf_process_sequence(struct super_block *sb, long block,
} }
brelse(bh); brelse(bh);
} }
}
return 0; return 0;
} }
...@@ -1437,6 +1425,7 @@ static int udf_process_sequence(struct super_block *sb, long block, ...@@ -1437,6 +1425,7 @@ static int udf_process_sequence(struct super_block *sb, long block,
static int udf_check_valid(struct super_block *sb, int novrs, int silent) static int udf_check_valid(struct super_block *sb, int novrs, int silent)
{ {
long block; long block;
struct udf_sb_info *sbi;
if (novrs) { if (novrs) {
udf_debug("Validity check skipped because of novrs option\n"); 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,18 +1433,16 @@ static int udf_check_valid(struct super_block *sb, int novrs, int silent)
} }
/* Check that it is NSR02 compliant */ /* Check that it is NSR02 compliant */
/* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */ /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */
else {
block = udf_vrs(sb, silent); block = udf_vrs(sb, silent);
if (block == -1) { if (block != -1)
struct udf_sb_info *sbi = UDF_SB(sb); return !block;
sbi = UDF_SB(sb);
udf_debug("Failed to read byte 32768. Assuming open " udf_debug("Failed to read byte 32768. Assuming open "
"disc. Skipping validity check\n"); "disc. Skipping validity check\n");
if (!sbi->s_last_block) if (!sbi->s_last_block)
sbi->s_last_block = udf_get_last_block(sb); sbi->s_last_block = udf_get_last_block(sb);
return 0; return 0;
} else
return !block;
}
} }
static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) 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,6 +1461,7 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
for (i = 0; i < ARRAY_SIZE(sbi->s_anchor); i++) { for (i = 0; i < ARRAY_SIZE(sbi->s_anchor); i++) {
if (!sbi->s_anchor[i]) if (!sbi->s_anchor[i])
continue; continue;
bh = udf_read_tagged(sb, sbi->s_anchor[i], sbi->s_anchor[i], bh = udf_read_tagged(sb, sbi->s_anchor[i], sbi->s_anchor[i],
&ident); &ident);
if (!bh) if (!bh)
...@@ -1515,9 +1503,11 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) ...@@ -1515,9 +1503,11 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
for (i = 0; i < sbi->s_partitions; i++) { for (i = 0; i < sbi->s_partitions; i++) {
kernel_lb_addr uninitialized_var(ino); kernel_lb_addr uninitialized_var(ino);
struct udf_part_map *map = &sbi->s_partmaps[i]; struct udf_part_map *map = &sbi->s_partmaps[i];
switch (map->s_partition_type) {
case UDF_VIRTUAL_MAP15: if (map->s_partition_type != UDF_VIRTUAL_MAP15 &&
case UDF_VIRTUAL_MAP20: map->s_partition_type != UDF_VIRTUAL_MAP20)
continue;
if (!sbi->s_last_block) { if (!sbi->s_last_block) {
sbi->s_last_block = udf_get_last_block(sb); sbi->s_last_block = udf_get_last_block(sb);
udf_find_anchor(sb); udf_find_anchor(sb);
...@@ -1581,7 +1571,6 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset) ...@@ -1581,7 +1571,6 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
sbi->s_partmaps[ino.partitionReferenceNum]. sbi->s_partmaps[ino.partitionReferenceNum].
s_partition_len; s_partition_len;
} }
}
return 0; return 0;
} }
...@@ -1589,11 +1578,13 @@ static void udf_open_lvid(struct super_block *sb) ...@@ -1589,11 +1578,13 @@ static void udf_open_lvid(struct super_block *sb)
{ {
struct udf_sb_info *sbi = UDF_SB(sb); struct udf_sb_info *sbi = UDF_SB(sb);
struct buffer_head *bh = sbi->s_lvid_bh; struct buffer_head *bh = sbi->s_lvid_bh;
if (bh) { struct logicalVolIntegrityDesc *lvid;
struct logicalVolIntegrityDesc *lvid = struct logicalVolIntegrityDescImpUse *lvidiu;
(struct logicalVolIntegrityDesc *)bh->b_data; if (!bh)
struct logicalVolIntegrityDescImpUse *lvidiu = return;
udf_sb_lvidiu(sbi);
lvid = (struct logicalVolIntegrityDesc *)bh->b_data;
lvidiu = udf_sb_lvidiu(sbi);
lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
...@@ -1603,12 +1594,10 @@ static void udf_open_lvid(struct super_block *sb) ...@@ -1603,12 +1594,10 @@ static void udf_open_lvid(struct super_block *sb)
lvid->descTag.descCRC = cpu_to_le16( lvid->descTag.descCRC = cpu_to_le16(
udf_crc((char *)lvid + sizeof(tag), udf_crc((char *)lvid + sizeof(tag),
le16_to_cpu(lvid->descTag.descCRCLength), le16_to_cpu(lvid->descTag.descCRCLength), 0));
0));
lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag); lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag);
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
}
} }
static void udf_close_lvid(struct super_block *sb) static void udf_close_lvid(struct super_block *sb)
...@@ -1616,22 +1605,22 @@ static void udf_close_lvid(struct super_block *sb) ...@@ -1616,22 +1605,22 @@ static void udf_close_lvid(struct super_block *sb)
struct udf_sb_info *sbi = UDF_SB(sb); struct udf_sb_info *sbi = UDF_SB(sb);
struct buffer_head *bh = sbi->s_lvid_bh; struct buffer_head *bh = sbi->s_lvid_bh;
struct logicalVolIntegrityDesc *lvid; struct logicalVolIntegrityDesc *lvid;
struct logicalVolIntegrityDescImpUse *lvidiu;
if (!bh) if (!bh)
return; return;
lvid = (struct logicalVolIntegrityDesc *)bh->b_data; lvid = (struct logicalVolIntegrityDesc *)bh->b_data;
if (lvid->integrityType == LVID_INTEGRITY_TYPE_OPEN) { if (lvid->integrityType != LVID_INTEGRITY_TYPE_OPEN)
struct logicalVolIntegrityDescImpUse *lvidiu = return;
udf_sb_lvidiu(sbi);
lvidiu = udf_sb_lvidiu(sbi);
lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
udf_time_to_disk_stamp(&lvid->recordingDateAndTime, udf_time_to_disk_stamp(&lvid->recordingDateAndTime, CURRENT_TIME);
CURRENT_TIME);
if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev)) if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev))
lvidiu->maxUDFWriteRev = lvidiu->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
cpu_to_le16(UDF_MAX_WRITE_VERSION);
if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev)) if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev))
lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev); lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev);
if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev)) if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev))
...@@ -1645,7 +1634,6 @@ static void udf_close_lvid(struct super_block *sb) ...@@ -1645,7 +1634,6 @@ static void udf_close_lvid(struct super_block *sb)
lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag); lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag);
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
}
} }
static void udf_sb_free_bitmap(struct udf_bitmap *bitmap) static void udf_sb_free_bitmap(struct udf_bitmap *bitmap)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册