Skip to main content

vfat_rs/
lib.rs

1//! vfat-rs is a simple vfat (fat32) implementation in Rust.
2//! Use it in your custom kernel or integrate it in your user level application.
3#![doc = include_str!("../README.md")]
4#![cfg_attr(not(any(test, feature = "std")), no_std)]
5#![deny(missing_docs)]
6//#![deny(unsafe_code)]
7// to remove:
8//#![allow(unused_variables)]
9//#![allow(dead_code)]
10#![allow(clippy::too_many_arguments)]
11
12extern crate alloc;
13extern crate core;
14
15use alloc::sync::Arc;
16
17pub use api::EntryType;
18use api::raw_directory_entry::{
19    Attributes, RegularDirectoryEntry, UnknownDirectoryEntry, VfatDirectoryEntry,
20};
21pub use api::{Directory, DirectoryEntry, Metadata, VfatMetadataTrait};
22pub(crate) use cache::CachedPartition;
23pub use error::{Result, VfatRsError};
24pub(crate) use formats::cluster_id::ClusterId;
25#[cfg(not(feature = "std"))]
26pub use formats::path::PathBuf;
27#[cfg(feature = "std")]
28pub use std::path::PathBuf;
29
30pub use formats::sector_id::SectorId;
31pub use vfat::VfatFS;
32
33mod api;
34mod cache;
35mod cluster;
36/// VfatRs error definitions
37mod error;
38mod fat_table;
39#[cfg(feature = "std")]
40mod fileblockdevice;
41mod formats;
42/// I/O traits and error types.
43pub mod io;
44mod macros;
45/// Master Boot Record parsing.
46pub mod mbr;
47mod time;
48/// OS-integration traits (`BlockDevice`, `TimeManagerTrait`).
49pub mod traits;
50mod vfat;
51
52const EBPF_VFAT_MAGIC: u8 = 0x28;
53const EBPF_VFAT_MAGIC_ALT: u8 = 0x29;
54
55/// Sector size in bytes. Hardcoded to 512 as virtually all FAT32 media uses this size.
56pub const SECTOR_SIZE: usize = 512;
57
58/// Why Arc? Because CachedPartition owns the block device. And
59/// Vfat needs to be cloned, and potentially we could send references across threads.
60type ArcMutex<CachedPartition> = Arc<CachedPartition>;
61
62#[cfg(feature = "std")]
63pub use time::TimeManagerChronos;
64pub use time::TimeManagerNoop;
65
66#[cfg(feature = "std")]
67pub use fileblockdevice::FilebackedBlockDevice;
68
69pub use traits::{BlockDevice, TimeManagerTrait};