From d701808514f109240ec7450895c86ad566120f1f Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Tue, 6 Dec 2022 09:17:03 +0100 Subject: [PATCH] move fuse code from pbs-client to pbs-pxar-fuse it's used by pxar-bin and proxmox-backup-client for mounting, but pbs-client is used by more (eg. the proxmox-backup-qemu library which really doesn't need to pull in any fuse dependencies) Signed-off-by: Wolfgang Bumiller --- Cargo.toml | 4 +++- Makefile | 3 ++- pbs-client/Cargo.toml | 1 - pbs-client/src/catalog_shell.rs | 6 +++++- pbs-client/src/pxar/mod.rs | 1 - pbs-pxar-fuse/Cargo.toml | 19 +++++++++++++++++++ .../pxar/fuse.rs => pbs-pxar-fuse/src/lib.rs | 0 proxmox-backup-client/Cargo.toml | 8 +++++--- proxmox-backup-client/src/catalog.rs | 4 ++-- proxmox-backup-client/src/mount.rs | 14 +++++--------- pxar-bin/Cargo.toml | 11 ++++++----- pxar-bin/src/main.rs | 6 ++---- 12 files changed, 49 insertions(+), 28 deletions(-) create mode 100644 pbs-pxar-fuse/Cargo.toml rename pbs-client/src/pxar/fuse.rs => pbs-pxar-fuse/src/lib.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 38e9c1f2..de83e1fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ members = [ "pbs-config", "pbs-datastore", "pbs-fuse-loop", - "proxmox-rrd", + "pbs-pxar-fuse", "pbs-tape", "pbs-tools", @@ -33,6 +33,8 @@ members = [ "proxmox-backup-client", "proxmox-file-restore", "proxmox-restore-daemon", + "proxmox-rrd", + "pxar-bin", ] diff --git a/Makefile b/Makefile index 87b5ca01..2b6377dd 100644 --- a/Makefile +++ b/Makefile @@ -38,13 +38,14 @@ SUBCRATES := \ pbs-config \ pbs-datastore \ pbs-fuse-loop \ - proxmox-rrd \ + pbs-pxar-fuse \ pbs-tape \ pbs-tools \ proxmox-backup-banner \ proxmox-backup-client \ proxmox-file-restore \ proxmox-restore-daemon \ + proxmox-rrd \ pxar-bin ifeq ($(BUILD_MODE), release) diff --git a/pbs-client/Cargo.toml b/pbs-client/Cargo.toml index a288e0e7..40b6bc99 100644 --- a/pbs-client/Cargo.toml +++ b/pbs-client/Cargo.toml @@ -35,7 +35,6 @@ pathpatterns = "0.1.2" proxmox-async = "0.4" proxmox-compression = "0.1.1" -proxmox-fuse = "0.1.3" proxmox-http = { version = "0.7", features = [ "client", "http-helpers", "websocket" ] } proxmox-io = { version = "1.0.1", features = [ "tokio" ] } proxmox-lang = "1.1" diff --git a/pbs-client/src/catalog_shell.rs b/pbs-client/src/catalog_shell.rs index 25e27b37..98af5699 100644 --- a/pbs-client/src/catalog_shell.rs +++ b/pbs-client/src/catalog_shell.rs @@ -17,16 +17,20 @@ use pathpatterns::{MatchEntry, MatchList, MatchPattern, MatchType, PatternFlag}; use proxmox_router::cli::{self, CliCommand, CliCommandMap, CliHelper, CommandLineInterface}; use proxmox_schema::api; use proxmox_sys::fs::{create_path, CreateOptions}; +use pxar::accessor::ReadAt; use pxar::{EntryKind, Metadata}; use pbs_datastore::catalog::{self, DirEntryAttribute}; use proxmox_async::runtime::block_in_place; -use crate::pxar::fuse::{Accessor, FileEntry}; use crate::pxar::Flags; type CatalogReader = pbs_datastore::catalog::CatalogReader; +type Reader = std::sync::Arc; +type Accessor = pxar::accessor::aio::Accessor; +type FileEntry = pxar::accessor::aio::FileEntry; + const MAX_SYMLINK_COUNT: usize = 40; static mut SHELL: Option = None; diff --git a/pbs-client/src/pxar/mod.rs b/pbs-client/src/pxar/mod.rs index 725fc2d9..a158101d 100644 --- a/pbs-client/src/pxar/mod.rs +++ b/pbs-client/src/pxar/mod.rs @@ -50,7 +50,6 @@ pub(crate) mod create; pub(crate) mod dir_stack; pub(crate) mod extract; -pub mod fuse; pub(crate) mod metadata; pub(crate) mod tools; diff --git a/pbs-pxar-fuse/Cargo.toml b/pbs-pxar-fuse/Cargo.toml new file mode 100644 index 00000000..cb0abfe8 --- /dev/null +++ b/pbs-pxar-fuse/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "pbs-pxar-fuse" +version = "0.1.0" +edition = "2021" +description = "pxar fuse file system code" + +[dependencies] +anyhow = "1.0" +futures = "0.3" +libc = "0.2" +log = "0.4" +tokio = "1.6" + +proxmox-fuse = "0.1.3" +proxmox-io = "1.0.1" +proxmox-lang = "1.1" +proxmox-sys = "0.4.1" + +pxar = { version = "0.10.2", features = [ "tokio-io" ] } diff --git a/pbs-client/src/pxar/fuse.rs b/pbs-pxar-fuse/src/lib.rs similarity index 100% rename from pbs-client/src/pxar/fuse.rs rename to pbs-pxar-fuse/src/lib.rs diff --git a/proxmox-backup-client/Cargo.toml b/proxmox-backup-client/Cargo.toml index bce6a0d1..518b2004 100644 --- a/proxmox-backup-client/Cargo.toml +++ b/proxmox-backup-client/Cargo.toml @@ -9,8 +9,8 @@ anyhow = "1.0" futures = "0.3" hyper = { version = "0.14", features = [ "full" ] } libc = "0.2" -nix = "0.24" log = "0.4" +nix = "0.24" openssl = "0.10" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" @@ -24,16 +24,18 @@ pathpatterns = "0.1.2" pxar = { version = "0.10.2", features = [ "tokio-io" ] } proxmox-async = "0.4" +proxmox-fuse = "0.1.3" proxmox-io = "1.0.1" proxmox-router = { version = "1.3.0", features = [ "cli" ] } proxmox-schema = { version = "1.3.1", features = [ "api-macro" ] } -proxmox-time = "1" proxmox-sys = { version = "0.4.1", features = [ "sortable-macro" ] } +proxmox-time = "1" pbs-api-types = { path = "../pbs-api-types" } pbs-buildcfg = { path = "../pbs-buildcfg" } -pbs-config = { path = "../pbs-config" } pbs-client = { path = "../pbs-client" } +pbs-config = { path = "../pbs-config" } pbs-datastore = { path = "../pbs-datastore" } pbs-fuse-loop = { path = "../pbs-fuse-loop" } +pbs-pxar-fuse = { path = "../pbs-pxar-fuse" } pbs-tools = { path = "../pbs-tools" } diff --git a/proxmox-backup-client/src/catalog.rs b/proxmox-backup-client/src/catalog.rs index 6566147e..8c8c1458 100644 --- a/proxmox-backup-client/src/catalog.rs +++ b/proxmox-backup-client/src/catalog.rs @@ -219,8 +219,8 @@ async fn catalog_shell(param: Value) -> Result<(), Error> { ); let reader = BufferedDynamicReader::new(index, chunk_reader); let archive_size = reader.archive_size(); - let reader: pbs_client::pxar::fuse::Reader = Arc::new(BufferedDynamicReadAt::new(reader)); - let decoder = pbs_client::pxar::fuse::Accessor::new(reader, archive_size).await?; + let reader: pbs_pxar_fuse::Reader = Arc::new(BufferedDynamicReadAt::new(reader)); + let decoder = pbs_pxar_fuse::Accessor::new(reader, archive_size).await?; client.download(CATALOG_NAME, &mut tmpfile).await?; let index = DynamicIndexReader::new(tmpfile) diff --git a/proxmox-backup-client/src/mount.rs b/proxmox-backup-client/src/mount.rs index 385c23ed..afec2553 100644 --- a/proxmox-backup-client/src/mount.rs +++ b/proxmox-backup-client/src/mount.rs @@ -295,16 +295,12 @@ async fn mount_do(param: Value, pipe: Option) -> Result { ); let reader = BufferedDynamicReader::new(index, chunk_reader); let archive_size = reader.archive_size(); - let reader: pbs_client::pxar::fuse::Reader = Arc::new(BufferedDynamicReadAt::new(reader)); - let decoder = pbs_client::pxar::fuse::Accessor::new(reader, archive_size).await?; + let reader: pbs_pxar_fuse::Reader = Arc::new(BufferedDynamicReadAt::new(reader)); + let decoder = pbs_pxar_fuse::Accessor::new(reader, archive_size).await?; - let session = pbs_client::pxar::fuse::Session::mount( - decoder, - options, - false, - Path::new(target.unwrap()), - ) - .map_err(|err| format_err!("pxar mount failed: {}", err))?; + let session = + pbs_pxar_fuse::Session::mount(decoder, options, false, Path::new(target.unwrap())) + .map_err(|err| format_err!("pxar mount failed: {}", err))?; daemonize()?; diff --git a/pxar-bin/Cargo.toml b/pxar-bin/Cargo.toml index 4c8cefef..f025e02c 100644 --- a/pxar-bin/Cargo.toml +++ b/pxar-bin/Cargo.toml @@ -17,12 +17,13 @@ serde_json = "1.0" tokio = { version = "1.6", features = [ "rt", "rt-multi-thread" ] } pathpatterns = "0.1.2" -#proxmox = "0.15.3" -proxmox-async = "0.4" -proxmox-schema = { version = "1.3.1", features = [ "api-macro" ] } -proxmox-router = "1.3.0" -proxmox-sys = "0.4.1" pxar = { version = "0.10.2", features = [ "tokio-io" ] } +proxmox-async = "0.4" +proxmox-router = "1.3.0" +proxmox-schema = { version = "1.3.1", features = [ "api-macro" ] } +proxmox-sys = "0.4.1" + pbs-client = { path = "../pbs-client" } +pbs-pxar-fuse = { path = "../pbs-pxar-fuse" } pbs-tools = { path = "../pbs-tools" } diff --git a/pxar-bin/src/main.rs b/pxar-bin/src/main.rs index 9d7cf9de..90887321 100644 --- a/pxar-bin/src/main.rs +++ b/pxar-bin/src/main.rs @@ -12,9 +12,7 @@ use futures::select; use tokio::signal::unix::{signal, SignalKind}; use pathpatterns::{MatchEntry, MatchType, PatternFlag}; -use pbs_client::pxar::{ - format_single_line_entry, fuse, Flags, PxarExtractOptions, ENCODER_MAX_ENTRIES, -}; +use pbs_client::pxar::{format_single_line_entry, Flags, PxarExtractOptions, ENCODER_MAX_ENTRIES}; use proxmox_router::cli::*; use proxmox_schema::api; @@ -382,7 +380,7 @@ async fn mount_archive(archive: String, mountpoint: String, verbose: bool) -> Re let mountpoint = Path::new(&mountpoint); let options = OsStr::new("ro,default_permissions"); - let session = fuse::Session::mount_path(archive, options, verbose, mountpoint) + let session = pbs_pxar_fuse::Session::mount_path(archive, options, verbose, mountpoint) .await .map_err(|err| format_err!("pxar mount failed: {}", err))?;