Skip to content

Commit e7800ca

Browse files
committed
feature/mdadm: workaround for the error in determining the RAID device in use
Sometimes on Fedora, bash may end up with the following error: /srv/features/mdadm/guess/device: line 46: /sys/devices/virtual/block/md127/uevent: Success In this line, the file is sourced from sysfs: MAJOR= MINOR= . "$SYSFS_PATH$1"/uevent As a workaround, we try to read the file in other ways. If that doesn't work, we make the rules for all raid devices. Signed-off-by: Alexey Gladkov <[email protected]>
1 parent 4146f87 commit e7800ca

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

features/mdadm/bin/generate-udev-rules

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash -efu
1+
#!/bin/bash -eu
22
# SPDX-License-Identifier: GPL-3.0-or-later
33

44
. sh-functions
@@ -9,12 +9,26 @@ if [ "${1-}" = dirs ]; then
99
mkdir ${verbose2-} -p -- "$DIR/etc/initrd/md"
1010
fi
1111

12+
if [ -z "${GENERATE_UDEV_RULES_FOR_MD_DEVICE-}" ]; then
13+
verbose2 "No preferred RAID devices. Generating rules for all raid devices..."
14+
15+
GENERATE_UDEV_RULES_FOR_MD_DEVICE=
16+
17+
# If the variable is not specified, we generate rules for all
18+
# raid devices.
19+
for path in /dev/dev/block/*/md; do
20+
if [ -d "$path" ]; then
21+
majmin="${path%/md}"
22+
majmin="${majmin##*/}"
23+
GENERATE_UDEV_RULES_FOR_MD_DEVICE="$GENERATE_UDEV_RULES_FOR_MD_DEVICE $majmin"
24+
fi
25+
done
26+
fi
27+
1228
for majmin in ${GENERATE_UDEV_RULES_FOR_MD_DEVICE-}; do
1329
verbose2 "Processing MD device $majmin..."
1430

15-
DEVNAME=
16-
17-
. "$SYSFS_PATH/dev/block/$majmin/uevent"
31+
DEVNAME="$(sed -n -e 's,^DEVNAME=,,p' "$SYSFS_PATH/dev/block/$majmin/uevent")"
1832

1933
[ -n "${DEVNAME-}" ] ||
2034
fatal "unable to find device name in \`$SYSFS_PATH/dev/block/$majmin/uevent'"

features/mdadm/guess/device

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ fi
4141

4242
guess_feature mdadm
4343

44-
MAJOR=
45-
MINOR=
46-
. "$SYSFS_PATH$1"/uevent
44+
[ -n "${MAKE_INITRD_TRACE-}" ] || {
45+
stat "$SYSFS_PATH$1/uevent" 2>&1 ||:;
46+
}
4747

48-
guess_variable GENERATE_UDEV_RULES_FOR_MD_DEVICE "$MAJOR:$MINOR"
48+
majmin=
49+
readline majmin "$SYSFS_PATH$1/dev"
50+
51+
[ -z "$majmin" ] ||
52+
guess_variable GENERATE_UDEV_RULES_FOR_MD_DEVICE "$majmin"

0 commit comments

Comments
 (0)