]> git.proxmox.com Git - proxmox-backup.git/blobdiff - src/bin/sg-tape-cmd.rs
Set MMAP_THRESHOLD to a fixed value (128K)
[proxmox-backup.git] / src / bin / sg-tape-cmd.rs
index 521cbdf3a5c6354dc6462f6ad185637e0053975d..7edfe5c57644e8e652dfcd3c6b8182a82d61c169 100644 (file)
@@ -9,32 +9,23 @@ use std::os::unix::io::{AsRawFd, FromRawFd};
 use anyhow::{bail, Error};
 use serde_json::Value;
 
-use proxmox::{
-    api::{
-        api,
-        cli::*,
-        RpcEnvironment,
-    },
-    tools::Uuid,
+use proxmox_router::{cli::*, RpcEnvironment};
+use proxmox_schema::api;
+use proxmox_uuid::Uuid;
+
+use pbs_api_types::{
+    Fingerprint, LTO_DRIVE_PATH_SCHEMA, DRIVE_NAME_SCHEMA, TAPE_ENCRYPTION_KEY_FINGERPRINT_SCHEMA,
+    MEDIA_SET_UUID_SCHEMA, LtoTapeDrive,
 };
 
-use pbs_api_types::Fingerprint;
+use pbs_tape::linux_list_drives::{open_lto_tape_device, check_tape_is_lto_tape_device};
 
 use proxmox_backup::{
-    config,
-    api2::types::{
-        LTO_DRIVE_PATH_SCHEMA,
-        DRIVE_NAME_SCHEMA,
-        TAPE_ENCRYPTION_KEY_FINGERPRINT_SCHEMA,
-        MEDIA_SET_UUID_SCHEMA,
-        LtoTapeDrive,
-    },
     tape::{
         drive::{
             TapeDriver,
             LtoTapeHandle,
-            open_lto_tape_device,
-            check_tape_is_lto_tape_device,
+            open_lto_tape_drive,
         },
     },
 };
@@ -42,13 +33,13 @@ use proxmox_backup::{
 fn get_tape_handle(param: &Value) -> Result<LtoTapeHandle, Error> {
 
     let handle = if let Some(name) = param["drive"].as_str() {
-        let (config, _digest) = config::drive::config()?;
-        let drive: LtoTapeDrive = config.lookup("lto", &name)?;
+        let (config, _digest) = pbs_config::drive::config()?;
+        let drive: LtoTapeDrive = config.lookup("lto", name)?;
         eprintln!("using device {}", drive.path);
-        drive.open()?
+        open_lto_tape_drive(&drive)?
     } else if let Some(device) = param["device"].as_str() {
         eprintln!("using device {}", device);
-        LtoTapeHandle::new(open_lto_tape_device(&device)?)?
+        LtoTapeHandle::new(open_lto_tape_device(device)?)?
     } else if let Some(true) = param["stdin"].as_bool() {
         eprintln!("using stdin");
         let fd = std::io::stdin().as_raw_fd();
@@ -56,12 +47,12 @@ fn get_tape_handle(param: &Value) -> Result<LtoTapeHandle, Error> {
         check_tape_is_lto_tape_device(&file)?;
         LtoTapeHandle::new(file)?
     } else if let Ok(name) = std::env::var("PROXMOX_TAPE_DRIVE") {
-        let (config, _digest) = config::drive::config()?;
+        let (config, _digest) = pbs_config::drive::config()?;
         let drive: LtoTapeDrive = config.lookup("lto", &name)?;
         eprintln!("using device {}", drive.path);
-        drive.open()?
+        open_lto_tape_drive(&drive)?
     } else {
-        let (config, _digest) = config::drive::config()?;
+        let (config, _digest) = pbs_config::drive::config()?;
 
         let mut drive_names = Vec::new();
         for (name, (section_type, _)) in config.sections.iter() {
@@ -71,9 +62,9 @@ fn get_tape_handle(param: &Value) -> Result<LtoTapeHandle, Error> {
 
         if drive_names.len() == 1 {
             let name = drive_names[0];
-            let drive: LtoTapeDrive = config.lookup("lto", &name)?;
+            let drive: LtoTapeDrive = config.lookup("lto", name)?;
             eprintln!("using device {}", drive.path);
-            drive.open()?
+            open_lto_tape_drive(&drive)?
         } else {
             bail!("no drive/device specified");
         }
@@ -116,7 +107,7 @@ fn set_encryption(
     param: Value,
 ) -> Result<(), Error> {
 
-    let result = proxmox::try_block!({
+    let result = proxmox_lang::try_block!({
         let mut handle = get_tape_handle(&param)?;
 
         match (fingerprint, uuid) {