Skip to content

Commit

Permalink
将 io 移动至 vfs 目录,并修正引用路径
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrysisa committed Aug 23, 2023
1 parent f09a983 commit a551179
Show file tree
Hide file tree
Showing 22 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion kernel/src/driver/disk/ahci/ahci_inode.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::filesystem::devfs::{DevFS, DeviceINode};
use crate::filesystem::vfs::file::FileMode;
use crate::filesystem::vfs::io::device::BlockDevice;
use crate::filesystem::vfs::{
core::generate_inode_id, make_rawdev, FilePrivateData, FileSystem, FileType, IndexNode,
Metadata, PollStatus,
};
use crate::io::device::BlockDevice;
use crate::syscall::SystemError;
use crate::{libs::spinlock::SpinLock, time::TimeSpec};
use alloc::{
Expand Down
14 changes: 7 additions & 7 deletions kernel/src/driver/disk/ahci/ahcidisk.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::{_port, hba::HbaCmdTable, virt_2_phys};
use crate::driver::disk::ahci::HBA_PxIS_TFES;
use crate::filesystem::mbr::MbrDiskPartionTable;
use crate::filesystem::vfs::io::{device::BlockDevice, disk_info::Partition, SeekFrom};
use crate::include::bindings::bindings::verify_area;
use crate::io::{device::BlockDevice, disk_info::Partition, SeekFrom};

use crate::libs::{spinlock::SpinLock, vec_cursor::VecCursor};
use crate::mm::phys_2_virt;
Expand Down Expand Up @@ -52,8 +52,8 @@ impl Debug for AhciDisk {
impl AhciDisk {
fn read_at(
&self,
lba_id_start: crate::io::device::BlockId, // 起始lba编号
count: usize, // 读取lba的数量
lba_id_start: crate::filesystem::vfs::io::device::BlockId, // 起始lba编号
count: usize, // 读取lba的数量
buf: &mut [u8],
) -> Result<usize, SystemError> {
compiler_fence(core::sync::atomic::Ordering::SeqCst);
Expand Down Expand Up @@ -211,7 +211,7 @@ impl AhciDisk {

fn write_at(
&self,
lba_id_start: crate::io::device::BlockId,
lba_id_start: crate::filesystem::vfs::io::device::BlockId,
count: usize,
buf: &[u8],
) -> Result<usize, SystemError> {
Expand Down Expand Up @@ -449,7 +449,7 @@ impl BlockDevice for LockedAhciDisk {
#[inline]
fn read_at(
&self,
lba_id_start: crate::io::device::BlockId,
lba_id_start: crate::filesystem::vfs::io::device::BlockId,
count: usize,
buf: &mut [u8],
) -> Result<usize, SystemError> {
Expand All @@ -463,7 +463,7 @@ impl BlockDevice for LockedAhciDisk {
#[inline]
fn write_at(
&self,
lba_id_start: crate::io::device::BlockId,
lba_id_start: crate::filesystem::vfs::io::device::BlockId,
count: usize,
buf: &[u8],
) -> Result<usize, SystemError> {
Expand All @@ -475,7 +475,7 @@ impl BlockDevice for LockedAhciDisk {
}

#[inline]
fn device(&self) -> Arc<dyn crate::io::device::Device> {
fn device(&self) -> Arc<dyn crate::filesystem::vfs::io::device::Device> {
return self.0.lock().self_ref.upgrade().unwrap();
}

Expand Down
4 changes: 2 additions & 2 deletions kernel/src/driver/disk/ahci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ pub mod ahci_inode;
pub mod ahcidisk;
pub mod hba;

use crate::io::device::BlockDevice;
use crate::filesystem::vfs::io::device::BlockDevice;
// 依赖的rust工具包
use crate::filesystem::devfs::devfs_register;
use crate::io::disk_info::BLK_GF_AHCI;
use crate::filesystem::vfs::io::disk_info::BLK_GF_AHCI;
use crate::kerror;
use crate::libs::spinlock::{SpinLock, SpinLockGuard};
use crate::mm::virt_2_phys;
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/filesystem/fat/bpb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use alloc::{sync::Arc, vec::Vec};

use crate::{
io::{device::LBA_SIZE, disk_info::Partition, SeekFrom},
filesystem::vfs::io::{device::LBA_SIZE, disk_info::Partition, SeekFrom},
kerror,
libs::vec_cursor::VecCursor,
syscall::SystemError,
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/filesystem/fat/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use core::{cmp::min, intrinsics::unlikely};

use crate::{
io::{device::LBA_SIZE, SeekFrom},
filesystem::vfs::io::{device::LBA_SIZE, SeekFrom},
kwarn,
libs::vec_cursor::VecCursor,
syscall::SystemError,
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/filesystem/fat/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use alloc::{
};

use crate::{
filesystem::vfs::io::{device::LBA_SIZE, disk_info::Partition, SeekFrom},
filesystem::vfs::{
core::generate_inode_id,
file::{FileMode, FilePrivateData},
FileSystem, FileType, IndexNode, InodeId, Metadata, PollStatus,
},
io::{device::LBA_SIZE, disk_info::Partition, SeekFrom},
kerror,
libs::{
spinlock::{SpinLock, SpinLockGuard},
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/filesystem/vfs/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn migrate_virtual_filesystem(new_fs: Arc<dyn FileSystem>) -> Result<(), SystemE
#[no_mangle]
pub extern "C" fn mount_root_fs() -> i32 {
kinfo!("Try to mount FAT32 as root fs...");
let partiton: Arc<crate::io::disk_info::Partition> =
let partiton: Arc<crate::filesystem::vfs::io::disk_info::Partition> =
ahci::get_disks_by_name("ahci_disk_0".to_string())
.unwrap()
.0
Expand Down
4 changes: 2 additions & 2 deletions kernel/src/filesystem/vfs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use alloc::{boxed::Box, string::String, sync::Arc, vec::Vec};

use crate::{
arch::asm::current::current_pcb, driver::tty::TtyFilePrivateData,
filesystem::procfs::ProcfsFilePrivateData, include::bindings::bindings::process_control_block,
io::SeekFrom, kerror, syscall::SystemError,
filesystem::procfs::ProcfsFilePrivateData, filesystem::vfs::io::SeekFrom,
include::bindings::bindings::process_control_block, kerror, syscall::SystemError,
};

use super::{Dirent, FileType, IndexNode, Metadata};
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions kernel/src/filesystem/vfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pub mod core;
pub mod fcntl;
pub mod file;
pub mod io;
pub mod mount;
pub mod syscall;
mod utils;
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/filesystem/vfs/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use alloc::{boxed::Box, sync::Arc, vec::Vec};
use crate::{
arch::asm::current::current_pcb,
filesystem::vfs::file::FileDescriptorVec,
filesystem::vfs::io::SeekFrom,
include::bindings::bindings::{verify_area, AT_REMOVEDIR, PAGE_4K_SIZE, PROC_MAX_FD_NUM},
io::SeekFrom,
kerror,
syscall::{Syscall, SystemError},
time::TimeSpec,
Expand Down
1 change: 0 additions & 1 deletion kernel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ mod include;
mod driver; // 如果driver依赖了libs,应该在libs后面导出
mod exception;
mod filesystem;
mod io;
mod ipc;
mod mm;
mod net;
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/libs/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use elf::{endian::AnyEndian, file::FileHeader, segment::ProgramHeader};
use crate::{
arch::MMArch,
current_pcb,
io::SeekFrom,
filesystem::vfs::io::SeekFrom,
kerror,
libs::align::page_align_up,
mm::{
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/libs/vec_cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::mem::size_of;

use alloc::vec::Vec;

use crate::{io::SeekFrom, syscall::SystemError};
use crate::{filesystem::vfs::io::SeekFrom, syscall::SystemError};

/// @brief 本模块用于为数组提供游标的功能,以简化其操作。
#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/process/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use core::{fmt::Debug, ptr::null};
use alloc::{collections::BTreeMap, string::String, sync::Arc, vec::Vec};

use crate::{
filesystem::vfs::io::SeekFrom,
filesystem::vfs::{
file::{File, FileMode},
ROOT_INODE,
},
io::SeekFrom,
libs::elf::ELF_LOADER,
mm::{
ucontext::{AddressSpace, UserStack},
Expand Down
3 changes: 1 addition & 2 deletions kernel/src/syscall/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use num_traits::{FromPrimitive, ToPrimitive};

use crate::{
arch::{cpu::cpu_reset, MMArch},
filesystem::vfs::io::SeekFrom,
filesystem::vfs::{
fcntl::FcntlCommand,
file::FileMode,
syscall::{PosixKstat, SEEK_CUR, SEEK_END, SEEK_MAX, SEEK_SET},
MAX_PATHLEN,
},
include::bindings::bindings::{pid_t, PAGE_2M_SIZE, PAGE_4K_SIZE},
io::SeekFrom,
kinfo,
libs::align::page_align_up,
mm::{verify_area, MemoryManagementArch, VirtAddr},
Expand Down Expand Up @@ -664,7 +664,6 @@ impl Syscall {
Ok(pipefd) => Self::pipe(pipefd),
},
}

}

SYS_UNLINK_AT => {
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/syscall/user_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ impl<'a> UserBufferWriter<'a> {
};
return Ok(chunks);
}

fn convert_one_with_offset<T>(src: &mut [u8], offset: usize) -> Result<&mut T, SystemError> {
if offset + core::mem::size_of::<T>() > src.len() {
return Err(SystemError::EINVAL);
Expand Down

0 comments on commit a551179

Please sign in to comment.