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 <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2022-12-06 09:17:03 +01:00
parent 16f6766a68
commit d701808514
12 changed files with 49 additions and 28 deletions

View File

@ -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",
]

View File

@ -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)

View File

@ -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"

View File

@ -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<std::fs::File>;
type Reader = std::sync::Arc<dyn ReadAt + Send + Sync + 'static>;
type Accessor = pxar::accessor::aio::Accessor<Reader>;
type FileEntry = pxar::accessor::aio::FileEntry<Reader>;
const MAX_SYMLINK_COUNT: usize = 40;
static mut SHELL: Option<usize> = None;

View File

@ -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;

19
pbs-pxar-fuse/Cargo.toml Normal file
View File

@ -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" ] }

View File

@ -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" }

View File

@ -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)

View File

@ -295,15 +295,11 @@ async fn mount_do(param: Value, pipe: Option<OwnedFd>) -> Result<Value, 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?;
let session = pbs_client::pxar::fuse::Session::mount(
decoder,
options,
false,
Path::new(target.unwrap()),
)
let session =
pbs_pxar_fuse::Session::mount(decoder, options, false, Path::new(target.unwrap()))
.map_err(|err| format_err!("pxar mount failed: {}", err))?;
daemonize()?;

View File

@ -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" }

View File

@ -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))?;