vermaden / lsblk

List information about block devices in the FreeBSD system.
BSD 2-Clause "Simplified" License
25 stars 2 forks source link

Device path is incompatible with linux #7

Open borisrudakov opened 11 months ago

borisrudakov commented 11 months ago

In the Linux implementation, you need to specify the path to the device.

$ lsblk sda
lsblk: sda: not a block device
$ lsblk /dev/sda
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 223,6G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
└─sda2   8:2    0 223,1G  0 part /

In your implementation, specifying the /dev/ directory results in an error.

# lsblk ada0
DEVICE         MAJ:MIN SIZE TYPE                                          LABEL MOUNT
ada0             0:106 932G GPT                                               - -
  ada0p1         0:108 512K freebsd-boot                                      - -
  <FREE>         -:-   492K -                                                 - -
  ada0p2         0:110 932G freebsd-zfs                                       - <ZFS>
  <FREE>         -:-   676K -                                                 - -
# lsblk /dev/ada0
NOPE: disk '/dev/ada0' does not exist in the system

Because of this, it is difficult to use lsblk in scripts running under both Linux and FreeBSD

vermaden commented 11 months ago

I agree.

I will modify lsblk(8) to work with devices that start with /dev.

vermaden commented 11 months ago

Fixed.

Details: https://github.com/vermaden/lsblk/commit/ed8b75af6c958c2b21bb57825e57a623bf440cef

Let me know how it works.

Regards.