mount: use the ubi class to check for attached devices

Use the generic sys class to check if a mtd device is attached.
The virtual node may not be present in some kernel versions.

Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
This commit is contained in:
Isaac Hermida 2024-04-26 14:10:14 +02:00
parent 55b313e7d2
commit e2caf16da4
1 changed files with 2 additions and 2 deletions

View File

@ -146,8 +146,8 @@ if [ "${SUBSYSTEM}" = "block" ]; then
elif [ "${SUBSYSTEM}" = "mtd" ]; then elif [ "${SUBSYSTEM}" = "mtd" ]; then
# Before attaching, find out if partition already attached # Before attaching, find out if partition already attached
MTD_NUM="$(echo ${MTDN} | sed -ne 's,.*mtd\([0-9]\+\),\1,g;T;p')" MTD_NUM="$(echo ${MTDN} | sed -ne 's,.*mtd\([0-9]\+\),\1,g;T;p')"
for ubidev in /sys/devices/virtual/ubi/*; do for ubidev in /sys/class/ubi/*; do
echo "${ubidev}" | grep -qs '/sys/devices/virtual/ubi/\*' && continue echo "${ubidev}" | grep -qs '/sys/class/ubi/\*' && continue
mtd_att="$(cat ${ubidev}/mtd_num)" mtd_att="$(cat ${ubidev}/mtd_num)"
if [ "${mtd_att}" = "${MTD_NUM}" ]; then if [ "${mtd_att}" = "${MTD_NUM}" ]; then
dev_number="$(echo ${ubidev} | sed -ne 's,.*ubi\([0-9]\+\),\1,g;T;p')" dev_number="$(echo ${ubidev} | sed -ne 's,.*ubi\([0-9]\+\),\1,g;T;p')"