8 releases

0.2.0 Jul 15, 2022
0.1.6 Feb 19, 2022
0.1.5 Jan 11, 2021
0.1.4 May 16, 2020
0.1.1 Jul 1, 2017

#2459 in Parser implementations

Download history 1/week @ 2024-07-29 8/week @ 2024-08-05 3/week @ 2024-08-12 20/week @ 2024-08-19 4/week @ 2024-08-26 2/week @ 2024-09-02 8/week @ 2024-09-09 44/week @ 2024-09-23 23/week @ 2024-09-30 14/week @ 2024-10-07 21/week @ 2024-10-14 36/week @ 2024-11-04 21/week @ 2024-11-11

59 downloads per month
Used in 2 crates

MIT license

26KB
310 lines

This crate can parse GPT and basic MBR partition tables.

Github CI crates.io

Documentation and Examples

https://docs.rs/bootsector

Limitations

  • MBR extended partitions are not read (although they are returned, so you could read them yourself). This should be implemented.
  • GPT backup tables are not validated, which is "kinda" required by the spec. This could be implemented, but isn't super important, unless you're doing data recovery.
  • Sector sizes apart from 512 bytes are not well tested. These devices don't seem to exist as of 2017.

MSRV

Rust 1.46 is supported, and checked by CI. Updating this is a semver bump.


lib.rs:

Read basic MBR and GPT partition tables from a reader.

Examples

Load MBR or GPT partitions from a reader:

use std::io;
use bootsector::{list_partitions, open_partition, Options, Attributes};

// let reader = ...;
let partitions = list_partitions(&mut reader, &Options::default())?;
let part = &partitions[0];

// See what type of partition this is
match part.attributes {
    Attributes::GPT {
        type_uuid,
        ..
    } => println!("gpt: {:?}", type_uuid),
    Attributes::MBR {
        type_code,
        ..
    } => println!("mbr: {:x}", type_code),
}

let part_reader = open_partition(reader, part);
// part_reader.read_exact(...

Dependencies

~0.7–1MB