btrfs-progs: print-tree: Remove btrfs_root parameter
[platform/upstream/btrfs-progs.git] / btrfs-debugfs
index 08e3ec6..a7ecd16 100755 (executable)
@@ -4,7 +4,7 @@
 # LGPLv2 license
 # Copyright Facebook 2014
 
-import sys,os,struct,fcntl,ctypes,stat,argparse
+import sys, os, fcntl, ctypes, stat, argparse
 
 # helpers for max ints
 maxu64 = (1L << 64) - 1
@@ -96,7 +96,7 @@ class btrfs_ioctl_search_args(ctypes.Structure):
                  ("buf", ctypes.c_ubyte * args_buffer_size),
                ]
 
-# the search ioctl resturns one header for each item
+# the search ioctl returns one header for each item
 #
 class btrfs_ioctl_search_header(ctypes.Structure):
     _pack_ = 1
@@ -233,7 +233,6 @@ def print_file_extents(filename):
     s.args.min_objectid = st.st_ino
     s.args.max_objectid = st.st_ino
 
-    size = st.st_size
 
     while True:
         try:
@@ -314,7 +313,7 @@ def print_block_groups(mountpoint):
 
     try:
         fd = os.open(mountpoint, os.O_RDONLY)
-        st = os.fstat(fd)
+        os.fstat(fd)
     except Exception, e:
         sys.stderr.write("Failed to open %s (%s)\n" % (mountpoint, e))
         return -1
@@ -336,7 +335,7 @@ def print_block_groups(mountpoint):
         h = ctypes.addressof(header)
         p_left = args_buffer_size
 
-        for x in xrange(0, s.args.nr_items):
+        for _ in xrange(0, s.args.nr_items):
             # for each itme, copy the header from the buffer into
             # our header struct
             ctypes.memmove(h, p, header_size)
@@ -357,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: