]> git.proxmox.com Git - proxmox-backup.git/blobdiff - src/tape/mod.rs
split out pbs-buildcfg module
[proxmox-backup.git] / src / tape / mod.rs
index 485ffc66d807b8655e94d34627d034781bfa46fa..5248d21b4676fbb5c03c017e07ce6c21d03f5532 100644 (file)
@@ -7,7 +7,10 @@ use proxmox::tools::fs::{
     CreateOptions,
 };
 
-pub mod sgutils2;
+use pbs_buildcfg::PROXMOX_BACKUP_RUN_DIR_M;
+
+#[cfg(test)]
+mod test;
 
 pub mod file_formats;
 
@@ -20,17 +23,18 @@ pub use tape_read::*;
 mod helpers;
 pub use helpers::*;
 
+mod media_set;
+pub use media_set::*;
+
 mod inventory;
 pub use inventory::*;
 
-mod changer;
-pub use changer::*;
+mod linux_list_drives;
+pub use linux_list_drives::*;
 
-mod drive;
-pub use drive::*;
+pub mod changer;
 
-mod online_status_map;
-pub use online_status_map::*;
+pub mod drive;
 
 mod media_pool;
 pub use media_pool::*;
@@ -38,18 +42,18 @@ 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::*;
 
 /// Directory path where we store all tape status information
 pub const TAPE_STATUS_DIR: &str = "/var/lib/proxmox-backup/tape";
 
+/// Directory path where we store temporary drive state
+pub const DRIVE_STATE_DIR: &str = concat!(PROXMOX_BACKUP_RUN_DIR_M!(), "/drive-state");
+
+/// Directory path where we store cached changer state
+pub const CHANGER_STATE_DIR: &str = concat!(PROXMOX_BACKUP_RUN_DIR_M!(), "/changer-state");
+
 /// We limit chunk archive size, so that we can faster restore a
 /// specific chunk (The catalog only store file numbers, so we
 /// need to read the whole archive to restore a single chunk)
@@ -62,14 +66,44 @@ pub const COMMIT_BLOCK_SIZE: usize = 128*1024*1024*1024; // 128 GiB
 /// Create tape status dir with correct permission
 pub fn create_tape_status_dir() -> Result<(), Error> {
     let backup_user = crate::backup::backup_user()?;
-    let mode = nix::sys::stat::Mode::from_bits_truncate(0o0640);
-    let opts = CreateOptions::new()
+    let mode = nix::sys::stat::Mode::from_bits_truncate(0o0750);
+    let options = CreateOptions::new()
         .perm(mode)
         .owner(backup_user.uid)
         .group(backup_user.gid);
 
-    create_path(TAPE_STATUS_DIR, None, Some(opts))
+    create_path(TAPE_STATUS_DIR, None, Some(options))
         .map_err(|err: Error| format_err!("unable to create tape status dir - {}", err))?;
 
     Ok(())
 }
+
+/// Create drive state dir with correct permission
+pub fn create_drive_state_dir() -> Result<(), Error> {
+    let backup_user = crate::backup::backup_user()?;
+    let mode = nix::sys::stat::Mode::from_bits_truncate(0o0750);
+    let options = CreateOptions::new()
+        .perm(mode)
+        .owner(backup_user.uid)
+        .group(backup_user.gid);
+
+    create_path(DRIVE_STATE_DIR, None, Some(options))
+        .map_err(|err: Error| format_err!("unable to create drive state dir - {}", err))?;
+
+    Ok(())
+}
+
+/// Create changer state cache dir with correct permission
+pub fn create_changer_state_dir() -> Result<(), Error> {
+    let backup_user = crate::backup::backup_user()?;
+    let mode = nix::sys::stat::Mode::from_bits_truncate(0o0750);
+    let options = CreateOptions::new()
+        .perm(mode)
+        .owner(backup_user.uid)
+        .group(backup_user.gid);
+
+    create_path(CHANGER_STATE_DIR, None, Some(options))
+        .map_err(|err: Error| format_err!("unable to create changer state dir - {}", err))?;
+
+    Ok(())
+}