linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 1/6] f2fs-tools: add packed attribute for struct f2fs_super_block
@ 2023-05-05 10:02 Chao Yu
  2023-05-05 10:02 ` [f2fs-dev] [PATCH 2/6] f2fs-tools: rename i_padding to i_compress_flag Chao Yu
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Chao Yu @ 2023-05-05 10:02 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel

Otherwise, it may trigger static assert below when the structure
updates.

static_assert(sizeof(struct f2fs_super_block) == 3072, "")

Signed-off-by: Chao Yu <chao@kernel.org>
---
 include/f2fs_fs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 6948814..c71b59d 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -849,7 +849,7 @@ struct f2fs_super_block {
 	__u8 s_errors[MAX_F2FS_ERRORS];		/* reason of image corrupts */
 	__u8 reserved[258];		/* valid reserved region */
 	__le32 crc;			/* checksum of superblock */
-};
+} __attribute__((packed));
 
 static_assert(sizeof(struct f2fs_super_block) == 3072, "");
 
-- 
2.25.1



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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [f2fs-dev] [PATCH 2/6] f2fs-tools: rename i_padding to i_compress_flag
  2023-05-05 10:02 [f2fs-dev] [PATCH 1/6] f2fs-tools: add packed attribute for struct f2fs_super_block Chao Yu
@ 2023-05-05 10:02 ` Chao Yu
  2023-05-05 10:02 ` [f2fs-dev] [PATCH 3/6] f2fs-tools: fix typo in f2fs_inode structure Chao Yu
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2023-05-05 10:02 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel

Commit b28f047b28c5 ("f2fs: compress: support chksum") renames i_padding
to i_compress_flag in struct f2fs_inode, adjust f2fs-tools' codes as well.

Signed-off-by: Chao Yu <chao@kernel.org>
---
 fsck/mount.c       | 2 +-
 include/f2fs_fs.h  | 5 ++++-
 mkfs/f2fs_format.c | 4 ++--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index df0314d..2e1634f 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -304,7 +304,7 @@ void print_inode_info(struct f2fs_sb_info *sbi,
 			DISP_u64(inode, i_compr_blocks);
 			DISP_u32(inode, i_compress_algrithm);
 			DISP_u32(inode, i_log_cluster_size);
-			DISP_u32(inode, i_padding);
+			DISP_u32(inode, i_compress_flag);
 		}
 	}
 
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index c71b59d..7ad1c40 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -1076,7 +1076,10 @@ struct f2fs_inode {
 			__le64 i_compr_blocks;	/* # of compressed blocks */
 			__u8 i_compress_algrithm;	/* compress algrithm */
 			__u8 i_log_cluster_size;	/* log of cluster size */
-			__le16 i_padding;		/* padding */
+			__le16 i_compress_flag;		/* compress flag */
+						/* 0 bit: chksum flag
+						 * [8,15] bits: compress level
+						 */
 			__le32 i_extra_end[0];	/* for attribute size calculation */
 		} __attribute__((packed));
 		__le32 i_addr[DEF_ADDRS_PER_INODE];	/* Pointers to data blocks */
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index d3bb622..11804eb 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -1289,7 +1289,7 @@ static int f2fs_write_root_inode(void)
 	if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) {
 		raw_node->i.i_compress_algrithm = 0;
 		raw_node->i.i_log_cluster_size = 0;
-		raw_node->i.i_padding = 0;
+		raw_node->i.i_compress_flag = 0;
 	}
 
 	data_blk_nor = get_sb(main_blkaddr) +
@@ -1611,7 +1611,7 @@ static int f2fs_write_lpf_inode(void)
 	if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) {
 		raw_node->i.i_compress_algrithm = 0;
 		raw_node->i.i_log_cluster_size = 0;
-		raw_node->i.i_padding = 0;
+		raw_node->i.i_compress_flag = 0;
 	}
 
 	data_blk_nor = f2fs_add_default_dentry_lpf();
-- 
2.25.1



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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [f2fs-dev] [PATCH 3/6] f2fs-tools: fix typo in f2fs_inode structure
  2023-05-05 10:02 [f2fs-dev] [PATCH 1/6] f2fs-tools: add packed attribute for struct f2fs_super_block Chao Yu
  2023-05-05 10:02 ` [f2fs-dev] [PATCH 2/6] f2fs-tools: rename i_padding to i_compress_flag Chao Yu
@ 2023-05-05 10:02 ` Chao Yu
  2023-05-05 10:02 ` [f2fs-dev] [PATCH 4/6] f2fs-tools: add DISP_u8() macro Chao Yu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2023-05-05 10:02 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel

:%s/i_compress_algrithm/i_compress_algorithm/g

Signed-off-by: Chao Yu <chao@kernel.org>
---
 fsck/mount.c       | 2 +-
 fsck/segment.c     | 2 +-
 include/f2fs_fs.h  | 2 +-
 mkfs/f2fs_format.c | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index 2e1634f..b314756 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -302,7 +302,7 @@ void print_inode_info(struct f2fs_sb_info *sbi,
 		}
 		if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) {
 			DISP_u64(inode, i_compr_blocks);
-			DISP_u32(inode, i_compress_algrithm);
+			DISP_u32(inode, i_compress_algorithm);
 			DISP_u32(inode, i_log_cluster_size);
 			DISP_u32(inode, i_compress_flag);
 		}
diff --git a/fsck/segment.c b/fsck/segment.c
index 0307bdd..0ca8b5a 100644
--- a/fsck/segment.c
+++ b/fsck/segment.c
@@ -633,7 +633,7 @@ int f2fs_build_file(struct f2fs_sb_info *sbi, struct dentry *de)
 		get_node_info(sbi, de->ino, &ni);
 		ASSERT(dev_read_block(node_blk, ni.blk_addr) >= 0);
 		/* update inode meta */
-		node_blk->i.i_compress_algrithm = c.compress.alg;
+		node_blk->i.i_compress_algorithm = c.compress.alg;
 		node_blk->i.i_log_cluster_size =
 				c.compress.cc.log_cluster_size;
 		node_blk->i.i_flags = cpu_to_le32(F2FS_COMPR_FL);
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 7ad1c40..dca4cd8 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -1074,7 +1074,7 @@ struct f2fs_inode {
 			__le64 i_crtime;	/* creation time */
 			__le32 i_crtime_nsec;	/* creation time in nano scale */
 			__le64 i_compr_blocks;	/* # of compressed blocks */
-			__u8 i_compress_algrithm;	/* compress algrithm */
+			__u8 i_compress_algorithm;	/* compress algorithm */
 			__u8 i_log_cluster_size;	/* log of cluster size */
 			__le16 i_compress_flag;		/* compress flag */
 						/* 0 bit: chksum flag
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 11804eb..e8c9675 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -1287,7 +1287,7 @@ static int f2fs_write_root_inode(void)
 	}
 
 	if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) {
-		raw_node->i.i_compress_algrithm = 0;
+		raw_node->i.i_compress_algorithm = 0;
 		raw_node->i.i_log_cluster_size = 0;
 		raw_node->i.i_compress_flag = 0;
 	}
@@ -1609,7 +1609,7 @@ static int f2fs_write_lpf_inode(void)
 	}
 
 	if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) {
-		raw_node->i.i_compress_algrithm = 0;
+		raw_node->i.i_compress_algorithm = 0;
 		raw_node->i.i_log_cluster_size = 0;
 		raw_node->i.i_compress_flag = 0;
 	}
-- 
2.25.1



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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [f2fs-dev] [PATCH 4/6] f2fs-tools: add DISP_u8() macro
  2023-05-05 10:02 [f2fs-dev] [PATCH 1/6] f2fs-tools: add packed attribute for struct f2fs_super_block Chao Yu
  2023-05-05 10:02 ` [f2fs-dev] [PATCH 2/6] f2fs-tools: rename i_padding to i_compress_flag Chao Yu
  2023-05-05 10:02 ` [f2fs-dev] [PATCH 3/6] f2fs-tools: fix typo in f2fs_inode structure Chao Yu
@ 2023-05-05 10:02 ` Chao Yu
  2023-05-05 10:02 ` [f2fs-dev] [PATCH 5/6] f2fs-tools: print more raw sb info Chao Yu
  2023-05-05 10:02 ` [f2fs-dev] [PATCH 6/6] f2fs-tools: use f2fs_init_inode() to clean up codes Chao Yu
  4 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2023-05-05 10:02 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel

Introduce DISP_u8(), and use DISP_u16() and DISP_u8() to print below fields:
- i_compress_algorithm
- i_log_cluster_size
- i_compress_flag

Signed-off-by: Chao Yu <chao@kernel.org>
---
 fsck/mount.c      |  6 +++---
 include/f2fs_fs.h | 11 +++++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index b314756..5e475a3 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -302,9 +302,9 @@ void print_inode_info(struct f2fs_sb_info *sbi,
 		}
 		if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) {
 			DISP_u64(inode, i_compr_blocks);
-			DISP_u32(inode, i_compress_algorithm);
-			DISP_u32(inode, i_log_cluster_size);
-			DISP_u32(inode, i_compress_flag);
+			DISP_u8(inode, i_compress_algorithm);
+			DISP_u8(inode, i_log_cluster_size);
+			DISP_u16(inode, i_compress_flag);
 		}
 	}
 
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index dca4cd8..e5d5d13 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -282,6 +282,17 @@ static inline uint64_t bswap_64(uint64_t val)
 		printf("%-30s" fmt, #member, ((ptr)->member));	\
 	} while (0)
 
+#define DISP_u8(ptr, member)						\
+	do {								\
+		assert(sizeof((ptr)->member) == 1);			\
+		if (c.layout)						\
+			printf("%-30s %u\n",				\
+			#member":", ((ptr)->member));			\
+		else							\
+			printf("%-30s" "\t\t[0x%8x : %u]\n",		\
+			#member, ((ptr)->member), ((ptr)->member));	\
+	} while (0)
+
 #define DISP_u16(ptr, member)						\
 	do {								\
 		assert(sizeof((ptr)->member) == 2);			\
-- 
2.25.1



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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [f2fs-dev] [PATCH 5/6] f2fs-tools: print more raw sb info
  2023-05-05 10:02 [f2fs-dev] [PATCH 1/6] f2fs-tools: add packed attribute for struct f2fs_super_block Chao Yu
                   ` (2 preceding siblings ...)
  2023-05-05 10:02 ` [f2fs-dev] [PATCH 4/6] f2fs-tools: add DISP_u8() macro Chao Yu
@ 2023-05-05 10:02 ` Chao Yu
  2023-05-05 10:02 ` [f2fs-dev] [PATCH 6/6] f2fs-tools: use f2fs_init_inode() to clean up codes Chao Yu
  4 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2023-05-05 10:02 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel

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 <chao@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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [f2fs-dev] [PATCH 6/6] f2fs-tools: use f2fs_init_inode() to clean up codes
  2023-05-05 10:02 [f2fs-dev] [PATCH 1/6] f2fs-tools: add packed attribute for struct f2fs_super_block Chao Yu
                   ` (3 preceding siblings ...)
  2023-05-05 10:02 ` [f2fs-dev] [PATCH 5/6] f2fs-tools: print more raw sb info Chao Yu
@ 2023-05-05 10:02 ` Chao Yu
  2023-05-08 19:42   ` Jaegeuk Kim
  4 siblings, 1 reply; 8+ messages in thread
From: Chao Yu @ 2023-05-05 10:02 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel

No logic changes.

Signed-off-by: Chao Yu <chao@kernel.org>
---
 fsck/node.c        |   7 ++-
 include/f2fs_fs.h  |  36 +++++++++-----
 mkfs/f2fs_format.c | 118 ++++++++-------------------------------------
 3 files changed, 50 insertions(+), 111 deletions(-)

diff --git a/fsck/node.c b/fsck/node.c
index c3e383b..9ce8a72 100644
--- a/fsck/node.c
+++ b/fsck/node.c
@@ -57,7 +57,12 @@ int f2fs_rebuild_qf_inode(struct f2fs_sb_info *sbi, int qtype)
 		MSG(1, "\tError: Calloc Failed for raw_node!!!\n");
 		return -ENOMEM;
 	}
-	f2fs_init_qf_inode(sb, raw_node, qtype, time(NULL));
+	f2fs_init_inode(sb, raw_node,
+			le32_to_cpu(sb->qf_ino[qtype]), time(NULL), 0x8180);
+
+	raw_node->i.i_size = cpu_to_le64(1024 * 6);
+	raw_node->i.i_blocks = cpu_to_le64(1);
+	raw_node->i.i_flags = FS_IMMUTABLE_FL;
 
 	if (is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG))
 		cp_ver |= (cur_cp_crc(ckpt) << 32);
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 4accade..cab452d 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -1741,20 +1741,16 @@ static inline void show_version(const char *prog)
 #endif
 }
 
-static inline void f2fs_init_qf_inode(struct f2fs_super_block *sb,
-		struct f2fs_node *raw_node, int qtype, time_t mtime)
+static inline void f2fs_init_inode(struct f2fs_super_block *sb,
+		struct f2fs_node *raw_node, nid_t ino, time_t mtime, mode_t mode)
 {
-	raw_node->footer.nid = sb->qf_ino[qtype];
-	raw_node->footer.ino = sb->qf_ino[qtype];
+	raw_node->footer.nid = cpu_to_le32(ino);
+	raw_node->footer.ino = cpu_to_le32(ino);
 	raw_node->footer.cp_ver = cpu_to_le64(1);
-	raw_node->i.i_mode = cpu_to_le16(0x8180);
-	raw_node->i.i_links = cpu_to_le32(1);
+
 	raw_node->i.i_uid = cpu_to_le32(c.root_uid);
 	raw_node->i.i_gid = cpu_to_le32(c.root_gid);
 
-	raw_node->i.i_size = cpu_to_le64(1024 * 6); /* Hard coded */
-	raw_node->i.i_blocks = cpu_to_le64(1);
-
 	raw_node->i.i_atime = cpu_to_le32(mtime);
 	raw_node->i.i_atime_nsec = 0;
 	raw_node->i.i_ctime = cpu_to_le32(mtime);
@@ -1763,9 +1759,15 @@ static inline void f2fs_init_qf_inode(struct f2fs_super_block *sb,
 	raw_node->i.i_mtime_nsec = 0;
 	raw_node->i.i_generation = 0;
 	raw_node->i.i_xattr_nid = 0;
-	raw_node->i.i_flags = FS_IMMUTABLE_FL;
-	raw_node->i.i_current_depth = cpu_to_le32(0);
+	raw_node->i.i_flags = 0;
+	raw_node->i.i_current_depth = cpu_to_le32(S_ISDIR(mode) ? 1 : 0);
 	raw_node->i.i_dir_level = DEF_DIR_LEVEL;
+	raw_node->i.i_mode = cpu_to_le16(mode);
+	raw_node->i.i_links = cpu_to_le32(S_ISDIR(mode) ? 2 : 1);
+
+	/* for dentry block in directory */
+	raw_node->i.i_size = cpu_to_le64(1 << get_sb(log_blocksize));
+	raw_node->i.i_blocks = cpu_to_le64(2);
 
 	if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) {
 		raw_node->i.i_inline = F2FS_EXTRA_ATTR;
@@ -1775,6 +1777,18 @@ static inline void f2fs_init_qf_inode(struct f2fs_super_block *sb,
 	if (c.feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA))
 		raw_node->i.i_projid = cpu_to_le32(F2FS_DEF_PROJID);
 
+	if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CRTIME)) {
+		raw_node->i.i_crtime = cpu_to_le32(mtime);
+		raw_node->i.i_crtime_nsec = 0;
+	}
+
+	if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) {
+		raw_node->i.i_compr_blocks = 0;
+		raw_node->i.i_compress_algorithm = 0;
+		raw_node->i.i_log_cluster_size = 0;
+		raw_node->i.i_compress_flag = 0;
+	}
+
 	raw_node->i.i_ext.fofs = 0;
 	raw_node->i.i_ext.blk_addr = 0;
 	raw_node->i.i_ext.len = 0;
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 666af45..6d02a57 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -1233,7 +1233,7 @@ static int f2fs_discard_obsolete_dnode(void)
 static int f2fs_write_root_inode(void)
 {
 	struct f2fs_node *raw_node = NULL;
-	uint64_t blk_size_bytes, data_blk_nor;
+	uint64_t data_blk_nor;
 	uint64_t main_area_node_seg_blk_offset = 0;
 
 	raw_node = calloc(F2FS_BLKSIZE, 1);
@@ -1242,65 +1242,21 @@ static int f2fs_write_root_inode(void)
 		return -1;
 	}
 
-	raw_node->footer.nid = sb->root_ino;
-	raw_node->footer.ino = sb->root_ino;
-	raw_node->footer.cp_ver = cpu_to_le64(1);
-	raw_node->footer.next_blkaddr = cpu_to_le32(
-			get_sb(main_blkaddr) +
-			c.cur_seg[CURSEG_HOT_NODE] *
-			c.blks_per_seg + 1);
+	f2fs_init_inode(sb, raw_node, le32_to_cpu(sb->root_ino),
+						mkfs_time, 0x41ed);
 
-	raw_node->i.i_mode = cpu_to_le16(0x41ed);
 	if (c.lpf_ino)
 		raw_node->i.i_links = cpu_to_le32(3);
-	else
-		raw_node->i.i_links = cpu_to_le32(2);
-	raw_node->i.i_uid = cpu_to_le32(c.root_uid);
-	raw_node->i.i_gid = cpu_to_le32(c.root_gid);
-
-	blk_size_bytes = 1 << get_sb(log_blocksize);
-	raw_node->i.i_size = cpu_to_le64(1 * blk_size_bytes); /* dentry */
-	raw_node->i.i_blocks = cpu_to_le64(2);
-
-	raw_node->i.i_atime = cpu_to_le32(mkfs_time);
-	raw_node->i.i_atime_nsec = 0;
-	raw_node->i.i_ctime = cpu_to_le32(mkfs_time);
-	raw_node->i.i_ctime_nsec = 0;
-	raw_node->i.i_mtime = cpu_to_le32(mkfs_time);
-	raw_node->i.i_mtime_nsec = 0;
-	raw_node->i.i_generation = 0;
-	raw_node->i.i_xattr_nid = 0;
-	raw_node->i.i_flags = 0;
-	raw_node->i.i_current_depth = cpu_to_le32(1);
-	raw_node->i.i_dir_level = DEF_DIR_LEVEL;
-
-	if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) {
-		raw_node->i.i_inline = F2FS_EXTRA_ATTR;
-		raw_node->i.i_extra_isize = cpu_to_le16(calc_extra_isize());
-	}
-
-	if (c.feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA))
-		raw_node->i.i_projid = cpu_to_le32(F2FS_DEF_PROJID);
 
-	if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CRTIME)) {
-		raw_node->i.i_crtime = cpu_to_le32(mkfs_time);
-		raw_node->i.i_crtime_nsec = 0;
-	}
-
-	if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) {
-		raw_node->i.i_compress_algorithm = 0;
-		raw_node->i.i_log_cluster_size = 0;
-		raw_node->i.i_compress_flag = 0;
-	}
+	raw_node->footer.next_blkaddr = cpu_to_le32(
+			get_sb(main_blkaddr) +
+			c.cur_seg[CURSEG_HOT_NODE] *
+			c.blks_per_seg + 1);
 
 	data_blk_nor = get_sb(main_blkaddr) +
 		c.cur_seg[CURSEG_HOT_DATA] * c.blks_per_seg;
 	raw_node->i.i_addr[get_extra_isize(raw_node)] = cpu_to_le32(data_blk_nor);
 
-	raw_node->i.i_ext.fofs = 0;
-	raw_node->i.i_ext.blk_addr = 0;
-	raw_node->i.i_ext.len = 0;
-
 	main_area_node_seg_blk_offset = get_sb(main_blkaddr);
 	main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE] *
 					c.blks_per_seg;
@@ -1403,13 +1359,17 @@ static int f2fs_write_qf_inode(int qtype, int offset)
 		MSG(1, "\tError: Calloc Failed for raw_node!!!\n");
 		return -1;
 	}
-	f2fs_init_qf_inode(sb, raw_node, qtype, mkfs_time);
+	f2fs_init_inode(sb, raw_node,
+			le32_to_cpu(sb->qf_ino[qtype]), mkfs_time, 0x8180);
+
+	raw_node->i.i_size = cpu_to_le64(1024 * 6);
+	raw_node->i.i_blocks = cpu_to_le64(1 + QUOTA_DATA(qtype));
+	raw_node->i.i_flags = FS_IMMUTABLE_FL;
 
 	raw_node->footer.next_blkaddr = cpu_to_le32(
 			get_sb(main_blkaddr) +
 			c.cur_seg[CURSEG_HOT_NODE] *
 			c.blks_per_seg + 1 + qtype + 1);
-	raw_node->i.i_blocks = cpu_to_le64(1 + QUOTA_DATA(qtype));
 
 	data_blk_nor = get_sb(main_blkaddr) +
 		c.cur_seg[CURSEG_HOT_DATA] * c.blks_per_seg + 1
@@ -1552,7 +1512,7 @@ static block_t f2fs_add_default_dentry_lpf(void)
 static int f2fs_write_lpf_inode(void)
 {
 	struct f2fs_node *raw_node;
-	uint64_t blk_size_bytes, main_area_node_seg_blk_offset;
+	uint64_t main_area_node_seg_blk_offset;
 	block_t data_blk_nor;
 	int err = 0;
 
@@ -1564,56 +1524,16 @@ static int f2fs_write_lpf_inode(void)
 		return -1;
 	}
 
-	raw_node->footer.nid = cpu_to_le32(c.lpf_ino);
-	raw_node->footer.ino = raw_node->footer.nid;
-	raw_node->footer.cp_ver = cpu_to_le64(1);
-	raw_node->footer.next_blkaddr = cpu_to_le32(
-			get_sb(main_blkaddr) +
-			c.cur_seg[CURSEG_HOT_NODE] * c.blks_per_seg +
-			1 + c.quota_inum + 1);
-
-	raw_node->i.i_mode = cpu_to_le16(0x41c0); /* 0700 */
-	raw_node->i.i_links = cpu_to_le32(2);
-	raw_node->i.i_uid = cpu_to_le32(c.root_uid);
-	raw_node->i.i_gid = cpu_to_le32(c.root_gid);
+	f2fs_init_inode(sb, raw_node, c.lpf_ino, mkfs_time, 0x41c0);
 
-	blk_size_bytes = 1 << get_sb(log_blocksize);
-	raw_node->i.i_size = cpu_to_le64(1 * blk_size_bytes);
-	raw_node->i.i_blocks = cpu_to_le64(2);
-
-	raw_node->i.i_atime = cpu_to_le32(mkfs_time);
-	raw_node->i.i_atime_nsec = 0;
-	raw_node->i.i_ctime = cpu_to_le32(mkfs_time);
-	raw_node->i.i_ctime_nsec = 0;
-	raw_node->i.i_mtime = cpu_to_le32(mkfs_time);
-	raw_node->i.i_mtime_nsec = 0;
-	raw_node->i.i_generation = 0;
-	raw_node->i.i_xattr_nid = 0;
-	raw_node->i.i_flags = 0;
 	raw_node->i.i_pino = le32_to_cpu(sb->root_ino);
 	raw_node->i.i_namelen = le32_to_cpu(strlen(LPF));
 	memcpy(raw_node->i.i_name, LPF, strlen(LPF));
-	raw_node->i.i_current_depth = cpu_to_le32(1);
-	raw_node->i.i_dir_level = DEF_DIR_LEVEL;
 
-	if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) {
-		raw_node->i.i_inline = F2FS_EXTRA_ATTR;
-		raw_node->i.i_extra_isize = cpu_to_le16(calc_extra_isize());
-	}
-
-	if (c.feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA))
-		raw_node->i.i_projid = cpu_to_le32(F2FS_DEF_PROJID);
-
-	if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CRTIME)) {
-		raw_node->i.i_crtime = cpu_to_le32(mkfs_time);
-		raw_node->i.i_crtime_nsec = 0;
-	}
-
-	if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) {
-		raw_node->i.i_compress_algorithm = 0;
-		raw_node->i.i_log_cluster_size = 0;
-		raw_node->i.i_compress_flag = 0;
-	}
+	raw_node->footer.next_blkaddr = cpu_to_le32(
+			get_sb(main_blkaddr) +
+			c.cur_seg[CURSEG_HOT_NODE] * c.blks_per_seg +
+			1 + c.quota_inum + 1);
 
 	data_blk_nor = f2fs_add_default_dentry_lpf();
 	if (data_blk_nor == 0) {
-- 
2.25.1



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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [f2fs-dev] [PATCH 6/6] f2fs-tools: use f2fs_init_inode() to clean up codes
  2023-05-05 10:02 ` [f2fs-dev] [PATCH 6/6] f2fs-tools: use f2fs_init_inode() to clean up codes Chao Yu
@ 2023-05-08 19:42   ` Jaegeuk Kim
  2023-05-17  2:02     ` Chao Yu
  0 siblings, 1 reply; 8+ messages in thread
From: Jaegeuk Kim @ 2023-05-08 19:42 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-f2fs-devel

Added this to avoid android build failure.

--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -23,6 +23,7 @@

 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/stat.h>
 #include <stddef.h>
 #include <string.h>
 #include <time.h>

On 05/05, Chao Yu wrote:
> No logic changes.
> 
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
>  fsck/node.c        |   7 ++-
>  include/f2fs_fs.h  |  36 +++++++++-----
>  mkfs/f2fs_format.c | 118 ++++++++-------------------------------------
>  3 files changed, 50 insertions(+), 111 deletions(-)
> 
> diff --git a/fsck/node.c b/fsck/node.c
> index c3e383b..9ce8a72 100644
> --- a/fsck/node.c
> +++ b/fsck/node.c
> @@ -57,7 +57,12 @@ int f2fs_rebuild_qf_inode(struct f2fs_sb_info *sbi, int qtype)
>  		MSG(1, "\tError: Calloc Failed for raw_node!!!\n");
>  		return -ENOMEM;
>  	}
> -	f2fs_init_qf_inode(sb, raw_node, qtype, time(NULL));
> +	f2fs_init_inode(sb, raw_node,
> +			le32_to_cpu(sb->qf_ino[qtype]), time(NULL), 0x8180);
> +
> +	raw_node->i.i_size = cpu_to_le64(1024 * 6);
> +	raw_node->i.i_blocks = cpu_to_le64(1);
> +	raw_node->i.i_flags = FS_IMMUTABLE_FL;
>  
>  	if (is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG))
>  		cp_ver |= (cur_cp_crc(ckpt) << 32);
> diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
> index 4accade..cab452d 100644
> --- a/include/f2fs_fs.h
> +++ b/include/f2fs_fs.h
> @@ -1741,20 +1741,16 @@ static inline void show_version(const char *prog)
>  #endif
>  }
>  
> -static inline void f2fs_init_qf_inode(struct f2fs_super_block *sb,
> -		struct f2fs_node *raw_node, int qtype, time_t mtime)
> +static inline void f2fs_init_inode(struct f2fs_super_block *sb,
> +		struct f2fs_node *raw_node, nid_t ino, time_t mtime, mode_t mode)
>  {
> -	raw_node->footer.nid = sb->qf_ino[qtype];
> -	raw_node->footer.ino = sb->qf_ino[qtype];
> +	raw_node->footer.nid = cpu_to_le32(ino);
> +	raw_node->footer.ino = cpu_to_le32(ino);
>  	raw_node->footer.cp_ver = cpu_to_le64(1);
> -	raw_node->i.i_mode = cpu_to_le16(0x8180);
> -	raw_node->i.i_links = cpu_to_le32(1);
> +
>  	raw_node->i.i_uid = cpu_to_le32(c.root_uid);
>  	raw_node->i.i_gid = cpu_to_le32(c.root_gid);
>  
> -	raw_node->i.i_size = cpu_to_le64(1024 * 6); /* Hard coded */
> -	raw_node->i.i_blocks = cpu_to_le64(1);
> -
>  	raw_node->i.i_atime = cpu_to_le32(mtime);
>  	raw_node->i.i_atime_nsec = 0;
>  	raw_node->i.i_ctime = cpu_to_le32(mtime);
> @@ -1763,9 +1759,15 @@ static inline void f2fs_init_qf_inode(struct f2fs_super_block *sb,
>  	raw_node->i.i_mtime_nsec = 0;
>  	raw_node->i.i_generation = 0;
>  	raw_node->i.i_xattr_nid = 0;
> -	raw_node->i.i_flags = FS_IMMUTABLE_FL;
> -	raw_node->i.i_current_depth = cpu_to_le32(0);
> +	raw_node->i.i_flags = 0;
> +	raw_node->i.i_current_depth = cpu_to_le32(S_ISDIR(mode) ? 1 : 0);
>  	raw_node->i.i_dir_level = DEF_DIR_LEVEL;
> +	raw_node->i.i_mode = cpu_to_le16(mode);
> +	raw_node->i.i_links = cpu_to_le32(S_ISDIR(mode) ? 2 : 1);
> +
> +	/* for dentry block in directory */
> +	raw_node->i.i_size = cpu_to_le64(1 << get_sb(log_blocksize));
> +	raw_node->i.i_blocks = cpu_to_le64(2);
>  
>  	if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) {
>  		raw_node->i.i_inline = F2FS_EXTRA_ATTR;
> @@ -1775,6 +1777,18 @@ static inline void f2fs_init_qf_inode(struct f2fs_super_block *sb,
>  	if (c.feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA))
>  		raw_node->i.i_projid = cpu_to_le32(F2FS_DEF_PROJID);
>  
> +	if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CRTIME)) {
> +		raw_node->i.i_crtime = cpu_to_le32(mtime);
> +		raw_node->i.i_crtime_nsec = 0;
> +	}
> +
> +	if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) {
> +		raw_node->i.i_compr_blocks = 0;
> +		raw_node->i.i_compress_algorithm = 0;
> +		raw_node->i.i_log_cluster_size = 0;
> +		raw_node->i.i_compress_flag = 0;
> +	}
> +
>  	raw_node->i.i_ext.fofs = 0;
>  	raw_node->i.i_ext.blk_addr = 0;
>  	raw_node->i.i_ext.len = 0;
> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
> index 666af45..6d02a57 100644
> --- a/mkfs/f2fs_format.c
> +++ b/mkfs/f2fs_format.c
> @@ -1233,7 +1233,7 @@ static int f2fs_discard_obsolete_dnode(void)
>  static int f2fs_write_root_inode(void)
>  {
>  	struct f2fs_node *raw_node = NULL;
> -	uint64_t blk_size_bytes, data_blk_nor;
> +	uint64_t data_blk_nor;
>  	uint64_t main_area_node_seg_blk_offset = 0;
>  
>  	raw_node = calloc(F2FS_BLKSIZE, 1);
> @@ -1242,65 +1242,21 @@ static int f2fs_write_root_inode(void)
>  		return -1;
>  	}
>  
> -	raw_node->footer.nid = sb->root_ino;
> -	raw_node->footer.ino = sb->root_ino;
> -	raw_node->footer.cp_ver = cpu_to_le64(1);
> -	raw_node->footer.next_blkaddr = cpu_to_le32(
> -			get_sb(main_blkaddr) +
> -			c.cur_seg[CURSEG_HOT_NODE] *
> -			c.blks_per_seg + 1);
> +	f2fs_init_inode(sb, raw_node, le32_to_cpu(sb->root_ino),
> +						mkfs_time, 0x41ed);
>  
> -	raw_node->i.i_mode = cpu_to_le16(0x41ed);
>  	if (c.lpf_ino)
>  		raw_node->i.i_links = cpu_to_le32(3);
> -	else
> -		raw_node->i.i_links = cpu_to_le32(2);
> -	raw_node->i.i_uid = cpu_to_le32(c.root_uid);
> -	raw_node->i.i_gid = cpu_to_le32(c.root_gid);
> -
> -	blk_size_bytes = 1 << get_sb(log_blocksize);
> -	raw_node->i.i_size = cpu_to_le64(1 * blk_size_bytes); /* dentry */
> -	raw_node->i.i_blocks = cpu_to_le64(2);
> -
> -	raw_node->i.i_atime = cpu_to_le32(mkfs_time);
> -	raw_node->i.i_atime_nsec = 0;
> -	raw_node->i.i_ctime = cpu_to_le32(mkfs_time);
> -	raw_node->i.i_ctime_nsec = 0;
> -	raw_node->i.i_mtime = cpu_to_le32(mkfs_time);
> -	raw_node->i.i_mtime_nsec = 0;
> -	raw_node->i.i_generation = 0;
> -	raw_node->i.i_xattr_nid = 0;
> -	raw_node->i.i_flags = 0;
> -	raw_node->i.i_current_depth = cpu_to_le32(1);
> -	raw_node->i.i_dir_level = DEF_DIR_LEVEL;
> -
> -	if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) {
> -		raw_node->i.i_inline = F2FS_EXTRA_ATTR;
> -		raw_node->i.i_extra_isize = cpu_to_le16(calc_extra_isize());
> -	}
> -
> -	if (c.feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA))
> -		raw_node->i.i_projid = cpu_to_le32(F2FS_DEF_PROJID);
>  
> -	if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CRTIME)) {
> -		raw_node->i.i_crtime = cpu_to_le32(mkfs_time);
> -		raw_node->i.i_crtime_nsec = 0;
> -	}
> -
> -	if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) {
> -		raw_node->i.i_compress_algorithm = 0;
> -		raw_node->i.i_log_cluster_size = 0;
> -		raw_node->i.i_compress_flag = 0;
> -	}
> +	raw_node->footer.next_blkaddr = cpu_to_le32(
> +			get_sb(main_blkaddr) +
> +			c.cur_seg[CURSEG_HOT_NODE] *
> +			c.blks_per_seg + 1);
>  
>  	data_blk_nor = get_sb(main_blkaddr) +
>  		c.cur_seg[CURSEG_HOT_DATA] * c.blks_per_seg;
>  	raw_node->i.i_addr[get_extra_isize(raw_node)] = cpu_to_le32(data_blk_nor);
>  
> -	raw_node->i.i_ext.fofs = 0;
> -	raw_node->i.i_ext.blk_addr = 0;
> -	raw_node->i.i_ext.len = 0;
> -
>  	main_area_node_seg_blk_offset = get_sb(main_blkaddr);
>  	main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE] *
>  					c.blks_per_seg;
> @@ -1403,13 +1359,17 @@ static int f2fs_write_qf_inode(int qtype, int offset)
>  		MSG(1, "\tError: Calloc Failed for raw_node!!!\n");
>  		return -1;
>  	}
> -	f2fs_init_qf_inode(sb, raw_node, qtype, mkfs_time);
> +	f2fs_init_inode(sb, raw_node,
> +			le32_to_cpu(sb->qf_ino[qtype]), mkfs_time, 0x8180);
> +
> +	raw_node->i.i_size = cpu_to_le64(1024 * 6);
> +	raw_node->i.i_blocks = cpu_to_le64(1 + QUOTA_DATA(qtype));
> +	raw_node->i.i_flags = FS_IMMUTABLE_FL;
>  
>  	raw_node->footer.next_blkaddr = cpu_to_le32(
>  			get_sb(main_blkaddr) +
>  			c.cur_seg[CURSEG_HOT_NODE] *
>  			c.blks_per_seg + 1 + qtype + 1);
> -	raw_node->i.i_blocks = cpu_to_le64(1 + QUOTA_DATA(qtype));
>  
>  	data_blk_nor = get_sb(main_blkaddr) +
>  		c.cur_seg[CURSEG_HOT_DATA] * c.blks_per_seg + 1
> @@ -1552,7 +1512,7 @@ static block_t f2fs_add_default_dentry_lpf(void)
>  static int f2fs_write_lpf_inode(void)
>  {
>  	struct f2fs_node *raw_node;
> -	uint64_t blk_size_bytes, main_area_node_seg_blk_offset;
> +	uint64_t main_area_node_seg_blk_offset;
>  	block_t data_blk_nor;
>  	int err = 0;
>  
> @@ -1564,56 +1524,16 @@ static int f2fs_write_lpf_inode(void)
>  		return -1;
>  	}
>  
> -	raw_node->footer.nid = cpu_to_le32(c.lpf_ino);
> -	raw_node->footer.ino = raw_node->footer.nid;
> -	raw_node->footer.cp_ver = cpu_to_le64(1);
> -	raw_node->footer.next_blkaddr = cpu_to_le32(
> -			get_sb(main_blkaddr) +
> -			c.cur_seg[CURSEG_HOT_NODE] * c.blks_per_seg +
> -			1 + c.quota_inum + 1);
> -
> -	raw_node->i.i_mode = cpu_to_le16(0x41c0); /* 0700 */
> -	raw_node->i.i_links = cpu_to_le32(2);
> -	raw_node->i.i_uid = cpu_to_le32(c.root_uid);
> -	raw_node->i.i_gid = cpu_to_le32(c.root_gid);
> +	f2fs_init_inode(sb, raw_node, c.lpf_ino, mkfs_time, 0x41c0);
>  
> -	blk_size_bytes = 1 << get_sb(log_blocksize);
> -	raw_node->i.i_size = cpu_to_le64(1 * blk_size_bytes);
> -	raw_node->i.i_blocks = cpu_to_le64(2);
> -
> -	raw_node->i.i_atime = cpu_to_le32(mkfs_time);
> -	raw_node->i.i_atime_nsec = 0;
> -	raw_node->i.i_ctime = cpu_to_le32(mkfs_time);
> -	raw_node->i.i_ctime_nsec = 0;
> -	raw_node->i.i_mtime = cpu_to_le32(mkfs_time);
> -	raw_node->i.i_mtime_nsec = 0;
> -	raw_node->i.i_generation = 0;
> -	raw_node->i.i_xattr_nid = 0;
> -	raw_node->i.i_flags = 0;
>  	raw_node->i.i_pino = le32_to_cpu(sb->root_ino);
>  	raw_node->i.i_namelen = le32_to_cpu(strlen(LPF));
>  	memcpy(raw_node->i.i_name, LPF, strlen(LPF));
> -	raw_node->i.i_current_depth = cpu_to_le32(1);
> -	raw_node->i.i_dir_level = DEF_DIR_LEVEL;
>  
> -	if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) {
> -		raw_node->i.i_inline = F2FS_EXTRA_ATTR;
> -		raw_node->i.i_extra_isize = cpu_to_le16(calc_extra_isize());
> -	}
> -
> -	if (c.feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA))
> -		raw_node->i.i_projid = cpu_to_le32(F2FS_DEF_PROJID);
> -
> -	if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CRTIME)) {
> -		raw_node->i.i_crtime = cpu_to_le32(mkfs_time);
> -		raw_node->i.i_crtime_nsec = 0;
> -	}
> -
> -	if (c.feature & cpu_to_le32(F2FS_FEATURE_COMPRESSION)) {
> -		raw_node->i.i_compress_algorithm = 0;
> -		raw_node->i.i_log_cluster_size = 0;
> -		raw_node->i.i_compress_flag = 0;
> -	}
> +	raw_node->footer.next_blkaddr = cpu_to_le32(
> +			get_sb(main_blkaddr) +
> +			c.cur_seg[CURSEG_HOT_NODE] * c.blks_per_seg +
> +			1 + c.quota_inum + 1);
>  
>  	data_blk_nor = f2fs_add_default_dentry_lpf();
>  	if (data_blk_nor == 0) {
> -- 
> 2.25.1


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [f2fs-dev] [PATCH 6/6] f2fs-tools: use f2fs_init_inode() to clean up codes
  2023-05-08 19:42   ` Jaegeuk Kim
@ 2023-05-17  2:02     ` Chao Yu
  0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2023-05-17  2:02 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-f2fs-devel

On 2023/5/9 3:42, Jaegeuk Kim wrote:
> Added this to avoid android build failure.
> 
> --- a/include/f2fs_fs.h
> +++ b/include/f2fs_fs.h
> @@ -23,6 +23,7 @@
> 
>   #include <stdio.h>
>   #include <stdlib.h>
> +#include <sys/stat.h>
>   #include <stddef.h>
>   #include <string.h>
>   #include <time.h>

Thank you for the fix, :)

Thanks,


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-05-17  2:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-05 10:02 [f2fs-dev] [PATCH 1/6] f2fs-tools: add packed attribute for struct f2fs_super_block Chao Yu
2023-05-05 10:02 ` [f2fs-dev] [PATCH 2/6] f2fs-tools: rename i_padding to i_compress_flag Chao Yu
2023-05-05 10:02 ` [f2fs-dev] [PATCH 3/6] f2fs-tools: fix typo in f2fs_inode structure Chao Yu
2023-05-05 10:02 ` [f2fs-dev] [PATCH 4/6] f2fs-tools: add DISP_u8() macro Chao Yu
2023-05-05 10:02 ` [f2fs-dev] [PATCH 5/6] f2fs-tools: print more raw sb info Chao Yu
2023-05-05 10:02 ` [f2fs-dev] [PATCH 6/6] f2fs-tools: use f2fs_init_inode() to clean up codes Chao Yu
2023-05-08 19:42   ` Jaegeuk Kim
2023-05-17  2:02     ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).