udev: automount UBI volumes named "linux" or "recovery"

Traditionally, platforms based on NAND, used one UBI volume
per MTD partition.
Now it's possible to use only one MTD partition containing many
UBI volumes.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>

https://onedigi.atlassian.net/browse/DEL-7614
This commit is contained in:
Hector Palacios 2021-08-20 13:46:54 +02:00
parent c33fc8a7fe
commit 91bfa01a52
2 changed files with 11 additions and 0 deletions

View File

@ -16,6 +16,7 @@
# Digi-mounted partitions: linux, update
SUBSYSTEM=="block", ENV{ID_PART_ENTRY_NAME}=="linux*|update*", ACTION=="add", RUN+="/etc/udev/scripts/mount_digiparts.sh", GOTO="automount_rules_end"
SUBSYSTEM=="mtd", ATTRS{name}=="linux*|update*", ACTION=="add", RUN+="/etc/udev/scripts/mount_digiparts.sh", GOTO="automount_rules_end"
SUBSYSTEM=="ubi", ATTRS{name}=="linux*|update*", ACTION=="add", RUN+="/etc/udev/scripts/mount_digiparts.sh", GOTO="automount_rules_end"
# Avoid mounting recovery partition
SUBSYSTEM=="block", ENV{ID_PART_ENTRY_NAME}=="recovery*", ACTION=="add", GOTO="automount_rules_end"

View File

@ -22,6 +22,8 @@ if [ "${SUBSYSTEM}" = "block" ]; then
elif [ "${SUBSYSTEM}" = "mtd" ]; then
MTDN="$(echo ${DEVNAME} | cut -f 3 -d /)"
PARTNAME="$(grep ${MTDN} /proc/mtd | sed -ne 's,.*"\(.*\)",\1,g;T;p')"
elif [ "${SUBSYSTEM}" = "ubi" ]; then
PARTNAME="$(cat /sys/${DEVPATH}/name)"
fi
MOUNT_PARAMS="-o silent"
@ -89,4 +91,12 @@ elif [ "${SUBSYSTEM}" = "mtd" ]; then
logger -t udev "ERROR: Could not mount '${PARTNAME}' partition, volume not found"
rmdir --ignore-fail-on-non-empty ${MOUNTPOINT}
fi
elif [ "${SUBSYSTEM}" = "ubi" ]; then
# In the case of a 'system' partition with many UBI volumes, the device
# is always /dev/ubi0
# Mount the volume.
if ! mount -t ubifs ubi0:${PARTNAME} ${MOUNT_PARAMS} ${MOUNTPOINT}; then
logger -t udev "ERROR: Could not mount '${PARTNAME}' volume"
rmdir --ignore-fail-on-non-empty ${MOUNTPOINT}
fi
fi