Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
192745d
add async vfs path
Koichi98 Jun 26, 2025
86da4ad
Merge branch 'main' into feat/async_vfs_path
Koichi98 Jun 26, 2025
aa09abf
fix for unpin
Koichi98 Jun 27, 2025
94cc80b
delete WalkDirIterator related
Koichi98 Jun 27, 2025
88808e0
Merge branch 'fix/Vfserror_for_nostd' into feat/async_vfs_path
Koichi98 Jun 28, 2025
4607f36
rename Error to IOError in AsyncFIlesystem
Koichi98 Jun 28, 2025
1b5069f
fix clippy
Koichi98 Jun 28, 2025
650839a
merge with main
Koichi98 Jul 1, 2025
5eaa1f7
fix comment
Koichi98 Jul 1, 2025
fb37660
minor fix
Koichi98 Jul 1, 2025
b43d719
delete Fatfs related from path.rs
Koichi98 Jul 1, 2025
f6e6f5d
add trait bound for IoError
Koichi98 Jul 1, 2025
79b6c8c
add VfsIoError
Koichi98 Jul 2, 2025
8c7a1cc
fix for deleting generic type E from VfsError
Koichi98 Jul 2, 2025
c32ae75
fix
Koichi98 Jul 2, 2025
b87be67
fix
Koichi98 Jul 2, 2025
d74f4ee
Merge branch 'fix/introduce_vfsioerror' into feat/async_vfs_path
Koichi98 Jul 2, 2025
edea2a8
fix comment
Koichi98 Jul 2, 2025
a408137
delete unnecessary changes
Koichi98 Jul 2, 2025
a3b8250
Merge branch 'main' into feat/async_vfs_path
Koichi98 Jul 3, 2025
dd2457b
fix
Koichi98 Jul 3, 2025
477f0ee
Merge branch 'feat/async_vfs_path' of github.com:tier4/awkernel into …
Koichi98 Jul 3, 2025
437408e
cargo fmt
Koichi98 Jul 3, 2025
480c7e3
fix clippy
Koichi98 Jul 3, 2025
1e00847
delete empty line
Koichi98 Jul 3, 2025
2baf176
add Debug
Koichi98 Jul 3, 2025
0f91fb6
fix simple_async_copy
Koichi98 Jul 3, 2025
1344a66
fix copy_dir&move_dir
Koichi98 Jul 3, 2025
d8d2448
fix unnecessary changes
Koichi98 Jul 3, 2025
2563284
fix unnecessary
Koichi98 Jul 3, 2025
516461f
fix
Koichi98 Jul 3, 2025
031b384
fix read_to_string
Koichi98 Jul 3, 2025
13f459d
Update awkernel_async_lib/src/file/path.rs
Koichi98 Jul 3, 2025
20a69f8
cargo fmt
Koichi98 Jul 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions awkernel_async_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pin-project = "1"
log = "0.4"
array-macro = "2.1"
fixedbitset = "0.5.7"
async-trait = "0.1"
async-recursion = "1.1"

[dependencies.futures]
version = "0.3"
Expand Down
2 changes: 2 additions & 0 deletions awkernel_async_lib/src/file.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod filesystem;
pub mod path;
36 changes: 33 additions & 3 deletions awkernel_async_lib/src/file/filesystem.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//! The async filesystem trait definitions needed to implement new async virtual filesystems
use super::path::AsyncVfsPath;
use crate::time::Time;
use alloc::{boxed::Box, string::String};
use alloc::{boxed::Box, string::String, vec::Vec};
use async_trait::async_trait;
use awkernel_lib::file::{
error::IoError,
io::SeekFrom,
vfs::error::{VfsError, VfsErrorKind, VfsResult},
vfs::path::VfsMetadata,
};
use core::fmt::Debug;
use futures::stream::Stream;

// NOTE: We're currently using our own AsyncSeekAndRead and AsyncSeekAndWrite traits. We might replace these with traits from embedded-io-async in the future. However, that change would involve many modifications, and embedded-io-async doesn't seem stable yet, so we're sticking with our current approach for now.
Expand All @@ -31,6 +31,30 @@ pub trait AsyncSeekAndRead: Send + Unpin {

Ok(())
}

async fn read_to_string(&mut self, buf: &mut String) -> Result<usize, VfsError> {
let mut bytes = Vec::new();
let mut chunk = [0; 8192];

loop {
let bytes_read = self.read(&mut chunk).await?;
if bytes_read == 0 {
break;
}
bytes.extend_from_slice(&chunk[..bytes_read]);
}

match String::from_utf8(bytes) {
Ok(s) => {
let len = s.len();
buf.push_str(&s);
Ok(len)
}
Err(_) => Err(VfsError::from(VfsErrorKind::Other(
"Invalid UTF-8 sequence".into(),
))),
}
}
}

#[async_trait]
Expand Down Expand Up @@ -86,7 +110,7 @@ impl AsyncSeekAndWrite for Box<dyn AsyncSeekAndWrite + Send + Unpin> {
///
/// Please use the test_macros [test_macros::test_async_vfs!] and [test_macros::test_async_vfs_readonly!]
#[async_trait]
pub trait AsyncFileSystem: Sync + Send + 'static {
pub trait AsyncFileSystem: Sync + Send + Debug {
/// Iterates over all direct children of this directory path
/// NOTE: the returned String items denote the local bare filenames, i.e. they should not contain "/" anywhere
async fn read_dir(
Expand Down Expand Up @@ -147,3 +171,9 @@ pub trait AsyncFileSystem: Sync + Send + 'static {
Err(VfsErrorKind::NotSupported.into())
}
}

impl From<Box<dyn AsyncFileSystem>> for AsyncVfsPath {
fn from(filesystem: Box<dyn AsyncFileSystem>) -> Self {
AsyncVfsPath::new(filesystem)
}
}
Loading