mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
lsluns: try harder to find udevadm
Hard-coding udevadm's location isn't robust enough - for instance, Ubuntu 20.04 moved it to /usr/bin. First see if we can reach it through $PATH, then fall back to hard-coded locations that we know about. Also when finally falling back to udevsettle, check that it exists. Otherwise we end up throwing tons of "No such file or directory" error messages at the user. Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com> Reviewed-by: Steffen Maier <maier@linux.ibm.com> Reviewed-by: Fedor Loshakov <loshakov@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
20b05e1f82
commit
e679a4002e
17
zconf/lsluns
17
zconf/lsluns
@@ -24,13 +24,22 @@ my $wlun = "0xc101000000000000";
|
||||
my $lun0 = "0x0000000000000000";
|
||||
my $sg_dir = "/sys/class/scsi_generic";
|
||||
my $udevsettle_call;
|
||||
my $udevadm = "/sbin/udevadm";
|
||||
|
||||
|
||||
if (! -e $udevadm) {
|
||||
$udevsettle_call = "/sbin/udevsettle";
|
||||
# See if we can find udevadm through $PATH:
|
||||
if (!system("udevadm --version > /dev/null 2>&1")) {
|
||||
$udevsettle_call = "udevadm settle";
|
||||
# Search udevadm in well-known locations:
|
||||
} elsif (-e "/sbin/udevadm") {
|
||||
$udevsettle_call = "/sbin/udevadm settle";
|
||||
} elsif (-e "/usr/bin/udevadm") {
|
||||
$udevsettle_call = "/usr/bin/udevadm settle";
|
||||
# Fall back to udevsettle:
|
||||
} elsif (-e "/sbin/udevsettle") {
|
||||
$udevsettle_call = "/sbin/udevsettle";
|
||||
} else {
|
||||
$udevsettle_call = "$udevadm settle";
|
||||
$udevsettle_call = "";
|
||||
print "Failed to find any candidate for udevsettle.\n";
|
||||
}
|
||||
|
||||
# read the first line of a sysfs-entry and compare it to a given string
|
||||
|
||||
Reference in New Issue
Block a user