mkfs, fsck: change the results for readability

This patch cleans up several printing formats.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
This commit is contained in:
Jaegeuk Kim 2014-02-06 01:09:36 +09:00
parent 28d45d09cd
commit 858c4039c8
5 changed files with 32 additions and 21 deletions

View File

@ -70,22 +70,28 @@ void ssa_dump(struct f2fs_sb_info *sbi, int start_ssa, int end_ssa)
fd = open("dump_ssa", O_CREAT|O_WRONLY|O_TRUNC, 0666);
ASSERT(fd >= 0);
snprintf(buf, BUF_SZ, "Note: dump.f2fs -b blkaddr = 0x%x + segno * "
" 0x200 + offset\n",
sbi->sm_info->main_blkaddr);
ret = write(fd, buf, strlen(buf));
ASSERT(ret >= 0);
for (segno = start_ssa; segno < end_ssa; segno++) {
ret = get_sum_block(sbi, segno, &sum_blk);
memset(buf, 0, BUF_SZ);
switch (ret) {
case SEG_TYPE_CUR_NODE:
snprintf(buf, BUF_SZ, "\n\nsegno: %d, Current Node\n", segno);
snprintf(buf, BUF_SZ, "\n\nsegno: %x, Current Node\n", segno);
break;
case SEG_TYPE_CUR_DATA:
snprintf(buf, BUF_SZ, "\n\nsegno: %d, Current Data\n", segno);
snprintf(buf, BUF_SZ, "\n\nsegno: %x, Current Data\n", segno);
break;
case SEG_TYPE_NODE:
snprintf(buf, BUF_SZ, "\n\nsegno: %d, Node\n", segno);
snprintf(buf, BUF_SZ, "\n\nsegno: %x, Node\n", segno);
break;
case SEG_TYPE_DATA:
snprintf(buf, BUF_SZ, "\n\nsegno: %d, Data\n", segno);
snprintf(buf, BUF_SZ, "\n\nsegno: %x, Data\n", segno);
break;
}
ret = write(fd, buf, strlen(buf));
@ -98,10 +104,8 @@ void ssa_dump(struct f2fs_sb_info *sbi, int start_ssa, int end_ssa)
ret = write(fd, buf, strlen(buf));
ASSERT(ret >= 0);
}
snprintf(buf, BUF_SZ, " [%8x, %3d, %3x]",
le32_to_cpu(sum_blk.entries[i].nid),
le16_to_cpu(sum_blk.entries[i].ofs_in_node),
sum_blk.entries[i].version);
snprintf(buf, BUF_SZ, "[%3d: %6x]", i,
le32_to_cpu(sum_blk.entries[i].nid));
ret = write(fd, buf, strlen(buf));
ASSERT(ret >= 0);
}
@ -147,28 +151,36 @@ int dump_node(struct f2fs_sb_info *sbi, nid_t nid)
int dump_inode_from_blkaddr(struct f2fs_sb_info *sbi, u32 blk_addr)
{
nid_t ino, nid;
int ret;
int type, ret;
struct f2fs_summary sum_entry;
struct node_info ni;
struct f2fs_node *node_blk;
ret = get_sum_entry(sbi, blk_addr, &sum_entry);
type = get_sum_entry(sbi, blk_addr, &sum_entry);
nid = le32_to_cpu(sum_entry.nid);
DBG(1, "Node ID [0x%x]\n", nid);
DBG(1, "Segment Type [%s]\n", seg_type_name[ret]);
DBG(1, "version [%d]\n", sum_entry.version);
DBG(1, "ofs_in_node [%d]\n", sum_entry.ofs_in_node);
ret = get_node_info(sbi, nid, &ni);
ASSERT(ret >= 0);
DBG(1, "Note: blkaddr = main_blkaddr + segno * 512 + offset\n");
DBG(1, "Block_addr [0x%x]\n", blk_addr);
DBG(1, " - Segno [0x%x]\n", GET_SEGNO(sbi, blk_addr));
DBG(1, " - Offset [0x%x]\n", OFFSET_IN_SEG(sbi, blk_addr));
DBG(1, "SUM.nid [0x%x]\n", nid);
DBG(1, "SUM.type [%s]\n", seg_type_name[type]);
DBG(1, "SUM.version [%d]\n", sum_entry.version);
DBG(1, "SUM.ofs_in_node [%d]\n", sum_entry.ofs_in_node);
DBG(1, "NAT.blkaddr [0x%x]\n", ni.blk_addr);
DBG(1, "NAT.ino [0x%x]\n", ni.ino);
node_blk = calloc(BLOCK_SZ, 1);
read_node_blk:
dev_read_block(node_blk, ni.blk_addr);
dev_read_block(node_blk, blk_addr);
ino = le32_to_cpu(node_blk->footer.ino);
nid = le32_to_cpu(node_blk->footer.nid);
if (ino == nid) {
print_node_info(node_blk);
} else {

View File

@ -104,7 +104,7 @@ static int is_valid_ssa_node_blk(struct f2fs_sb_info *sbi, u32 nid, u32 blk_addr
if (le32_to_cpu(sum_entry.nid) != nid) {
DBG(0, "nid [0x%x]\n", nid);
DBG(0, "target blk_addr [0x%x]\n", blk_addr);
DBG(0, "summary blk_addr [0x%lx]\n",
DBG(0, "summary blk_addr [0x%x]\n",
GET_SUM_BLKADDR(sbi, GET_SEGNO(sbi, blk_addr)));
DBG(0, "seg no / offset [0x%x / 0x%x]\n",
GET_SEGNO(sbi, blk_addr), OFFSET_IN_SEG(sbi, blk_addr));
@ -667,7 +667,7 @@ int fsck_chk_orphan_node(struct f2fs_sb_info *sbi)
for (j = 0; j < le32_to_cpu(orphan_blk->entry_count); j++) {
nid_t ino = le32_to_cpu(orphan_blk->ino[j]);
DBG(1, "[%3ld] ino [0x%x]\n", i, ino);
DBG(1, "[%3d] ino [0x%x]\n", i, ino);
blk_cnt = 1;
ret = fsck_chk_node_blk(sbi,
NULL,

View File

@ -738,7 +738,7 @@ int get_sum_block(struct f2fs_sb_info *sbi, unsigned int segno, struct f2fs_summ
ssa_blk = GET_SUM_BLKADDR(sbi, segno);
for (type = 0; type < NR_CURSEG_NODE_TYPE; type++) {
if (segno == ckpt->cur_node_segno[type]) {
curseg = CURSEG_I(sbi, type);
curseg = CURSEG_I(sbi, CURSEG_HOT_NODE + type);
memcpy(sum_blk, curseg->sum_blk, BLOCK_SZ);
return SEG_TYPE_CUR_NODE; /* current node seg was not stored */
}

View File

@ -25,7 +25,7 @@ typedef u_int64_t u64;
typedef u_int32_t u32;
typedef u_int16_t u16;
typedef u_int8_t u8;
typedef u64 block_t;
typedef u32 block_t;
typedef u32 nid_t;
typedef u8 bool;
typedef unsigned long pgoff_t;

View File

@ -570,8 +570,7 @@ static int f2fs_write_check_point_pack(void)
ckp->cp_pack_start_sum = cpu_to_le32(1);
ckp->valid_node_count = cpu_to_le32(1);
ckp->valid_inode_count = cpu_to_le32(1);
ckp->next_free_nid = cpu_to_le32(
le32_to_cpu(super_block.root_ino) + 1);
ckp->next_free_nid = cpu_to_le32(0xc00000);
ckp->sit_ver_bitmap_bytesize = cpu_to_le32(
((le32_to_cpu(super_block.segment_count_sit) / 2) <<