[pve-devel] [PATCH pve-storage] dismanagement: account for leading white space in serial number
Shannon Sterz
s.sterz at proxmox.com
Wed Mar 12 09:38:19 CET 2025
some manufacturer seem to report leading white space in the
`ID_SERIAL_SHORT` field. the regex failed here, as it just didn't
match the whitespace at all.
reported on the forum:
https://forum.proxmox.com/threads/nvme-drive-serial-unknown.163480/#post-754953
Signed-off-by: Shannon Sterz <s.sterz at proxmox.com>
---
not sure this is the ideal fix, but i tried to stay on the more
conservative side here. alternatively the regex could be:
^E: ID_SERIAL_SHORT=(.+)$
but then the whitespace would be considered as part of the serial, not
sure this is intended or could have negative side effects.
src/PVE/Diskmanage.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PVE/Diskmanage.pm b/src/PVE/Diskmanage.pm
index 0217c75..4272668 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -328,7 +328,7 @@ sub get_udev_info {
return if !defined($data->{devpath});
$data->{serial} = 'unknown';
- $data->{serial} = $1 if $info =~ m/^E: ID_SERIAL_SHORT=(\S+)$/m;
+ $data->{serial} = $1 if $info =~ m/^E: ID_SERIAL_SHORT=\s*(\S+)$/m;
$data->{gpt} = $info =~ m/^E: ID_PART_TABLE_TYPE=gpt$/m ? 1 : 0;
--
2.39.5
More information about the pve-devel
mailing list