mirror of
https://github.com/sgmarz/osblog.git
synced 2024-11-24 02:16:19 +04:00
Fix warnings
This commit is contained in:
parent
6367e064cf
commit
5b5e5d9e2b
@ -69,7 +69,6 @@ pub struct DirEntry {
|
|||||||
|
|
||||||
/// The MinixFileSystem implements the FileSystem trait for the VFS.
|
/// The MinixFileSystem implements the FileSystem trait for the VFS.
|
||||||
pub struct MinixFileSystem {
|
pub struct MinixFileSystem {
|
||||||
bdev: usize,
|
|
||||||
inode_cache: BTreeMap<String, Inode>
|
inode_cache: BTreeMap<String, Inode>
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,14 +162,13 @@ impl MinixFileSystem {
|
|||||||
// Run this ONLY in a process!
|
// Run this ONLY in a process!
|
||||||
pub fn init(bdev: usize) -> Self {
|
pub fn init(bdev: usize) -> Self {
|
||||||
let mut btm = BTreeMap::new();
|
let mut btm = BTreeMap::new();
|
||||||
let mut cwd = String::from("/");
|
let cwd = String::from("/");
|
||||||
|
|
||||||
// Let's look at the root (inode #1)
|
// Let's look at the root (inode #1)
|
||||||
Self::cache_at(&mut btm, &cwd, 1, bdev);
|
Self::cache_at(&mut btm, &cwd, 1, bdev);
|
||||||
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
bdev,
|
|
||||||
inode_cache: btm
|
inode_cache: btm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,7 +192,7 @@ impl MinixFileSystem {
|
|||||||
let mut blocks_seen = 0u32;
|
let mut blocks_seen = 0u32;
|
||||||
let offset_block = offset / BLOCK_SIZE;
|
let offset_block = offset / BLOCK_SIZE;
|
||||||
let mut offset_byte = offset % BLOCK_SIZE;
|
let mut offset_byte = offset % BLOCK_SIZE;
|
||||||
const num_indirect_pointers: usize = BLOCK_SIZE as usize / 4;
|
const NUM_INDIRECT_POINTERS: usize = BLOCK_SIZE as usize / 4;
|
||||||
// First, the _size parameter (now in bytes_left) is the size of the buffer, not
|
// First, the _size parameter (now in bytes_left) is the size of the buffer, not
|
||||||
// necessarily the size of the file. If our buffer is bigger than the file, we're OK.
|
// necessarily the size of the file. If our buffer is bigger than the file, we're OK.
|
||||||
// If our buffer is smaller than the file, then we can only read up to the buffer size.
|
// If our buffer is smaller than the file, then we can only read up to the buffer size.
|
||||||
@ -283,7 +281,7 @@ impl MinixFileSystem {
|
|||||||
if inode.zones[7] != 0 {
|
if inode.zones[7] != 0 {
|
||||||
syc_read(bdev, indirect_buffer.get_mut(), BLOCK_SIZE, BLOCK_SIZE * inode.zones[7]);
|
syc_read(bdev, indirect_buffer.get_mut(), BLOCK_SIZE, BLOCK_SIZE * inode.zones[7]);
|
||||||
let izones = indirect_buffer.get() as *const u32;
|
let izones = indirect_buffer.get() as *const u32;
|
||||||
for i in 0..num_indirect_pointers {
|
for i in 0..NUM_INDIRECT_POINTERS{
|
||||||
// Where do I put unsafe? Dereferencing the pointers and memcpy are the unsafe functions.
|
// Where do I put unsafe? Dereferencing the pointers and memcpy are the unsafe functions.
|
||||||
unsafe {
|
unsafe {
|
||||||
if izones.add(i).read() != 0 {
|
if izones.add(i).read() != 0 {
|
||||||
@ -323,10 +321,10 @@ impl MinixFileSystem {
|
|||||||
if inode.zones[8] != 0 {
|
if inode.zones[8] != 0 {
|
||||||
syc_read(bdev, indirect_buffer.get_mut(), BLOCK_SIZE, BLOCK_SIZE * inode.zones[8]);
|
syc_read(bdev, indirect_buffer.get_mut(), BLOCK_SIZE, BLOCK_SIZE * inode.zones[8]);
|
||||||
unsafe {
|
unsafe {
|
||||||
for i in 0..num_indirect_pointers {
|
for i in 0..NUM_INDIRECT_POINTERS {
|
||||||
if izones.add(i).read() != 0 {
|
if izones.add(i).read() != 0 {
|
||||||
syc_read(bdev, iindirect_buffer.get_mut(), BLOCK_SIZE, BLOCK_SIZE * izones.add(i).read());
|
syc_read(bdev, iindirect_buffer.get_mut(), BLOCK_SIZE, BLOCK_SIZE * izones.add(i).read());
|
||||||
for j in 0..num_indirect_pointers {
|
for j in 0..NUM_INDIRECT_POINTERS {
|
||||||
if iizones.add(j).read() != 0 {
|
if iizones.add(j).read() != 0 {
|
||||||
// Notice that this inner code is the same for all end-zone pointers. I'm thinking about
|
// Notice that this inner code is the same for all end-zone pointers. I'm thinking about
|
||||||
// moving this out of here into a function of its own, but that might make it harder
|
// moving this out of here into a function of its own, but that might make it harder
|
||||||
@ -369,10 +367,10 @@ impl MinixFileSystem {
|
|||||||
if inode.zones[9] != 0 {
|
if inode.zones[9] != 0 {
|
||||||
syc_read(bdev, indirect_buffer.get_mut(), BLOCK_SIZE, BLOCK_SIZE * inode.zones[9]);
|
syc_read(bdev, indirect_buffer.get_mut(), BLOCK_SIZE, BLOCK_SIZE * inode.zones[9]);
|
||||||
unsafe {
|
unsafe {
|
||||||
for i in 0..num_indirect_pointers {
|
for i in 0..NUM_INDIRECT_POINTERS {
|
||||||
if izones.add(i).read() != 0 {
|
if izones.add(i).read() != 0 {
|
||||||
syc_read(bdev, iindirect_buffer.get_mut(), BLOCK_SIZE, BLOCK_SIZE * izones.add(i).read());
|
syc_read(bdev, iindirect_buffer.get_mut(), BLOCK_SIZE, BLOCK_SIZE * izones.add(i).read());
|
||||||
for j in 0..num_indirect_pointers {
|
for j in 0..NUM_INDIRECT_POINTERS {
|
||||||
if iizones.add(j).read() != 0 {
|
if iizones.add(j).read() != 0 {
|
||||||
syc_read(
|
syc_read(
|
||||||
bdev,
|
bdev,
|
||||||
@ -380,7 +378,7 @@ impl MinixFileSystem {
|
|||||||
BLOCK_SIZE,
|
BLOCK_SIZE,
|
||||||
BLOCK_SIZE * iizones.add(j,).read(),
|
BLOCK_SIZE * iizones.add(j,).read(),
|
||||||
);
|
);
|
||||||
for k in 0..num_indirect_pointers {
|
for k in 0..NUM_INDIRECT_POINTERS {
|
||||||
if iiizones.add(k).read() != 0 {
|
if iiizones.add(k).read() != 0 {
|
||||||
// Hey look! This again.
|
// Hey look! This again.
|
||||||
if offset_block <= blocks_seen {
|
if offset_block <= blocks_seen {
|
||||||
@ -425,7 +423,7 @@ impl MinixFileSystem {
|
|||||||
bytes_read
|
bytes_read
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write(&mut self, desc: &String, _buffer: *const u8, _offset: u32, _size: u32) -> u32 {
|
pub fn write(&mut self, _desc: &Inode, _buffer: *const u8, _offset: u32, _size: u32) -> u32 {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,10 +4,9 @@
|
|||||||
// 12 May 2020
|
// 12 May 2020
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
use crate::{kmem::{kfree, kmalloc},
|
use crate::{page::{zalloc, PAGE_SIZE},
|
||||||
page::{zalloc, PAGE_SIZE},
|
|
||||||
virtio,
|
virtio,
|
||||||
virtio::{Descriptor, MmioOffsets, Queue, StatusField, VIRTIO_RING_SIZE}};
|
virtio::{MmioOffsets, Queue, StatusField, VIRTIO_RING_SIZE}};
|
||||||
use core::{mem::size_of, ptr::null_mut};
|
use core::{mem::size_of, ptr::null_mut};
|
||||||
|
|
||||||
pub struct GpuDevice {
|
pub struct GpuDevice {
|
||||||
|
@ -16,16 +16,15 @@ use crate::{cpu::{build_satp,
|
|||||||
PROCESS_LIST,
|
PROCESS_LIST,
|
||||||
PROCESS_LIST_MUTEX,
|
PROCESS_LIST_MUTEX,
|
||||||
STACK_ADDR,
|
STACK_ADDR,
|
||||||
STACK_PAGES},
|
STACK_PAGES}};
|
||||||
syscall::{syscall_get_pid, syscall_fs_read, syscall_exit}};
|
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
|
|
||||||
/// Test block will load raw binaries into memory to execute them. This function
|
/// Test block will load raw binaries into memory to execute them. This function
|
||||||
/// will load ELF files and try to execute them.
|
/// will load ELF files and try to execute them.
|
||||||
pub fn test_elf() {
|
pub fn test_elf() {
|
||||||
// This won't be necessary after we connect this to the VFS, but for now, we need it.
|
// This won't be necessary after we connect this to the VFS, but for now, we need it.
|
||||||
const bdev: usize = 8;
|
const BDEV: usize = 8;
|
||||||
let mfs = MinixFileSystem::init(bdev);
|
let mfs = MinixFileSystem::init(BDEV);
|
||||||
let desc = mfs.open(&String::from("/helloworld.elf")).ok();
|
let desc = mfs.open(&String::from("/helloworld.elf")).ok();
|
||||||
if desc.is_none() {
|
if desc.is_none() {
|
||||||
println!("Error reading /helloworld.elf");
|
println!("Error reading /helloworld.elf");
|
||||||
@ -39,7 +38,7 @@ pub fn test_elf() {
|
|||||||
// Read the file from the disk. I got the inode by mounting
|
// Read the file from the disk. I got the inode by mounting
|
||||||
// the harddrive as a loop on Linux and stat'ing the inode.
|
// the harddrive as a loop on Linux and stat'ing the inode.
|
||||||
|
|
||||||
let bytes_read = MinixFileSystem::read(bdev, &ino, buffer.get_mut(), ino.size, 0);
|
let bytes_read = MinixFileSystem::read(BDEV, &ino, buffer.get_mut(), ino.size, 0);
|
||||||
// After compiling our program, I manually looked and saw it was 18,360
|
// After compiling our program, I manually looked and saw it was 18,360
|
||||||
// bytes. So, to make sure we got the right one, I do a manual check
|
// bytes. So, to make sure we got the right one, I do a manual check
|
||||||
// here.
|
// here.
|
||||||
|
Loading…
Reference in New Issue
Block a user