update to proxmox-sys 0.2 crate
- imported pbs-api-types/src/common_regex.rs from old proxmox crate - use hex crate to generate/parse hex digest - remove all reference to proxmox crate (use proxmox-sys and proxmox-serde instead) Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
@ -11,6 +11,7 @@ libc = "0.2"
|
||||
anyhow = "1.0"
|
||||
thiserror = "1.0"
|
||||
endian_trait = { version = "0.6", features = ["arrays"] }
|
||||
hex = "0.4.3"
|
||||
nix = "0.19.1"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
@ -18,7 +19,6 @@ bitflags = "1.2.1"
|
||||
regex = "1.2"
|
||||
udev = "0.4"
|
||||
|
||||
proxmox = "0.15.3"
|
||||
proxmox-io = "1"
|
||||
proxmox-lang = "1"
|
||||
# api-macro is only used by the binaries, so maybe we should split them out
|
||||
@ -28,6 +28,7 @@ proxmox-uuid = "1"
|
||||
|
||||
# router::cli is only used by binaries, so maybe we should split them out
|
||||
proxmox-router = "1.1"
|
||||
proxmox-sys = "0.2"
|
||||
|
||||
pbs-api-types = { path = "../pbs-api-types" }
|
||||
pbs-tools = { path = "../pbs-tools" }
|
||||
|
@ -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::io_bail!("detected tape block with wrong magic number - not written by proxmox tape");
|
||||
proxmox_sys::io_bail!("detected tape block with wrong magic number - not written by proxmox tape");
|
||||
}
|
||||
|
||||
if seq_nr != buffer.seq_nr() {
|
||||
proxmox::io_bail!(
|
||||
proxmox_sys::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::io_bail!("detected tape block with wrong payload size ({} > {}", size, buffer.payload.len());
|
||||
proxmox_sys::io_bail!("detected tape block with wrong payload size ({} > {}", size, buffer.payload.len());
|
||||
} else if size == 0 && !found_end_marker {
|
||||
proxmox::io_bail!("detected tape block with zero payload size");
|
||||
proxmox_sys::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::io_format_err!("got wrong block size").into());
|
||||
return Err(proxmox_sys::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::io_bail!("detected tape block after block-stream end marker");
|
||||
proxmox_sys::io_bail!("detected tape block after block-stream end marker");
|
||||
}
|
||||
Err(BlockReadError::EndOfFile) => {
|
||||
return Ok(());
|
||||
}
|
||||
Err(BlockReadError::EndOfStream) => {
|
||||
proxmox::io_bail!("got unexpected end of tape");
|
||||
proxmox_sys::io_bail!("got unexpected end of tape");
|
||||
}
|
||||
Err(BlockReadError::Error(err)) => {
|
||||
return 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::io_bail!("detected tape stream without end marker");
|
||||
proxmox_sys::io_bail!("detected tape stream without end marker");
|
||||
}
|
||||
return Ok(0); // EOD
|
||||
}
|
||||
Err(BlockReadError::EndOfStream) => {
|
||||
proxmox::io_bail!("got unexpected end of tape");
|
||||
proxmox_sys::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::io_bail!("is_incomplete failed: EOD not reached");
|
||||
proxmox_sys::io_bail!("is_incomplete failed: EOD not reached");
|
||||
}
|
||||
if !self.found_end_marker {
|
||||
proxmox::io_bail!("is_incomplete failed: no end marker found");
|
||||
proxmox_sys::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::io_bail!("has_end_marker failed: EOD not reached");
|
||||
proxmox_sys::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::io_bail!("detected read after error - internal error");
|
||||
proxmox_sys::io_bail!("detected read after error - internal error");
|
||||
}
|
||||
|
||||
let mut buffer_size = self.buffer.size();
|
||||
@ -299,7 +299,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn large_data() -> Result<(), Error> {
|
||||
let data = proxmox::sys::linux::random_data(1024*1024*5)?;
|
||||
let data = proxmox_sys::linux::random_data(1024*1024*5)?;
|
||||
write_and_verify(&data)
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ mod test {
|
||||
let writer = EmulateTapeWriter::new(&mut tape_data, 1024*1024);
|
||||
let mut writer = BlockedWriter::new(writer);
|
||||
// write at least one block
|
||||
let data = proxmox::sys::linux::random_data(PROXMOX_TAPE_BLOCK_SIZE)?;
|
||||
let data = proxmox_sys::linux::random_data(PROXMOX_TAPE_BLOCK_SIZE)?;
|
||||
writer.write_all(&data)?;
|
||||
// but do not call finish here
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ impl <W: BlockWrite> BlockedWriter<W> {
|
||||
|
||||
fn write_eof(&mut self) -> Result<(), std::io::Error> {
|
||||
if self.wrote_eof {
|
||||
proxmox::io_bail!("BlockedWriter: detected multiple EOF writes");
|
||||
proxmox_sys::io_bail!("BlockedWriter: detected multiple EOF writes");
|
||||
}
|
||||
self.wrote_eof = true;
|
||||
|
||||
|
@ -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::io_format_err!("detected read after EOF!")));
|
||||
return Err(BlockReadError::Error(proxmox_sys::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::io_format_err!(
|
||||
proxmox_sys::io_format_err!(
|
||||
"EmulateTapeReader: read_block with wrong block size ({} != {})",
|
||||
buffer.len(),
|
||||
PROXMOX_TAPE_BLOCK_SIZE,
|
||||
|
@ -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::io_bail!("EmulateTapeWriter: got write with wrong block size ({} != {}",
|
||||
proxmox_sys::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::io_bail!("EmulateTapeWriter: detected multiple EOF writes");
|
||||
proxmox_sys::io_bail!("EmulateTapeWriter: detected multiple EOF writes");
|
||||
}
|
||||
// do nothing, just record the call
|
||||
self.wrote_eof = true;
|
||||
|
@ -7,9 +7,9 @@ use std::os::unix::io::AsRawFd;
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use nix::fcntl::{fcntl, FcntlArg, OFlag};
|
||||
|
||||
use proxmox::sys::error::SysResult;
|
||||
use proxmox_sys::error::SysResult;
|
||||
use proxmox_sys::fs::scan_subdir;
|
||||
|
||||
use pbs_tools::fs::scan_subdir;
|
||||
use pbs_api_types::{DeviceKind, OptionalDeviceIdentification, TapeDeviceInfo};
|
||||
|
||||
lazy_static::lazy_static!{
|
||||
|
@ -25,7 +25,7 @@ pub use mam::*;
|
||||
mod report_density;
|
||||
pub use report_density::*;
|
||||
|
||||
use proxmox::sys::error::SysResult;
|
||||
use proxmox_sys::error::SysResult;
|
||||
use proxmox_io::{ReadExt, WriteExt};
|
||||
|
||||
use pbs_api_types::{MamAttribute, Lp17VolumeStatistics, LtoDriveAndMediaStatus};
|
||||
@ -530,11 +530,11 @@ impl SgTape {
|
||||
) -> Result<(), std::io::Error> {
|
||||
|
||||
if count > 255 {
|
||||
proxmox::io_bail!("write_filemarks failed: got strange count '{}'", count);
|
||||
proxmox_sys::io_bail!("write_filemarks failed: got strange count '{}'", count);
|
||||
}
|
||||
|
||||
let mut sg_raw = SgRaw::new(&mut self.file, 16)
|
||||
.map_err(|err| proxmox::io_format_err!("write_filemarks failed (alloc) - {}", err))?;
|
||||
.map_err(|err| proxmox_sys::io_format_err!("write_filemarks failed (alloc) - {}", err))?;
|
||||
|
||||
sg_raw.set_timeout(Self::SCSI_TAPE_DEFAULT_TIMEOUT);
|
||||
let mut cmd = Vec::new();
|
||||
@ -553,7 +553,7 @@ impl SgTape {
|
||||
/* LEOM - ignore */
|
||||
}
|
||||
Err(err) => {
|
||||
proxmox::io_bail!("write filemark failed - {}", err);
|
||||
proxmox_sys::io_bail!("write filemark failed - {}", err);
|
||||
}
|
||||
}
|
||||
|
||||
@ -632,7 +632,7 @@ impl SgTape {
|
||||
let transfer_len = data.len();
|
||||
|
||||
if transfer_len > 0x800000 {
|
||||
proxmox::io_bail!("write failed - data too large");
|
||||
proxmox_sys::io_bail!("write failed - data too large");
|
||||
}
|
||||
|
||||
let mut sg_raw = SgRaw::new(&mut self.file, 0)
|
||||
@ -656,7 +656,7 @@ impl SgTape {
|
||||
return Ok(true); // LEOM
|
||||
}
|
||||
Err(err) => {
|
||||
proxmox::io_bail!("write failed - {}", err);
|
||||
proxmox_sys::io_bail!("write failed - {}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -666,7 +666,7 @@ impl SgTape {
|
||||
|
||||
if transfer_len > 0xFFFFFF {
|
||||
return Err(BlockReadError::Error(
|
||||
proxmox::io_format_err!("read failed - buffer too large")
|
||||
proxmox_sys::io_format_err!("read failed - buffer too large")
|
||||
));
|
||||
}
|
||||
|
||||
@ -693,14 +693,14 @@ impl SgTape {
|
||||
}
|
||||
Err(err) => {
|
||||
return Err(BlockReadError::Error(
|
||||
proxmox::io_format_err!("read failed - {}", err)
|
||||
proxmox_sys::io_format_err!("read failed - {}", err)
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
if data.len() != transfer_len {
|
||||
return Err(BlockReadError::Error(
|
||||
proxmox::io_format_err!("read failed - unexpected block len ({} != {})", data.len(), buffer.len())
|
||||
proxmox_sys::io_format_err!("read failed - unexpected block len ({} != {})", data.len(), buffer.len())
|
||||
));
|
||||
}
|
||||
|
||||
@ -951,7 +951,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::io_format_err!("detected read after EOF!")));
|
||||
return Err(BlockReadError::Error(proxmox_sys::io_format_err!("detected read after EOF!")));
|
||||
}
|
||||
match self.sg_tape.read_block(buffer) {
|
||||
Ok(usize) => Ok(usize),
|
||||
|
@ -175,7 +175,7 @@ fn decode_mam_attributes(data: &[u8]) -> Result<Vec<MamAttribute>, Error> {
|
||||
unreachable!();
|
||||
}
|
||||
},
|
||||
MamFormat::BINARY => proxmox::tools::digest_to_hex(&data),
|
||||
MamFormat::BINARY => hex::encode(&data),
|
||||
};
|
||||
list.push(MamAttribute {
|
||||
id: head_id,
|
||||
|
@ -34,7 +34,7 @@ pub trait TapeWrite {
|
||||
data: &[u8],
|
||||
) -> Result<bool, std::io::Error> {
|
||||
if header.size as usize != data.len() {
|
||||
proxmox::io_bail!("write_header with wrong size - internal error");
|
||||
proxmox_sys::io_bail!("write_header with wrong size - internal error");
|
||||
}
|
||||
let header = header.to_le();
|
||||
|
||||
|
Reference in New Issue
Block a user