i2SOM:udev: add rule to mount part on NAND and eMMC
This commit is contained in:
@ -0,0 +1,31 @@
|
||||
# There are a number of modifiers that are allowed to be used in some
|
||||
# of the different fields. They provide the following subsitutions:
|
||||
#
|
||||
# %n the "kernel number" of the device.
|
||||
# For example, 'sda3' has a "kernel number" of '3'
|
||||
# %e the smallest number for that name which does not matches an existing node
|
||||
# %k the kernel name for the device
|
||||
# %M the kernel major number for the device
|
||||
# %m the kernel minor number for the device
|
||||
# %b the bus id for the device
|
||||
# %c the string returned by the PROGRAM
|
||||
# %s{filename} the content of a sysfs attribute
|
||||
# %% the '%' char itself
|
||||
#
|
||||
|
||||
# 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"
|
||||
|
||||
# Recovery partition
|
||||
SUBSYSTEM=="block", ENV{ID_PART_ENTRY_NAME}=="recovery*", ACTION=="add", GOTO="automount_rules_end"
|
||||
SUBSYSTEM=="mtd", ATTRS{name}=="recovery", ACTION=="add", 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"
|
||||
SUBSYSTEM=="block", ACTION=="change", ENV{DISK_MEDIA_CHANGE}=="1" RUN+="/etc/udev/scripts/mount.sh"
|
||||
LABEL="automount_rules_end"
|
||||
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
#===============================================================================
|
||||
#
|
||||
# mount_bootparts.sh
|
||||
#
|
||||
# Copyright (C) 2017 i2SOM Team.
|
||||
# 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 boot partitions read-only (called from udev)
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
MOUNT="/bin/mount"
|
||||
|
||||
# Use 'silent' if util-linux's mount (busybox's does not support that option)
|
||||
[ "$(readlink ${MOUNT})" = "/bin/mount.util-linux" ] && MOUNT="${MOUNT} -o silent"
|
||||
|
||||
MOUNTPOINT="/mnt/${ID_PART_ENTRY_NAME}"
|
||||
mkdir -p ${MOUNTPOINT}
|
||||
if ! ${MOUNT} -t auto -r ${DEVNAME} ${MOUNTPOINT}; then
|
||||
logger -t udev "mount_bootparts.sh: mount ${DEVNAME} under ${MOUNTPOINT} failed!"
|
||||
rmdir --ignore-fail-on-non-empty ${MOUNTPOINT}
|
||||
fi
|
||||
@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
#===============================================================================
|
||||
#
|
||||
# mount_partition.sh
|
||||
#
|
||||
# Copyright (C) 2017 i2SOM Team.
|
||||
# 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
|
||||
26
meta-i2som-nxp/recipes-core/udev/udev-extraconf_1.1.bbappend
Normal file
26
meta-i2som-nxp/recipes-core/udev/udev-extraconf_1.1.bbappend
Normal file
@ -0,0 +1,26 @@
|
||||
#
|
||||
# Copyright (C) 2017 i2SOM Team.
|
||||
#
|
||||
|
||||
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
|
||||
|
||||
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
|
||||
printf "%s\n%s\n" \
|
||||
"# Symlink to the bluetooth tty" \
|
||||
"KERNEL==\"${BT_TTY}\", MODE=\"0660\", GROUP=\"dialout\", SYMLINK+=\"ttyBt\"" \
|
||||
>> ${D}${sysconfdir}/udev/rules.d/localextra.rules
|
||||
fi
|
||||
}
|
||||
|
||||
# BT_TTY is machine specific (defined in machine config file)
|
||||
PACKAGE_ARCH = "${MACHINE_ARCH}"
|
||||
Reference in New Issue
Block a user