tape: cleanup - move tape file readers/writers into src/tape/file_formats folder
This commit is contained in:
parent
a80d72f999
commit
f47e035721
@ -57,7 +57,6 @@ use crate::{
|
||||
TapeRead,
|
||||
MediaId,
|
||||
MediaCatalog,
|
||||
ChunkArchiveDecoder,
|
||||
MediaPool,
|
||||
Inventory,
|
||||
file_formats::{
|
||||
@ -67,6 +66,7 @@ use crate::{
|
||||
PROXMOX_BACKUP_CONTENT_HEADER_MAGIC_1_0,
|
||||
PROXMOX_BACKUP_CHUNK_ARCHIVE_MAGIC_1_0,
|
||||
MediaContentHeader,
|
||||
ChunkArchiveDecoder,
|
||||
},
|
||||
drive::{
|
||||
TapeDriver,
|
||||
|
@ -45,8 +45,8 @@ use proxmox_backup::{
|
||||
complete_media_set_uuid,
|
||||
file_formats::{
|
||||
PROXMOX_BACKUP_CONTENT_HEADER_MAGIC_1_0,
|
||||
PROXMOX_BACKUP_CONTENT_NAME,
|
||||
MediaContentHeader,
|
||||
proxmox_tape_magic_to_text,
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -565,7 +565,7 @@ fn debug_scan(param: Value) -> Result<(), Error> {
|
||||
Ok(header) => {
|
||||
if header.magic != PROXMOX_BACKUP_CONTENT_HEADER_MAGIC_1_0 {
|
||||
println!("got MediaContentHeader with wrong magic: {:?}", header.magic);
|
||||
} else if let Some(name) = PROXMOX_BACKUP_CONTENT_NAME.get(&header.content_magic) {
|
||||
} else if let Some(name) = proxmox_tape_magic_to_text(&header.content_magic) {
|
||||
println!("got content header: {}", name);
|
||||
println!(" uuid: {}", header.content_uuid());
|
||||
println!(" ctime: {}", strftime_local("%c", header.ctime)?);
|
||||
|
@ -40,15 +40,13 @@ use crate::{
|
||||
},
|
||||
file_formats::{
|
||||
PROXMOX_TAPE_BLOCK_SIZE,
|
||||
PROXMOX_BACKUP_MEDIA_SET_LABEL_MAGIC_1_0,
|
||||
MediaSetLabel,
|
||||
MediaContentHeader,
|
||||
PROXMOX_BACKUP_MEDIA_SET_LABEL_MAGIC_1_0,
|
||||
},
|
||||
helpers::{
|
||||
BlockedReader,
|
||||
BlockedWriter,
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
fn run_sg_tape_cmd(subcmd: &str, args: &[&str], fd: RawFd) -> Result<String, Error> {
|
||||
|
@ -30,12 +30,12 @@ use crate::{
|
||||
MediaSetLabel,
|
||||
MediaContentHeader,
|
||||
PROXMOX_BACKUP_MEDIA_SET_LABEL_MAGIC_1_0,
|
||||
BlockedReader,
|
||||
BlockedWriter,
|
||||
},
|
||||
helpers::{
|
||||
EmulateTapeReader,
|
||||
EmulateTapeWriter,
|
||||
BlockedReader,
|
||||
BlockedWriter,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -1,4 +1,17 @@
|
||||
//! File format definitions for data written to tapes
|
||||
//! File format definitions and implementations for data written to
|
||||
//! tapes
|
||||
|
||||
mod blocked_reader;
|
||||
pub use blocked_reader::*;
|
||||
|
||||
mod blocked_writer;
|
||||
pub use blocked_writer::*;
|
||||
|
||||
mod chunk_archive;
|
||||
pub use chunk_archive::*;
|
||||
|
||||
mod snapshot_archive;
|
||||
pub use snapshot_archive::*;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
@ -33,8 +46,8 @@ pub const PROXMOX_BACKUP_CHUNK_ARCHIVE_ENTRY_MAGIC_1_0: [u8; 8] = [72, 87, 109,
|
||||
pub const PROXMOX_BACKUP_SNAPSHOT_ARCHIVE_MAGIC_1_0: [u8; 8] = [9, 182, 2, 31, 125, 232, 114, 133];
|
||||
|
||||
lazy_static::lazy_static!{
|
||||
/// Map content Uuid to human readable names.
|
||||
pub static ref PROXMOX_BACKUP_CONTENT_NAME: HashMap<&'static [u8;8], &'static str> = {
|
||||
// Map content magic numbers to human readable names.
|
||||
static ref PROXMOX_TAPE_CONTENT_NAME: HashMap<&'static [u8;8], &'static str> = {
|
||||
let mut map = HashMap::new();
|
||||
map.insert(&PROXMOX_BACKUP_MEDIA_LABEL_MAGIC_1_0, "Proxmox Backup Tape Label v1.0");
|
||||
map.insert(&PROXMOX_BACKUP_MEDIA_SET_LABEL_MAGIC_1_0, "Proxmox Backup MediaSet Label v1.0");
|
||||
@ -44,6 +57,11 @@ lazy_static::lazy_static!{
|
||||
};
|
||||
}
|
||||
|
||||
/// Map content magic numbers to human readable names.
|
||||
pub fn proxmox_tape_magic_to_text(magic: &[u8; 8]) -> Option<String> {
|
||||
PROXMOX_TAPE_CONTENT_NAME.get(magic).map(|s| String::from(*s))
|
||||
}
|
||||
|
||||
/// Tape Block Header with data payload
|
||||
///
|
||||
/// All tape files are written as sequence of blocks.
|
@ -4,11 +4,5 @@ pub use emulate_tape_writer::*;
|
||||
mod emulate_tape_reader;
|
||||
pub use emulate_tape_reader::*;
|
||||
|
||||
mod blocked_reader;
|
||||
pub use blocked_reader::*;
|
||||
|
||||
mod blocked_writer;
|
||||
pub use blocked_writer::*;
|
||||
|
||||
mod snapshot_reader;
|
||||
pub use snapshot_reader::*;
|
||||
|
@ -40,12 +40,6 @@ pub use media_pool::*;
|
||||
mod media_catalog;
|
||||
pub use media_catalog::*;
|
||||
|
||||
mod chunk_archive;
|
||||
pub use chunk_archive::*;
|
||||
|
||||
mod snapshot_archive;
|
||||
pub use snapshot_archive::*;
|
||||
|
||||
mod pool_writer;
|
||||
pub use pool_writer::*;
|
||||
|
||||
|
@ -16,15 +16,17 @@ use crate::{
|
||||
MAX_CHUNK_ARCHIVE_SIZE,
|
||||
COMMIT_BLOCK_SIZE,
|
||||
TapeWrite,
|
||||
ChunkArchiveWriter,
|
||||
SnapshotReader,
|
||||
SnapshotChunkIterator,
|
||||
MediaPool,
|
||||
MediaId,
|
||||
MediaCatalog,
|
||||
MediaSetCatalog,
|
||||
tape_write_snapshot_archive,
|
||||
file_formats::MediaSetLabel,
|
||||
file_formats::{
|
||||
MediaSetLabel,
|
||||
ChunkArchiveWriter,
|
||||
tape_write_snapshot_archive,
|
||||
},
|
||||
drive::{
|
||||
TapeDriver,
|
||||
request_and_load_media,
|
||||
|
Loading…
Reference in New Issue
Block a user