Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp806380lqt; Thu, 6 Jun 2024 21:28:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVLyBMLqgYKYuaezucvwCrBfMrw09pUfY7Rje96g0J8dulsMilpphq5nDojnq8S+QNPpvkde+dPaHhCFWJ/TEB5vkpDaoVCVLMxiqmR4w== X-Google-Smtp-Source: AGHT+IFQCnGjcSxNtGRFnZEGxxgGRiKnGe0iOw3iZHa2HK4SHgaYuJb5CCU+ZJxzqzWkKvGQ7RK4 X-Received: by 2002:a50:c347:0:b0:57a:9405:786a with SMTP id 4fb4d7f45d1cf-57c5084faa5mr678933a12.5.1717734487386; Thu, 06 Jun 2024 21:28:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717734487; cv=pass; d=google.com; s=arc-20160816; b=foarB0lXZd+T8y7dM9FmD7WQzH6di7RDti4joxtNmX6xe9cMXk8IqgrR7aJWsoRqPP lFUsxo8mbbygzasVrL2fcQLnLW+VTL/iIka5B2piUGe1fnACxI6v20JQqoRXjI/M40xB psf2TRRvXsNYHhsyzCm2YHCmHLLN8R2PS4QmGyxK3V7Kjv2W914/ltv5xMPQmWYWEfjd xPzmSJLHrS6m4Bjx16DhejY5Zc+upjd64fLw1FBKJBMfaO1MakhVsBIpr00ctM3zSEd+ NpBVUAGEiF4GjHgqvq0T9A6mURGazLXGu8AmQLEoZLRzmqvLC9Y7CRu45J6Gr0hxVrR3 7mpw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=8PwiPgfTbbhlaI2LaT/ED/WV/IKnQtG4SH0GOoNjuBA=; fh=yXYChwFvQA/NaaLzCC0IJdkW11OhjXgO4DHXzVmnGFw=; b=pnWU5ke2CWeFhNhRIQI6OPOs5vc6rV6v9Vas1HwL4Zad64TCv4hN6Sp0zR9hv7jXh4 hy2ofS/dvpf3shPM+1GIih5cAvFWl5efq53ECMMbz5w60tGOcOz6iu7/JHGKrZQKZzAQ axzbsAkGf49MXoofXVRrdZvegZFzz3gWdr7hdWkG5hynUiMZK2MVq1Q4VXvBR+qbwJqm 2exYiWnm+3pRmR9BKIWrm4bSOOWudMH2Hwe5u+Z0jm9Mw9F5PYoiPHpBjQG3sHr1jk/A eNhMKLS5GYjHU8asyy+zHSQ/a+M9ATloljVyYpzB3JtUVURxzuC8cDdgRV8woJ8iL624 f+Jg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-205289-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205289-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae28e927si1416647a12.675.2024.06.06.21.28.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 21:28:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205289-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-205289-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205289-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1D5821F21D3E for ; Fri, 7 Jun 2024 04:28:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F8E41386BF; Fri, 7 Jun 2024 04:26:42 +0000 (UTC) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF3DE61FFC for ; Fri, 7 Jun 2024 04:26:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717734401; cv=none; b=Rl0HqxyQz2+N6/68bpotKfAOfcudzP3AHcNjvshBlK6CVhItv4nCIsxRAQkYxwlJFEkO6vmr9um6Tz1G+ouARiuEg709bjrqRksFTXo3jqHuCa/+uaW/T93cBWvUMhBUZYwImiMf5GcfJuLU5FmUS3ygwIO0k1hUis+cTG7anEI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717734401; c=relaxed/simple; bh=/jvOs1AG1WNw7x7fdX0WtGgfUb52sPHx9xijjWoakNw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DnVjfFgqDDSUQIpsINz1gGXtuRpdcFi3/hUqCusZrxHK6ksUIOQTWDV5M7vo7fUPJjl8R7NbQyUvTXadobXAWr5Uk2aM+iRqSa5uuFEBL7dpCaxOxvq1quZXMjCHlpmGQgS+pu61p3bRNbVQOjxxqsUVUQ0zGUQ+2y4sZl4KG4E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.255 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VwSj54Jh5z1S8tw; Fri, 7 Jun 2024 12:22:33 +0800 (CST) Received: from kwepemm600013.china.huawei.com (unknown [7.193.23.68]) by mail.maildlp.com (Postfix) with ESMTPS id 56FD518007E; Fri, 7 Jun 2024 12:26:32 +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:31 +0800 From: Zhihao Cheng To: , , , , , CC: , Subject: [RFC PATCH mtd-utils 007/110] ubifs-utils: Move 'debug_level' into ubifs_info structure Date: Fri, 7 Jun 2024 12:24:32 +0800 Message-ID: <20240607042615.2069840-8-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600013.china.huawei.com (7.193.23.68) Embed new member 'debug_level' into 'ubifs_info' structure, then global variable 'debug_level' can be removed from mkfs.ubifs.c. Next patches will import UBIFS libs from linux kernel, which could print messages with different levels, then 'debug_level' can be used to control which level messages should be printed. Signed-off-by: Zhihao Cheng --- ubifs-utils/common/defs.h | 6 +++--- ubifs-utils/common/hashtable/hashtable.c | 1 + ubifs-utils/common/ubifs.h | 3 +++ ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 6 ++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ubifs-utils/common/defs.h b/ubifs-utils/common/defs.h index 56336b6a..cafc94af 100644 --- a/ubifs-utils/common/defs.h +++ b/ubifs-utils/common/defs.h @@ -12,6 +12,8 @@ #include #include +#include "ubifs.h" + /* common.h requires the PROGRAM_NAME macro */ extern struct ubifs_info info_; #define PROGRAM_NAME (info_.program_name) @@ -21,9 +23,7 @@ extern struct ubifs_info info_; enum { MKFS_PROGRAM_TYPE = 0 }; -extern int debug_level; - -#define dbg_msg(lvl, fmt, ...) do {if (debug_level >= lvl) \ +#define dbg_msg(lvl, fmt, ...) do {if (info_.debug_level >= lvl) \ printf("%s: %s: " fmt "\n", PROGRAM_NAME, __FUNCTION__, ##__VA_ARGS__); \ } while(0) diff --git a/ubifs-utils/common/hashtable/hashtable.c b/ubifs-utils/common/hashtable/hashtable.c index a3bae166..af7fed97 100644 --- a/ubifs-utils/common/hashtable/hashtable.c +++ b/ubifs-utils/common/hashtable/hashtable.c @@ -6,6 +6,7 @@ #include #include "ubifs.h" +#include "defs.h" #include "hashtable.h" #include "hashtable_private.h" diff --git a/ubifs-utils/common/ubifs.h b/ubifs-utils/common/ubifs.h index 2b0ffe56..58aaba9b 100644 --- a/ubifs-utils/common/ubifs.h +++ b/ubifs-utils/common/ubifs.h @@ -273,6 +273,8 @@ struct ubifs_znode * @highest_inum: highest used inode number * @max_sqnum: current global sequence number * + * @debug_level: level of debug messages, 0 - none, 1 - statistics, + * 2 - files, 3 - more details * @program_type: used to identify the type of current program * @program_name: program name * @@ -363,6 +365,7 @@ struct ubifs_info ino_t highest_inum; unsigned long long max_sqnum; + int debug_level; int program_type; const char *program_name; diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c index 0bcaa5e4..51852861 100644 --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c @@ -138,8 +138,6 @@ struct ubifs_info info_; static struct ubifs_info *c = &info_; static libubi_t ubi; -/* Debug levels are: 0 (none), 1 (statistics), 2 (files) ,3 (more details) */ -int debug_level; int verbose; int yes; @@ -657,9 +655,9 @@ static int get_options(int argc, char**argv) common_print_version(); exit(EXIT_SUCCESS); case 'g': - debug_level = strtol(optarg, &endp, 0); + c->debug_level = strtol(optarg, &endp, 0); if (*endp != '\0' || endp == optarg || - debug_level < 0 || debug_level > 3) + c->debug_level < 0 || c->debug_level > 3) return errmsg("bad debugging level '%s'", optarg); break; -- 2.13.6