From patchwork Fri May 26 06:11:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13256415 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 05C0CC7EE23 for ; Fri, 26 May 2023 06:11:49 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1q2Qfy-0003ve-Om; Fri, 26 May 2023 06:11:47 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q2Qfy-0003vY-3Y for linux-f2fs-devel@lists.sourceforge.net; Fri, 26 May 2023 06:11:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Gvrnf2+VqBOpdmjyh+MYLNt9zIIobbqoyA7a4oa2vdQ=; b=cqJPrJuSR4YXeP7kMcrb0Sdo/d 1DvTymWkrCcmDubEbvz5nfrH4d/WGRYlG2SJYbIYgQ+Q1BxaZKXqupBhoYrW2lYbbP6jL9NlX6NE9 eiplsV3YXXY2xgRBKIepI+lV6D4UAOKcp/Hp5XBY52JikBpL8z/BpC/JKcYFe3RWhmdA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Gvrnf2+VqBOpdmjyh+MYLNt9zIIobbqoyA7a4oa2vdQ=; b=XkzgMGToHYyvOJ//NObMDgU2EK BMQilPTTbinAcArX3gVx1eKMlUgpBIYj1tjwtQvr/I2PAIlRyee+HfIYh6qk6qHzEiiVxm7LCr+Ck 7SL9N9nhDxxn0n9KeF5rKM37azByXEpdGtFyjxw6qWC9p8Wlw0awgpWUY/O5jrEekatM=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1q2Qfx-0002ct-Rn for linux-f2fs-devel@lists.sourceforge.net; Fri, 26 May 2023 06:11:46 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B1A1B64CD4 for ; Fri, 26 May 2023 06:11:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F6D2C4339E; Fri, 26 May 2023 06:11:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685081496; bh=ONUEYU4rfcMIQQDvoNfqWwWHZxhiDpp14GIuRThjJLM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SAqLhQrzueHjbx9bAwSlE/SLlMA+C7IUuyxDdN9p4Xjg/EbdhWIQAg67PMk/2Pknu ipA1N6H3TjwTgr5UKdNS+DOURwoU2mk8pw9X5hoTYp7htPn6f//HJbG0VU+WKxovBb Htec1DXudHS4D3+j1pUaKUJ6x6HjhjdFbM9FABEjByjIJglDLRThiZAFRdqRWPjsV0 f4qV50eEA2eSEKinbWZ/dBEYlDfIbApldogs+yFEJyfruydSLuRpThgMmAVppLYdIK roD3pNtrV91/SWT9rgyrAadjUEbjjGW9I1n86/mocE32qBieYnAcxPMBlozgb1BBPD oXzxoy+GuBfnA== From: Chao Yu To: jaegeuk@kernel.org Date: Fri, 26 May 2023 14:11:29 +0800 Message-Id: <20230526061129.2999437-2-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230526061129.2999437-1-chao@kernel.org> References: <20230526061129.2999437-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1q2Qfx-0002ct-Rn Subject: [f2fs-dev] [PATCH 2/2] f2fs-tools: reuse feature_table in print_sb_state() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Signed-off-by: Chao Yu --- 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);