From: Chao Yu <chao@kernel.org>
To: jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH 2/2] f2fs-tools: reuse feature_table in print_sb_state()
Date: Fri, 26 May 2023 14:11:29 +0800 [thread overview]
Message-ID: <20230526061129.2999437-2-chao@kernel.org> (raw)
In-Reply-To: <20230526061129.2999437-1-chao@kernel.org>
Signed-off-by: Chao Yu <chao@kernel.org>
---
fsck/mount.c | 56 +++++++++++++----------------------------------
include/f2fs_fs.h | 42 +++++++++++++++++++++--------------
2 files changed, 41 insertions(+), 57 deletions(-)
diff --git a/fsck/mount.c b/fsck/mount.c
index 70e8b46..60ad493 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -599,54 +599,28 @@ void print_cp_state(u32 flag)
MSG(0, "\n");
}
+extern struct feature feature_table[];
void print_sb_state(struct f2fs_super_block *sb)
{
unsigned int f = get_sb(feature);
+ char *name;
int i;
MSG(0, "Info: superblock features = %x : ", f);
- if (f & F2FS_FEATURE_ENCRYPT) {
- MSG(0, "%s", " encrypt");
- }
- if (f & F2FS_FEATURE_VERITY) {
- MSG(0, "%s", " verity");
- }
- if (f & F2FS_FEATURE_BLKZONED) {
- MSG(0, "%s", " blkzoned");
- }
- if (f & F2FS_FEATURE_EXTRA_ATTR) {
- MSG(0, "%s", " extra_attr");
- }
- if (f & F2FS_FEATURE_PRJQUOTA) {
- MSG(0, "%s", " project_quota");
- }
- if (f & F2FS_FEATURE_INODE_CHKSUM) {
- MSG(0, "%s", " inode_checksum");
- }
- if (f & F2FS_FEATURE_FLEXIBLE_INLINE_XATTR) {
- MSG(0, "%s", " flexible_inline_xattr");
- }
- if (f & F2FS_FEATURE_QUOTA_INO) {
- MSG(0, "%s", " quota_ino");
- }
- if (f & F2FS_FEATURE_INODE_CRTIME) {
- MSG(0, "%s", " inode_crtime");
- }
- if (f & F2FS_FEATURE_LOST_FOUND) {
- MSG(0, "%s", " lost_found");
- }
- if (f & F2FS_FEATURE_SB_CHKSUM) {
- MSG(0, "%s", " sb_checksum");
- }
- if (f & F2FS_FEATURE_CASEFOLD) {
- MSG(0, "%s", " casefold");
- }
- if (f & F2FS_FEATURE_COMPRESSION) {
- MSG(0, "%s", " compression");
- }
- if (f & F2FS_FEATURE_RO) {
- MSG(0, "%s", " ro");
+
+ for (i = 0; i < 32; i++) {
+ unsigned int bit = 1 << i;
+
+ if (!(f & bit))
+ continue;
+
+ name = feature_name(feature_table, bit);
+ if (!name)
+ continue;
+
+ MSG(0, " %s", name);
}
+
MSG(0, "\n");
MSG(0, "Info: superblock encrypt level = %d, salt = ",
sb->encryption_level);
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 9d35b42..a97c974 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -1811,35 +1811,45 @@ static inline void f2fs_init_inode(struct f2fs_super_block *sb,
struct feature {
char *name;
- u32 mask;
+ u32 mask;
+ u32 settable;
};
#define INIT_FEATURE_TABLE \
struct feature feature_table[] = { \
- { "encrypt", F2FS_FEATURE_ENCRYPT }, \
- { "extra_attr", F2FS_FEATURE_EXTRA_ATTR }, \
- { "project_quota", F2FS_FEATURE_PRJQUOTA }, \
- { "inode_checksum", F2FS_FEATURE_INODE_CHKSUM }, \
- { "flexible_inline_xattr", F2FS_FEATURE_FLEXIBLE_INLINE_XATTR },\
- { "quota", F2FS_FEATURE_QUOTA_INO }, \
- { "inode_crtime", F2FS_FEATURE_INODE_CRTIME }, \
- { "lost_found", F2FS_FEATURE_LOST_FOUND }, \
- { "verity", F2FS_FEATURE_VERITY }, /* reserved */ \
- { "sb_checksum", F2FS_FEATURE_SB_CHKSUM }, \
- { "casefold", F2FS_FEATURE_CASEFOLD }, \
- { "compression", F2FS_FEATURE_COMPRESSION }, \
- { "ro", F2FS_FEATURE_RO}, \
- { NULL, 0x0}, \
+ { "encrypt", F2FS_FEATURE_ENCRYPT, 1}, \
+ { "blkzoned", F2FS_FEATURE_BLKZONED, 0}, \
+ { "extra_attr", F2FS_FEATURE_EXTRA_ATTR, 1}, \
+ { "project_quota", F2FS_FEATURE_PRJQUOTA, 1}, \
+ { "inode_checksum", F2FS_FEATURE_INODE_CHKSUM, 1}, \
+ { "flexible_inline_xattr", F2FS_FEATURE_FLEXIBLE_INLINE_XATTR,1}, \
+ { "quota", F2FS_FEATURE_QUOTA_INO, 1}, \
+ { "inode_crtime", F2FS_FEATURE_INODE_CRTIME, 1}, \
+ { "lost_found", F2FS_FEATURE_LOST_FOUND, 1}, \
+ { "verity", F2FS_FEATURE_VERITY, 1}, \
+ { "sb_checksum", F2FS_FEATURE_SB_CHKSUM, 1}, \
+ { "casefold", F2FS_FEATURE_CASEFOLD, 1}, \
+ { "compression", F2FS_FEATURE_COMPRESSION, 1}, \
+ { "ro", F2FS_FEATURE_RO, 1}, \
+ { NULL, 0x0, 0}, \
};
static inline u32 feature_map(struct feature *table, char *feature)
{
struct feature *p;
- for (p = table; p->name && strcmp(p->name, feature); p++)
+ for (p = table; p->name && p->settable && strcmp(p->name, feature); p++)
;
return p->mask;
}
+static inline char *feature_name(struct feature *table, u32 mask)
+{
+ struct feature *p;
+ for (p = table; p->name && p->mask != mask; p++)
+ ;
+ return p->name;
+}
+
static inline int set_feature_bits(struct feature *table, char *features)
{
u32 mask = feature_map(table, features);
--
2.40.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2023-05-26 6:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 6:11 [f2fs-dev] [PATCH 1/2] f2fs-tools: fix to le32 type variable correctly Chao Yu
2023-05-26 6:11 ` Chao Yu [this message]
2023-05-26 16:25 ` [f2fs-dev] [PATCH 2/2] f2fs-tools: reuse feature_table in print_sb_state() Jaegeuk Kim
2023-05-27 0:05 ` Chao Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230526061129.2999437-2-chao@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).