Output is as below:

magic                                   [0xf2f52010 : 4076150800]
major_ver                               [0x       1 : 1]
minor_ver                               [0x      10 : 16]
log_sectorsize                          [0x       9 : 9]
log_sectors_per_block                   [0x       3 : 3]
log_blocksize                           [0x       c : 12]
log_blocks_per_seg                      [0x       9 : 9]
segs_per_sec                            [0x       1 : 1]
secs_per_zone                           [0x       1 : 1]
checksum_offset                         [0x       0 : 0]
block_count                             [0x  300000 : 3145728]
section_count                           [0x    17d3 : 6099]
segment_count                           [0x    17ff : 6143]
segment_count_ckpt                      [0x       2 : 2]
segment_count_sit                       [0x       2 : 2]
segment_count_nat                       [0x      1c : 28]
segment_count_ssa                       [0x       c : 12]
segment_count_main                      [0x    17d3 : 6099]
segment0_blkaddr                        [0x     200 : 512]
cp_blkaddr                              [0x     200 : 512]
sit_blkaddr                             [0x     600 : 1536]
nat_blkaddr                             [0x     a00 : 2560]
ssa_blkaddr                             [0x    4200 : 16896]
main_blkaddr                            [0x    5a00 : 23040]
root_ino                                [0x       3 : 3]
node_ino                                [0x       1 : 1]
meta_ino                                [0x       2 : 2]
uuid                                    [f16856a6-8781-422b-adce-d51c0632c94e]
volum_name                              []
extension_count                         [0x      24 : 36]
cold file extentsions
                                        [mp      wm      og      jp      ]
                                        [avi     m4v     m4p     mkv     ]
                                        [mov     webm    wav     m4a     ]
                                        [3gp     opus    flac    gif     ]
                                        [png     svg     webp    jar     ]
                                        [deb     iso     gz      xz      ]
                                        [zst     pdf     pyc     ttc     ]
                                        [ttf     exe     apk     cnt     ]
                                        [exo     odex    vdex    so      ]
hot_ext_count                           [0x       4 : 4]
hot file extentsions
                                        [db      vmdk    vdi     qcow2   ]
cp_payload                              [0x       0 : 0]
version                                 [Linux version 6.3.0+ (gcc (Ubuntu 
9.4.0-1ubuntu1~20.04.1) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #143 SMP 
PREEMPT_DYNAMIC Thu May  4 09:50:08 HKT 2023]
init_version                            [Linux version 6.3.0+ (gcc (Ubuntu 
9.4.0-1ubuntu1~20.04.1) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #143 SMP 
PREEMPT_DYNAMIC Thu May  4 09:50:08 HKT 2023]
feature                                 [0x    21f8 : 8696]
encryption_level                        [0x       0 : 0]
encrypt_pw_salt                         [00000000-0000-0000-0000-000000000000]
qf_ino[USRQUOTA]                        [0x       4 : 4]
qf_ino[GRPQUOTA]                        [0x       5 : 5]
qf_ino[PRJQUOTA]                        [0x       6 : 6]
s_encoding                              [0x       0 : 0]
crc                                     [0x       0 : 0]

Signed-off-by: Chao Yu <c...@kernel.org>
---
 fsck/mount.c       | 105 +++++++++++++++++++++++++++++++++++++++++++--
 include/f2fs_fs.h  |  19 ++++++++
 mkfs/f2fs_format.c |   1 +
 3 files changed, 122 insertions(+), 3 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index 5e475a3..93ad806 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -11,6 +11,7 @@
 #include "fsck.h"
 #include "node.h"
 #include "xattr.h"
+#include "quota.h"
 #include <locale.h>
 #include <stdbool.h>
 #include <time.h>
@@ -20,6 +21,9 @@
 #ifdef HAVE_SYS_ACL_H
 #include <sys/acl.h>
 #endif
+#ifdef HAVE_UUID_UUID_H
+#include <uuid/uuid.h>
+#endif
 
 #ifndef ACL_UNDEFINED_TAG
 #define ACL_UNDEFINED_TAG      (0x00)
@@ -365,6 +369,40 @@ void print_node_info(struct f2fs_sb_info *sbi,
        }
 }
 
+void print_extention_list(struct f2fs_super_block *sb, int cold)
+{
+       int start, end, i;
+
+       if (cold) {
+               DISP_u32(sb, extension_count);
+
+               start = 0;
+               end = le32_to_cpu(sb->extension_count);
+       } else {
+               DISP_u8(sb, hot_ext_count);
+
+               start = le32_to_cpu(sb->extension_count);
+               end = start + sb->hot_ext_count;
+       }
+
+       printf("%s file extentsions\n", cold ? "cold" : "hot");
+
+       for (i = start; i < end; i++) {
+               if (c.layout) {
+                       printf("%-30s %-8.8s\n", "extension_list",
+                                               sb->extension_list[i]);
+               } else {
+                       if (i % 4 == 0)
+                               printf("%-30s\t\t[", "");
+
+                       printf("%-8.8s", sb->extension_list[i]);
+
+                       if (i % 4 == 4 - 1 || i == end - start - 1)
+                               printf("]\n");
+               }
+       }
+}
+
 static void DISP_label(uint16_t *name)
 {
        char buffer[MAX_VOLUME_NAME];
@@ -376,8 +414,14 @@ static void DISP_label(uint16_t *name)
                printf("%-30s" "\t\t[%s]\n", "volum_name", buffer);
 }
 
+void print_sb_debug_info(struct f2fs_super_block *sb);
 void print_raw_sb_info(struct f2fs_super_block *sb)
 {
+#ifdef HAVE_LIBUUID
+       char uuid[40];
+       char encrypt_pw_salt[40];
+#endif
+
        if (c.layout)
                goto printout;
        if (!c.dbg_lv)
@@ -391,8 +435,6 @@ printout:
        DISP_u32(sb, magic);
        DISP_u32(sb, major_ver);
 
-       DISP_label(sb->volume_name);
-
        DISP_u32(sb, minor_ver);
        DISP_u32(sb, log_sectorsize);
        DISP_u32(sb, log_sectors_per_block);
@@ -423,9 +465,39 @@ printout:
        DISP_u32(sb, root_ino);
        DISP_u32(sb, node_ino);
        DISP_u32(sb, meta_ino);
+
+#ifdef HAVE_LIBUUID
+       uuid_unparse(sb->uuid, uuid);
+       DISP_raw_str("%-.36s", uuid);
+#endif
+
+       DISP_label(sb->volume_name);
+
+       print_extention_list(sb, 1);
+       print_extention_list(sb, 0);
+
        DISP_u32(sb, cp_payload);
+
+       DISP_str("%-.252s", sb, version);
+       DISP_str("%-.252s", sb, init_version);
+
+       DISP_u32(sb, feature);
+       DISP_u8(sb, encryption_level);
+
+#ifdef HAVE_LIBUUID
+       uuid_unparse(sb->encrypt_pw_salt, encrypt_pw_salt);
+       DISP_raw_str("%-.36s", encrypt_pw_salt);
+#endif
+
+       DISP_u32(sb, qf_ino[USRQUOTA]);
+       DISP_u32(sb, qf_ino[GRPQUOTA]);
+       DISP_u32(sb, qf_ino[PRJQUOTA]);
+
+       DISP_u16(sb, s_encoding);
        DISP_u32(sb, crc);
-       DISP("%-.252s", sb, version);
+
+       print_sb_debug_info(sb);
+
        printf("\n");
 }
 
@@ -647,6 +719,33 @@ void print_sb_errors(struct f2fs_super_block *sb)
        MSG(0, "\n");
 }
 
+void print_sb_debug_info(struct f2fs_super_block *sb)
+{
+       u8 *reason = sb->s_stop_reason;
+       u8 *errors = sb->s_errors;
+       int i;
+
+       for (i = 0; i < STOP_CP_REASON_MAX; i++) {
+               if (!reason[i])
+                       continue;
+               if (c.layout)
+                       printf("%-30s %s(%s, %d)\n", "", "stop_reason",
+                               stop_reason_str[i], reason[i]);
+               else
+                       printf("%-30s\t\t[%-20s : %u]\n", "",
+                               stop_reason_str[i], reason[i]);
+       }
+
+       for (i = 0; i < ERROR_MAX; i++) {
+               if (!test_bit_le(i, errors))
+                       continue;
+               if (c.layout)
+                       printf("%-30s %s(%s)\n", "", "errors", errors_str[i]);
+               else
+                       printf("%-30s\t\t[%-20s]\n", "", errors_str[i]);
+       }
+}
+
 bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
                                        block_t blkaddr, int type)
 {
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index e5d5d13..4accade 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -282,6 +282,25 @@ static inline uint64_t bswap_64(uint64_t val)
                printf("%-30s" fmt, #member, ((ptr)->member));  \
        } while (0)
 
+#define DISP_raw_str(fmt, member)                                      \
+       do {                                                            \
+               if (c.layout)                                           \
+                       printf("%-30s " fmt "\n", #member":", member);  \
+               else                                                    \
+                       printf("%-30s" "\t\t[" fmt "]\n",               \
+                       #member, member);                               \
+       } while (0)
+
+#define DISP_str(fmt, ptr, member)                                     \
+       do {                                                            \
+               if (c.layout)                                           \
+                       printf("%-30s " fmt "\n",                       \
+                       #member":", ((ptr)->member));                   \
+               else                                                    \
+                       printf("%-30s" "\t\t[" fmt "]\n",               \
+                       #member, ((ptr)->member));                      \
+       } while (0)
+
 #define DISP_u8(ptr, member)                                           \
        do {                                                            \
                assert(sizeof((ptr)->member) == 1);                     \
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index e8c9675..666af45 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -29,6 +29,7 @@
 #ifndef HAVE_LIBUUID
 #define uuid_parse(a, b) -1
 #define uuid_generate(a)
+#define uuid_unparse(a, b) -1
 #endif
 
 #include "quota.h"
-- 
2.25.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to