Skip to content

Commit

Permalink
Oxidize fuse
Browse files Browse the repository at this point in the history
  • Loading branch information
TimeEngineer committed Oct 17, 2023
1 parent d8f99c9 commit b94dded
Show file tree
Hide file tree
Showing 17 changed files with 1,603 additions and 141 deletions.
8 changes: 8 additions & 0 deletions .cspell/custom-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ freeline
Freepik
freethreaded
fromjson
fsyncdir
fusepy
fusermount
fuzzer
Expand All @@ -169,6 +170,7 @@ GetRandom
gloo
gradlew
grapheq
gtod
guce
guci
hashdigest
Expand All @@ -194,6 +196,8 @@ ifnewer
ijkl
imgconverter
inversed
iodepth
ioengine
ionicons
iqmp
itemsoverlay
Expand Down Expand Up @@ -324,6 +328,7 @@ newsfragment
newsfragments
nextest
Niño
nlookup
nmspc
nocapture
NONCEBYTES
Expand Down Expand Up @@ -479,6 +484,7 @@ rustflags
rustfmt
rustup
rwfile
rwmixread
salsabox
SaltBytes
saltlen
Expand Down Expand Up @@ -576,6 +582,8 @@ UNFINISHPAGE
unhexlify
Unmarshal
unmock
unmounter
Unmounter
unpackb
unsync
unwinify
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/ci-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ jobs:
save-if: ${{ github.ref == 'refs/heads/master' }}
timeout-minutes: 5

# Install fuse
- name: Install fuse
shell: bash
run: |
until sudo apt-get -y install fuse3 libfuse3-dev; do
echo "Fail to install APT package retrying ...";
done
timeout-minutes: 5

# Install cargo nextest command
- uses: taiki-e/install-action@47d27149ff6b3422864ec504071d5cc7873d642e # pin v2.20.3
with:
Expand Down
75 changes: 74 additions & 1 deletion Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ console_log = { version = "1.0.0", default-features = false }
crc32fast = { version = "1.3.2", default-features = false }
crypto_box = { version = "0.8.2", default-features = false }
crypto_secretbox = { version = "0.1.1", default-features = false }
ctrlc = { version = "3.4.1", default-features = false }
data-encoding = { version = "2.4.0", default-features = false }
diesel = { version = "2.1.3", default-features = false }
digest = { version = "0.10.7", default-features = false }
Expand All @@ -110,6 +111,7 @@ eventsource-stream = { version = "0.2.3", default-features = false }
flate2 = { version = "1.0.28", default-features = false }
flume = { version = "0.10.14", default-features = false }
fnmatch-regex = { version = "0.2.0", default-features = false }
fuser = { version = "0.13.0", default-features = false }
futures-core = { version = "0.3.28", default-features = false }
futures-lite = { version = "1.13.0", default-features = false }
futures = { version = "0.3.28", default-features = false }
Expand All @@ -126,6 +128,7 @@ itertools = { version = "0.11.0", default-features = false }
jni = { version = "0.21.1", default-features = false }
js-sys = { version = "0.3.64", default-features = false }
lazy_static = { version = "1.4.0", default-features = false }
libc = { version = "0.2.147", default-features = false }
libsodium-sys = { version = "0.2.7", default-features = false }
libsqlite3-sys = { version = "0.26.0", default-features = false }
log = { version = "0.4.20", default-features = false }
Expand Down Expand Up @@ -170,7 +173,7 @@ wasm-bindgen-test = { version = "0.3.37", default-features = false }
wasm-bindgen = { version = "0.2.87", default-features = false }
web-sys = { version = "0.3.64", default-features = false }
winfsp_build = { version = "0.1.1", default-features = false }
winfsp_wrs = { git = "https://github.com/Scille/winfsp_wrs.git", rev = "debed94", default-features = false }
winfsp_wrs = { git = "https://github.com/Scille/winfsp_wrs.git", rev = "d768c7e", default-features = false }
x25519-dalek = { version = "2.0.0", default-features = false }
zeroize = { version = "1.6.0", default-features = false }

Expand Down
10 changes: 10 additions & 0 deletions libparsec/crates/platform_mountpoint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,20 @@ winfsp_wrs = { workspace = true }
once_cell = { workspace = true }
regex = { workspace = true }

[target.'cfg(target_os = "linux")'.dependencies]
fuser = { workspace = true, features = ["libfuse"] }
libc = { workspace = true }

[dependencies]
libparsec_types = { workspace = true }
chrono = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
libparsec_tests_lite = { workspace = true }
libparsec_tests_fixtures = { workspace = true }
env_logger = { workspace = true }
ctrlc = { workspace = true }

[target.'cfg(target_os = "windows")'.build-dependencies]
winfsp_build = { workspace = true }
27 changes: 27 additions & 0 deletions libparsec/crates/platform_mountpoint/examples/memfs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS

fn main() {
#[cfg(not(target_os = "macos"))]
{
use std::path::Path;

use libparsec_platform_mountpoint::{FileSystemMounted, MemFS};

env_logger::init();
let mut args = std::env::args();

#[cfg(target_os = "windows")]
winfsp_wrs::init().expect("Can't init WinFSP");

let arg = args.nth(1).expect("Please provide mountpoint path");
let path = Path::new(&arg);

let fs = FileSystemMounted::mount(path, MemFS::default()).unwrap();

let (tx, rx) = std::sync::mpsc::channel();
ctrlc::set_handler(move || tx.send(()).unwrap()).unwrap();
rx.recv().unwrap();

fs.stop();
}
}
19 changes: 17 additions & 2 deletions libparsec/crates/platform_mountpoint/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,33 @@

use thiserror::Error;

use libparsec_types::EntryNameError;

#[derive(Debug, Error)]
pub(crate) enum MountpointError {
pub enum MountpointError {
#[error("Access denied")]
AccessDenied,
#[error("Dir is not empty")]
DirNotEmpty,
#[error("End of file")]
EndOfFile,
#[error("Invalid name")]
InvalidName,
#[error("Name collision")]
NameCollision,
#[error("Name too long")]
NameTooLong,
#[error("Not found")]
NotFound,
}

pub(crate) type MountpointResult<T> = Result<T, MountpointError>;
pub type MountpointResult<T> = Result<T, MountpointError>;

impl From<EntryNameError> for MountpointError {
fn from(value: EntryNameError) -> Self {
match value {
EntryNameError::NameTooLong => Self::NameTooLong,
EntryNameError::InvalidName => Self::InvalidName,
}
}
}
Loading

0 comments on commit b94dded

Please sign in to comment.