1
0
mirror of https://github.com/sgmarz/osblog.git synced 2024-11-28 04:13:31 +04:00
osblog/risc_v/src/minixfs.rs

80 lines
1.4 KiB
Rust
Raw Normal View History

2020-03-18 18:40:27 +04:00
// minixfs.rs
// Minix 3 Filesystem Implementation
// Stephen Marz
// 16 March 2020
2020-03-19 06:01:05 +04:00
use crate::fs::{Descriptor, FileSystem, Stat, FsError};
2020-04-22 04:23:39 +04:00
2020-03-19 06:01:05 +04:00
use alloc::string::String;
2020-04-22 04:23:39 +04:00
2020-03-19 06:01:05 +04:00
pub const MAGIC: u16 = 0x4d5a;
#[repr(C)]
pub struct SuperBlock {
ninodes: u32,
pad0: u16,
imap_blocks: u16,
zmap_blocks: u16,
first_data_zone: u16,
log_zone_size: u16,
pad1: u16,
max_size: u32,
zones: u32,
magic: u16,
pad2: u16,
block_size: u16,
disk_version: u8,
}
#[repr(C)]
pub struct Inode {
mode: u16,
nlinks: u16,
uid: u16,
gid: u16,
size: u32,
atime: u32,
mtime: u32,
ctime: u32,
zones: [u32; 10],
}
#[repr(C)]
pub struct DirEntry {
inode: u32,
name: [u8; 60],
}
2020-03-18 18:40:27 +04:00
pub struct MinixFileSystem {
2020-03-19 06:01:05 +04:00
sb: SuperBlock
}
impl FileSystem for MinixFileSystem {
2020-04-22 04:23:39 +04:00
fn init(_bdev: usize) -> bool {
2020-03-19 06:01:05 +04:00
false
}
2020-04-22 04:23:39 +04:00
fn open(_path: &String) -> Result<Descriptor, FsError> {
2020-03-19 06:01:05 +04:00
Err(FsError::FileNotFound)
}
2020-04-22 04:23:39 +04:00
fn read(_desc: &Descriptor, _buffer: *mut u8, _offset: u32, _size: u32) -> u32 {
2020-03-19 06:01:05 +04:00
0
}
2020-04-22 04:23:39 +04:00
fn write(_desc: &Descriptor, _buffer: *const u8, _offset: u32, _size: u32) -> u32 {
2020-03-19 06:01:05 +04:00
0
}
2020-04-22 04:23:39 +04:00
fn close(_desc: &mut Descriptor) {
2020-03-18 18:40:27 +04:00
2020-03-19 06:01:05 +04:00
}
2020-04-22 04:23:39 +04:00
fn stat(_desc: &Descriptor) -> Stat {
2020-03-19 06:01:05 +04:00
Stat {
mode: 0,
size: 0,
uid: 0,
gid: 0,
}
}
2020-03-18 18:40:27 +04:00
}