#block-devices

drives

Library listing mounted or mountable drives on linux

10 releases (6 breaking)

0.6.0 Jan 27, 2024
0.5.0 May 19, 2023
0.4.1 May 6, 2023
0.3.1 Apr 10, 2023
0.0.2 Mar 14, 2023

#234 in Unix APIs

Download history 22/week @ 2024-06-04 10/week @ 2024-06-11 9/week @ 2024-06-18 148/week @ 2024-06-25 429/week @ 2024-07-02 555/week @ 2024-07-09 159/week @ 2024-07-16 531/week @ 2024-07-23 438/week @ 2024-07-30 155/week @ 2024-08-06 286/week @ 2024-08-13 773/week @ 2024-08-20 561/week @ 2024-08-27 632/week @ 2024-09-03 564/week @ 2024-09-10 699/week @ 2024-09-17

2,535 downloads per month
Used in imge

MIT/Apache

27KB
585 lines

Build and Tests codecov

drives

A rust library (crate) for listing mounted or mountable drives on linux (flash drives, sd-cards, etc.)

Uses the virtual kernel filesystems (/sys, /proc and /dev) to gather information about the block devices known by the linux kernel. Optionally reads the GUID Partition Table (GPT) to enrich gathered data with informations from the partition table.

Data

  • devices
    • name
    • model, serial
    • size
    • partitions
    • is removable
    • uuid (optionally from GPT)
  • partition
    • name
    • size
    • mountpoint (path, filesystem)
    • part_uuid (optionally from GPT)

Example

For an simple example see simple_main.rs:

cargo run --example simple_main

Documentation

Documentation can be found on docs.rs.

Optional Data from GUID Partition Table (GPT)

Currently only the UUID for a device and the PART_UUID of partitions are retreived using the GPT. This needs the feature "gpt" to be enabled.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Dependencies

~0.3–0.8MB
~19K SLoC