From patchwork Sat Sep 30 15:54:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Holger_Hoffst=C3=A4tte?= X-Patchwork-Id: 9979513 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E9E4B60375 for ; Sat, 30 Sep 2017 15:54:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D80F128A07 for ; Sat, 30 Sep 2017 15:54:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C955C28CBC; Sat, 30 Sep 2017 15:54:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 361FE28A07 for ; Sat, 30 Sep 2017 15:54:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751742AbdI3Py3 (ORCPT ); Sat, 30 Sep 2017 11:54:29 -0400 Received: from mail02.iobjects.de ([188.40.134.68]:60160 "EHLO mail02.iobjects.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751404AbdI3Py3 (ORCPT ); Sat, 30 Sep 2017 11:54:29 -0400 Received: from tux.wizards.de (p4FF5825E.dip0.t-ipconnect.de [79.245.130.94]) by mail02.iobjects.de (Postfix) with ESMTPSA id E95AA41602C9; Sat, 30 Sep 2017 17:54:27 +0200 (CEST) Received: from [192.168.100.223] (ragnarok.applied-asynchrony.com [192.168.100.223]) by tux.wizards.de (Postfix) with ESMTP id 73ECE825FE0; Sat, 30 Sep 2017 17:54:27 +0200 (CEST) To: linux-btrfs Cc: David Sterba From: =?UTF-8?Q?Holger_Hoffst=c3=a4tte?= Subject: [PATCH] btrfs-progs: right-align number columns in btrfs-debugfs output Organization: Applied Asynchrony, Inc. Message-ID: <59f60b49-3e74-547d-5124-8ce0097059ff@applied-asynchrony.com> Date: Sat, 30 Sep 2017 17:54:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 Content-Language: en-US Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The values for block group offset, length etc. in btrfs-debugfs' output are left-aligned, which creates unaligned output and makes the usage percentage hard to read/process further. This patch adds right-aligning format specifiers for the number values. Ideally the format values wouldn't be hardcoded but instead derived from the filesystem size, but this seems to work for now. Signed-off-by: Holger Hoffstätte --- btrfs-debugfs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/btrfs-debugfs b/btrfs-debugfs index dfb88539..a7ecd16d 100755 --- a/btrfs-debugfs +++ b/btrfs-debugfs @@ -356,8 +356,13 @@ def print_block_groups(mountpoint): ctypes.memmove(ctypes.addressof(bg), p, ctypes.sizeof(bg)) if bg.flags & BTRFS_BLOCK_GROUP_DATA: - print "block group offset %Lu len %Lu used %Lu chunk_objectid %Lu flags %Lu usage %.2f" %\ - (header.objectid, header.offset, bg.used, bg.chunk_objectid, bg.flags, float(bg.used) / float(header.offset)) + print "block group offset %s len %s used %s chunk_objectid %Lu flags %Lu usage %.2f" %\ + ('{:>14}'.format(header.objectid), + '{:>10}'.format(header.offset), + '{:>10}'.format(bg.used), + bg.chunk_objectid, + bg.flags, + float(bg.used) / float(header.offset)) total_free += (header.offset - bg.used) if min_used >= bg.used: