[−][src]Crate gpt
A pure-Rust library to work with GPT partition tables.
It provides support for manipulating (R/W) GPT headers and partition tables. Raw disk devices as well as disk images are supported.
extern crate gpt; fn inspect_disk() { let diskpath = std::path::Path::new("/dev/sdz"); let cfg = gpt::GptConfig::new().writable(false); let disk = cfg.open(diskpath).expect("failed to open disk"); println!("Disk header: {:#?}", disk.primary_header()); println!("Partition layout: {:#?}", disk.partitions()); } fn create_partition() { let diskpath = std::path::Path::new("/tmp/chris.img"); let cfg = gpt::GptConfig::new().writable(true).initialized(true); let mut disk = cfg.open(diskpath).expect("failed to open disk"); let result = disk.add_partition( "rust_partition", 100, gpt::partition_types::LINUX_FS, 0, ); disk.write().unwrap(); }
Modules
disk | Disk-related types and helper functions. |
header | GPT-header object and helper functions. |
mbr | MBR-related types and helper functions. |
partition | Partition-related types and helper functions. |
partition_types | Parition type constants |
Structs
GptConfig | Configuration options to open a GPT disk. |
GptDisk | A file-backed GPT disk. |