tape/changer: refactor marking of import/export slots from config
we did this for 'mtx', but missed it for the sg_pt_changer code refactor it into the MtxStatus strut, and call it from both code paths Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
committed by
Dietmar Maurer
parent
2da7aca8e8
commit
4be4736603
@ -31,6 +31,7 @@ use crate::{
|
||||
scsi_ascii_to_string,
|
||||
scsi_inquiry,
|
||||
},
|
||||
api2::types::ScsiTapeChanger,
|
||||
};
|
||||
|
||||
const SCSI_CHANGER_DEFAULT_TIMEOUT: usize = 60*5; // 5 minutes
|
||||
@ -397,6 +398,21 @@ pub fn read_element_status<F: AsRawFd>(file: &mut F) -> Result<MtxStatus, Error>
|
||||
Ok(status)
|
||||
}
|
||||
|
||||
/// Read status and map import-export slots from config
|
||||
pub fn status(config: &ScsiTapeChanger) -> Result<MtxStatus, Error> {
|
||||
let path = &config.path;
|
||||
|
||||
let mut file = open(path)
|
||||
.map_err(|err| format_err!("error opening '{}': {}", path, err))?;
|
||||
let mut status = read_element_status(&mut file)
|
||||
.map_err(|err| format_err!("error reading element status: {}", err))?;
|
||||
|
||||
status.mark_import_export_slots(&config)?;
|
||||
|
||||
Ok(status)
|
||||
}
|
||||
|
||||
|
||||
#[repr(C, packed)]
|
||||
#[derive(Endian)]
|
||||
struct ElementStatusHeader {
|
||||
|
Reference in New Issue
Block a user