diff --git a/meta-digi-arm/recipes-core/udev/udev-extraconf/automount.rules b/meta-digi-arm/recipes-core/udev/udev-extraconf/automount.rules index 8c1b63d48..3e8ee44c3 100644 --- a/meta-digi-arm/recipes-core/udev/udev-extraconf/automount.rules +++ b/meta-digi-arm/recipes-core/udev/udev-extraconf/automount.rules @@ -16,6 +16,10 @@ # Boot partitions SUBSYSTEM=="block", ENV{ID_PART_ENTRY_NAME}=="linux*", ACTION=="add", RUN+="/etc/udev/scripts/mount_bootparts.sh", GOTO="automount_rules_end" +# Update partition +SUBSYSTEM=="block", ENV{ID_PART_ENTRY_NAME}=="update*", ACTION=="add", RUN+="/etc/udev/scripts/mount_partition.sh 'update'", GOTO="automount_rules_end" +SUBSYSTEM=="mtd", ATTRS{name}=="update", ACTION=="add", RUN+="/etc/udev/scripts/mount_partition.sh 'update'", GOTO="automount_rules_end" + # Media automounting SUBSYSTEM=="block", ACTION=="add" RUN+="/etc/udev/scripts/mount.sh" SUBSYSTEM=="block", ACTION=="remove" RUN+="/etc/udev/scripts/mount.sh" diff --git a/meta-digi-arm/recipes-core/udev/udev-extraconf/mount_partition.sh b/meta-digi-arm/recipes-core/udev/udev-extraconf/mount_partition.sh new file mode 100644 index 000000000..05f719b18 --- /dev/null +++ b/meta-digi-arm/recipes-core/udev/udev-extraconf/mount_partition.sh @@ -0,0 +1,46 @@ +#!/bin/sh +#=============================================================================== +# +# mount_partition.sh +# +# Copyright (C) 2017 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# !Description: Attempt to mount the partition triggered by udev +# +#=============================================================================== + +MOUNT="/bin/mount" +PARTITION_NAME="${1}" +MOUNTPOINT="/mnt/${PARTITION_NAME}" + +# Use 'silent' if util-linux's mount (busybox's does not support that option) +[ "$(readlink ${MOUNT})" = "/bin/mount.util-linux" ] && MOUNT="${MOUNT} -o silent" + +if mkdir -p "${MOUNTPOINT}" && ! mountpoint -q "${MOUNTPOINT}"; then + if [ "${SUBSYSTEM}" = "block" ]; then + FSTYPE="$(blkid ${DEVNAME} | sed -e 's,.*TYPE="\([^"]\+\)".*,\1,g')" + if ! mount ${FSTYPE:+-t ${FSTYPE}} "${DEVNAME}" "${MOUNTPOINT}"; then + logger -t udev "ERROR: Could not mount '${PARTITION_NAME}' partition" + rmdir --ignore-fail-on-non-empty ${MOUNTPOINT} + fi + elif [ "${SUBSYSTEM}" = "mtd" ]; then + # Attach and get UBI device number + dev_number="$(ubiattach -p ${DEVNAME} 2>/dev/null | sed -ne 's,.*device number \([0-9]\).*,\1,g;T;p' 2>/dev/null)" + # Check if volume exists. + if ubinfo "/dev/ubi${dev_number}" -N "${PARTITION_NAME}" >/dev/null 2>&1; then + # Mount the volume. + if ! mount -t ubifs "ubi${dev_number}:${PARTITION_NAME}" "${MOUNTPOINT}"; then + logger -t udev "ERROR: Could not mount '${PARTITION_NAME}' partition" + rmdir --ignore-fail-on-non-empty ${MOUNTPOINT} + fi + else + logger -t udev "ERROR: Could not mount '${PARTITION_NAME}' partition, volume not found" + rmdir --ignore-fail-on-non-empty ${MOUNTPOINT} + fi + fi +fi diff --git a/meta-digi-arm/recipes-core/udev/udev-extraconf_1.1.bbappend b/meta-digi-arm/recipes-core/udev/udev-extraconf_1.1.bbappend index 901ff61dd..662156665 100644 --- a/meta-digi-arm/recipes-core/udev/udev-extraconf_1.1.bbappend +++ b/meta-digi-arm/recipes-core/udev/udev-extraconf_1.1.bbappend @@ -2,10 +2,14 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" -SRC_URI += "file://mount_bootparts.sh" +SRC_URI += " \ + file://mount_bootparts.sh \ + file://mount_partition.sh \ +" do_install_append() { install -m 0755 ${WORKDIR}/mount_bootparts.sh ${D}${sysconfdir}/udev/scripts/ + install -m 0755 ${WORKDIR}/mount_partition.sh ${D}${sysconfdir}/udev/scripts/ # Bluetooth tty symlink if [ -n "${BT_TTY}" ]; then