All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: right-align number columns in btrfs-debugfs output
@ 2017-09-30 15:54 Holger Hoffstätte
  2017-10-02 14:42 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Holger Hoffstätte @ 2017-09-30 15:54 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba


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 <holger@applied-asynchrony.com>
---
 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:
-- 
2.14.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] btrfs-progs: right-align number columns in btrfs-debugfs output
  2017-09-30 15:54 [PATCH] btrfs-progs: right-align number columns in btrfs-debugfs output Holger Hoffstätte
@ 2017-10-02 14:42 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2017-10-02 14:42 UTC (permalink / raw)
  To: Holger Hoffstätte; +Cc: linux-btrfs

On Sat, Sep 30, 2017 at 05:54:27PM +0200, Holger Hoffstätte  wrote:
> 
> 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 <holger@applied-asynchrony.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-02 14:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-30 15:54 [PATCH] btrfs-progs: right-align number columns in btrfs-debugfs output Holger Hoffstätte
2017-10-02 14:42 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.