file_system/
lib.rs

1//! # File System Module
2//!
3//! This crate provides a comprehensive file system abstraction layer for the Xila operating system.
4//! It includes support for various file system operations, device management, partition handling,
5//! and Master Boot Record (MBR) operations.
6//!
7//! ## Overview
8//!
9//! The File System module is designed to provide a unified interface for:
10//! - File and directory operations (create, read, write, delete, etc.)
11//! - Device abstraction for block devices and memory devices
12//! - Partition management and MBR (Master Boot Record) support
13//! - File system metadata handling (permissions, timestamps, etc.)
14//! - Cross-platform file system traits
15//!
16//! ## Key Components
17//!
18//! ### File System Traits
19//! - [`FileSystemTraits`] - Core trait for implementing file systems
20//! - Support for POSIX-like operations with task and user isolation
21//!
22//! ### Device Management
23//! - [`DeviceTrait`] - Abstraction for storage devices
24//! - [`MemoryDevice`] - In-memory device implementation for testing
25//! - [`Device`] - Thread-safe device wrapper
26//!
27//! ### Partition Support
28//! - [`PartitionDevice`] - Device representing a partition on a larger device
29//! - [`PartitionEntry`] - MBR partition table entry
30//! - [`PartitionKind`] - Enumeration of partition types
31//!
32//! ### MBR (Master Boot Record)
33//! - [`Mbr`] - Complete MBR structure with partition table
34//! - Utilities for creating, reading, and validating MBRs
35//! - Support for creating partition devices from MBR entries
36//!
37//! ### Fundamental Types
38//! - [`Path`] - File system path representation
39//! - [`Error`] - File system error enumeration
40//! - [`Size`] - Size and position types
41//! - [`Time`] - Timestamp handling
42//! - [`Flags`] - File operation flags
43//!
44//! ## Features
45//!
46//! - `std` - Enables standard library support for environments that have it
47//! - Default is `no_std` for embedded systems
48//!
49//! ## Examples
50//!
51//! ### Basic Device Operations
52//!
53//! ```rust
54//! # extern crate alloc;
55//! # use file_system::*;
56//!
57//! // Create an in-memory device for testing
58//! let device = create_device!(Memory_device_type::<512>::new(1024 * 1024));
59//!
60//! // Write some data
61//! let data = b"Hello, File System!";
62//! let result = device.Write(data);
63//! assert!(result.is_ok());
64//! ```
65//!
66//! ### MBR Operations
67//!
68//! ```rust
69//! # extern crate alloc;
70//! # use file_system::*;
71//!
72//! // Create a device and format it with MBR
73//! let device = create_device!(Memory_device_type::<512>::new(4 * 1024 * 1024));
74//!
75//! // Create MBR and add a partition
76//! let mut mbr = MBR_type::New_with_signature(0x12345678);
77//! mbr.Add_partition(Partition_type_type::Fat32_lba, 2048, 8192, true).unwrap();
78//!
79//! // Write MBR to device
80//! mbr.Write_to_device(&device).unwrap();
81//!
82//! // Create a partition device
83//! let partition = Create_partition_device(device, &mbr.Partitions[0]).unwrap();
84//! ```
85//!
86//! ## Safety and Concurrency
87//!
88//! This crate is designed to be thread-safe and supports concurrent access to file systems
89//! and devices. All device implementations must be `Send + Sync` and should use appropriate
90//! synchronization primitives to handle concurrent access.
91//!
92//! ## Error Handling
93//!
94//! All operations return [`Result<T>`] which is an alias for `Result<T, Error>`.
95//! The [`Error`] enum provides comprehensive error reporting for all file system operations.
96
97#![no_std]
98
99extern crate alloc;
100
101#[cfg(feature = "std")]
102extern crate std;
103
104mod device;
105mod error;
106mod file_system;
107mod fundamentals;
108mod mbr;
109mod partition;
110
111mod memory_device;
112mod time;
113
114pub use device::{Device, DeviceTrait};
115pub use error::*;
116
117pub use file_system::*;
118pub use fundamentals::*;
119pub use memory_device::*;
120pub use partition::*;
121pub use time::*;
122
123// Export MBR module and its contents
124pub use mbr::*;