1
0
mirror of https://github.com/sgmarz/osblog.git synced 2024-11-23 18:06:20 +04:00

Add inode number to fs_read

This commit is contained in:
Stephen Marz 2020-04-24 19:22:27 -04:00
parent a113db700a
commit 4c31f8c563
3 changed files with 13 additions and 11 deletions

View File

@ -135,7 +135,7 @@ impl MinixFileSystem {
// Now, we read the inode itself.
syc_read(desc, buffer.get_mut(), 512, inode_offset as u32);
println!("Inode sizex = {} {:o}, DZ {} {} {} {} {} {} {}", inode.size, inode.mode, inode.zones[0], inode.zones[1], inode.zones[2], inode.zones[3], inode.zones[4], inode.zones[5], inode.zones[6]);
println!("Inode {} sizex = {} {:o}, DZ {} {} {} {} {} {} {}", inode_num, inode.size, inode.mode, inode.zones[0], inode.zones[1], inode.zones[2], inode.zones[3], inode.zones[4], inode.zones[5], inode.zones[6]);
return Some(*inode);
}
// If we get here, some result wasn't OK. Either the super block
@ -154,7 +154,6 @@ impl FileSystem for MinixFileSystem {
}
fn read(desc: &Descriptor, buffer: *mut u8, size: u32, offset: u32) -> u32 {
println!("MinixFileSystem::read: {}, {:p}, off: {}, sz: {}", desc.blockdev, buffer, offset, size);
let mut blocks_seen = 0u32;
let offset_block = offset / BLOCK_SIZE;
let offset_byte = offset % BLOCK_SIZE;
@ -233,6 +232,7 @@ struct ProcArgs {
pub buffer: *mut u8,
pub size: u32,
pub offset: u32,
pub node: u32,
}
fn read_proc(args_addr: usize) {
@ -240,7 +240,7 @@ fn read_proc(args_addr: usize) {
let args = unsafe { args_ptr.as_ref().unwrap() };
let desc = Descriptor { blockdev: args.dev,
node: 1,
node: args.node,
loc: 0,
size: 500,
pid: args.pid, };
@ -249,7 +249,7 @@ fn read_proc(args_addr: usize) {
tfree(args_ptr);
}
pub fn process_read(pid: u16, dev: usize, buffer: *mut u8, size: u32, offset: u32) {
pub fn process_read(pid: u16, dev: usize, node: u32, buffer: *mut u8, size: u32, offset: u32) {
// println!("FS read {}, {}, 0x{:x}, {}, {}", pid, dev, buffer as usize, size, offset);
let args = talloc::<ProcArgs>().unwrap();
args.pid = pid;
@ -257,6 +257,7 @@ pub fn process_read(pid: u16, dev: usize, buffer: *mut u8, size: u32, offset: u3
args.buffer = buffer;
args.size = size;
args.offset = offset;
args.node = node;
set_waiting(pid);
let _ = add_kernel_process_args(read_proc, args as *mut ProcArgs as usize);
}

View File

@ -49,10 +49,11 @@ pub fn do_syscall(mepc: usize, frame: *mut TrapFrame) -> usize {
// This needs to be put into a process and ran.
let _ = minixfs::process_read(
(*frame).pid as u16,
(*frame).regs[10] as usize,
(*frame).regs[11] as *mut u8,
(*frame).regs[12] as u32,
(*frame).regs[13] as u32
(*frame).regs[10] as usize,
(*frame).regs[11] as u32,
(*frame).regs[12] as *mut u8,
(*frame).regs[13] as u32,
(*frame).regs[14] as u32
);
// If we return 0, the trap handler will schedule another process.
0
@ -97,8 +98,8 @@ pub fn syscall_exit() {
let _ = do_make_syscall(93, 0, 0, 0, 0, 0, 0);
}
pub fn syscall_fs_read(dev: usize, buffer: *mut u8, size: u32, offset: u32) -> usize {
do_make_syscall(63, dev, buffer as usize, size as usize, offset as usize, 0, 0)
pub fn syscall_fs_read(dev: usize, inode: u32, buffer: *mut u8, size: u32, offset: u32) -> usize {
do_make_syscall(63, dev, inode as usize, buffer as usize, size as usize, offset as usize, 0)
}
pub fn syscall_block_read(dev: usize, buffer: *mut u8, size: u32, offset: u32) -> usize {

View File

@ -7,7 +7,7 @@ pub fn test_block() {
let buffer = crate::kmem::kmalloc(1024);
println!("Started test block process, buffer is at {:p}.", buffer);
unsafe {
syscall_fs_read(8, buffer, 0, 1024);
syscall_fs_read(8, 1, buffer, 0, 1024);
for i in 0..32 {
print!("{:02x} ", buffer.add(i).read());
if (i+1) % 16 == 0 {