Skip to content

Commit

Permalink
refactor(mkfs): cleanup (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
llenotre committed Jul 4, 2024
1 parent 1872985 commit 013c0bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/mkfs/ext2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const WRITE_REQUIRED_DIRECTORY_BINARY_TREE: u32 = 0x4;
/// The root inode.
const ROOT_INODE: u32 = 2;

/// The ext2 superblock structure.
/// The ext2 superblock.
#[repr(C, packed)]
struct Superblock {
/// Total number of inodes in the filesystem.
Expand Down Expand Up @@ -188,8 +188,7 @@ impl Superblock {
}
}

/// Structure representing a block group descriptor to be stored into the Block Group Descriptor
/// Table (BGDT).
/// A block group descriptor to be stored into the Block Group Descriptor Table (BGDT).
#[repr(C, packed)]
struct BlockGroupDescriptor {
/// The block address of the block usage bitmap.
Expand Down Expand Up @@ -331,7 +330,7 @@ impl INode {
/// Each directory entry represent a file that is the stored in the
/// directory and points to its inode.
///
/// The name of the entry is not included to prevent the structure from being usized.
/// The name of the entry is not included to avoid making the structure unsized.
#[repr(C, packed)]
pub struct DirectoryEntry {
/// The inode associated with the entry.
Expand Down
8 changes: 4 additions & 4 deletions src/mkfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ pub fn main(fs_name: &str, args: ArgsOs) {
"ext2",
Box::<ext2::Ext2Factory>::default() as Box<dyn FSFactory>,
)]);
let factory = factories.get(args.fs_type.as_str()).unwrap_or_else(|| {
let Some(factory) = factories.get(&args.fs_type) else {
error(
"mkfs",
format_args!("invalid filesystem type `{}`", args.fs_type),
);
});
let device_path = args.device_path.unwrap_or_else(|| {
};
let Some(device_path) = args.device_path else {
error("mkfs", "specify path to a device");
});
};
let mut file = OpenOptions::new()
.read(true)
.write(true)
Expand Down

0 comments on commit 013c0bb

Please sign in to comment.