Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4254676rwr; Sun, 23 Apr 2023 01:31:34 -0700 (PDT) X-Google-Smtp-Source: AKy350ZYEnQUQfru4XfB0+Ny+lZOIjOBfZ62VbeISGCjDdJXQYgfcQj/4a6VY6bp9IFRj0YoEFiP X-Received: by 2002:a05:6a20:8f0d:b0:ef:a696:993a with SMTP id b13-20020a056a208f0d00b000efa696993amr13529208pzk.22.1682238694015; Sun, 23 Apr 2023 01:31:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682238693; cv=none; d=google.com; s=arc-20160816; b=DbeB8wdSOznbXXK5Ub2N6W0cBkXQsgcmbxPRm1dJsq6MpWncxcWiREabwzqsE8GSAz Av9PSEM4xcEkoZveXnpXs/XxRtzYOTXou1syPc9UnjVH7ppVAuI1vAzixsoN2yf69mDz EbqMlqKUJPBuJeRoJaQnssLZ5arbQaDXVI0eoHcGxeG7UM8VD64ky5+7aiXmWoNlsDRH TkF9TzXfgURAacH5S3ICIYVXglZvrUpZsBaN7fjySLyD5FkgJ8Bnl87v0BYyaoev+HNb iX78L6W+vaq7ipbkpoZ2S2ijx5Hpzt8SauoX/eTQ7tM2q5sH3xhw+KT4OFatsoicPUy1 IN7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4x4Kv1RaCy6lG2iFUrXPjjtV4EerznzunSsPqh8ZCU8=; b=VuTGK8wF1TUw3hohoHGWSDhEKxn0st9RlUes0AUS8WVqrRDszjo3idHDFBKyhb7NdE LWRIqSQSpzfGr0rbFZqiBVzB5N19oGIxFeJSdM6vh5QKMxk39NJ95C32lcZuE9TgEdtS rjJ56wWE+wYqEF3sAtWPtOt0g3aTII4l81zm+589pgu8kPMchUk9hajtl/NuvaJh8DdP mAI0tEONSbqRMxEKh5LdOchsNMrAz46wlhkqcpsoannsSLWXeFDOIvS1rQsmIknGybDD G8J/xzn6rIScIMcI9eMBfZFKk5M5wkKD/61GS4Lj2nzAT3uAA0UlFAPyVQXXy2RLricq Y6Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=AwubQXzV; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x1-20020a654141000000b0051b749eb32fsi8150008pgp.562.2023.04.23.01.31.14; Sun, 23 Apr 2023 01:31:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=AwubQXzV; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229641AbjDWIZs (ORCPT + 99 others); Sun, 23 Apr 2023 04:25:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbjDWIZr (ORCPT ); Sun, 23 Apr 2023 04:25:47 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4404C198B for ; Sun, 23 Apr 2023 01:25:46 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f1950f569eso12186405e9.2 for ; Sun, 23 Apr 2023 01:25:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682238344; x=1684830344; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4x4Kv1RaCy6lG2iFUrXPjjtV4EerznzunSsPqh8ZCU8=; b=AwubQXzV6VxxvXjqLenmufrlUar8bgbYQ/8OTGLayii6dxyHxZ4XbGOdoiq547wxJb MfA3RvGCaFubb8HAi5EThqjVslJT7GWI8HV7rvhuHe4Gj1oARE/1fNPXA/Zcr8CnkAJx jcRA1VyhUjJwP5Lrj3iIssCHp0AEpmXuymB9wWdbwXHB/vL7+HYFpXC0v6tphpno57rm m+RgFhMDeKH3u34D26/IOg+nAAVPx+lukfH7rywO9O8N4Nhw6kfhkFGmcGYQhfnEGSnS vf4oGBdcJ9ULQwBChT8EDrRK++AwITWUIPrUXK3LzqFg9Hwf44WuTL6un3dbGhN+5jqb nEcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682238344; x=1684830344; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4x4Kv1RaCy6lG2iFUrXPjjtV4EerznzunSsPqh8ZCU8=; b=eu9iCjfCmFi3VU0jB5VjetCTqgT0okVFFf26EZjlXmLmGEyA+j9XAyjlUo1Io6Qu+P Qt6fTQnbmtoGQGYm8DZpaYJD/gj7sjL901MWOq4aZdrG2UQ+1GRFvM6hfheXWAwLQLFS VBimlsctiyGCak9GGTcqDWVgHufL3Nz/M3cA38U6JIQG8H0Y6gdaBj2t6s2tV+BPCJh7 J4FJKngfnHsKFg8aB92ZvxUqe7MLrDOGeNSilVaDCkFOSntwMKm6LqnDgukUC8rd+pQ6 N+e++VNguqTESmpOJbJ9jVSsrRRAG1wksLEdWc/PER3ixBsyv0GDbhsHqiylW4qZauC9 WVgw== X-Gm-Message-State: AAQBX9eDeKR8XovjWtCpeGeDPDaBgHg/bdAMYc37r9VJvcAClNx0kRnW 0KTQYp/tKDXNVwyS4JjIAQTby7iSN05dVA== X-Received: by 2002:a05:6000:1819:b0:300:2067:f5d8 with SMTP id m25-20020a056000181900b003002067f5d8mr7571030wrh.65.1682238344184; Sun, 23 Apr 2023 01:25:44 -0700 (PDT) Received: from localhost.localdomain ([213.177.197.108]) by smtp.gmail.com with ESMTPSA id i40-20020a05600c4b2800b003ee6aa4e6a9sm12389153wmp.5.2023.04.23.01.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Apr 2023 01:25:43 -0700 (PDT) From: =?UTF-8?q?Oscar=20Megia=20L=C3=B3pez?= To: linux-ext4@vger.kernel.org Cc: =?UTF-8?q?Oscar=20Megia=20L=C3=B3pez?= Subject: [PATCH 1/1] e2fsck: Add percent to files and blocks feature Date: Sun, 23 Apr 2023 10:23:49 +0200 Message-Id: <20230423082349.53474-2-megia.oscar@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230423082349.53474-1-megia.oscar@gmail.com> References: <20230423082349.53474-1-megia.oscar@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org I need percentages to see how disk is occupied. Used and maximum are good, but humans work better with percentages. When my linux boots, I haven't enough time to remember numbers and calculate. My PC is very fast. I can only see the message for one or two seconds. If also I would see percentages for me would be perfect. I think that this feature is going to be good for everyone. Signed-off-by: Oscar Megia López --- e2fsck/unix.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/e2fsck/unix.c b/e2fsck/unix.c index e5b672a2..b820ca8d 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -350,6 +350,8 @@ static void check_if_skip(e2fsck_t ctx) int defer_check_on_battery; int broken_system_clock; time_t lastcheck; + char percent_files[9]; + char percent_blocks[9]; if (ctx->flags & E2F_FLAG_PROBLEMS_FIXED) return; @@ -442,14 +444,33 @@ static void check_if_skip(e2fsck_t ctx) ext2fs_mark_super_dirty(fs); } + /* Calculate percentages */ + if (fs->super->s_inodes_count > 0) { + snprintf(percent_files, sizeof(percent_files), " (%u%%) ", + ((fs->super->s_inodes_count - fs->super->s_free_inodes_count) * 100) / + fs->super->s_inodes_count); + } else { + snprintf(percent_files, sizeof(percent_files), " "); + } + + if (ext2fs_blocks_count(fs->super) > 0) { + snprintf(percent_blocks, sizeof(percent_blocks), " (%llu%%) ", + (unsigned long long) ((ext2fs_blocks_count(fs->super) - + ext2fs_free_blocks_count(fs->super)) * 100) / ext2fs_blocks_count(fs->super)); + } else { + snprintf(percent_blocks, sizeof(percent_blocks), " "); + } + /* Print the summary message when we're skipping a full check */ - log_out(ctx, _("%s: clean, %u/%u files, %llu/%llu blocks"), + log_out(ctx, _("%s: clean, %u/%u%sfiles, %llu/%llu%sblocks"), ctx->device_name, fs->super->s_inodes_count - fs->super->s_free_inodes_count, fs->super->s_inodes_count, + percent_files, (unsigned long long) ext2fs_blocks_count(fs->super) - ext2fs_free_blocks_count(fs->super), - (unsigned long long) ext2fs_blocks_count(fs->super)); + (unsigned long long) ext2fs_blocks_count(fs->super), + percent_blocks); next_check = 100000; if (fs->super->s_max_mnt_count > 0) { next_check = fs->super->s_max_mnt_count - fs->super->s_mnt_count; -- 2.40.0