Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dev_tests/src/ratchet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn ratchet_globals() -> Result<()> {
ratchet(
&[
("dev_bench/", 1),
("litebox/", 8),
("litebox/", 7),
("litebox_broker_core/", 1),
("litebox_broker_transport_linux_userland/", 1),
("litebox_broker_userland/", 1),
Expand Down
7 changes: 0 additions & 7 deletions litebox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ buddy_system_allocator = { version = "0.11.0", default-features = false, feature
# Depend on (currently unreleased) slabmalloc `main`, which contains some fixes on top of `0.11.0`
slabmalloc = { git = "https://github.com/gz/rust-slabmalloc.git", rev = "19480b2e82704210abafe575fb9699184c1be110" }
litebox_util_log = { version = "0.1.0", path = "../litebox_util_log" }
litebox_broker_core = { version = "0.1.0", path = "../litebox_broker_core" }
litebox_broker_local = { version = "0.1.0", path = "../litebox_broker_local" }
litebox_broker_protocol = { version = "0.1.0", path = "../litebox_broker_protocol" }
litebox_broker_transport = { version = "0.1.0", path = "../litebox_broker_transport" }
Expand All @@ -35,11 +34,5 @@ lock_tracing = ["litebox_platform/lock_tracing"]
panic_on_unclosed_fd_drop = []
enforce_singleton_litebox_instance = []

# TODO: Remove these dev-dependencies together with `fs::file_tests`, once production callers
# exercise the broker file API end to end.
[dev-dependencies]
litebox_broker_core = { version = "0.1.0", path = "../litebox_broker_core", features = ["test-support"] }
litebox_broker_host = { version = "0.1.0", path = "../litebox_broker_host", features = ["test-support"] }

[lints]
workspace = true
46 changes: 15 additions & 31 deletions litebox/src/fs/errors.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Possible errors from [`Resolver`]

#[expect(
unused_imports,
reason = "used for doc string links to work out, but not for code"
)]
use super::resolver::Resolver;
//! Errors from LiteBox file operations.

use thiserror::Error;

// XXX(jayb): We probably need to introduce a notion of `Stale` to many/most of these errors, in
// order to more correctly support network-attached file systems.

/// Possible errors from [`Resolver::open`]
/// Possible errors from [`crate::LiteBox::open_file`].
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum OpenError {
Expand All @@ -34,12 +28,12 @@ pub enum OpenError {
PathError(#[from] PathError),
}

/// Possible errors from [`Resolver::close`]
/// Possible errors from [`crate::LiteBox::close_file`].
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum CloseError {}

/// Possible errors from [`Resolver::read`]
/// Possible errors from [`crate::LiteBox::read_file`].
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum ReadError {
Expand All @@ -53,7 +47,7 @@ pub enum ReadError {
Io,
}

/// Possible errors from [`Resolver::write`]
/// Possible errors from [`crate::LiteBox::write_file`].
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum WriteError {
Expand All @@ -67,7 +61,7 @@ pub enum WriteError {
Io,
}

/// Possible errors from [`Resolver::seek`]
/// Possible errors from [`crate::LiteBox::seek_file`].
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum SeekError {
Expand All @@ -85,7 +79,7 @@ pub enum SeekError {
Io,
}

/// Possible errors from [`Resolver::truncate`]
/// Possible errors from [`crate::LiteBox::truncate_file`].
#[derive(Error, Debug)]
pub enum TruncateError {
#[error("fd has been closed already")]
Expand All @@ -100,7 +94,7 @@ pub enum TruncateError {
Io,
}

/// Possible errors from [`Resolver::chmod`]
/// Possible errors from [`crate::LiteBox::chmod_file`].
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum ChmodError {
Expand All @@ -117,7 +111,7 @@ pub enum ChmodError {
PathError(#[from] PathError),
}

/// Possible errors from [`Resolver::chown`]
/// Possible errors from [`crate::LiteBox::chown_file`].
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum ChownError {
Expand All @@ -134,7 +128,7 @@ pub enum ChownError {
PathError(#[from] PathError),
}

/// Possible errors from [`Resolver::unlink`]
/// Possible errors from [`crate::LiteBox::unlink_file`].
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum UnlinkError {
Expand All @@ -150,7 +144,7 @@ pub enum UnlinkError {
PathError(#[from] PathError),
}

/// Possible errors from [`Resolver::mkdir`]
/// Possible errors from [`crate::LiteBox::mkdir_file`].
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum MkdirError {
Expand All @@ -166,7 +160,7 @@ pub enum MkdirError {
PathError(#[from] PathError),
}

/// Possible errors from [`Resolver::rmdir`]
/// Possible errors from [`crate::LiteBox::rmdir_file`].
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum RmdirError {
Expand All @@ -188,7 +182,7 @@ pub enum RmdirError {
PathError(#[from] PathError),
}

/// Possible errors from [`Resolver::read_dir`]
/// Possible errors from [`crate::LiteBox::read_file_directory`].
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum ReadDirError {
Expand All @@ -202,7 +196,7 @@ pub enum ReadDirError {
Io,
}

/// Possible errors from [`Resolver::file_status`]
/// Possible errors from [`crate::LiteBox::path_file_status`] and [`crate::LiteBox::file_status`].
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum FileStatusError {
Expand All @@ -214,16 +208,6 @@ pub enum FileStatusError {
PathError(#[from] PathError),
}

/// Possible errors from a backend walk
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum WalkError {
#[error("I/O error")]
Io,
#[error(transparent)]
PathError(#[from] PathError),
}

/// Possible errors in any file-system function due to path errors.
#[derive(Error, Debug)]
pub enum PathError {
Expand All @@ -234,7 +218,7 @@ pub enum PathError {
#[cfg(debug_assertions)]
dir: alloc::string::String,
#[cfg(debug_assertions)]
perms: crate::fs::Mode,
perms: litebox_broker_protocol::fs::FileMode,
},
#[error("invalid characters, not permitted by underlying file system")]
InvalidPathname,
Expand Down
5 changes: 1 addition & 4 deletions litebox/src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,11 @@ fn read_directory_broker_error(error: crate::broker::error::BrokerControlError)
fn path_error(error: FileError) -> Option<PathError> {
match error {
FileError::NoSuchFileOrDirectory => Some(PathError::NoSuchFileOrDirectory),
// TODO: `PathError` still carries the compatibility `crate::fs::Mode` used by the local
// resolver path. It becomes a protocol `FileMode` once the resolver compatibility surface
// is removed.
FileError::NoSearchPermissions => Some(PathError::NoSearchPerms {
#[cfg(debug_assertions)]
dir: String::new(),
#[cfg(debug_assertions)]
perms: super::Mode::empty(),
perms: Mode::empty(),
}),
FileError::InvalidPathname => Some(PathError::InvalidPathname),
FileError::MissingComponent => Some(PathError::MissingComponent),
Expand Down
Loading
Loading