aboutsummaryrefslogtreecommitdiffstats
path: root/meta-mentor-staging/recipes-core/udev/udev-extraconf/0001-udev-extraconf-mount.sh-add-LABELs-to-mountpoints.patch
blob: e5b5ab856e8c64a1439517d9cc13b22533fa5010 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From 3ad00853d0e81fc8e0729c7c7312fab3a5a1a94c Mon Sep 17 00:00:00 2001
From: "Arsalan H. Awan" <Arsalan_Awan@mentor.com>
Date: Thu, 1 Nov 2018 17:37:07 +0500
Subject: [PATCH] udev-extraconf/mount.sh: add LABELs to mountpoints

This alters the mountpoints such that if a device has a LABEL or
a PARTLABEL, it will be mounted at e.g.:

  /run/media/$LABEL-<device-node>
  /run/media/$PARTLABEL-<device-node>
  /run/media/rootfs-sda2

otherwise the device will be mounted at e.g.:

  /run/media/<device-node>
  /run/media/sda1

The <device-node> appended with LABEL or PARTLABEL makes sure that
the mountpoint is unique, therefore, avoids overlapping mounts.

Signed-off-by: Arsalan H. Awan <Arsalan_Awan@mentor.com>
---
 mount.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)

Index: 1.1-r0/mount.sh
===================================================================
--- 1.1-r0.orig/mount.sh
+++ 1.1-r0/mount.sh
@@ -94,6 +94,16 @@ automount() {
 	# configured in fstab
 	grep -q "^$DEVNAME " /proc/mounts && return
 
+	# Get the LABEL or PARTLABEL
+	LABEL=`/sbin/blkid | grep "${DEVNAME}:" | 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
+		# with $name e.g. label-sda. That would avoid overlapping
+		# mounts in case two devices have same LABEL
+		name="${LABEL}-${name}"
+	fi
+
 	! test -d "$MOUNT_BASE/$name" && mkdir -p "$MOUNT_BASE/$name"
 	# Silent util-linux's version of mounting auto
 	if [ "x`readlink $MOUNT`" = "x/bin/mount.util-linux" ] ;