public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox/proxmox-backup v2] improve proxmox-async dependencies
@ 2022-02-21 10:39 Dominik Csapak
  2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox v2 1/2] move io error helpers to proxmox-lang Dominik Csapak
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Dominik Csapak @ 2022-02-21 10:39 UTC (permalink / raw)
  To: pbs-devel

this series tries to minimize the dependecies for proxmox-async
so that we can more easily argue to depend on it in proxmox-router for [0]

we have to bump proxmox-lang (to 1.1.0?) and update the dependencies
in the relevant crates/packages

also not sure if we have to bump proxmox-sys, since it lost the
io_format_err macros, etc.

changes from v1:
* move io_ macros/helpers to proxmox-lang instead of writing out the code

0: https://lists.proxmox.com/pipermail/pbs-devel/2022-February/004696.html

proxmox:

Dominik Csapak (2):
  move io error helpers to proxmox-lang
  split out compression code into new crate 'proxmox-compression'

 Cargo.toml                                    |  1 +
 Makefile                                      |  1 +
 proxmox-async/Cargo.toml                      | 10 +---
 proxmox-async/src/io/async_channel_writer.rs  |  3 +-
 proxmox-async/src/lib.rs                      |  2 -
 proxmox-compression/Cargo.toml                | 27 +++++++++
 proxmox-compression/debian/changelog          |  5 ++
 proxmox-compression/debian/control            | 56 +++++++++++++++++++
 proxmox-compression/debian/copyright          | 16 ++++++
 proxmox-compression/debian/debcargo.toml      |  7 +++
 .../src/compression.rs                        |  2 +-
 proxmox-compression/src/lib.rs                |  4 ++
 .../src/zip.rs                                |  2 +-
 proxmox-http/Cargo.toml                       |  2 +
 proxmox-http/src/websocket/mod.rs             |  2 +-
 proxmox-lang/src/error.rs                     | 53 ++++++++++++++++++
 proxmox-lang/src/lib.rs                       |  1 +
 proxmox-sys/src/error.rs                      |  7 +--
 proxmox-sys/src/linux/pid.rs                  |  4 +-
 proxmox-sys/src/macros.rs                     | 44 ---------------
 proxmox-sys/src/mmap.rs                       |  4 +-
 21 files changed, 185 insertions(+), 68 deletions(-)
 create mode 100644 proxmox-compression/Cargo.toml
 create mode 100644 proxmox-compression/debian/changelog
 create mode 100644 proxmox-compression/debian/control
 create mode 100644 proxmox-compression/debian/copyright
 create mode 100644 proxmox-compression/debian/debcargo.toml
 rename {proxmox-async => proxmox-compression}/src/compression.rs (99%)
 create mode 100644 proxmox-compression/src/lib.rs
 rename {proxmox-async => proxmox-compression}/src/zip.rs (99%)
 create mode 100644 proxmox-lang/src/error.rs

proxmox-backup:

Dominik Csapak (2):
  depend on new 'proxmox-compression' crate
  use io_format_err,io_bail,io_err_other from proxmox-lang

 pbs-client/Cargo.toml                         |  1 +
 pbs-client/src/pxar/extract.rs                |  2 +-
 pbs-client/src/pxar/fuse.rs                   | 20 ++++----------
 pbs-datastore/src/cached_chunk_reader.rs      |  4 +--
 pbs-tape/src/blocked_reader.rs                | 26 +++++++++----------
 pbs-tape/src/blocked_writer.rs                |  2 +-
 pbs-tape/src/emulate_tape_reader.rs           |  4 +--
 pbs-tape/src/emulate_tape_writer.rs           |  4 +--
 pbs-tape/src/sg_tape.rs                       | 18 ++++++-------
 pbs-tape/src/tape_write.rs                    |  2 +-
 proxmox-rest-server/Cargo.toml                |  1 +
 proxmox-rest-server/src/rest.rs               |  4 +--
 proxmox-restore-daemon/Cargo.toml             |  1 +
 .../src/proxmox_restore_daemon/api.rs         |  2 +-
 src/tape/drive/virtual_tape.rs                |  4 +--
 src/tape/file_formats/catalog_archive.rs      |  4 +--
 src/tape/file_formats/chunk_archive.rs        |  2 +-
 src/tape/file_formats/multi_volume_reader.rs  | 10 +++----
 src/tape/file_formats/multi_volume_writer.rs  | 14 +++++-----
 src/tape/file_formats/snapshot_archive.rs     |  8 +++---
 src/tools/disks/mod.rs                        |  4 +--
 21 files changed, 65 insertions(+), 72 deletions(-)

-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pbs-devel] [PATCH proxmox v2 1/2] move io error helpers to proxmox-lang
  2022-02-21 10:39 [pbs-devel] [PATCH proxmox/proxmox-backup v2] improve proxmox-async dependencies Dominik Csapak
@ 2022-02-21 10:39 ` Dominik Csapak
  2022-02-21 12:48   ` [pbs-devel] applied: " Wolfgang Bumiller
  2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox v2 2/2] split out compression code into new crate 'proxmox-compression' Dominik Csapak
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Dominik Csapak @ 2022-02-21 10:39 UTC (permalink / raw)
  To: pbs-devel

this removes proxmox_sys as a dependecy for proxmox-async

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 proxmox-async/Cargo.toml                     |  2 +-
 proxmox-async/src/compression.rs             |  2 +-
 proxmox-async/src/io/async_channel_writer.rs |  3 +-
 proxmox-http/Cargo.toml                      |  2 +
 proxmox-http/src/websocket/mod.rs            |  2 +-
 proxmox-lang/src/error.rs                    | 53 ++++++++++++++++++++
 proxmox-lang/src/lib.rs                      |  1 +
 proxmox-sys/src/error.rs                     |  7 +--
 proxmox-sys/src/linux/pid.rs                 |  4 +-
 proxmox-sys/src/macros.rs                    | 44 ----------------
 proxmox-sys/src/mmap.rs                      |  4 +-
 11 files changed, 66 insertions(+), 58 deletions(-)
 create mode 100644 proxmox-lang/src/error.rs

diff --git a/proxmox-async/Cargo.toml b/proxmox-async/Cargo.toml
index 291ff32..917e5f5 100644
--- a/proxmox-async/Cargo.toml
+++ b/proxmox-async/Cargo.toml
@@ -20,9 +20,9 @@ pin-utils = "0.1.0"
 tokio = { version = "1.0", features = ["fs", "net", "rt", "rt-multi-thread", "sync"] }
 walkdir = "2"
 
-proxmox-sys = { path = "../proxmox-sys", version = "0.2.0" }
 proxmox-io = { path = "../proxmox-io", version = "1", features = [ "tokio" ] }
 proxmox-time = { path = "../proxmox-time", version = "1" }
+proxmox-lang = { path = "../proxmox-lang", version = "1" }
 
 [dev-dependencies]
 tokio = { version = "1.6", features = [ "macros" ] }
diff --git a/proxmox-async/src/compression.rs b/proxmox-async/src/compression.rs
index b36f291..632a599 100644
--- a/proxmox-async/src/compression.rs
+++ b/proxmox-async/src/compression.rs
@@ -10,7 +10,7 @@ use futures::stream::Stream;
 use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
 
 use proxmox_io::ByteBuffer;
-use proxmox_sys::io_format_err;
+use proxmox_lang::io_format_err;
 
 const BUFFER_SIZE: usize = 8192;
 
diff --git a/proxmox-async/src/io/async_channel_writer.rs b/proxmox-async/src/io/async_channel_writer.rs
index f63648a..697e65b 100644
--- a/proxmox-async/src/io/async_channel_writer.rs
+++ b/proxmox-async/src/io/async_channel_writer.rs
@@ -12,8 +12,7 @@ use tokio::io::AsyncWrite;
 use tokio::sync::mpsc::Sender;
 
 use proxmox_io::ByteBuffer;
-use proxmox_sys::error::io_err_other;
-use proxmox_sys::io_format_err;
+use proxmox_lang::{error::io_err_other, io_format_err};
 
 /// Wrapper around tokio::sync::mpsc::Sender, which implements Write
 pub struct AsyncChannelWriter {
diff --git a/proxmox-http/Cargo.toml b/proxmox-http/Cargo.toml
index 884fe40..40bba3e 100644
--- a/proxmox-http/Cargo.toml
+++ b/proxmox-http/Cargo.toml
@@ -23,6 +23,7 @@ tokio-openssl = { version = "0.6.1", optional = true }
 
 proxmox-sys = { path = "../proxmox-sys", optional = true, version = "0.2.0" }
 proxmox-io = { path = "../proxmox-io", optional = true, version = "1.0.0" }
+proxmox-lang = { path = "../proxmox-lang", optional = true, version = "1.0.0" }
 
 [features]
 default = []
@@ -36,6 +37,7 @@ websocket = [
     "openssl",
     "proxmox-sys",
     "proxmox-io/tokio",
+    "proxmox-lang",
     "tokio/io-util",
     "tokio/sync",
 ]
diff --git a/proxmox-http/src/websocket/mod.rs b/proxmox-http/src/websocket/mod.rs
index cb17776..50477f6 100644
--- a/proxmox-http/src/websocket/mod.rs
+++ b/proxmox-http/src/websocket/mod.rs
@@ -23,7 +23,7 @@ use futures::future::FutureExt;
 use futures::ready;
 
 use proxmox_io::ByteBuffer;
-use proxmox_sys::error::io_err_other;
+use proxmox_lang::error::io_err_other;
 
 // see RFC6455 section 7.4.1
 #[derive(Debug, Clone, Copy)]
diff --git a/proxmox-lang/src/error.rs b/proxmox-lang/src/error.rs
new file mode 100644
index 0000000..2e03c5b
--- /dev/null
+++ b/proxmox-lang/src/error.rs
@@ -0,0 +1,53 @@
+//! A set of macros/helpers for I/O handling. These provide for `std::io::Error` what `anyhow` provides
+//! for `anyhow::Error.`
+
+use std::io;
+
+/// Helper to convert non-system-errors into an `io::Error` or `io::ErrorKind::Other`.
+///
+/// A more convenient way is to use the `io_format_err!` macro.
+pub fn io_err_other<E: ToString>(e: E) -> io::Error {
+    io::Error::new(std::io::ErrorKind::Other, e.to_string())
+}
+
+
+/// Like anyhow's `format_err` but producing a `std::io::Error`.
+#[macro_export]
+macro_rules! io_format_err {
+    ($($msg:tt)+) => {
+        ::std::io::Error::new(::std::io::ErrorKind::Other, format!($($msg)+))
+    };
+}
+
+/// Shortcut to return an `io::Error::last_os_error`.
+///
+/// This is effectively `return Err(::std::io::Error::last_os_error().into());`.
+#[macro_export]
+macro_rules! io_bail_last {
+    () => {{
+        return Err(::std::io::Error::last_os_error().into());
+    }};
+}
+
+/// Like anyhow's `bail` but producing a `std::io::Error`.
+#[macro_export]
+macro_rules! io_bail {
+    ($($msg:tt)+) => {{
+        return Err($crate::io_format_err!($($msg)+));
+    }};
+}
+
+#[doc(hidden)]
+/// Non-panicking assertion: shortcut for returning an `io::Error` if the condition is not met.
+/// Essentially: `if !expr { io_bail_last!() }`.
+///
+/// Note that this uses `errno`, care must be taken not to overwrite it with different value as a
+/// side effect.
+#[macro_export]
+macro_rules! io_assert {
+    ($value:expr) => {
+        if !$value {
+            $crate::io_bail_last!();
+        }
+    };
+}
diff --git a/proxmox-lang/src/lib.rs b/proxmox-lang/src/lib.rs
index f5c6ebe..788165a 100644
--- a/proxmox-lang/src/lib.rs
+++ b/proxmox-lang/src/lib.rs
@@ -6,6 +6,7 @@
 
 mod constnamedbitmap;
 
+pub mod error;
 pub mod ops;
 
 /// Macro to write error-handling blocks (like perl eval {})
diff --git a/proxmox-sys/src/error.rs b/proxmox-sys/src/error.rs
index 3af6038..78f846b 100644
--- a/proxmox-sys/src/error.rs
+++ b/proxmox-sys/src/error.rs
@@ -18,12 +18,7 @@ use std::io;
 use nix::errno::Errno;
 use nix::Error;
 
-/// Helper to convert non-system-errors into an `io::Error` or `io::ErrorKind::Other`.
-///
-/// A more convenient way is to use the `io_format_err!` macro.
-pub fn io_err_other<E: ToString>(e: E) -> io::Error {
-    io::Error::new(std::io::ErrorKind::Other, e.to_string())
-}
+use proxmox_lang::error::io_err_other;
 
 /// This trait should be implemented for error types which can represent system errors. Note that
 /// it is discouraged to try to map non-system errors to with this trait, since users of this trait
diff --git a/proxmox-sys/src/linux/pid.rs b/proxmox-sys/src/linux/pid.rs
index ad5fdc2..07d7163 100644
--- a/proxmox-sys/src/linux/pid.rs
+++ b/proxmox-sys/src/linux/pid.rs
@@ -11,9 +11,9 @@ use nix::sys::stat::Mode;
 use nix::unistd::Pid;
 use nix::NixPath;
 
-use proxmox_lang::c_str;
+use proxmox_lang::{c_str, error::io_err_other};
 
-use crate::error::{io_err_other, SysResult};
+use crate::error::SysResult;
 use crate::linux::procfs::{MountInfo, PidStat};
 use crate::fd::Fd;
 use crate::{c_result, c_try};
diff --git a/proxmox-sys/src/macros.rs b/proxmox-sys/src/macros.rs
index cab6eb3..a76db90 100644
--- a/proxmox-sys/src/macros.rs
+++ b/proxmox-sys/src/macros.rs
@@ -1,47 +1,3 @@
-//! A set of macros for I/O handling. These provide for `std::io::Error` what `anyhow` provides
-//! for `anyhow::Error.`
-
-/// Like anyhow's `format_err` but producing a `std::io::Error`.
-#[macro_export]
-macro_rules! io_format_err {
-    ($($msg:tt)+) => {
-        ::std::io::Error::new(::std::io::ErrorKind::Other, format!($($msg)+))
-    };
-}
-
-/// Shortcut to return an `io::Error::last_os_error`.
-///
-/// This is effectively `return Err(::std::io::Error::last_os_error().into());`.
-#[macro_export]
-macro_rules! io_bail_last {
-    () => {{
-        return Err(::std::io::Error::last_os_error().into());
-    }};
-}
-
-/// Like anyhow's `bail` but producing a `std::io::Error`.
-#[macro_export]
-macro_rules! io_bail {
-    ($($msg:tt)+) => {{
-        return Err($crate::io_format_err!($($msg)+));
-    }};
-}
-
-#[doc(hidden)]
-/// Non-panicking assertion: shortcut for returning an `io::Error` if the condition is not met.
-/// Essentially: `if !expr { io_bail_last!() }`.
-///
-/// Note that this uses `errno`, care must be taken not to overwrite it with different value as a
-/// side effect.
-#[macro_export]
-macro_rules! io_assert {
-    ($value:expr) => {
-        if !$value {
-            $crate::io_bail_last!();
-        }
-    };
-}
-
 /// Roughly equivalent to `nix::Errno::result`. Turns a `-1` into an `io::Error`, while passing
 /// other values through as `Ok(n)`.
 #[macro_export]
diff --git a/proxmox-sys/src/mmap.rs b/proxmox-sys/src/mmap.rs
index cfbf9f7..b296c30 100644
--- a/proxmox-sys/src/mmap.rs
+++ b/proxmox-sys/src/mmap.rs
@@ -7,7 +7,9 @@ use std::{io, mem, ptr};
 
 use nix::sys::mman;
 
-use crate::error::{io_err_other, SysError};
+use proxmox_lang::error::io_err_other;
+
+use crate::error::{SysError};
 
 pub struct Mmap<T> {
     data: *mut T,
-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pbs-devel] [PATCH proxmox v2 2/2] split out compression code into new crate 'proxmox-compression'
  2022-02-21 10:39 [pbs-devel] [PATCH proxmox/proxmox-backup v2] improve proxmox-async dependencies Dominik Csapak
  2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox v2 1/2] move io error helpers to proxmox-lang Dominik Csapak
@ 2022-02-21 10:39 ` Dominik Csapak
  2022-02-21 13:21   ` [pbs-devel] applied: " Wolfgang Bumiller
  2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox-backup v2 1/2] depend on new 'proxmox-compression' crate Dominik Csapak
  2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox-backup v2 2/2] use io_format_err, io_bail, io_err_other from proxmox-lang Dominik Csapak
  3 siblings, 1 reply; 8+ messages in thread
From: Dominik Csapak @ 2022-02-21 10:39 UTC (permalink / raw)
  To: pbs-devel

this removes quite a bit of dependecies of proxmox-async

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 Cargo.toml                                    |  1 +
 Makefile                                      |  1 +
 proxmox-async/Cargo.toml                      |  8 +--
 proxmox-async/src/lib.rs                      |  2 -
 proxmox-compression/Cargo.toml                | 27 +++++++++
 proxmox-compression/debian/changelog          |  5 ++
 proxmox-compression/debian/control            | 56 +++++++++++++++++++
 proxmox-compression/debian/copyright          | 16 ++++++
 proxmox-compression/debian/debcargo.toml      |  7 +++
 .../src/compression.rs                        |  0
 proxmox-compression/src/lib.rs                |  4 ++
 .../src/zip.rs                                |  2 +-
 12 files changed, 119 insertions(+), 10 deletions(-)
 create mode 100644 proxmox-compression/Cargo.toml
 create mode 100644 proxmox-compression/debian/changelog
 create mode 100644 proxmox-compression/debian/control
 create mode 100644 proxmox-compression/debian/copyright
 create mode 100644 proxmox-compression/debian/debcargo.toml
 rename {proxmox-async => proxmox-compression}/src/compression.rs (100%)
 create mode 100644 proxmox-compression/src/lib.rs
 rename {proxmox-async => proxmox-compression}/src/zip.rs (99%)

diff --git a/Cargo.toml b/Cargo.toml
index 4a458d2..a992dd0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,6 +3,7 @@ members = [
     "proxmox-api-macro",
     "proxmox-async",
     "proxmox-borrow",
+    "proxmox-compression",
     "proxmox-http",
     "proxmox-io",
     "proxmox-lang",
diff --git a/Makefile b/Makefile
index e4b08a3..8c72c65 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@ CRATES = \
 	 proxmox-api-macro \
 	 proxmox-async \
 	 proxmox-borrow \
+	 proxmox-compression \
 	 proxmox-http \
 	 proxmox-io \
 	 proxmox-lang \
diff --git a/proxmox-async/Cargo.toml b/proxmox-async/Cargo.toml
index 917e5f5..30cd399 100644
--- a/proxmox-async/Cargo.toml
+++ b/proxmox-async/Cargo.toml
@@ -10,18 +10,12 @@ exclude = [ "debian" ]
 
 [dependencies]
 anyhow = "1.0"
-bytes = "1.0"
-crc32fast = "1"
-endian_trait = { version = "0.6", features = ["arrays"] }
-flate2 = "1.0"
 futures = "0.3"
 lazy_static = "1.4"
 pin-utils = "0.1.0"
-tokio = { version = "1.0", features = ["fs", "net", "rt", "rt-multi-thread", "sync"] }
-walkdir = "2"
+tokio = { version = "1.0", features = [ "net", "rt", "rt-multi-thread", "sync"] }
 
 proxmox-io = { path = "../proxmox-io", version = "1", features = [ "tokio" ] }
-proxmox-time = { path = "../proxmox-time", version = "1" }
 proxmox-lang = { path = "../proxmox-lang", version = "1" }
 
 [dev-dependencies]
diff --git a/proxmox-async/src/lib.rs b/proxmox-async/src/lib.rs
index ad540d3..5445f68 100644
--- a/proxmox-async/src/lib.rs
+++ b/proxmox-async/src/lib.rs
@@ -1,8 +1,6 @@
 pub mod blocking;
 pub mod broadcast_future;
-pub mod compression;
 pub mod io;
 pub mod net;
 pub mod runtime;
 pub mod stream;
-pub mod zip;
diff --git a/proxmox-compression/Cargo.toml b/proxmox-compression/Cargo.toml
new file mode 100644
index 0000000..0f98360
--- /dev/null
+++ b/proxmox-compression/Cargo.toml
@@ -0,0 +1,27 @@
+[package]
+name = "proxmox-compression"
+version = "0.1.0"
+authors = ["Proxmox Support Team <support@proxmox.com>"]
+edition = "2018"
+license = "AGPL-3"
+description = "contains compression utilitites (such as an Zip Encoder for async rust)"
+
+exclude = [ "debian" ]
+
+[dependencies]
+anyhow = "1.0"
+bytes = "1.0"
+crc32fast = "1"
+endian_trait = { version = "0.6" }
+flate2 = "1.0"
+futures = "0.3"
+tokio = { version = "1.6", features = [ "fs", "io-util"] }
+walkdir = "2"
+
+proxmox-time = { path = "../proxmox-time", version = "1" }
+proxmox-io = { path = "../proxmox-io", version = "1", features = [ "tokio" ] }
+proxmox-lang = { path = "../proxmox-lang", version = "1" }
+
+[dev-dependencies]
+tokio = { version = "1.6", features = [ "macros" ] }
+
diff --git a/proxmox-compression/debian/changelog b/proxmox-compression/debian/changelog
new file mode 100644
index 0000000..3c81e27
--- /dev/null
+++ b/proxmox-compression/debian/changelog
@@ -0,0 +1,5 @@
+rust-proxmox-compression (0.1.0-1) stable; urgency=medium
+
+  * initial split out of `proxmox-async`
+
+ -- Proxmox Support Team <support@proxmox.com>  Fri, 18 Feb 2022 11:59:30 +0100
diff --git a/proxmox-compression/debian/control b/proxmox-compression/debian/control
new file mode 100644
index 0000000..12fa4e6
--- /dev/null
+++ b/proxmox-compression/debian/control
@@ -0,0 +1,56 @@
+Source: rust-proxmox-compression
+Section: rust
+Priority: optional
+Build-Depends: debhelper (>= 12),
+ dh-cargo (>= 25),
+ cargo:native <!nocheck>,
+ rustc:native <!nocheck>,
+ libstd-rust-dev <!nocheck>,
+ librust-anyhow-1+default-dev <!nocheck>,
+ librust-bytes-1+default-dev <!nocheck>,
+ librust-crc32fast-1+default-dev <!nocheck>,
+ librust-endian-trait-0.6+default-dev <!nocheck>,
+ librust-flate2-1+default-dev <!nocheck>,
+ librust-futures-0.3+default-dev <!nocheck>,
+ librust-proxmox-io-1+default-dev <!nocheck>,
+ librust-proxmox-io-1+tokio-dev <!nocheck>,
+ librust-proxmox-time-1+default-dev <!nocheck>,
+ librust-tokio-1+default-dev <!nocheck>,
+ librust-tokio-1+fs-dev <!nocheck>,
+ librust-tokio-1+io-util-dev <!nocheck>,
+ librust-walkdir-2+default-dev <!nocheck>
+Maintainer: Proxmox Support Team <support@proxmox.com>
+Standards-Version: 4.5.1
+Vcs-Git: git://git.proxmox.com/git/proxmox.git
+Vcs-Browser: https://git.proxmox.com/?p=proxmox.git
+Rules-Requires-Root: no
+
+Package: librust-proxmox-compression-dev
+Architecture: any
+Multi-Arch: same
+Depends:
+ ${misc:Depends},
+ librust-anyhow-1+default-dev,
+ librust-bytes-1+default-dev,
+ librust-crc32fast-1+default-dev,
+ librust-endian-trait-0.6+default-dev,
+ librust-flate2-1+default-dev,
+ librust-futures-0.3+default-dev,
+ librust-proxmox-io-1+default-dev,
+ librust-proxmox-io-1+tokio-dev,
+ librust-proxmox-time-1+default-dev,
+ librust-tokio-1+default-dev,
+ librust-tokio-1+fs-dev,
+ librust-tokio-1+io-util-dev,
+ librust-walkdir-2+default-dev
+Provides:
+ librust-proxmox-compression+default-dev (= ${binary:Version}),
+ librust-proxmox-compression-0-dev (= ${binary:Version}),
+ librust-proxmox-compression-0+default-dev (= ${binary:Version}),
+ librust-proxmox-compression-0.1-dev (= ${binary:Version}),
+ librust-proxmox-compression-0.1+default-dev (= ${binary:Version}),
+ librust-proxmox-compression-0.1.0-dev (= ${binary:Version}),
+ librust-proxmox-compression-0.1.0+default-dev (= ${binary:Version})
+Description: Contains compression utilitites (such as an Zip Encoder for async rust) - Rust source code
+ This package contains the source for the Rust proxmox-compression crate,
+ packaged by debcargo for use with cargo and dh-cargo.
diff --git a/proxmox-compression/debian/copyright b/proxmox-compression/debian/copyright
new file mode 100644
index 0000000..d2d30fc
--- /dev/null
+++ b/proxmox-compression/debian/copyright
@@ -0,0 +1,16 @@
+Copyright (C) 2022 Proxmox Server Solutions GmbH
+
+This software is written by Proxmox Server Solutions GmbH <support@proxmox.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
diff --git a/proxmox-compression/debian/debcargo.toml b/proxmox-compression/debian/debcargo.toml
new file mode 100644
index 0000000..b7864cd
--- /dev/null
+++ b/proxmox-compression/debian/debcargo.toml
@@ -0,0 +1,7 @@
+overlay = "."
+crate_src_path = ".."
+maintainer = "Proxmox Support Team <support@proxmox.com>"
+
+[source]
+vcs_git = "git://git.proxmox.com/git/proxmox.git"
+vcs_browser = "https://git.proxmox.com/?p=proxmox.git"
diff --git a/proxmox-async/src/compression.rs b/proxmox-compression/src/compression.rs
similarity index 100%
rename from proxmox-async/src/compression.rs
rename to proxmox-compression/src/compression.rs
diff --git a/proxmox-compression/src/lib.rs b/proxmox-compression/src/lib.rs
new file mode 100644
index 0000000..05cf06b
--- /dev/null
+++ b/proxmox-compression/src/lib.rs
@@ -0,0 +1,4 @@
+mod compression;
+pub use compression::*;
+
+pub mod zip;
diff --git a/proxmox-async/src/zip.rs b/proxmox-compression/src/zip.rs
similarity index 99%
rename from proxmox-async/src/zip.rs
rename to proxmox-compression/src/zip.rs
index 04bd4e0..a84c1c9 100644
--- a/proxmox-async/src/zip.rs
+++ b/proxmox-compression/src/zip.rs
@@ -437,7 +437,7 @@ where
 /// use anyhow::{Error, Result};
 /// use tokio::fs::File;
 ///
-/// use proxmox_async::zip::{ZipEncoder, ZipEntry};
+/// use proxmox_compression::zip::{ZipEncoder, ZipEntry};
 ///
 /// #[tokio::main]
 /// async fn main() -> Result<(), Error> {
-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pbs-devel] [PATCH proxmox-backup v2 1/2] depend on new 'proxmox-compression' crate
  2022-02-21 10:39 [pbs-devel] [PATCH proxmox/proxmox-backup v2] improve proxmox-async dependencies Dominik Csapak
  2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox v2 1/2] move io error helpers to proxmox-lang Dominik Csapak
  2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox v2 2/2] split out compression code into new crate 'proxmox-compression' Dominik Csapak
@ 2022-02-21 10:39 ` Dominik Csapak
  2022-02-21 13:28   ` [pbs-devel] applied-series: " Wolfgang Bumiller
  2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox-backup v2 2/2] use io_format_err, io_bail, io_err_other from proxmox-lang Dominik Csapak
  3 siblings, 1 reply; 8+ messages in thread
From: Dominik Csapak @ 2022-02-21 10:39 UTC (permalink / raw)
  To: pbs-devel

the compression utilities live there now

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 pbs-client/Cargo.toml                                    | 1 +
 pbs-client/src/pxar/extract.rs                           | 2 +-
 proxmox-rest-server/Cargo.toml                           | 1 +
 proxmox-rest-server/src/rest.rs                          | 2 +-
 proxmox-restore-daemon/Cargo.toml                        | 1 +
 proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs | 2 +-
 6 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/pbs-client/Cargo.toml b/pbs-client/Cargo.toml
index 60dc32d3..a61777a6 100644
--- a/pbs-client/Cargo.toml
+++ b/pbs-client/Cargo.toml
@@ -31,6 +31,7 @@ xdg = "2.2"
 pathpatterns = "0.1.2"
 
 proxmox-async = "0.3"
+proxmox-compression = "0.1"
 proxmox-fuse = "0.1.1"
 proxmox-http = { version = "0.6", features = [ "client", "http-helpers", "websocket" ] }
 proxmox-io = { version = "1.0.1", features = [ "tokio" ] }
diff --git a/pbs-client/src/pxar/extract.rs b/pbs-client/src/pxar/extract.rs
index 8c85dd02..b1f8718e 100644
--- a/pbs-client/src/pxar/extract.rs
+++ b/pbs-client/src/pxar/extract.rs
@@ -25,7 +25,7 @@ use proxmox_sys::c_result;
 use proxmox_sys::fs::{create_path, CreateOptions};
 use proxmox_io::{sparse_copy, sparse_copy_async};
 
-use proxmox_async::zip::{ZipEncoder, ZipEntry};
+use proxmox_compression::zip::{ZipEncoder, ZipEntry};
 
 use crate::pxar::dir_stack::PxarDirStack;
 use crate::pxar::metadata;
diff --git a/proxmox-rest-server/Cargo.toml b/proxmox-rest-server/Cargo.toml
index 8fbbe8c0..ce863926 100644
--- a/proxmox-rest-server/Cargo.toml
+++ b/proxmox-rest-server/Cargo.toml
@@ -32,6 +32,7 @@ url = "2.1"
 
 #proxmox = "0.15.3"
 proxmox-async = "0.3"
+proxmox-compression = "0.1"
 proxmox-io = "1"
 proxmox-lang = "1"
 proxmox-http = { version = "0.6", features = [ "client" ] }
diff --git a/proxmox-rest-server/src/rest.rs b/proxmox-rest-server/src/rest.rs
index 093e6226..5194151c 100644
--- a/proxmox-rest-server/src/rest.rs
+++ b/proxmox-rest-server/src/rest.rs
@@ -30,7 +30,7 @@ use proxmox_schema::{ObjectSchemaType, ParameterSchema};
 
 use proxmox_http::client::RateLimitedStream;
 
-use proxmox_async::compression::{DeflateEncoder, Level};
+use proxmox_compression::{DeflateEncoder, Level};
 use proxmox_async::stream::AsyncReaderStream;
 
 use crate::{
diff --git a/proxmox-restore-daemon/Cargo.toml b/proxmox-restore-daemon/Cargo.toml
index e25f12f7..088372be 100644
--- a/proxmox-restore-daemon/Cargo.toml
+++ b/proxmox-restore-daemon/Cargo.toml
@@ -27,6 +27,7 @@ pathpatterns = "0.1.2"
 pxar = { version = "0.10.1", features = [ "tokio-io" ] }
 
 proxmox-async = "0.3"
+proxmox-compression = "0.1"
 proxmox-router = { version = "1.1", features = [ "cli" ] }
 proxmox-schema = { version = "1.1", features = [ "api-macro" ] }
 proxmox-time = "1"
diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
index 4c755210..1333590d 100644
--- a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
+++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
@@ -18,7 +18,7 @@ use proxmox_router::{
     ApiHandler, ApiMethod, ApiResponseFuture, Permission, Router, RpcEnvironment, SubdirMap,
 };
 use proxmox_schema::*;
-use proxmox_async::zip::zip_directory;
+use proxmox_compression::zip::zip_directory;
 use proxmox_sys::fs::read_subdir;
 use proxmox_sys::sortable;
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pbs-devel] [PATCH proxmox-backup v2 2/2] use io_format_err, io_bail, io_err_other from proxmox-lang
  2022-02-21 10:39 [pbs-devel] [PATCH proxmox/proxmox-backup v2] improve proxmox-async dependencies Dominik Csapak
                   ` (2 preceding siblings ...)
  2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox-backup v2 1/2] depend on new 'proxmox-compression' crate Dominik Csapak
@ 2022-02-21 10:39 ` Dominik Csapak
  3 siblings, 0 replies; 8+ messages in thread
From: Dominik Csapak @ 2022-02-21 10:39 UTC (permalink / raw)
  To: pbs-devel

and move the comment from the local io_bail in pbs-client/src/pxar/fuse.rs
to the only use

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 pbs-client/src/pxar/fuse.rs                  | 20 ++++-----------
 pbs-datastore/src/cached_chunk_reader.rs     |  4 +--
 pbs-tape/src/blocked_reader.rs               | 26 ++++++++++----------
 pbs-tape/src/blocked_writer.rs               |  2 +-
 pbs-tape/src/emulate_tape_reader.rs          |  4 +--
 pbs-tape/src/emulate_tape_writer.rs          |  4 +--
 pbs-tape/src/sg_tape.rs                      | 18 +++++++-------
 pbs-tape/src/tape_write.rs                   |  2 +-
 proxmox-rest-server/src/rest.rs              |  2 +-
 src/tape/drive/virtual_tape.rs               |  4 +--
 src/tape/file_formats/catalog_archive.rs     |  4 +--
 src/tape/file_formats/chunk_archive.rs       |  2 +-
 src/tape/file_formats/multi_volume_reader.rs | 10 ++++----
 src/tape/file_formats/multi_volume_writer.rs | 14 +++++------
 src/tape/file_formats/snapshot_archive.rs    |  8 +++---
 src/tools/disks/mod.rs                       |  4 +--
 16 files changed, 59 insertions(+), 69 deletions(-)

diff --git a/pbs-client/src/pxar/fuse.rs b/pbs-client/src/pxar/fuse.rs
index b039c6bd..0b90ff2c 100644
--- a/pbs-client/src/pxar/fuse.rs
+++ b/pbs-client/src/pxar/fuse.rs
@@ -25,6 +25,7 @@ use pxar::accessor::{self, EntryRangeInfo, ReadAt};
 
 use proxmox_fuse::requests::{self, FuseRequest};
 use proxmox_fuse::{EntryParam, Fuse, ReplyBufState, Request, ROOT_ID};
+use proxmox_lang::io_format_err;
 use proxmox_sys::fs::xattr;
 
 /// We mark inodes for regular files this way so we know how to access them.
@@ -110,20 +111,6 @@ macro_rules! io_return {
     }};
 }
 
-/// Format an "other" error, see `io_bail` below for details.
-macro_rules! io_format_err {
-    ($($fmt:tt)*) => {
-        ::std::io::Error::new(::std::io::ErrorKind::Other, format!($($fmt)*))
-    }
-}
-
-/// We use this to bail out of a functionin an unexpected error case. This will cause the fuse
-/// request to be answered with a generic `EIO` error code. The error message contained in here
-/// will be printed to stdout if the verbose flag is used, otherwise silently dropped.
-macro_rules! io_bail {
-    ($($fmt:tt)*) => { return Err(io_format_err!($($fmt)*).into()); }
-}
-
 /// This is what we need to cache as a "lookup" entry. The kernel assumes that these are easily
 /// accessed.
 struct Lookup {
@@ -157,7 +144,10 @@ impl Lookup {
         loop {
             let old = self.refs.load(Ordering::Acquire);
             if count >= old {
-                io_bail!("reference count underflow");
+                // We use this to bail out of a functionin an unexpected error case. This will cause the fuse
+                // request to be answered with a generic `EIO` error code. The error message contained in here
+                // will be printed to stdout if the verbose flag is used, otherwise silently dropped.
+                return Err(io_format_err!("reference count underflow").into());
             }
             let new = old - count;
             match self
diff --git a/pbs-datastore/src/cached_chunk_reader.rs b/pbs-datastore/src/cached_chunk_reader.rs
index 1fa26436..0a383904 100644
--- a/pbs-datastore/src/cached_chunk_reader.rs
+++ b/pbs-datastore/src/cached_chunk_reader.rs
@@ -10,8 +10,8 @@ use anyhow::Error;
 use futures::ready;
 use tokio::io::{AsyncRead, AsyncSeek, ReadBuf};
 
-use proxmox_sys::io_format_err;
-use proxmox_sys::error::io_err_other;
+use proxmox_lang::io_format_err;
+use proxmox_lang::error::io_err_other;
 
 use pbs_tools::async_lru_cache::{AsyncCacher, AsyncLruCache};
 
diff --git a/pbs-tape/src/blocked_reader.rs b/pbs-tape/src/blocked_reader.rs
index 5a05e081..b01361f3 100644
--- a/pbs-tape/src/blocked_reader.rs
+++ b/pbs-tape/src/blocked_reader.rs
@@ -69,11 +69,11 @@ impl <R: BlockRead> BlockedReader<R> {
     fn check_buffer(buffer: &BlockHeader, seq_nr: u32) -> Result<(usize, bool), std::io::Error> {
 
         if buffer.magic != PROXMOX_TAPE_BLOCK_HEADER_MAGIC_1_0 {
-            proxmox_sys::io_bail!("detected tape block with wrong magic number - not written by proxmox tape");
+            proxmox_lang::io_bail!("detected tape block with wrong magic number - not written by proxmox tape");
         }
 
         if seq_nr != buffer.seq_nr() {
-            proxmox_sys::io_bail!(
+            proxmox_lang::io_bail!(
                 "detected tape block with wrong sequence number ({} != {})",
                 seq_nr, buffer.seq_nr())
         }
@@ -82,9 +82,9 @@ impl <R: BlockRead> BlockedReader<R> {
         let found_end_marker = buffer.flags.contains(BlockHeaderFlags::END_OF_STREAM);
 
         if size > buffer.payload.len() {
-            proxmox_sys::io_bail!("detected tape block with wrong payload size ({} > {}", size, buffer.payload.len());
+            proxmox_lang::io_bail!("detected tape block with wrong payload size ({} > {}", size, buffer.payload.len());
         } else if size == 0 && !found_end_marker {
-            proxmox_sys::io_bail!("detected tape block with zero payload size");
+            proxmox_lang::io_bail!("detected tape block with zero payload size");
         }
 
 
@@ -103,7 +103,7 @@ impl <R: BlockRead> BlockedReader<R> {
         let bytes = reader.read_block(data)?;
 
         if bytes != BlockHeader::SIZE {
-            return Err(proxmox_sys::io_format_err!("got wrong block size").into());
+            return Err(proxmox_lang::io_format_err!("got wrong block size").into());
         }
 
         Ok(())
@@ -113,13 +113,13 @@ impl <R: BlockRead> BlockedReader<R> {
         let mut tmp_buf = [0u8; 512]; // use a small buffer for testing EOF
         match reader.read_block(&mut tmp_buf) {
             Ok(_) => {
-                proxmox_sys::io_bail!("detected tape block after block-stream end marker");
+                proxmox_lang::io_bail!("detected tape block after block-stream end marker");
             }
             Err(BlockReadError::EndOfFile) => {
                 Ok(())
             }
             Err(BlockReadError::EndOfStream) => {
-                proxmox_sys::io_bail!("got unexpected end of tape");
+                proxmox_lang::io_bail!("got unexpected end of tape");
             }
             Err(BlockReadError::Error(err)) => {
                 Err(err)
@@ -135,12 +135,12 @@ impl <R: BlockRead> BlockedReader<R> {
                 self.got_eod = true;
                 self.read_pos = self.buffer.payload.len();
                 if !self.found_end_marker && check_end_marker {
-                    proxmox_sys::io_bail!("detected tape stream without end marker");
+                    proxmox_lang::io_bail!("detected tape stream without end marker");
                 }
                 return Ok(0); // EOD
             }
             Err(BlockReadError::EndOfStream) => {
-                proxmox_sys::io_bail!("got unexpected end of tape");
+                proxmox_lang::io_bail!("got unexpected end of tape");
             }
             Err(BlockReadError::Error(err)) => {
                 return Err(err);
@@ -167,10 +167,10 @@ impl <R: BlockRead> TapeRead for BlockedReader<R> {
 
     fn is_incomplete(&self) -> Result<bool, std::io::Error> {
         if !self.got_eod {
-            proxmox_sys::io_bail!("is_incomplete failed: EOD not reached");
+            proxmox_lang::io_bail!("is_incomplete failed: EOD not reached");
         }
         if !self.found_end_marker {
-            proxmox_sys::io_bail!("is_incomplete failed: no end marker found");
+            proxmox_lang::io_bail!("is_incomplete failed: no end marker found");
         }
 
         Ok(self.incomplete)
@@ -178,7 +178,7 @@ impl <R: BlockRead> TapeRead for BlockedReader<R> {
 
     fn has_end_marker(&self) -> Result<bool, std::io::Error> {
         if !self.got_eod {
-            proxmox_sys::io_bail!("has_end_marker failed: EOD not reached");
+            proxmox_lang::io_bail!("has_end_marker failed: EOD not reached");
         }
 
         Ok(self.found_end_marker)
@@ -207,7 +207,7 @@ impl <R: BlockRead> Read for BlockedReader<R> {
     fn read(&mut self, buffer: &mut [u8]) -> Result<usize, std::io::Error> {
 
          if self.read_error {
-            proxmox_sys::io_bail!("detected read after error - internal error");
+            proxmox_lang::io_bail!("detected read after error - internal error");
         }
 
         let mut buffer_size = self.buffer.size();
diff --git a/pbs-tape/src/blocked_writer.rs b/pbs-tape/src/blocked_writer.rs
index e98db5d0..9d5d39e4 100644
--- a/pbs-tape/src/blocked_writer.rs
+++ b/pbs-tape/src/blocked_writer.rs
@@ -65,7 +65,7 @@ impl <W: BlockWrite> BlockedWriter<W> {
 
     fn write_eof(&mut self) -> Result<(), std::io::Error> {
         if self.wrote_eof {
-            proxmox_sys::io_bail!("BlockedWriter: detected multiple EOF writes");
+            proxmox_lang::io_bail!("BlockedWriter: detected multiple EOF writes");
         }
         self.wrote_eof = true;
 
diff --git a/pbs-tape/src/emulate_tape_reader.rs b/pbs-tape/src/emulate_tape_reader.rs
index 1e6454ce..6553c3b4 100644
--- a/pbs-tape/src/emulate_tape_reader.rs
+++ b/pbs-tape/src/emulate_tape_reader.rs
@@ -22,7 +22,7 @@ impl <R: Read> EmulateTapeReader<R> {
 impl <R: Read> BlockRead for EmulateTapeReader<R> {
     fn read_block(&mut self, buffer: &mut [u8]) -> Result<usize, BlockReadError> {
         if self.got_eof {
-             return Err(BlockReadError::Error(proxmox_sys::io_format_err!("detected read after EOF!")));
+             return Err(BlockReadError::Error(proxmox_lang::io_format_err!("detected read after EOF!")));
         }
         match self.reader.read_exact_or_eof(buffer)? {
             false => {
@@ -33,7 +33,7 @@ impl <R: Read> BlockRead for EmulateTapeReader<R> {
                 // test buffer len after EOF test (to allow EOF test with small buffers in BufferedReader)
                 if buffer.len() != PROXMOX_TAPE_BLOCK_SIZE {
                     return Err(BlockReadError::Error(
-                        proxmox_sys::io_format_err!(
+                        proxmox_lang::io_format_err!(
                             "EmulateTapeReader: read_block with wrong block size ({} != {})",
                             buffer.len(),
                             PROXMOX_TAPE_BLOCK_SIZE,
diff --git a/pbs-tape/src/emulate_tape_writer.rs b/pbs-tape/src/emulate_tape_writer.rs
index 04ad697e..bae427c7 100644
--- a/pbs-tape/src/emulate_tape_writer.rs
+++ b/pbs-tape/src/emulate_tape_writer.rs
@@ -39,7 +39,7 @@ impl <W: Write> BlockWrite for EmulateTapeWriter<W> {
     fn write_block(&mut self, buffer: &[u8]) -> Result<bool, io::Error> {
 
         if buffer.len() != PROXMOX_TAPE_BLOCK_SIZE {
-            proxmox_sys::io_bail!("EmulateTapeWriter: got write with wrong block size ({} != {}",
+            proxmox_lang::io_bail!("EmulateTapeWriter: got write with wrong block size ({} != {}",
                               buffer.len(), PROXMOX_TAPE_BLOCK_SIZE);
         }
 
@@ -59,7 +59,7 @@ impl <W: Write> BlockWrite for EmulateTapeWriter<W> {
 
     fn write_filemark(&mut self) -> Result<(), std::io::Error> {
         if self.wrote_eof {
-            proxmox_sys::io_bail!("EmulateTapeWriter: detected multiple EOF writes");
+            proxmox_lang::io_bail!("EmulateTapeWriter: detected multiple EOF writes");
         }
         // do nothing, just record the call
         self.wrote_eof = true;
diff --git a/pbs-tape/src/sg_tape.rs b/pbs-tape/src/sg_tape.rs
index 9801ad47..e0590671 100644
--- a/pbs-tape/src/sg_tape.rs
+++ b/pbs-tape/src/sg_tape.rs
@@ -528,11 +528,11 @@ impl SgTape {
     ) ->  Result<(), std::io::Error> {
 
         if count > 255 {
-            proxmox_sys::io_bail!("write_filemarks failed: got strange count '{}'", count);
+            proxmox_lang::io_bail!("write_filemarks failed: got strange count '{}'", count);
         }
 
         let mut sg_raw = SgRaw::new(&mut self.file, 16)
-            .map_err(|err| proxmox_sys::io_format_err!("write_filemarks failed (alloc) - {}", err))?;
+            .map_err(|err| proxmox_lang::io_format_err!("write_filemarks failed (alloc) - {}", err))?;
 
         sg_raw.set_timeout(Self::SCSI_TAPE_DEFAULT_TIMEOUT);
         let mut cmd = Vec::new();
@@ -551,7 +551,7 @@ impl SgTape {
                 /* LEOM - ignore */
             }
             Err(err) => {
-                proxmox_sys::io_bail!("write filemark  failed - {}", err);
+                proxmox_lang::io_bail!("write filemark  failed - {}", err);
             }
         }
 
@@ -630,7 +630,7 @@ impl SgTape {
         let transfer_len = data.len();
 
         if transfer_len > 0x800000 {
-           proxmox_sys::io_bail!("write failed - data too large");
+           proxmox_lang::io_bail!("write failed - data too large");
         }
 
         let mut sg_raw = SgRaw::new(&mut self.file, 0)
@@ -654,7 +654,7 @@ impl SgTape {
                 Ok(true) // LEOM
             }
             Err(err) => {
-                proxmox_sys::io_bail!("write failed - {}", err);
+                proxmox_lang::io_bail!("write failed - {}", err);
             }
         }
     }
@@ -664,7 +664,7 @@ impl SgTape {
 
         if transfer_len > 0xFFFFFF {
             return Err(BlockReadError::Error(
-                proxmox_sys::io_format_err!("read failed - buffer too large")
+                proxmox_lang::io_format_err!("read failed - buffer too large")
             ));
         }
 
@@ -691,14 +691,14 @@ impl SgTape {
             }
             Err(err) => {
                 return Err(BlockReadError::Error(
-                    proxmox_sys::io_format_err!("read failed - {}", err)
+                    proxmox_lang::io_format_err!("read failed - {}", err)
                 ));
             }
         };
 
         if data.len() != transfer_len {
             return Err(BlockReadError::Error(
-                proxmox_sys::io_format_err!("read failed - unexpected block len ({} != {})", data.len(), buffer.len())
+                proxmox_lang::io_format_err!("read failed - unexpected block len ({} != {})", data.len(), buffer.len())
             ));
         }
 
@@ -949,7 +949,7 @@ impl <'a> BlockRead for SgTapeReader<'a> {
 
     fn read_block(&mut self, buffer: &mut [u8]) -> Result<usize, BlockReadError> {
         if self.end_of_file {
-            return Err(BlockReadError::Error(proxmox_sys::io_format_err!("detected read after EOF!")));
+            return Err(BlockReadError::Error(proxmox_lang::io_format_err!("detected read after EOF!")));
         }
         match self.sg_tape.read_block(buffer) {
             Ok(usize) => Ok(usize),
diff --git a/pbs-tape/src/tape_write.rs b/pbs-tape/src/tape_write.rs
index 321fb5d8..0d52e71d 100644
--- a/pbs-tape/src/tape_write.rs
+++ b/pbs-tape/src/tape_write.rs
@@ -34,7 +34,7 @@ pub trait TapeWrite {
         data: &[u8],
     ) -> Result<bool, std::io::Error> {
         if header.size as usize != data.len() {
-            proxmox_sys::io_bail!("write_header with wrong size - internal error");
+            proxmox_lang::io_bail!("write_header with wrong size - internal error");
         }
         let header = header.to_le();
 
diff --git a/proxmox-rest-server/src/rest.rs b/proxmox-rest-server/src/rest.rs
index 5194151c..3343d5d6 100644
--- a/proxmox-rest-server/src/rest.rs
+++ b/proxmox-rest-server/src/rest.rs
@@ -476,7 +476,7 @@ pub(crate) async fn handle_api_request<Env: RpcEnvironment, S: 'static + BuildHa
             resp.map(|body| {
                 Body::wrap_stream(DeflateEncoder::with_quality(
                     TryStreamExt::map_err(body, |err| {
-                        proxmox_sys::io_format_err!("error during compression: {}", err)
+                        proxmox_lang::io_format_err!("error during compression: {}", err)
                     }),
                     Level::Default,
                 ))
diff --git a/src/tape/drive/virtual_tape.rs b/src/tape/drive/virtual_tape.rs
index 186e87ac..21f91e2b 100644
--- a/src/tape/drive/virtual_tape.rs
+++ b/src/tape/drive/virtual_tape.rs
@@ -309,7 +309,7 @@ impl TapeDriver for VirtualTapeHandle {
                 Ok(Box::new(reader))
             }
             None => {
-                return Err(BlockReadError::Error(proxmox_sys::io_format_err!("drive is empty (no tape loaded).")));
+                return Err(BlockReadError::Error(proxmox_lang::io_format_err!("drive is empty (no tape loaded).")));
             }
         }
     }
@@ -362,7 +362,7 @@ impl TapeDriver for VirtualTapeHandle {
 
                 Ok(writer)
             }
-            None => proxmox_sys::io_bail!("drive is empty (no tape loaded)."),
+            None => proxmox_lang::io_bail!("drive is empty (no tape loaded)."),
         }
     }
 
diff --git a/src/tape/file_formats/catalog_archive.rs b/src/tape/file_formats/catalog_archive.rs
index 04a60319..4e8b8fdf 100644
--- a/src/tape/file_formats/catalog_archive.rs
+++ b/src/tape/file_formats/catalog_archive.rs
@@ -61,13 +61,13 @@ pub fn tape_write_catalog<'a>(
         while remaining != 0 {
             let got = file.read(&mut file_copy_buffer[..])?;
             if got as u64 > remaining {
-                proxmox_sys::io_bail!("catalog '{}' changed while reading", uuid);
+                proxmox_lang::io_bail!("catalog '{}' changed while reading", uuid);
             }
             writer.write_all(&file_copy_buffer[..got])?;
             remaining -= got as u64;
         }
         if remaining > 0 {
-            proxmox_sys::io_bail!("catalog '{}' shrunk while reading", uuid);
+            proxmox_lang::io_bail!("catalog '{}' shrunk while reading", uuid);
         }
         Ok(())
     });
diff --git a/src/tape/file_formats/chunk_archive.rs b/src/tape/file_formats/chunk_archive.rs
index 40479700..827dc347 100644
--- a/src/tape/file_formats/chunk_archive.rs
+++ b/src/tape/file_formats/chunk_archive.rs
@@ -69,7 +69,7 @@ impl <'a> ChunkArchiveWriter<'a> {
     fn write_all(&mut self, data: &[u8]) -> Result<bool, std::io::Error> {
         match self.writer {
             Some(ref mut writer) => writer.write_all(data),
-            None => proxmox_sys::io_bail!(
+            None => proxmox_lang::io_bail!(
                 "detected write after archive finished - internal error"),
         }
     }
diff --git a/src/tape/file_formats/multi_volume_reader.rs b/src/tape/file_formats/multi_volume_reader.rs
index cc0d52ab..fcc1d3c0 100644
--- a/src/tape/file_formats/multi_volume_reader.rs
+++ b/src/tape/file_formats/multi_volume_reader.rs
@@ -48,23 +48,23 @@ impl <'a> Read for MultiVolumeReader<'a> {
 
         if self.reader.is_none() {
             let mut reader = (self.next_reader_fn)()
-                .map_err(|err| proxmox_sys::io_format_err!("multi-volume next failed: {}", err))?;
+                .map_err(|err| proxmox_lang::io_format_err!("multi-volume next failed: {}", err))?;
 
             proxmox_lang::try_block!({
                 let part_header: MediaContentHeader = unsafe { reader.read_le_value()? };
                 self.reader = Some(reader);
 
                 if part_header.uuid != self.header.uuid {
-                    proxmox_sys::io_bail!("got wrong part uuid");
+                    proxmox_lang::io_bail!("got wrong part uuid");
                 }
                 if part_header.content_magic!= self.header.content_magic {
-                    proxmox_sys::io_bail!("got wrong part content magic");
+                    proxmox_lang::io_bail!("got wrong part content magic");
                 }
 
                 let expect_part_number = self.header.part_number + 1;
 
                 if part_header.part_number != expect_part_number {
-                    proxmox_sys::io_bail!("got wrong part number ({} != {})",
+                    proxmox_lang::io_bail!("got wrong part number ({} != {})",
                                       part_header.part_number, expect_part_number);
                 }
 
@@ -72,7 +72,7 @@ impl <'a> Read for MultiVolumeReader<'a> {
 
                 Ok(())
             }).map_err(|err| {
-                proxmox_sys::io_format_err!("multi-volume read content header failed: {}", err)
+                proxmox_lang::io_format_err!("multi-volume read content header failed: {}", err)
             })?;
          }
 
diff --git a/src/tape/file_formats/multi_volume_writer.rs b/src/tape/file_formats/multi_volume_writer.rs
index d1b2c70b..bca2a27f 100644
--- a/src/tape/file_formats/multi_volume_writer.rs
+++ b/src/tape/file_formats/multi_volume_writer.rs
@@ -53,16 +53,16 @@ impl <'a> TapeWrite for MultiVolumeWriter<'a> {
     fn write_all(&mut self, buf: &[u8]) -> Result<bool, std::io::Error> {
 
         if self.finished {
-            proxmox_sys::io_bail!("multi-volume writer already finished: internal error");
+            proxmox_lang::io_bail!("multi-volume writer already finished: internal error");
         }
 
         if self.got_leom {
             if !self.wrote_header {
-                proxmox_sys::io_bail!("multi-volume writer: got LEOM before writing anything - internal error");
+                proxmox_lang::io_bail!("multi-volume writer: got LEOM before writing anything - internal error");
             }
             let mut writer = match self.writer.take() {
                 Some(writer) => writer,
-                None =>  proxmox_sys::io_bail!("multi-volume writer: no writer  -internal error"),
+                None =>  proxmox_lang::io_bail!("multi-volume writer: no writer  -internal error"),
             };
             self.bytes_written = writer.bytes_written();
             writer.finish(true)?;
@@ -70,11 +70,11 @@ impl <'a> TapeWrite for MultiVolumeWriter<'a> {
 
         if self.writer.is_none() {
             if self.header.part_number == u8::MAX {
-                proxmox_sys::io_bail!("multi-volume writer: too many parts");
+                proxmox_lang::io_bail!("multi-volume writer: too many parts");
             }
             self.writer = Some(
                 (self.next_writer_fn)()
-                    .map_err(|err| proxmox_sys::io_format_err!("multi-volume get next volume failed: {}", err))?
+                    .map_err(|err| proxmox_lang::io_format_err!("multi-volume get next volume failed: {}", err))?
             );
             self.got_leom = false;
             self.wrote_header = false;
@@ -107,12 +107,12 @@ impl <'a> TapeWrite for MultiVolumeWriter<'a> {
 
     fn finish(&mut self, incomplete: bool) -> Result<bool, std::io::Error> {
         if incomplete {
-            proxmox_sys::io_bail!(
+            proxmox_lang::io_bail!(
                 "incomplete flag makes no sense for multi-volume stream: internal error");
         }
 
         match self.writer.take() {
-            None if self.finished => proxmox_sys::io_bail!(
+            None if self.finished => proxmox_lang::io_bail!(
                 "multi-volume writer already finished: internal error"),
             None => Ok(false),
             Some(ref mut writer) => {
diff --git a/src/tape/file_formats/snapshot_archive.rs b/src/tape/file_formats/snapshot_archive.rs
index d3bd590b..51ba6015 100644
--- a/src/tape/file_formats/snapshot_archive.rs
+++ b/src/tape/file_formats/snapshot_archive.rs
@@ -58,14 +58,14 @@ pub fn tape_write_snapshot_archive<'a>(
         for filename in file_list.iter() {
 
             let mut file = snapshot_reader.open_file(filename)
-                .map_err(|err| proxmox_sys::io_format_err!("open file '{}' failed - {}", filename, err))?;
+                .map_err(|err| proxmox_lang::io_format_err!("open file '{}' failed - {}", filename, err))?;
             let metadata = file.metadata()?;
             let file_size = metadata.len();
 
             let metadata: pxar::Metadata = metadata.into();
 
             if !metadata.is_regular_file() {
-                proxmox_sys::io_bail!("file '{}' is not a regular file", filename);
+                proxmox_lang::io_bail!("file '{}' is not a regular file", filename);
             }
 
             let mut remaining = file_size;
@@ -73,14 +73,14 @@ pub fn tape_write_snapshot_archive<'a>(
             while remaining != 0 {
                 let got = file.read(&mut file_copy_buffer[..])?;
                 if got as u64 > remaining {
-                    proxmox_sys::io_bail!("file '{}' changed while reading", filename);
+                    proxmox_lang::io_bail!("file '{}' changed while reading", filename);
                 }
                 out.write_all(&file_copy_buffer[..got])?;
                 remaining -= got as u64;
 
             }
             if remaining > 0 {
-                proxmox_sys::io_bail!("file '{}' shrunk while reading", filename);
+                proxmox_lang::io_bail!("file '{}' shrunk while reading", filename);
             }
         }
         encoder.finish()?;
diff --git a/src/tools/disks/mod.rs b/src/tools/disks/mod.rs
index 267de8d4..94da7b3a 100644
--- a/src/tools/disks/mod.rs
+++ b/src/tools/disks/mod.rs
@@ -15,9 +15,9 @@ use once_cell::sync::OnceCell;
 use ::serde::{Deserialize, Serialize};
 
 use proxmox_schema::api;
-use proxmox_sys::error::io_err_other;
+use proxmox_lang::error::io_err_other;
 use proxmox_sys::linux::procfs::{mountinfo::Device, MountInfo};
-use proxmox_sys::{io_bail, io_format_err};
+use proxmox_lang::{io_bail, io_format_err};
 
 use pbs_api_types::{StorageStatus, BLOCKDEVICE_NAME_REGEX};
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pbs-devel] applied: [PATCH proxmox v2 1/2] move io error helpers to proxmox-lang
  2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox v2 1/2] move io error helpers to proxmox-lang Dominik Csapak
@ 2022-02-21 12:48   ` Wolfgang Bumiller
  0 siblings, 0 replies; 8+ messages in thread
From: Wolfgang Bumiller @ 2022-02-21 12:48 UTC (permalink / raw)
  To: Dominik Csapak; +Cc: pbs-devel

applied this one, bumped lang to 1.1 and version dependencies to it
workspace-wide




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pbs-devel] applied: [PATCH proxmox v2 2/2] split out compression code into new crate 'proxmox-compression'
  2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox v2 2/2] split out compression code into new crate 'proxmox-compression' Dominik Csapak
@ 2022-02-21 13:21   ` Wolfgang Bumiller
  0 siblings, 0 replies; 8+ messages in thread
From: Wolfgang Bumiller @ 2022-02-21 13:21 UTC (permalink / raw)
  To: Dominik Csapak; +Cc: pbs-devel

applied and bumped async to 0.4.0




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pbs-devel] applied-series: [PATCH proxmox-backup v2 1/2] depend on new 'proxmox-compression' crate
  2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox-backup v2 1/2] depend on new 'proxmox-compression' crate Dominik Csapak
@ 2022-02-21 13:28   ` Wolfgang Bumiller
  0 siblings, 0 replies; 8+ messages in thread
From: Wolfgang Bumiller @ 2022-02-21 13:28 UTC (permalink / raw)
  To: Dominik Csapak; +Cc: pbs-devel

applied both patches and updated dependencies




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-02-21 13:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-21 10:39 [pbs-devel] [PATCH proxmox/proxmox-backup v2] improve proxmox-async dependencies Dominik Csapak
2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox v2 1/2] move io error helpers to proxmox-lang Dominik Csapak
2022-02-21 12:48   ` [pbs-devel] applied: " Wolfgang Bumiller
2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox v2 2/2] split out compression code into new crate 'proxmox-compression' Dominik Csapak
2022-02-21 13:21   ` [pbs-devel] applied: " Wolfgang Bumiller
2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox-backup v2 1/2] depend on new 'proxmox-compression' crate Dominik Csapak
2022-02-21 13:28   ` [pbs-devel] applied-series: " Wolfgang Bumiller
2022-02-21 10:39 ` [pbs-devel] [PATCH proxmox-backup v2 2/2] use io_format_err, io_bail, io_err_other from proxmox-lang Dominik Csapak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal