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

#2551 in Parser implementations

Download history 3/week @ 2024-01-01 17/week @ 2024-01-29 24/week @ 2024-02-05 6/week @ 2024-02-12 28/week @ 2024-02-19 39/week @ 2024-02-26 23/week @ 2024-03-04 10/week @ 2024-03-11 16/week @ 2024-03-18

90 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