Skip to contentSkip to conversation

tools: Introduce f2fslabel

PATCH Dongwoo Lee 1 participant 1 message May 10, 2021 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

On 08/05/2021 15:28, Chao Yu wrote:>>

Quoted 52 lines

Review

Quoted 10 lines
(quoted diff) +10 -0
+static int verify_sb_chksum(struct f2fs_super_block *sb)
+{
+    if (get_sb(checksum_offset) != SB_CHKSUM_OFFSET)
+        return -1;
+
+    if (f2fs_crc_valid(get_sb(crc), sb, get_sb(checksum_offset)))
+        return -1;
+
+    return 0;
+}

How about reusing existed verify_sb_chksum() to avoid duplicated codes?

Quoted 14 lines
(quoted diff) +14 -0
+
+static void update_superblock(struct f2fs_super_block *sb, int sb_mask)
+{
+    int addr, ret;
+    u_int8_t *buf;
+
+    buf = calloc(F2FS_BLKSIZE, 1);
+    ASSERT(buf);
+
+    if (get_sb(feature) & F2FS_FEATURE_SB_CHKSUM) {
+        set_sb(crc, f2fs_cal_crc32(F2FS_SUPER_MAGIC, sb,
+                       SB_CHKSUM_OFFSET));
+    }
+

Review

Quoted 10 lines
(quoted diff) +10 -0
+    memcpy(buf + F2FS_SUPER_OFFSET, sb, sizeof(*sb));
+    for (addr = SB0_ADDR; addr < SB_MAX_ADDR; addr++) {
+        if (SB_MASK(addr) & sb_mask) {
+            ret = dev_write_block(buf, addr);
+            ASSERT(ret >= 0);
+        }
+    }
+
+    free(buf);
+}

Ditto,

Quoted 13 lines
Quoted 1 line

+

(quoted diff) +12 -0
+int main(int argc, char **argv)
+{
+    if (argc < 2 || argc > 3) {
+        fprintf(stderr, "Usage: f2fslabel device [newlabel]\n");
+        exit(1);
+    }
+
+    f2fs_init_configuration();
+
+    c.devices[0].path = argv[1];
+
+    if (argc == 2)
Quoted 8 lines

Review

Quoted 6 lines

+        print_label();
+    else if (argc == 3)
+        change_label(argv[2]);

(quoted diff) +3 -0
+
+    return 0;
+}

IMO, this can be integrated into fsck/main.c?

Sure, it would rather be simpler than this and duplicated codes would be removed accordingly.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel