Skip to content

Commit

Permalink
add support for creating and writing to a file (only direct pointer s…
Browse files Browse the repository at this point in the history
…upport, which means file sizes are limited to fs.block_size * 12)
  • Loading branch information
tsatke committed Jun 24, 2024
1 parent 2c08e0f commit fad9028
Show file tree
Hide file tree
Showing 13 changed files with 482 additions and 73 deletions.
199 changes: 168 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions ext2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ name = "ext2"
[dependencies]
bitflags = "2.3.1"
mkfs-filesystem = { version = "0.1.0", path = "../filesystem" }

[dev-dependencies]
rand = "0.9.0-alpha.1"
8 changes: 8 additions & 0 deletions ext2/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use core::num::NonZeroU32;
use core::ops::Deref;

#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
#[repr(transparent)]
pub struct InodeAddress(NonZeroU32);

impl Deref for InodeAddress {
Expand All @@ -18,6 +19,12 @@ impl From<NonZeroU32> for InodeAddress {
}
}

impl From<InodeAddress> for u32 {
fn from(value: InodeAddress) -> u32 {
value.0.get()
}
}

impl InodeAddress {
pub const fn new(n: u32) -> Option<Self> {
let nzu32 = NonZeroU32::new(n);
Expand All @@ -29,6 +36,7 @@ impl InodeAddress {
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
#[repr(transparent)]
pub struct BlockAddress(NonZeroU32);

impl Deref for BlockAddress {
Expand Down
Loading

0 comments on commit fad9028

Please sign in to comment.