fsck.f2fs: add "-l" to show the layout information
PATCH 1/1 fsck.f2fs: add "-l" to show the layout information
This patch add an option to print out superblock and checkpoint only.
Signed-off-by Jaegeuk Kim <[email protected]>
--- fsck/main.c | 6 +++++- fsck/mount.c | 15 ++++++++++++--- include/f2fs_fs.h | 30 ++++++++++++++++++++++++------ 3 files changed, 41 insertions(+), 10 deletions(-)
fsck/main.c +5 -1
@@ -71,6 +71,7 @@ void fsck_usage()MSG (0 ," -d debug level [default:0]\n" );MSG (0 ," -f check/fix entire partition\n" );MSG (0 ," -g add default options\n" ); +MSG (0 ," -l show superblock/checkpoint\n" );MSG (0 ," -O feature1[feature2,feature3,...] e.g. \"encrypt\"\n" );MSG (0 ," -p preen mode [default:0 the same as -a [0|1]]\n" );MSG (0 ," -S sparse_mode\n" );
@@ -216,7 +217,7 @@ void f2fs_parse_options(int argc, char *argv[]) }if (!strcmp ("fsck.f2fs" , prog)) { -const char *option_string =":aC:c:m:d:fg:O:p:q:StyV" ; +const char *option_string =":aC:c:m:d:fg:lO:p:q:StyV" ;int opt =0 , val;char *token;struct option long_opt[] = {
@@ -263,6 +264,9 @@ void f2fs_parse_options(int argc, char *argv[])if (!strcmp (optarg,"android" )) c.defset =CONF_ANDROID ;break ; +case 'l' : + c.layout =1 ; +break ;case 'O' :if (parse_feature (feature_table, optarg))fsck_usage ();
fsck/mount.c +12 -3
@@ -369,11 +369,16 @@ static void DISP_label(u_int16_t *name)char buffer[MAX_VOLUME_NAME ];utf16_to_utf8 (buffer, name,MAX_VOLUME_NAME ,MAX_VOLUME_NAME ); -printf ("%-30s" "\t\t[%s]\n" ,"volum_name" , buffer); +if (c.layout) +printf ("%-30s %s\n" ,"Filesystem volume name:" , buffer); +else +printf ("%-30s" "\t\t[%s]\n" ,"volum_name" , buffer); }void print_raw_sb_info (struct f2fs_super_block *sb) { +if (c.layout) + goto printout;if (!c.dbg_lv)return ;
@@ -381,7 +386,7 @@ void print_raw_sb_info(struct f2fs_super_block *sb)printf ("+--------------------------------------------------------+\n" );printf ("| Super block |\n" );printf ("+--------------------------------------------------------+\n" ); - +printout:DISP_u32 (sb, magic);DISP_u32 (sb, major_ver);
@@ -427,6 +432,8 @@ void print_ckpt_info(struct f2fs_sb_info *sbi) {struct f2fs_checkpoint *cp =F2FS_CKPT (sbi); +if (c.layout) + goto printout;if (!c.dbg_lv)return ;
@@ -434,7 +441,7 @@ void print_ckpt_info(struct f2fs_sb_info *sbi)printf ("+--------------------------------------------------------+\n" );printf ("| Checkpoint |\n" );printf ("+--------------------------------------------------------+\n" ); - +printout:DISP_u64 (cp, checkpoint_ver);DISP_u64 (cp, user_block_count);DISP_u64 (cp, valid_block_count);
@@ -3549,6 +3556,8 @@ int f2fs_do_mount(struct f2fs_sb_info *sbi)if (get_cp (ckpt_flags) &CP_QUOTA_NEED_FSCK_FLAG ) c.fix_on =1 ; } +if (c.layout) +return 1 ;if (tune_sb_features (sbi))return -1 ;
include/f2fs_fs.h +24 -6
@@ -239,14 +239,14 @@ static inline uint64_t bswap_64(uint64_t val)#define MSG (n, fmt, ...) \ do { \ - if (c.dbg_lv >= n) { \ + if (c.dbg_lv >= n && !c.layout) { \ printf(fmt, ##__VA_ARGS__); \ } \ } while (0)#define DBG (n, fmt, ...) \ do { \ - if (c.dbg_lv >= n) { \ + if (c.dbg_lv >= n && !c.layout) { \ printf("[%s:%4d] " fmt, \ __func__, __LINE__, ##__VA_ARGS__); \ } \
@@ -261,7 +261,11 @@ static inline uint64_t bswap_64(uint64_t val)#define DISP_u16 (ptr, member) \ do { \ assert(sizeof((ptr)->member) == 2); \ - printf("%-30s" "\t\t[0x%8x : %u]\n", \ + if (c.layout) \ + printf("%-30s %u\n", \ + #member":", le16_to_cpu(((ptr)->member))); \ + else \ + printf("%-30s" "\t\t[0x%8x : %u]\n", \ #member, le16_to_cpu(((ptr)->member)), \ le16_to_cpu(((ptr)->member))); \ } while (0)
@@ -269,7 +273,11 @@ static inline uint64_t bswap_64(uint64_t val)#define DISP_u32 (ptr, member) \ do { \ assert(sizeof((ptr)->member) <= 4); \ - printf("%-30s" "\t\t[0x%8x : %u]\n", \ + if (c.layout) \ + printf("%-30s %u\n", \ + #member":", le32_to_cpu(((ptr)->member))); \ + else \ + printf("%-30s" "\t\t[0x%8x : %u]\n", \ #member, le32_to_cpu(((ptr)->member)), \ le32_to_cpu(((ptr)->member))); \ } while (0)
@@ -277,14 +285,23 @@ static inline uint64_t bswap_64(uint64_t val)#define DISP_u64 (ptr, member) \ do { \ assert(sizeof((ptr)->member) == 8); \ - printf("%-30s" "\t\t[0x%8llx : %llu]\n", \ + if (c.layout) \ + printf("%-30s %llu\n", \ + #member":", le64_to_cpu(((ptr)->member))); \ + else \ + printf("%-30s" "\t\t[0x%8llx : %llu]\n", \ #member, le64_to_cpu(((ptr)->member)), \ le64_to_cpu(((ptr)->member))); \ } while (0)#define DISP_utf (ptr, member) \ do { \ - printf("%-30s" "\t\t[%s]\n", #member, ((ptr)->member)); \ + if (c.layout) \ + printf("%-30s %s\n", #member":", \ + ((ptr)->member)); \ + else \ + printf("%-30s" "\t\t[%s]\n", #member, \ + ((ptr)->member)); \ } while (0)/* Display to buffer */
@@ -471,6 +488,7 @@ struct f2fs_configuration {int bug_nat_bits;int alloc_failed;int auto_fix; +int layout;int quota_fix;int preen_mode;int ro;
Signature · 8 lines
2.31.1.818.g46aad6cb9e-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel