Crates.io | block-devs |
lib.rs | block-devs |
version | 0.1.0 |
source | src |
created_at | 2021-05-13 15:47:01.259558 |
updated_at | 2021-05-13 15:47:01.259558 |
description | Safe portable wrapper for block device opperations |
homepage | |
repository | https://github.com/aj-bagwell/block-devs |
max_upload_size | |
id | 396974 |
size | 17,588 |
![crates.io](http://meritbadge.herokuapp.com/block-devs
Block Devs provides safe wrappers for the ioctl call for dealing with block devices (USB sticks, SSDs, hard drives etc).
It aims to provide a consitent interface across all platforms for things like getting the number of bytes a disk has.
It does this by a extention trait on the standard File
struct.
use block-devs::BlockExt;
use std::fs::File;
let path = "/dev/sda2";
let file = File::open(path)?;
let bytes = file.get_block_device_size()?;
let gb = bytes >> 30;
println!("disk is {} blocks {}gb", bytes, gb);
It currently supports Linux, OS X, and Free BSD, pull requests for other platforms are welcome
block-devs is licensed under the MIT license. See LICENSE for more details.