-
Notifications
You must be signed in to change notification settings - Fork 89
Add 9p fs to LiteBox #663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
CvvT
wants to merge
16
commits into
main
Choose a base branch
from
weiteng/nine_p
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add 9p fs to LiteBox #663
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f532ff2
add 9p fs
CvvT e4ba56a
fix 9p fs
CvvT 79afcd0
fix error code
CvvT 0a83435
add test
CvvT c80537c
use 9p in linux shim
CvvT cc36869
fix fcall
CvvT 17d79df
remove clone_static
CvvT 5a9cede
remove some tests
CvvT 8c4d643
install diod
CvvT a078095
revert
CvvT b44c382
fix fmt
CvvT 6bbb2a4
refactor code
CvvT 333c449
add debug
CvvT 5cd4fc9
update comment
CvvT d5e5adc
revert change
CvvT 28d252a
add error handling
CvvT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,3 +36,6 @@ enforce_singleton_litebox_instance = [] | |
|
|
||
| [lints] | ||
| workspace = true | ||
|
|
||
| [dev-dependencies] | ||
| tempfile = "3" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,6 +100,7 @@ impl<Platform: sync::RawSyncPrimitivesProvider, Upper: super::FileSystem, Lower: | |
| match self.lower.file_status(path) { | ||
| Ok(stat) => Ok(stat.file_type), | ||
| Err(FileStatusError::ClosedFd) => unreachable!(), | ||
| Err(FileStatusError::Io) => Err(PathError::NoSuchFileOrDirectory), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| Err(FileStatusError::PathError(e)) => Err(e), | ||
| } | ||
| } | ||
|
|
@@ -132,6 +133,7 @@ impl<Platform: sync::RawSyncPrimitivesProvider, Upper: super::FileSystem, Lower: | |
| // perfectly fine, just fallthrough to next place in the loop | ||
| } | ||
| MkdirError::ReadOnlyFileSystem | ||
| | MkdirError::Io | ||
| | MkdirError::NoWritePerms | ||
| | MkdirError::PathError( | ||
| PathError::ComponentNotADirectory | ||
|
|
@@ -199,6 +201,7 @@ impl<Platform: sync::RawSyncPrimitivesProvider, Upper: super::FileSystem, Lower: | |
| Ok(fd) => fd, | ||
| Err(e) => match e { | ||
| OpenError::AccessNotAllowed => return Err(MigrationError::NoReadPerms), | ||
| OpenError::Io => return Err(MigrationError::Io), | ||
| OpenError::NoWritePerms | ||
| | OpenError::ReadOnlyFileSystem | ||
| | OpenError::AlreadyExists | ||
|
|
@@ -255,6 +258,7 @@ impl<Platform: sync::RawSyncPrimitivesProvider, Upper: super::FileSystem, Lower: | |
| return Err(MigrationError::NotAFile); | ||
| } | ||
| ReadError::ClosedFd | ReadError::NotForReading => unreachable!(), | ||
| ReadError::Io => return Err(MigrationError::Io), | ||
| }, | ||
| } | ||
| } | ||
|
|
@@ -419,6 +423,8 @@ pub enum MigrationError { | |
| NotAFile, | ||
| #[error("no read access permissions")] | ||
| NoReadPerms, | ||
| #[error("I/O error")] | ||
| Io, | ||
| #[error(transparent)] | ||
| PathError(#[from] PathError), | ||
| } | ||
|
|
@@ -525,14 +531,16 @@ impl< | |
| } | ||
| Err(e) => match &e { | ||
| OpenError::AccessNotAllowed | ||
| | OpenError::Io | ||
| | OpenError::NoWritePerms | ||
| | OpenError::ReadOnlyFileSystem | ||
| | OpenError::AlreadyExists | ||
| | OpenError::TruncateError( | ||
| TruncateError::IsDirectory | ||
| | TruncateError::NotForWriting | ||
| | TruncateError::IsTerminalDevice | ||
| | TruncateError::ClosedFd, | ||
| | TruncateError::ClosedFd | ||
| | TruncateError::Io, | ||
| ) | ||
| | OpenError::PathError( | ||
| PathError::ComponentNotADirectory | ||
|
|
@@ -816,6 +824,7 @@ impl< | |
| Ok(()) => {} | ||
| Err(MigrationError::NoReadPerms) => unimplemented!(), | ||
| Err(MigrationError::NotAFile) => return Err(WriteError::NotAFile), | ||
| Err(MigrationError::Io) => return Err(WriteError::Io), | ||
| Err(MigrationError::PathError(_e)) => unreachable!(), | ||
| } | ||
| // As a sanity check, in debug mode, confirm that it is now an upper file | ||
|
|
@@ -905,6 +914,7 @@ impl< | |
|
|
||
| Ok(()) | ||
| } | ||
| Err(TruncateError::Io) => Err(TruncateError::Io), | ||
| } | ||
| } else { | ||
| // The lower level truncate will correctly identify dir/file and handle | ||
|
|
@@ -924,6 +934,7 @@ impl< | |
| Ok(()) => return Ok(()), | ||
| Err(e) => match e { | ||
| ChmodError::NotTheOwner | ||
| | ChmodError::Io | ||
| | ChmodError::ReadOnlyFileSystem | ||
| | ChmodError::PathError( | ||
| PathError::ComponentNotADirectory | ||
|
|
@@ -944,6 +955,7 @@ impl< | |
| Ok(()) => {} | ||
| Err(MigrationError::NoReadPerms) => unimplemented!(), | ||
| Err(MigrationError::NotAFile) => unimplemented!(), | ||
| Err(MigrationError::Io) => return Err(ChmodError::Io), | ||
| Err(MigrationError::PathError(_e)) => unreachable!(), | ||
| } | ||
| // Since it has been migrated, we can just re-trigger, causing it to apply to the | ||
|
|
@@ -962,6 +974,7 @@ impl< | |
| Ok(()) => return Ok(()), | ||
| Err(e) => match e { | ||
| ChownError::NotTheOwner | ||
| | ChownError::Io | ||
| | ChownError::ReadOnlyFileSystem | ||
| | ChownError::PathError( | ||
| PathError::ComponentNotADirectory | ||
|
|
@@ -982,6 +995,7 @@ impl< | |
| Ok(()) => {} | ||
| Err(MigrationError::NoReadPerms) => unimplemented!(), | ||
| Err(MigrationError::NotAFile) => unimplemented!(), | ||
| Err(MigrationError::Io) => return Err(ChownError::Io), | ||
| Err(MigrationError::PathError(_e)) => unreachable!(), | ||
| } | ||
| // Since it has been migrated, we can just re-trigger, causing it to apply to the | ||
|
|
@@ -1005,6 +1019,7 @@ impl< | |
| } | ||
| Err(e) => match e { | ||
| UnlinkError::NoWritePerms | ||
| | UnlinkError::Io | ||
| | UnlinkError::IsADirectory | ||
| | UnlinkError::ReadOnlyFileSystem | ||
| | UnlinkError::PathError( | ||
|
|
@@ -1054,6 +1069,7 @@ impl< | |
| } | ||
| Err(e) => match e { | ||
| MkdirError::NoWritePerms | ||
| | MkdirError::Io | ||
| | MkdirError::AlreadyExists | ||
| | MkdirError::ReadOnlyFileSystem | ||
| | MkdirError::PathError( | ||
|
|
@@ -1099,6 +1115,7 @@ impl< | |
| } | ||
| OpenError::PathError(pe) => return Err(pe.into()), | ||
| OpenError::AccessNotAllowed => todo!(), | ||
| OpenError::Io => return Err(RmdirError::Io), | ||
| OpenError::ReadOnlyFileSystem => { | ||
| return Err(RmdirError::ReadOnlyFileSystem); | ||
| } | ||
|
|
@@ -1112,6 +1129,7 @@ impl< | |
| let entries = match self.read_dir(&dir_fd) { | ||
| Ok(entries) => entries, | ||
| Err(ReadDirError::ClosedFd | ReadDirError::NotADirectory) => unreachable!(), | ||
| Err(ReadDirError::Io) => return Err(RmdirError::Io), | ||
| }; | ||
| self.close(&dir_fd).expect("close dir fd failed"); | ||
| // "." and ".." are always present; anything more => not empty. | ||
|
|
@@ -1135,6 +1153,7 @@ impl< | |
| ) => unreachable!(), | ||
| RmdirError::Busy | ||
| | RmdirError::NoWritePerms | ||
| | RmdirError::Io | ||
| | RmdirError::PathError(PathError::NoSearchPerms { .. }) => return Err(e), | ||
| } | ||
| } | ||
|
|
@@ -1161,6 +1180,7 @@ impl< | |
| ) => unreachable!(), | ||
| RmdirError::Busy | ||
| | RmdirError::NoWritePerms | ||
| | RmdirError::Io | ||
| | RmdirError::PathError(PathError::NoSearchPerms { .. }) => return Err(e), | ||
| } | ||
| } | ||
|
|
@@ -1278,6 +1298,7 @@ impl< | |
| // None of these can be handled by lower level, just quit out early | ||
| return Err(e); | ||
| } | ||
| FileStatusError::Io => return Err(e), | ||
| FileStatusError::PathError( | ||
| PathError::NoSuchFileOrDirectory | PathError::MissingComponent, | ||
| ) => { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we interpret
Ioerror as network failure instead of the file or directory not exist?