Commit Diff


commit - 69c9c7b9f0759ba2c31afe74575fd262d9b5a0fd
commit + 185836d0dc69558b57f7c96d13febefa9815df26
blob - e0ad28be6592c25705e73fb742e3679d95679e26
blob + ef3c16603987e3422d9816c525d4843422c94801
--- ChangeLog.md
+++ ChangeLog.md
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](http
 - Use opendev(3) instead of open(2)
 - Sort drives by name
 - Dynamic padding of output
+- Allow drive names longer than `sd0`, like `vnd0`
 
 ### Removed
 - Options:
blob - efe7acbfe3aedd6f35039740dc8261d1e4961759
blob + 4a167ec545c050216c9e1befe9182eda7455f9de
--- README.md
+++ README.md
@@ -22,7 +22,7 @@ doas make unroot
 - [ ] `lsblk sd0a`
 - [ ] `lsblk -f duid,size`
 - [x] Don't use manual padding.
-- [ ] Support disks that have more than 2 letters, like `vnd0`
+- [x] Support disks that have more than 2 letters, like `vnd0`
 - [x] Sort drives by name
 - [ ] Add an option to make the output script-friendly (like -c for CSV).
 - [x] Maybe: Display the child device of a RAID partition
blob - 1d6996558b3dacfbf455d78de18ef399f0f1fb09
blob + cc62987b46b99f3029567b1ff981144f96282f05
--- lsblk.c
+++ lsblk.c
@@ -36,6 +36,7 @@
 #include <libgen.h>
 #include <stdio.h>
 #include <fcntl.h>
+#include <ctype.h>
 #include <errno.h>
 #include <util.h>
 #include <err.h>
@@ -496,7 +497,7 @@ static void read_raid (
             }
 
             len_vendor = strlen (bd.bd_vendor);
-            if (len_vendor != 4) {
+            if (len_vendor < 4 || len_vendor > 8) {
                 warnx ("read_raid(%s): unexpected vendor string: %.32s", disk->name, bd.bd_vendor);
                 continue;
             }
@@ -643,6 +644,11 @@ int main (int argc, char *argv[])
     } else {
         for (int i = 0; i < argc; ++i) {
             char *disk = basename (argv[i]);
+            char *last = disk + strlen (disk) - 1;
+            if (isalpha (*last)) {
+                warnx ("%s: specifying a partition is not supported, using the drive.", disk);
+                *last = '\0';
+            }
             disks[num_disks++] = read_disk (disk);
         }
     }