Skip to content

aj-bagwell/block-devs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Safe portable wrapper for block device opperations

crates.io

Documentation (Releases)

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 count = file.get_block_count().unwrap();
    let bytes = file.get_block_device_size()?;
    let gb = bytes >> 30;

    println!("disk is {} blocks totaling {}gb", count, gb);

Supported Platforms

It currently supports Linux, OS X, and Free BSD, pull requests for other platforms are welcome

License

block-devs is licensed under the MIT license. See LICENSE for more details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages