Commit Diff


commit - 55867e57a6f87ebc4f994e7a67a8aa31ba0ab44d
commit + 3103dec457d1a69422047e1eef4aae1c7d0cfc1c
blob - 3eb48fb293a0c290a2740bc72a2bfc3fcb0b42a4
blob + a80183d89544445d1fe6e1614124fda08509c3e6
--- lsblk.c
+++ lsblk.c
@@ -121,6 +121,19 @@ static int usage (void)
     return 1;
 }
 
+static char *stripdisk (char *n)
+{
+    const char sufx[] = " disk";
+    const size_t ln = strnlen (n, 16);
+    const size_t ls = sizeof sufx - 1;
+
+    if (!memcmp (n + ln - ls, sufx, ls)) {
+        n[ln - ls] = '\0';
+    }
+
+    return n;
+}
+
 int main (int argc, char *argv[])
 {
     if (unveil ("/dev", "r") == -1)
@@ -156,6 +169,7 @@ int main (int argc, char *argv[])
     for (char *disk; (disk = strsep (&names, ",")) != NULL;) {
         struct disklabel label;
         char *colon, *name = NULL;
+        char dtype[16];
         int fd;
 
         colon = strchr (disk, ':');
@@ -179,7 +193,8 @@ int main (int argc, char *argv[])
 
         printf ("%s    ", disk);
         printsize (DL_GETDSIZE (&label) * ss);
-        printf (" %s\n", label.d_typename);
+        memcpy (dtype, label.d_typename, sizeof dtype);
+        printf (" %-8.16s\n", stripdisk (dtype));
         for (uint16_t i = 0; i < label.d_npartitions; ++i) {
             const struct partition *p = &label.d_partitions[i];
             const uint64_t size = DL_GETPSIZE (p) * ss;
@@ -198,7 +213,7 @@ int main (int argc, char *argv[])
 
             printf ("  %s%c ", disk, *letter);
             printsize (size);
-            printf (" %s %s\n", fstypenames[p->p_fstype], mp);
+            printf (" %-8s %s\n", fstypenames[p->p_fstype], mp);
         }
     }