From patchwork Fri Jun 7 04:24:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhihao Cheng X-Patchwork-Id: 1944825 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=fA4wdry3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VwSpR0MJmz20Q5 for ; Fri, 7 Jun 2024 14:27:08 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QTonX5WId2yFFK69DCeY86bAjeVn3UsG0NtLU/hF9FM=; b=fA4wdry3rluPV1 iQeSPVdqRz81xJenIi3Bb7k8zsw61HdfLfM316QSU9yNoDQAvGzafXAbuyqnUe/iEd7Qdxv7Zggp1 wDmpbxVDfs9JD/zRrODndJXHgc9ka9DME89iFCZ7VxgwMkysfSC/b7oocEDPiwPvCZg3ZvytIMKmz dywlh+yolaCjZBrmfF2ozR/t7ifkAWZncxx58HZe26t0FFXMJwvSm3oujpYQMTvcraiwo1IPfKdUs 49K/FMQEvWH+zZXEBOVJgOT1OmIzzmyLEQe7EGrO3Q9jI77HgLy14eACJPY/WL5MW8U/zRQkKfngq 2sdDDxIxOfNJgGkDW1LQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFRBl-0000000CGC1-2Vb1; Fri, 07 Jun 2024 04:26:53 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFRBc-0000000CG3i-1mv4 for linux-mtd@lists.infradead.org; Fri, 07 Jun 2024 04:26:48 +0000 Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VwSj41ZmNzsRgt; Fri, 7 Jun 2024 12:22:32 +0800 (CST) Received: from kwepemm600013.china.huawei.com (unknown [7.193.23.68]) by mail.maildlp.com (Postfix) with ESMTPS id D52C818007E; Fri, 7 Jun 2024 12:26:30 +0800 (CST) Received: from huawei.com (10.175.104.67) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 7 Jun 2024 12:26:29 +0800 From: Zhihao Cheng To: , , , , , CC: , Subject: [RFC PATCH mtd-utils 005/110] ubifs-utils: Define PROGRAM_NAME as variable Date: Fri, 7 Jun 2024 12:24:30 +0800 Message-ID: <20240607042615.2069840-6-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240607042615.2069840-1-chengzhihao1@huawei.com> References: <20240607042615.2069840-1-chengzhihao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.67] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600013.china.huawei.com (7.193.23.68) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240606_212644_887233_3CFCE7DD X-CRM114-Status: GOOD ( 14.86 ) X-Spam-Score: -2.3 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: PROGRAM_NAME is defined as a const string "mkfs.ubifs", which won't be suitable for fsck.ubifs. Add 'program_name' member in ubifs_info structure, define PROGRAM_NAME as ubifs_info.program_name. Then, [...] Content analysis details: (-2.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.187 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [45.249.212.187 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org PROGRAM_NAME is defined as a const string "mkfs.ubifs", which won't be suitable for fsck.ubifs. Add 'program_name' member in ubifs_info structure, define PROGRAM_NAME as ubifs_info.program_name. Then, error messages will display right program name if fsck.ubifs is supported. Besides, add 'program_type' member in ubifs_info structure to identify which current program type is, without comparing program name. Signed-off-by: Zhihao Cheng --- ubifs-utils/common/crypto.c | 10 +++++++--- ubifs-utils/common/defs.h | 4 ++++ ubifs-utils/common/fscrypt.c | 7 +++++-- ubifs-utils/common/hashtable/hashtable.c | 14 +++++++++----- ubifs-utils/common/lpt.c | 7 +++++-- ubifs-utils/common/ubifs.h | 6 ++++++ ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 3 +++ 7 files changed, 39 insertions(+), 12 deletions(-) diff --git a/ubifs-utils/common/crypto.c b/ubifs-utils/common/crypto.c index 60a67a4e..614a16de 100644 --- a/ubifs-utils/common/crypto.c +++ b/ubifs-utils/common/crypto.c @@ -23,10 +23,14 @@ #include #include -#define PROGRAM_NAME "mkfs.ubifs" -#include "common.h" -#include "defs.h" #include "fscrypt.h" +#include "defs.h" +#include "ubifs.h" + +/* common.h requires the PROGRAM_NAME macro */ +extern struct ubifs_info info_; +#define PROGRAM_NAME (info_.program_name) +#include "common.h" static int do_hash(const EVP_MD *md, const unsigned char *in, size_t len, unsigned char *out) { diff --git a/ubifs-utils/common/defs.h b/ubifs-utils/common/defs.h index e1aded03..143f6c65 100644 --- a/ubifs-utils/common/defs.h +++ b/ubifs-utils/common/defs.h @@ -12,6 +12,10 @@ #include #include +#define MKFS_PROGRAM_NAME "mkfs.ubifs" + +enum { MKFS_PROGRAM_TYPE = 0 }; + extern int debug_level; #define dbg_msg(lvl, fmt, ...) do {if (debug_level >= lvl) \ diff --git a/ubifs-utils/common/fscrypt.c b/ubifs-utils/common/fscrypt.c index 94c6c377..cc989638 100644 --- a/ubifs-utils/common/fscrypt.c +++ b/ubifs-utils/common/fscrypt.c @@ -20,11 +20,14 @@ #include -#define PROGRAM_NAME "mkfs.ubifs" -#include "common.h" #include "fscrypt.h" #include "defs.h" +#include "ubifs.h" +/* common.h requires the PROGRAM_NAME macro */ +extern struct ubifs_info info_; +#define PROGRAM_NAME (info_.program_name) +#include "common.h" static __u8 fscrypt_masterkey[FS_MAX_KEY_SIZE]; static struct cipher *fscrypt_cipher; diff --git a/ubifs-utils/common/hashtable/hashtable.c b/ubifs-utils/common/hashtable/hashtable.c index c1f99edd..071afd22 100644 --- a/ubifs-utils/common/hashtable/hashtable.c +++ b/ubifs-utils/common/hashtable/hashtable.c @@ -1,15 +1,19 @@ /* Copyright (C) 2004 Christopher Clark */ -#define PROGRAM_NAME "hashtable" - -#include "common.h" -#include "hashtable.h" -#include "hashtable_private.h" #include #include #include #include +#include "ubifs.h" +#include "hashtable.h" +#include "hashtable_private.h" + +/* common.h requires the PROGRAM_NAME macro */ +extern struct ubifs_info info_; +#define PROGRAM_NAME (info_.program_name) +#include "common.h" + /* Credit for primes table: Aaron Krowne http://br.endernet.org/~akrowne/ diff --git a/ubifs-utils/common/lpt.c b/ubifs-utils/common/lpt.c index 23ffe7f7..746fc7db 100644 --- a/ubifs-utils/common/lpt.c +++ b/ubifs-utils/common/lpt.c @@ -24,14 +24,17 @@ #include #endif -#define PROGRAM_NAME "mkfs.ubifs" -#include "common.h" #include "lpt.h" #include "defs.h" #include "ubifs.h" #include "crc16.h" #include "sign.h" +/* common.h requires the PROGRAM_NAME macro */ +extern struct ubifs_info info_; +#define PROGRAM_NAME (info_.program_name) +#include "common.h" + /** * do_calc_lpt_geom - calculate sizes for the LPT area. * @c: the UBIFS file-system description object diff --git a/ubifs-utils/common/ubifs.h b/ubifs-utils/common/ubifs.h index 0eef31ac..2b0ffe56 100644 --- a/ubifs-utils/common/ubifs.h +++ b/ubifs-utils/common/ubifs.h @@ -273,6 +273,9 @@ struct ubifs_znode * @highest_inum: highest used inode number * @max_sqnum: current global sequence number * + * @program_type: used to identify the type of current program + * @program_name: program name + * * @jhead_cnt: count of journal heads * @max_bud_bytes: maximum number of bytes allowed in buds * @@ -360,6 +363,9 @@ struct ubifs_info ino_t highest_inum; unsigned long long max_sqnum; + int program_type; + const char *program_name; + int jhead_cnt; long long max_bud_bytes; diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c index a440bc4b..b4bed018 100644 --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c @@ -3056,6 +3056,9 @@ int main(int argc, char *argv[]) { int err; + info_.program_name = MKFS_PROGRAM_NAME; + info_.program_type = MKFS_PROGRAM_TYPE; + if (crypto_init()) return -1;