From 726b9d4469764b02334490fa2cef147de14bb405 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 25 Nov 2021 12:30:03 +0100 Subject: [PATCH] use proxmox-sys 0.2.1 and proxmox-io 1.0.1 And remove unused code from pbs-tools. Signed-off-by: Dietmar Maurer --- pbs-client/Cargo.toml | 2 +- pbs-client/src/pxar_backup_stream.rs | 2 +- pbs-tools/src/io.rs | 10 --------- pbs-tools/src/lib.rs | 2 -- pbs-tools/src/sync/mod.rs | 2 -- pbs-tools/src/sync/std_channel_writer.rs | 27 ------------------------ proxmox-backup-client/Cargo.toml | 4 ++-- proxmox-backup-client/src/main.rs | 2 +- proxmox-backup-client/src/mount.rs | 2 +- 9 files changed, 6 insertions(+), 47 deletions(-) delete mode 100644 pbs-tools/src/io.rs delete mode 100644 pbs-tools/src/sync/mod.rs delete mode 100644 pbs-tools/src/sync/std_channel_writer.rs diff --git a/pbs-client/Cargo.toml b/pbs-client/Cargo.toml index a1b5df44..3e167ef6 100644 --- a/pbs-client/Cargo.toml +++ b/pbs-client/Cargo.toml @@ -33,7 +33,7 @@ pathpatterns = "0.1.2" proxmox-async = "0.3" proxmox-fuse = "0.1.1" proxmox-http = { version = "0.6", features = [ "client", "http-helpers", "websocket" ] } -proxmox-io = { version = "1", features = [ "tokio" ] } +proxmox-io = { version = "1.0.1", features = [ "tokio" ] } proxmox-lang = "1" proxmox-router = { version = "1.1", features = [ "cli" ] } proxmox-schema = "1" diff --git a/pbs-client/src/pxar_backup_stream.rs b/pbs-client/src/pxar_backup_stream.rs index 484a3e32..28e569a7 100644 --- a/pbs-client/src/pxar_backup_stream.rs +++ b/pbs-client/src/pxar_backup_stream.rs @@ -13,9 +13,9 @@ use nix::fcntl::OFlag; use nix::sys::stat::Mode; use proxmox_async::blocking::TokioWriterAdapter; +use proxmox_io::StdChannelWriter; use pbs_datastore::catalog::CatalogWriter; -use pbs_tools::sync::StdChannelWriter; /// Stream implementation to encode and upload .pxar archives. /// diff --git a/pbs-tools/src/io.rs b/pbs-tools/src/io.rs deleted file mode 100644 index 6ddaa539..00000000 --- a/pbs-tools/src/io.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! I/O utilities. - -use proxmox_sys::fd::Fd; - -/// safe wrapper for `nix::unistd::pipe2` defaulting to `O_CLOEXEC` and guarding the file -/// descriptors. -pub fn pipe() -> Result<(Fd, Fd), nix::Error> { - let (pin, pout) = nix::unistd::pipe2(nix::fcntl::OFlag::O_CLOEXEC)?; - Ok((Fd(pin), Fd(pout))) -} diff --git a/pbs-tools/src/lib.rs b/pbs-tools/src/lib.rs index 857efcb7..053b3c0c 100644 --- a/pbs-tools/src/lib.rs +++ b/pbs-tools/src/lib.rs @@ -1,12 +1,10 @@ pub mod cert; pub mod crypt_config; pub mod format; -pub mod io; pub mod json; pub mod lru_cache; pub mod nom; pub mod sha; -pub mod sync; pub mod ticket; pub mod async_lru_cache; diff --git a/pbs-tools/src/sync/mod.rs b/pbs-tools/src/sync/mod.rs deleted file mode 100644 index fdd5eda4..00000000 --- a/pbs-tools/src/sync/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod std_channel_writer; -pub use std_channel_writer::StdChannelWriter; diff --git a/pbs-tools/src/sync/std_channel_writer.rs b/pbs-tools/src/sync/std_channel_writer.rs deleted file mode 100644 index c5131a12..00000000 --- a/pbs-tools/src/sync/std_channel_writer.rs +++ /dev/null @@ -1,27 +0,0 @@ -use std::io::Write; -use std::sync::mpsc::SyncSender; -use std::string::ToString; - -/// Wrapper around SyncSender, which implements Write -/// -/// Each write in translated into a send(Vec). -pub struct StdChannelWriter(SyncSender, E>>); - -impl StdChannelWriter { - pub fn new(sender: SyncSender, E>>) -> Self { - Self(sender) - } -} - -impl Write for StdChannelWriter { - fn write(&mut self, buf: &[u8]) -> Result { - self.0 - .send(Ok(buf.to_vec())) - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err.to_string())) - .and(Ok(buf.len())) - } - - fn flush(&mut self) -> Result<(), std::io::Error> { - Ok(()) - } -} diff --git a/proxmox-backup-client/Cargo.toml b/proxmox-backup-client/Cargo.toml index 7a289592..8dfd499c 100644 --- a/proxmox-backup-client/Cargo.toml +++ b/proxmox-backup-client/Cargo.toml @@ -23,11 +23,11 @@ pathpatterns = "0.1.2" pxar = { version = "0.10.1", features = [ "tokio-io" ] } proxmox-async = "0.3" +proxmox-io = "1.0.1" proxmox-router = { version = "1.1", features = [ "cli" ] } proxmox-schema = { version = "1", features = [ "api-macro" ] } proxmox-time = "1" -proxmox-sys = { version = "0.2", features = [ "sortable-macro" ] } - +proxmox-sys = { version = "0.2.1", features = [ "sortable-macro" ] } pbs-api-types = { path = "../pbs-api-types" } pbs-buildcfg = { path = "../pbs-buildcfg" } diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs index ca587594..95f82c78 100644 --- a/proxmox-backup-client/src/main.rs +++ b/proxmox-backup-client/src/main.rs @@ -13,6 +13,7 @@ use tokio_stream::wrappers::ReceiverStream; use xdg::BaseDirectories; use pathpatterns::{MatchEntry, MatchType, PatternFlag}; +use proxmox_io::StdChannelWriter; use proxmox_sys::fs::{file_get_json, replace_file, CreateOptions, image_size}; use proxmox_router::{ApiMethod, RpcEnvironment, cli::*}; use proxmox_schema::api; @@ -68,7 +69,6 @@ use pbs_datastore::manifest::{ ENCRYPTED_KEY_BLOB_NAME, MANIFEST_BLOB_NAME, ArchiveType, BackupManifest, archive_type, }; use pbs_datastore::read_chunk::AsyncReadChunk; -use pbs_tools::sync::StdChannelWriter; use pbs_tools::json; use pbs_tools::crypt_config::CryptConfig; diff --git a/proxmox-backup-client/src/mount.rs b/proxmox-backup-client/src/mount.rs index bc0bc8d5..360cd047 100644 --- a/proxmox-backup-client/src/mount.rs +++ b/proxmox-backup-client/src/mount.rs @@ -140,7 +140,7 @@ fn mount( // Process should be daemonized. // Make sure to fork before the async runtime is instantiated to avoid troubles. - let (pr, pw) = pbs_tools::io::pipe()?; + let (pr, pw) = proxmox_sys::pipe()?; match unsafe { fork() } { Ok(ForkResult::Parent { .. }) => { drop(pw);