automount: add rule to automount update partition

https://jira.digi.com/browse/DEL-3512

Signed-off-by: David Escalona <david.escalona@digi.com>
This commit is contained in:
David Escalona 2017-01-20 14:20:10 +01:00
parent e3ae7c8ea7
commit e0d6f4eda4
3 changed files with 55 additions and 1 deletions

View File

@ -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"

View File

@ -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

View File

@ -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