From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v3 2/2] tape: changer: improve error message on wrong counts
Date: Thu, 22 Jul 2021 11:05:23 +0200 [thread overview]
Message-ID: <20210722090523.1999546-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210722090523.1999546-1-d.csapak@proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/tape/changer/sg_pt_changer.rs | 37 ++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 8 deletions(-)
diff --git a/src/tape/changer/sg_pt_changer.rs b/src/tape/changer/sg_pt_changer.rs
index ddbb5d74..6abaac99 100644
--- a/src/tape/changer/sg_pt_changer.rs
+++ b/src/tape/changer/sg_pt_changer.rs
@@ -421,17 +421,38 @@ pub fn read_element_status<F: AsRawFd>(file: &mut F) -> Result<MtxStatus, Error>
let page = get_element(&inquiry, &mut sg_raw, ElementType::MediumTransport, allocation_len, false)?;
transports.extend(page.transports);
- if (setup.transport_element_count as usize) != transports.len() {
- bail!("got wrong number of transport elements");
+ let transport_count = setup.transport_element_count as usize;
+ let storage_count = setup.storage_element_count as usize;
+ let import_export_count = setup.import_export_element_count as usize;
+ let transfer_count = setup.transfer_element_count as usize;
+
+ if transport_count != transports.len() {
+ bail!(
+ "got wrong number of transport elements: expoected {}, got{}",
+ transport_count,
+ transports.len()
+ );
}
- if (setup.storage_element_count as usize) != storage_slots.len() {
- bail!("got wrong number of storage elements");
+ if storage_count != storage_slots.len() {
+ bail!(
+ "got wrong number of storage elements: expected {}, got {}",
+ storage_count,
+ storage_slots.len(),
+ );
}
- if (setup.import_export_element_count as usize) != import_export_slots.len() {
- bail!("got wrong number of import/export elements");
+ if import_export_count != import_export_slots.len() {
+ bail!(
+ "got wrong number of import/export elements: expected {}, got {}",
+ import_export_count,
+ import_export_slots.len(),
+ );
}
- if (setup.transfer_element_count as usize) != drives.len() {
- bail!("got wrong number of transfer elements");
+ if transfer_count != drives.len() {
+ bail!(
+ "got wrong number of transfer elements: expected {}, got {}",
+ transfer_count,
+ drives.len(),
+ );
}
// create same virtual slot order as mtx(1)
--
2.30.2
prev parent reply other threads:[~2021-07-22 9:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-22 9:05 [pbs-devel] [PATCH proxmox-backup v3 1/2] tape: changer: correctly consume data in decode_element_status_page Dominik Csapak
2021-07-22 9:05 ` Dominik Csapak [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210722090523.1999546-2-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox