Skip to contentSkip to conversation

udev-extraconf: Speed up automounter and make it safer

PATCH New Robert Tiemann 1 participant 3 messages Oct 2, 2025

lore
Share & tools
lore
#0 lore raw

cover udev-extraconf: Speed up automounter and make it safer

These patches address (1) a performance issue in mount.sh, and (2) a problem with partition labels which contain slashes.

Robert Tiemann (2):
udev-extraconf: Speed up mount.sh
udev-extraconf: Avoid slashes in mountpoint names

 meta/recipes-core/udev/udev-extraconf/mount.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 udev-extraconf: Speed up mount.sh

On devices with many partitions, running blkid without parameters can be rather slow because all block devices are inspected:

$ time /sbin/blkid
real    0m0.474s
user    0m0.026s
sys     0m0.172s

versus

$ time /sbin/blkid /dev/mmcblk0p10
real    0m0.027s
user    0m0.002s
sys     0m0.018s

Plugging in a device with 5 partitions means that mount.sh is going to be executed 5 times, and so will be blkid. In the real-world case outlined above, this adds up to an overhead of about 2.3 seconds for blkid alone.

This commit changes mount.sh so that the block device of interest is passed directly to blkid such that blkid inspects only that device, leading to significant speedup.

---
 meta/recipes-core/udev/udev-extraconf/mount.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/udev/udev-extraconf/mount.sh +1 -1
index 0cbae48729..fe78f3aba5 100644
@@ -178,7 +178,7 @@ rm_dir() {
 
 get_label_name() {
 	# Get the LABEL or PARTLABEL
-	LABEL=`/sbin/blkid | grep "$1:" | grep -o 'LABEL=".*"' | cut -d '"' -f2`
+	LABEL=`/sbin/blkid "$1" | grep -o 'LABEL=".*"' | cut -d '"' -f2`
 	# If the $DEVNAME has a LABEL or a PARTLABEL
 	if [ -n "$LABEL" ]; then
 	        # Set the mount location dir name to LABEL appended
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/2 udev-extraconf: Avoid slashes in mountpoint names

In reply to Robert Tiemann

Devices with labels such as "Hello/World/Foo/Bar" cause mount.sh to create the directory structure @MOUNT_BASE@/Hello/World/Foo/Bar. The partition is mounted to the nested "Bar" directory. On device removal, the directory structure is not cleaned up.

This commit replaces all forward slashes in partition labels by underscores to avoid this edge case.

---
 meta/recipes-core/udev/udev-extraconf/mount.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/udev/udev-extraconf/mount.sh +1 -1
index fe78f3aba5..4827779e2f 100644
@@ -178,7 +178,7 @@ rm_dir() {
 
 get_label_name() {
 	# Get the LABEL or PARTLABEL
-	LABEL=`/sbin/blkid "$1" | grep -o 'LABEL=".*"' | cut -d '"' -f2`
+	LABEL=`/sbin/blkid "$1" | grep -o 'LABEL=".*"' | cut -d '"' -f2 | sed 's,/,_,g'`
 	# If the $DEVNAME has a LABEL or a PARTLABEL
 	if [ -n "$LABEL" ]; then
 	        # Set the mount location dir name to LABEL appended
Signature · 1 line
2.43.0