refactor: integrate vfs into libk

This commit is contained in:
Mark Poliakov 2024-03-13 19:01:59 +02:00
parent d44bda6d62
commit 69b6a38c0a
53 changed files with 69 additions and 94 deletions

25
Cargo.lock generated
View File

@ -718,9 +718,9 @@ dependencies = [
name = "kernel-fs"
version = "0.1.0"
dependencies = [
"libk",
"libk-util",
"log",
"vfs",
"yggdrasil-abi",
]
@ -912,10 +912,10 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
name = "memfs"
version = "0.1.0"
dependencies = [
"libk",
"libk-util",
"log",
"static_assertions",
"vfs",
"yggdrasil-abi",
]
@ -1512,18 +1512,6 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "vfs"
version = "0.1.0"
dependencies = [
"futures-util",
"libk-mm",
"libk-thread",
"libk-util",
"log",
"yggdrasil-abi",
]
[[package]]
name = "vmalloc"
version = "0.1.0"
@ -1742,6 +1730,7 @@ dependencies = [
"device-api",
"futures-util",
"kernel-fs",
"libk",
"libk-mm",
"libk-thread",
"libk-util",
@ -1749,7 +1738,6 @@ dependencies = [
"memoffset 0.9.0",
"static_assertions",
"tock-registers 0.8.1",
"vfs",
"ygg_driver_pci",
"yggdrasil-abi",
]
@ -1758,10 +1746,10 @@ dependencies = [
name = "ygg_driver_input"
version = "0.1.0"
dependencies = [
"libk",
"libk-mm",
"libk-thread",
"libk-util",
"vfs",
"yggdrasil-abi",
]
@ -1771,6 +1759,7 @@ version = "0.1.0"
dependencies = [
"bytemuck",
"kernel-fs",
"libk",
"libk-device",
"libk-mm",
"libk-thread",
@ -1778,7 +1767,6 @@ dependencies = [
"log",
"serde",
"serde_json",
"vfs",
"yggdrasil-abi",
]
@ -1801,13 +1789,13 @@ dependencies = [
"device-api",
"futures-util",
"kernel-fs",
"libk",
"libk-mm",
"libk-thread",
"libk-util",
"log",
"static_assertions",
"tock-registers 0.8.1",
"vfs",
"ygg_driver_pci",
"yggdrasil-abi",
]
@ -1943,7 +1931,6 @@ dependencies = [
"spinning_top",
"static_assertions",
"tock-registers 0.8.1",
"vfs",
"vmalloc",
"yboot-proto",
"ygg_driver_ahci",

View File

@ -13,7 +13,6 @@ opt-level = 3
abi-lib = { path = "../lib/abi-lib" }
yggdrasil-abi = { path = "../lib/abi" }
vfs = { path = "lib/vfs" }
device-api = { path = "lib/device-api", features = ["derive"] }
libk = { path = "libk" }
libk-util = { path = "libk/libk-util" }

View File

@ -9,8 +9,8 @@ yggdrasil-abi = { path = "../../../../lib/abi" }
libk-mm = { path = "../../../libk/libk-mm" }
libk-thread = { path = "../../../libk/libk-thread" }
libk-util = { path = "../../../libk/libk-util" }
libk = { path = "../../../libk" }
device-api = { path = "../../../lib/device-api", features = ["derive"] }
vfs = { path = "../../../lib/vfs" }
ygg_driver_pci = { path = "../../bus/pci" }
kernel-fs = { path = "../../fs/kernel-fs" }

View File

@ -13,13 +13,13 @@ use device_api::{
};
use error::AhciError;
use kernel_fs::devfs;
use libk::vfs::block::{probe_partitions, NgBlockDeviceWrapper};
use libk_mm::{address::AsPhysicalAddress, device::DeviceMemoryIo, PageBox};
use libk_thread::runtime;
use libk_util::{sync::IrqSafeSpinlock, OneTimeInit};
use port::AhciPort;
use regs::{PortRegs, Regs};
use tock_registers::interfaces::{ReadWriteable, Readable, Writeable};
use vfs::block::{probe_partitions, NgBlockDeviceWrapper};
use ygg_driver_pci::{
device::{PciDeviceInfo, PreferredInterruptMode},
PciCommandRegister, PciConfigurationSpace,

View File

@ -7,10 +7,10 @@ use core::{
use alloc::{boxed::Box, string::String};
use bytemuck::Zeroable;
use futures_util::{task::AtomicWaker, Future};
use libk::vfs::block::{IoOperation, IoRequest, IoSubmissionId, NgBlockDevice};
use libk_mm::{address::AsPhysicalAddress, device::DeviceMemoryIo, PageBox};
use libk_util::{sync::IrqSafeSpinlock, waker::QueueWaker, OneTimeInit};
use tock_registers::interfaces::{Readable, Writeable};
use vfs::block::{IoOperation, IoRequest, IoSubmissionId, NgBlockDevice};
use yggdrasil_abi::error::Error;
use crate::{

View File

@ -9,8 +9,8 @@ yggdrasil-abi = { path = "../../../../lib/abi" }
libk-util = { path = "../../../libk/libk-util" }
libk-thread = { path = "../../../libk/libk-thread" }
libk-mm = { path = "../../../libk/libk-mm" }
libk = { path = "../../../libk" }
device-api = { path = "../../../lib/device-api", features = ["derive"] }
vfs = { path = "../../../lib/vfs" }
ygg_driver_pci = { path = "../../bus/pci" }
kernel-fs = { path = "../../fs/kernel-fs" }

View File

@ -2,12 +2,12 @@ use core::task::Poll;
use alloc::{boxed::Box, format};
use kernel_fs::devfs;
use libk::vfs::block::{
probe_partitions, IoOperation, IoRequest, IoSubmissionId, NgBlockDevice, NgBlockDeviceWrapper,
};
use libk_mm::address::AsPhysicalAddress;
use libk_thread::cpu_index;
use libk_util::waker::QueueWaker;
use vfs::block::{
probe_partitions, IoOperation, IoRequest, IoSubmissionId, NgBlockDevice, NgBlockDeviceWrapper,
};
use yggdrasil_abi::error::Error;
use crate::command::{IdentifyNamespaceRequest, IoRead};

View File

@ -6,7 +6,7 @@ authors = ["Mark Poliakov <mark@alnyan.me>"]
[dependencies]
yggdrasil-abi = { path = "../../../../lib/abi" }
vfs = { path = "../../../lib/vfs" }
libk-util = { path = "../../../libk/libk-util" }
libk = { path = "../../../libk" }
log = "0.4.20"

View File

@ -2,8 +2,8 @@
use core::sync::atomic::{AtomicUsize, Ordering};
use alloc::{format, string::String};
use libk::vfs::{block::BlockDevice, impls::MemoryDirectory, CharDevice, Node, NodeFlags, NodeRef};
use libk_util::OneTimeInit;
use vfs::{block::BlockDevice, impls::MemoryDirectory, CharDevice, Node, NodeFlags, NodeRef};
use yggdrasil_abi::error::Error;
/// Describes the kind of a character device

View File

@ -7,7 +7,7 @@ authors = ["Mark Poliakov <mark@alnyan.me>"]
[dependencies]
yggdrasil-abi = { path = "../../../../lib/abi" }
libk-util = { path = "../../../libk/libk-util" }
vfs = { path = "../../../lib/vfs" }
libk = { path = "../../../libk" }
static_assertions = "1.1.0"
log = "0.4.20"

View File

@ -1,6 +1,6 @@
use core::marker::PhantomData;
use vfs::{CommonImpl, DirectoryImpl, DirectoryOpenPosition, Node, NodeFlags, NodeRef};
use libk::vfs::{CommonImpl, DirectoryImpl, DirectoryOpenPosition, Node, NodeFlags, NodeRef};
use yggdrasil_abi::{error::Error, io::FileType};
use crate::{block::BlockAllocator, file::FileNode};

View File

@ -1,7 +1,7 @@
use core::any::Any;
use libk::vfs::{CommonImpl, InstanceData, Node, NodeFlags, NodeRef, RegularImpl};
use libk_util::sync::IrqSafeSpinlock;
use vfs::{CommonImpl, InstanceData, Node, NodeFlags, NodeRef, RegularImpl};
use yggdrasil_abi::{error::Error, io::OpenOptions};
use crate::{block::BlockAllocator, bvec::BVec};

View File

@ -15,7 +15,7 @@ use alloc::rc::Rc;
use block::BlockAllocator;
use dir::DirectoryNode;
use file::FileNode;
use vfs::{AccessToken, NodeRef};
use libk::vfs::{AccessToken, NodeRef};
use yggdrasil_abi::{
error::Error,
io::{FileMode, FileType, GroupId, UserId},

View File

@ -8,4 +8,4 @@ yggdrasil-abi = { path = "../../../lib/abi" }
libk-util = { path = "../../libk/libk-util" }
libk-thread = { path = "../../libk/libk-thread" }
libk-mm = { path = "../../libk/libk-mm" }
vfs = { path = "../../lib/vfs" }
libk = { path = "../../libk" }

View File

@ -4,9 +4,9 @@ extern crate alloc;
use core::task::{Context, Poll};
use libk::vfs::{CharDevice, FileReadiness};
use libk_thread::block;
use libk_util::ring::LossyRingQueue;
use vfs::{CharDevice, FileReadiness};
use yggdrasil_abi::{
error::Error,
io::{DeviceRequest, KeyboardKeyEvent},

View File

@ -9,7 +9,7 @@ libk-mm = { path = "../../../libk/libk-mm" }
libk-util = { path = "../../../libk/libk-util" }
libk-thread = { path = "../../../libk/libk-thread" }
libk-device = { path = "../../../libk/libk-device" }
vfs = { path = "../../../lib/vfs" }
libk = { path = "../../../libk" }
kernel-fs = { path = "../../fs/kernel-fs" }

View File

@ -1,6 +1,6 @@
use alloc::{boxed::Box, sync::Arc, vec::Vec};
use libk::vfs::{ChannelDescriptor, MessagePayload};
use serde::Serialize;
use vfs::{ChannelDescriptor, MessagePayload};
use yggdrasil_abi::{
error::Error,
io::{ChannelPublisherId, MessageDestination},

View File

@ -7,6 +7,7 @@ use core::{
};
use alloc::{collections::BTreeMap, sync::Arc, vec::Vec};
use libk::vfs::{ConnectionSocket, FileReadiness, ListenerSocket, PacketSocket, Socket};
use libk_device::monotonic_timestamp;
use libk_mm::PageBox;
use libk_thread::{
@ -21,7 +22,6 @@ use libk_util::{
},
waker::QueueWaker,
};
use vfs::{ConnectionSocket, FileReadiness, ListenerSocket, PacketSocket, Socket};
use yggdrasil_abi::{
error::Error,
net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4, SocketInterfaceQuery, SocketOption},

View File

@ -1,16 +0,0 @@
[package]
name = "vfs"
version = "0.1.0"
edition = "2021"
authors = ["Mark Poliakov <mark@alnyan.me>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
yggdrasil-abi = { path = "../../../lib/abi", features = ["alloc"] }
libk-mm = { path = "../../libk/libk-mm" }
libk-util = { path = "../../libk/libk-util" }
libk-thread = { path = "../../libk/libk-thread" }
log = "0.4.20"
futures-util = { version = "0.3.28", default-features = false, features = ["alloc", "async-await"] }

View File

@ -12,7 +12,7 @@ libk-device = { path = "../libk-device" }
kernel-arch = { path = "../../arch" }
abi-lib = { path = "../../../lib/abi-lib" }
yggdrasil-abi = { path = "../../../lib/abi" }
yggdrasil-abi = { path = "../../../lib/abi", features = ["alloc"] }
log = "0.4.20"
atomic_enum = "0.2.0"

View File

@ -13,7 +13,9 @@
const_maybe_uninit_uninit_array,
new_uninit,
inline_const,
trait_alias
trait_alias,
if_let_guard,
trait_upcasting
)]
extern crate alloc;
@ -21,6 +23,7 @@ extern crate alloc;
pub use libk_thread::{block, cpu_count, cpu_index, runtime};
pub mod arch;
pub mod vfs;
pub mod device {
pub use libk_device::*;

View File

@ -12,7 +12,7 @@ use libk_mm::{address::PhysicalAddress, table::MapAttributes, PageBox, PageProvi
use libk_util::waker::QueueWaker;
use yggdrasil_abi::{error::Error, io::DeviceRequest};
use crate::block::{
use crate::vfs::block::{
request::{IoOperation, IoRequest, IoSubmissionId},
BlockDevice,
};

View File

@ -18,7 +18,7 @@ use yggdrasil_abi::{
io::{ChannelPublisherId, MessageDestination},
};
use crate::{FileReadiness, FileRef};
use crate::vfs::{FileReadiness, FileRef};
/// Describes a channel over which messages can be sent to [Subscription]s
pub struct Channel {

View File

@ -1,6 +1,6 @@
use yggdrasil_abi::{error::Error, io::DeviceRequest};
use crate::{
use crate::vfs::{
block::BlockDevice,
node::{CommonImpl, NodeRef},
traits::FileReadiness,

View File

@ -1,7 +1,7 @@
use libk_util::sync::IrqSafeSpinlock;
use yggdrasil_abi::{error::Error, io::SeekFrom};
use crate::{
use crate::vfs::{
device::{BlockDeviceWrapper, CharDeviceWrapper},
node::NodeRef,
};

View File

@ -3,7 +3,7 @@ use core::{mem::MaybeUninit, str::FromStr};
use libk_util::sync::IrqSafeSpinlock;
use yggdrasil_abi::{error::Error, io::DirectoryEntry, util::FixedString};
use crate::node::NodeRef;
use crate::vfs::node::NodeRef;
use super::DirectoryOpenPosition;

View File

@ -19,7 +19,7 @@ use yggdrasil_abi::{
net::SocketAddr,
};
use crate::{
use crate::vfs::{
channel::ChannelDescriptor,
device::{BlockDeviceWrapper, CharDeviceWrapper},
node::NodeRef,

View File

@ -2,7 +2,7 @@ use libk_util::sync::IrqSafeSpinlock;
use yggdrasil_abi::{error::Error, io::SeekFrom};
use super::InstanceData;
use crate::node::NodeRef;
use crate::vfs::node::NodeRef;
#[derive(Clone)]
pub struct RegularFile {

View File

@ -6,7 +6,7 @@ use yggdrasil_abi::{
path::{Path, PathBuf},
};
use crate::{
use crate::vfs::{
node::{AccessToken, CreateInfo},
File, FileRef, NodeRef,
};

View File

@ -1,17 +1,17 @@
//! Virtual filesystem interfaces and driver implementation
#![cfg_attr(not(test), no_std)]
#![cfg_attr(test, allow(unused_imports))]
#![allow(clippy::new_ret_no_self, clippy::new_without_default)]
#![deny(missing_docs)]
#![feature(
if_let_guard,
maybe_uninit_slice,
trait_alias,
let_chains,
new_uninit,
trait_upcasting
)]
// #![cfg_attr(not(test), no_std)]
// #![cfg_attr(test, allow(unused_imports))]
// #![allow(clippy::new_ret_no_self, clippy::new_without_default)]
// #![deny(missing_docs)]
// #![feature(
// if_let_guard,
// maybe_uninit_slice,
// trait_alias,
// let_chains,
// new_uninit,
// trait_upcasting
// )]
extern crate alloc;

View File

@ -10,7 +10,7 @@ use alloc::{
use libk_util::sync::IrqSafeSpinlock;
use yggdrasil_abi::{error::Error, io::OpenOptions};
use crate::{DirectoryOpenPosition, InstanceData};
use crate::vfs::{DirectoryOpenPosition, InstanceData};
use super::{CommonImpl, DirectoryImpl, Node, NodeFlags, NodeRef, RegularImpl, SymlinkImpl};

View File

@ -19,7 +19,7 @@ mod tree;
pub use access::AccessToken;
pub use traits::{CommonImpl, DirectoryImpl, RegularImpl, SymlinkImpl};
use crate::{
use crate::vfs::{
block::BlockDevice,
device::{BlockDeviceWrapper, CharDevice, CharDeviceWrapper},
PseudoTerminalMaster, PseudoTerminalSlave,

View File

@ -5,7 +5,7 @@ use yggdrasil_abi::{
io::{DeviceRequest, DirectoryEntry, FileMode, GroupId, OpenOptions, UserId},
};
use crate::file::{File, FileRef};
use crate::vfs::file::{File, FileRef};
use super::{AccessToken, CreateInfo, Metadata, Node, NodeFlags, NodeImpl, NodeRef};

View File

@ -6,7 +6,7 @@ use yggdrasil_abi::{
io::{DirectoryEntry, FileType, OpenOptions},
};
use crate::file::{DirectoryOpenPosition, InstanceData};
use crate::vfs::file::{DirectoryOpenPosition, InstanceData};
use super::{Metadata, NodeRef};

View File

@ -11,7 +11,7 @@ use libk_thread::{runtime, sync::Mutex};
use libk_util::sync::LockMethod;
use yggdrasil_abi::{error::Error, io::RawFd};
use crate::{FileReadiness, FileRef};
use crate::vfs::{FileReadiness, FileRef};
/// Poll channel implementation. Allows blocking until a file descriptor signals an event or a
/// timeout is reached.

View File

@ -6,7 +6,7 @@ use yggdrasil_abi::{
net::{SocketAddr, SocketOption},
};
use crate::FileReadiness;
use crate::vfs::FileReadiness;
/// Interface for interacting with network sockets
#[allow(unused)]

View File

@ -14,7 +14,7 @@ use libk_thread::{
use libk_util::sync::LockMethod;
use yggdrasil_abi::error::Error;
use crate::{FileReadiness, Write};
use crate::vfs::{FileReadiness, Write};
/// File-like structure to generate periodic or one-shit events at certain intervals
pub struct TimerFile {

View File

@ -7,6 +7,7 @@ use core::{
use abi::{error::Error, io::DeviceRequest, process::ProcessId};
use device_api::Device;
use libk::vfs::block::BlockDevice;
use libk_mm::{
address::{IntoRaw, PhysicalAddress},
device::{DeviceMemoryAttributes, DeviceMemoryCaching, RawDeviceMemoryMapping},
@ -15,7 +16,6 @@ use libk_mm::{
};
use libk_thread::thread::Thread;
use libk_util::sync::IrqSafeSpinlock;
use vfs::block::BlockDevice;
use crate::arch::L3;

View File

@ -3,13 +3,13 @@
use core::ptr::NonNull;
use kernel_fs::devfs;
use libk::vfs::{impls::read_fn_node, NodeRef};
use libk_mm::{
address::{PhysicalAddress, Virtualize},
phys,
};
use libk_util::OneTimeInit;
use memfs::block::{self, BlockAllocator};
use vfs::{impls::read_fn_node, NodeRef};
use yggdrasil_abi::{error::Error, io::MountOptions};
use crate::proc::random;

View File

@ -2,12 +2,12 @@
use abi::error::Error;
use git_version::git_version;
use libk_mm::phys;
use libk_util::OneTimeInit;
use vfs::{
use libk::vfs::{
impls::{const_value_node, mdir, read_fn_node, ReadOnlyFnValueNode},
NodeRef,
};
use libk_mm::phys;
use libk_util::OneTimeInit;
use crate::{debug, util};

View File

@ -4,9 +4,9 @@ use abi::error::Error;
use alloc::borrow::ToOwned;
use kernel_fs::devfs;
use libk::runtime;
use libk::vfs::{impls::FnSymlink, IoContext, NodeRef};
use libk_thread::thread::Thread;
use memfs::MemoryFilesystem;
use vfs::{impls::FnSymlink, IoContext, NodeRef};
use crate::{
fs::{FileBlockAllocator, INITRD_DATA},

View File

@ -1,8 +1,8 @@
//! Process I/O management
use abi::error::Error;
use libk::vfs::{FileSet, IoContext, Node};
use libk_thread::process::ProcessIo;
use vfs::{FileSet, IoContext, Node};
/// I/O context of a process, contains information like root, current directory and file
/// descriptor table

View File

@ -2,8 +2,8 @@
use abi::{error::Error, path::Path, process::ProcessGroupId};
use alloc::sync::{Arc, Weak};
use libk::vfs::IoContext;
use libk_thread::thread::Thread;
use vfs::IoContext;
use crate::task::process::ProcessImpl;

View File

@ -1,8 +1,8 @@
//! System function call handlers
use abi::{error::Error, io::RawFd, SyscallFunction};
use libk::vfs::NodeRef;
use libk_util::sync::IrqSafeSpinlockGuard;
use vfs::NodeRef;
use crate::{proc::io::ProcessIoImpl, task::process::ProcessImpl};
@ -57,8 +57,10 @@ mod impls {
process::{ExecveOptions, ProcessGroupId, ProcessId, SpawnOption},
};
use alloc::{boxed::Box, sync::Arc};
use libk::{block, runtime};
use vfs::{File, IoContext, MessagePayload, Read, Seek, Write};
use libk::{
block, runtime,
vfs::{self, File, IoContext, MessagePayload, Read, Seek, Write},
};
use ygg_driver_net_core::socket::{RawSocket, TcpListener, TcpSocket, UdpSocket};
use core::{