From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 3/4] fetch-answer: partition: also search for exact-matching partition label
Date: Fri, 18 Oct 2024 13:59:39 +0200 [thread overview]
Message-ID: <20241018115943.813243-4-c.heiss@proxmox.com> (raw)
In-Reply-To: <20241018115943.813243-1-c.heiss@proxmox.com>
While some filesystems - such as FAT(32) - might not supported/allow
mixed-case labels, some implementations still handle them correctly,
such as Linux. Thus, also search for that variant.
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
.../src/fetch_plugins/partition.rs | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/proxmox-fetch-answer/src/fetch_plugins/partition.rs b/proxmox-fetch-answer/src/fetch_plugins/partition.rs
index 4472922..cbfe2d5 100644
--- a/proxmox-fetch-answer/src/fetch_plugins/partition.rs
+++ b/proxmox-fetch-answer/src/fetch_plugins/partition.rs
@@ -43,12 +43,22 @@ fn path_exists_logged(file_name: &str, search_path: &str) -> Option<PathBuf> {
}
}
-/// Searches for upper and lower case existence of the partlabel in the search_path
+/// Searches for the exact case, upper and finally lower case existence of the partlabel in the
+/// search_path, in that order.
+///
+/// While some filesystems - such as FAT(32) - might not supported/allow mixed-case labels, some
+/// implementations still handle them correctly, such as Linux. Thus, also search for that variant
+/// first.
///
/// # Arguments
-/// * `partlabel_source` - Partition Label, used as upper and lower case
+/// * `partlabel_source` - Partition Label, used for matching, in the exact, upper and lower case
/// * `search_path` - Path where to search for the partition label
fn scan_partlabels(partlabel: &str, search_path: &str) -> Result<PathBuf> {
+ if let Some(path) = path_exists_logged(partlabel, search_path) {
+ info!("Found partition with label '{partlabel}'");
+ return Ok(path);
+ }
+
let partlabel_upper_case = partlabel.to_uppercase();
if let Some(path) = path_exists_logged(&partlabel_upper_case, search_path) {
info!("Found partition with label '{partlabel_upper_case}'");
@@ -61,7 +71,7 @@ fn scan_partlabels(partlabel: &str, search_path: &str) -> Result<PathBuf> {
return Ok(path);
}
- bail!("Could not detect upper or lower case labels for '{partlabel}'");
+ bail!("Could not find partition for label '{partlabel}'");
}
/// Will search and mount a partition/FS labeled PARTLABEL (proxmox-ais) in lower or uppercase
--
2.46.0
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2024-10-18 11:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 11:59 [pve-devel] [PATCH installer 0/4] auto-install-assistant: allow specifying 'fetch-from' " Christoph Heiss
2024-10-18 11:59 ` [pve-devel] [PATCH installer 1/4] auto-install-assistant: add new parameter to specify " Christoph Heiss
2024-10-18 11:59 ` [pve-devel] [PATCH installer 2/4] fetch-answer: refactor cli argument parsing Christoph Heiss
2024-10-18 11:59 ` Christoph Heiss [this message]
2024-10-18 11:59 ` [pve-devel] [PATCH installer 4/4] fetch-answer: use partition label from fetch config instead of hardcoded Christoph Heiss
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=20241018115943.813243-4-c.heiss@proxmox.com \
--to=c.heiss@proxmox.com \
--cc=pve-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