From a78348acbbb2a45aa948c70d9706d9b6ce42eee6 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 14 Dec 2020 17:37:16 +0100 Subject: [PATCH] tape: rename DriveLabel to MediaLabel --- src/api2/tape/drive.rs | 8 ++++---- src/tape/drive/mod.rs | 16 ++++++++-------- src/tape/file_formats.rs | 10 +++++----- src/tape/inventory.rs | 12 ++++++------ src/tape/media_pool.rs | 4 ++-- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/api2/tape/drive.rs b/src/api2/tape/drive.rs index 39024d63..9aadcf99 100644 --- a/src/api2/tape/drive.rs +++ b/src/api2/tape/drive.rs @@ -50,7 +50,7 @@ use crate::{ media_changer, update_changer_online_status, file_formats::{ - DriveLabel, + MediaLabel, MediaSetLabel, }, }, @@ -356,7 +356,7 @@ pub fn label_media( } let ctime = proxmox::tools::time::epoch_i64(); - let label = DriveLabel { + let label = MediaLabel { changer_id: changer_id.to_string(), uuid: Uuid::generate(), ctime, @@ -372,7 +372,7 @@ pub fn label_media( fn write_media_label( worker: Arc, drive: &mut Box, - label: DriveLabel, + label: MediaLabel, pool: Option, ) -> Result<(), Error> { @@ -756,7 +756,7 @@ fn barcode_label_media_worker( } let ctime = proxmox::tools::time::epoch_i64(); - let label = DriveLabel { + let label = MediaLabel { changer_id: changer_id.to_string(), uuid: Uuid::generate(), ctime, diff --git a/src/tape/drive/mod.rs b/src/tape/drive/mod.rs index d1a633df..3573f4db 100644 --- a/src/tape/drive/mod.rs +++ b/src/tape/drive/mod.rs @@ -21,9 +21,9 @@ use crate::{ TapeWrite, TapeRead, file_formats::{ - PROXMOX_BACKUP_DRIVE_LABEL_MAGIC_1_0, + PROXMOX_BACKUP_MEDIA_LABEL_MAGIC_1_0, PROXMOX_BACKUP_MEDIA_SET_LABEL_MAGIC_1_0, - DriveLabel, + MediaLabel, MediaSetLabel, MediaContentHeader, }, @@ -36,7 +36,7 @@ use crate::{ #[derive(Serialize,Deserialize)] pub struct MediaLabelInfo { - pub label: DriveLabel, + pub label: MediaLabel, pub label_uuid: Uuid, #[serde(skip_serializing_if="Option::is_none")] pub media_set_label: Option<(MediaSetLabel, Uuid)> @@ -71,7 +71,7 @@ pub trait TapeDriver { /// Write label to tape (erase tape content) /// /// This returns the MediaContentHeader uuid (not the media uuid). - fn label_tape(&mut self, label: &DriveLabel) -> Result { + fn label_tape(&mut self, label: &MediaLabel) -> Result { self.rewind()?; @@ -79,7 +79,7 @@ pub trait TapeDriver { let raw = serde_json::to_string_pretty(&serde_json::to_value(&label)?)?; - let header = MediaContentHeader::new(PROXMOX_BACKUP_DRIVE_LABEL_MAGIC_1_0, raw.len() as u32); + let header = MediaContentHeader::new(PROXMOX_BACKUP_MEDIA_LABEL_MAGIC_1_0, raw.len() as u32); let content_uuid = header.content_uuid(); { @@ -112,10 +112,10 @@ pub trait TapeDriver { }; let header: MediaContentHeader = unsafe { reader.read_le_value()? }; - header.check(PROXMOX_BACKUP_DRIVE_LABEL_MAGIC_1_0, 1, 64*1024)?; + header.check(PROXMOX_BACKUP_MEDIA_LABEL_MAGIC_1_0, 1, 64*1024)?; let data = reader.read_exact_allocated(header.size as usize)?; - let label: DriveLabel = serde_json::from_slice(&data) + let label: MediaLabel = serde_json::from_slice(&data) .map_err(|err| format_err!("unable to parse drive label - {}", err))?; // make sure we read the EOF marker @@ -235,7 +235,7 @@ pub fn open_drive( pub fn request_and_load_media( config: &SectionConfigData, drive: &str, - label: &DriveLabel, + label: &MediaLabel, ) -> Result<( Box, MediaLabelInfo, diff --git a/src/tape/file_formats.rs b/src/tape/file_formats.rs index 8b0486c8..5924833d 100644 --- a/src/tape/file_formats.rs +++ b/src/tape/file_formats.rs @@ -16,7 +16,7 @@ pub const PROXMOX_TAPE_BLOCK_HEADER_MAGIC_1_0: [u8; 8] = [220, 189, 175, 202, 23 // openssl::sha::sha256(b"Proxmox Backup Content Header v1.0")[0..8]; pub const PROXMOX_BACKUP_CONTENT_HEADER_MAGIC_1_0: [u8; 8] = [99, 238, 20, 159, 205, 242, 155, 12]; // openssl::sha::sha256(b"Proxmox Backup Tape Label v1.0")[0..8]; -pub const PROXMOX_BACKUP_DRIVE_LABEL_MAGIC_1_0: [u8; 8] = [42, 5, 191, 60, 176, 48, 170, 57]; +pub const PROXMOX_BACKUP_MEDIA_LABEL_MAGIC_1_0: [u8; 8] = [42, 5, 191, 60, 176, 48, 170, 57]; // openssl::sha::sha256(b"Proxmox Backup MediaSet Label v1.0") pub const PROXMOX_BACKUP_MEDIA_SET_LABEL_MAGIC_1_0: [u8; 8] = [8, 96, 99, 249, 47, 151, 83, 216]; @@ -32,7 +32,7 @@ lazy_static::lazy_static!{ /// Map content Uuid to human readable names. pub static ref PROXMOX_BACKUP_CONTENT_NAME: HashMap<&'static [u8;8], &'static str> = { let mut map = HashMap::new(); - map.insert(&PROXMOX_BACKUP_DRIVE_LABEL_MAGIC_1_0, "Proxmox Backup Tape Label v1.0"); + 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"); map.insert(&PROXMOX_BACKUP_CHUNK_ARCHIVE_MAGIC_1_0, "Proxmox Backup Chunk Archive v1.0"); map.insert(&PROXMOX_BACKUP_SNAPSHOT_ARCHIVE_MAGIC_1_0, "Proxmox Backup Snapshot Archive v1.0"); @@ -152,11 +152,11 @@ pub struct ChunkArchiveEntryHeader { } #[derive(Serialize,Deserialize,Clone,Debug)] -/// Drive Label +/// Media Label /// -/// Drive Labels are used to uniquely identify a media. They are +/// Media labels are used to uniquely identify a media. They are /// stored as first file on the tape. -pub struct DriveLabel { +pub struct MediaLabel { /// Unique ID pub uuid: Uuid, /// Media Changer ID or Barcode diff --git a/src/tape/inventory.rs b/src/tape/inventory.rs index 1bb9377e..cb6387a9 100644 --- a/src/tape/inventory.rs +++ b/src/tape/inventory.rs @@ -2,7 +2,7 @@ //! //! The Inventory persistently stores the list of known backup //! media. A backup media is identified by its 'MediaId', which is the -//! DriveLabel/MediaSetLabel combination. +//! MediaLabel/MediaSetLabel combination. use std::collections::{HashMap, BTreeMap}; use std::path::{Path, PathBuf}; @@ -31,7 +31,7 @@ use crate::{ TAPE_STATUS_DIR, MediaLabelInfo, file_formats::{ - DriveLabel, + MediaLabel, MediaSetLabel, }, }, @@ -42,7 +42,7 @@ use crate::{ /// This combines the label and media set label. #[derive(Debug,Serialize,Deserialize,Clone)] pub struct MediaId { - pub label: DriveLabel, + pub label: MediaLabel, #[serde(skip_serializing_if="Option::is_none")] pub media_set_label: Option, } @@ -559,7 +559,7 @@ impl Inventory { /// Genreate and insert a new free tape (test helper) pub fn generate_free_tape(&mut self, changer_id: &str, ctime: i64) -> Uuid { - let label = DriveLabel { + let label = MediaLabel { changer_id: changer_id.to_string(), uuid: Uuid::generate(), ctime, @@ -580,7 +580,7 @@ impl Inventory { ctime: i64, ) -> Uuid { - let label = DriveLabel { + let label = MediaLabel { changer_id: changer_id.to_string(), uuid: Uuid::generate(), ctime, @@ -602,7 +602,7 @@ impl Inventory { set: MediaSetLabel, ctime: i64, ) -> Uuid { - let label = DriveLabel { + let label = MediaLabel { changer_id: changer_id.to_string(), uuid: Uuid::generate(), ctime, diff --git a/src/tape/media_pool.rs b/src/tape/media_pool.rs index 60d55278..181eba41 100644 --- a/src/tape/media_pool.rs +++ b/src/tape/media_pool.rs @@ -28,7 +28,7 @@ use crate::{ Inventory, MediaStateDatabase, file_formats::{ - DriveLabel, + MediaLabel, MediaSetLabel, }, } @@ -467,7 +467,7 @@ impl BackupMedia { } /// Returns the drive label - pub fn label(&self) -> &DriveLabel { + pub fn label(&self) -> &MediaLabel { &self.id.label }