Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
Minimal ext2 implementation (#2)
Browse files Browse the repository at this point in the history
* refactor(error): begin use of anyhow

* feat(dev): begin of devices implementations

* refactor(error): remove anyhow

* feat: continue implementation of devices

* feat: add `from` method for Slice and remove unused starting address

* feat: continue implementation of device

* feat: add Commit object + end test for generic implemented devices

* test(dev): add file test

* chore: update `flush` function to `commit`

* feat(dev): `read_at` and `write_at` given functions

* chore(dev): change `u32` in `Address` implementation to `usize`

* feat(ext2): begin parsing of superblock

* feat(ext2): complete superblock parsing

* feat(ext2): end implementation superblock

* feat(ext2): block group descriptors + beginning of inodes

* test(ext2): add bad parsing tests

* feat(ext2): add Osd2 struct for inodes

* feat(ext2): add read data from inodes

* refactor(dev): change Address implementation

* feat(ext2): add directory parsing

* feat(ext2): implementation of regular files

* refactor(ext2): structure parsing

* refactor(ext2): change Rc to simple borrow

* refactor(fs): delete Box to use type parameters

* refactor(ext2): celled implementation

* feat(ext2): end of directory and symlinks implementation

* refactor: split efs into crates

* revert: merge all crates into one

* feat(ext2): free block allocation

* feat(ext2): minimal version of file write

* fix(ext2): add tests for I/O operations + fix block writing

* feat(io): add connections with std

* test(ext2): add basic file write tests

* fix(ext2): fully tested and correct inode write

* refactor(fs): move generics to placeholders

* feat(ext2): Celled<Ext2> implements FileSystem

* fix(ext2): symlink stored path resolution for path with length <= 60

---------

Co-authored-by: Rat Cornu <ratcornu@skaven.org>
  • Loading branch information
RatCornu and Rat Cornu authored Jan 8, 2024
1 parent e78deea commit e35ca78
Show file tree
Hide file tree
Showing 34 changed files with 5,508 additions and 202 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.ext2 filter=lfs diff=lfs merge=lfs -text
*.ext3 filter=lfs diff=lfs merge=lfs -text
*.ext4 filter=lfs diff=lfs merge=lfs -text
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build

on: [push, pull_request, workflow_dispatch]
on: [pull_request, workflow_dispatch]

concurrency:
group: ${{ github.base_ref }}-build
Expand All @@ -13,15 +13,15 @@ jobs:

steps:
- uses: actions/checkout@master
- name: Checkout LFS objects
run: git lfs pull
- name: Deny check
uses: EmbarkStudios/cargo-deny-action@v1
- name: Format check
run: cargo fmt --check
- name: Lint check
run: cargo clippy --all-targets --all-features --no-deps
- name: Build
run: cargo build
run: cargo build --all-features
- name: Tests
run: |
cargo test --all-features
cargo test --all-features
run: cargo test --all-features
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Generate documentation
run: cargo doc --no-deps
run: cargo doc --no-deps --all-features
- name: Create index file
run: echo "<meta http-equiv=\"refresh\" content=\"0; url=efs\">" > target/doc/index.html
- name: Upload page artifact
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Release
on:
release:
types: [created]
push:


jobs:
release:
Expand Down
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ license = "MIT OR Apache-2.0"
keywords = ["filesystem", "no-std"]
categories = ["filesystem", "no-std"]

[lib]
name = "efs"
path = "src/lib.rs"

[dependencies]
bitflags = "2"
derive_more = "0.99"
itertools = { version = "0.11", default-features = false, features = ["use_alloc"] }
no_std_io = "0.6.0"
once_cell = "1"
regex = "1"

[dev-dependencies]
itertools = { version = "0.11", default-features = true }

[features]
default = ["no_std"]
no_std = []
default = ["ext2"]
ext2 = []
std = []
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
[![Documentation][documentation-badge]][documentation-link]
[![crates.io-badge]][crates.io-link]

[build-badge]: https://github.com/RatCornu/efs/workflows/Build/badge.svg
[build-link]: https://github.com/RatCornu/efs/actions?query=workflow:"Build"
[build-badge]: https://github.com/RatCornu/efs/actions/workflows/build.yml/badge.svg?branch=master
[build-link]: https://github.com/RatCornu/efs/actions/workflows/build.yml

[documentation-badge]: https://github.com/RatCornu/efs/workflows/Documentation/badge.svg
[documentation-link]: https://github.com/RatCornu/efs/actions?query=workflow:"Documentation"
[documentation-badge]: https://github.com/RatCornu/efs/actions/workflows/doc.yml/badge.svg?branch=master
[documentation-link]: https://github.com/RatCornu/efs/actions/workflows/doc.yml

[crates.io-badge]: https://img.shields.io/crates/v/efs.svg
[crates.io-link]: https://crates.io/crates/efs
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "Astre IAM";
description = "Extended FS flake";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
Expand Down
28 changes: 28 additions & 0 deletions src/dev/celled.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! Interface to use celled objects.
//!
//! It provides an interface to contenerize objects with the guarantee that the `clone` method is not expansive and the new celled
//! object point to the same initial one;
use alloc::rc::Rc;
use core::cell::RefCell;

use derive_more::{Deref, DerefMut};

/// Type alias for celled objects.
#[derive(Deref, DerefMut)]
pub struct Celled<T>(Rc<RefCell<T>>);

impl<T> Clone for Celled<T> {
#[inline]
fn clone(&self) -> Self {
Self(Rc::clone(&self.0))
}
}

impl<T> Celled<T> {
/// Creates a new celled object.
#[inline]
pub fn new(obj: T) -> Self {
Self(Rc::new(RefCell::new(obj)))
}
}
29 changes: 29 additions & 0 deletions src/dev/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//! Errors related to device manipulation.
use alloc::fmt;
use core::error;
use core::fmt::Display;

/// Enumeration of possible errors encountered with device's manipulation.
#[allow(clippy::module_name_repetitions)]
#[derive(Debug, PartialEq, Eq)]
pub enum DevError {
/// `OutOfBounds(structure, value, (lower_bound, upper_bound))`: the given `struct` has a `value` not between the given bounds
OutOfBounds(&'static str, i128, (i128, i128)),
}

impl Display for DevError {
#[inline]
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::OutOfBounds(structure, value, (lower_bound, upper_bound)) => {
write!(
formatter,
"Out of Bounds: the {structure} has a value {value} not between the lower bound {lower_bound} and the upper bound {upper_bound}"
)
},
}
}
}

impl error::Error for DevError {}
Loading

0 comments on commit e35ca78

Please sign in to comment.