summaryrefslogtreecommitdiff
path: root/meta-openvuplus
diff options
context:
space:
mode:
authorhschang <chang@dev3>2017-11-16 09:57:45 (GMT)
committerhschang <chang@dev3>2017-11-16 09:59:33 (GMT)
commit343ccad06ec85da46a194be39989a67f3e75d8fa (patch)
tree5267735e6d294d4becdfbe630ee308a8eeb1536d /meta-openvuplus
parent720225debd7278b9c3940743775160a01dce14d6 (diff)
[udev] fix device mount point.
Diffstat (limited to 'meta-openvuplus')
-rwxr-xr-xmeta-openvuplus/recipes-core/udev/udev-182/automount.py55
-rw-r--r--meta-openvuplus/recipes-core/udev/udev_182.bbappend2
2 files changed, 40 insertions, 17 deletions
diff --git a/meta-openvuplus/recipes-core/udev/udev-182/automount.py b/meta-openvuplus/recipes-core/udev/udev-182/automount.py
index 01695b6..22f81e2 100755
--- a/meta-openvuplus/recipes-core/udev/udev-182/automount.py
+++ b/meta-openvuplus/recipes-core/udev/udev-182/automount.py
@@ -1,10 +1,25 @@
#!/usr/bin/python
import os
import sys
+import glob
def readFile(fn):
return open(fn, "r").read()
+def getLabelFromDevName(dev_kernel):
+ for label in glob.glob("/dev/disk/by-label/*"):
+ realPath = os.path.realpath(label)
+ if realPath == dev_kernel:
+ return os.path.basename(label)
+ return None
+
+def getModel(dev_base):
+ model = None
+ modelpath = "/sys/block/%s/device/model" % dev_base
+ if os.access(modelpath, os.F_OK):
+ model = open(modelpath, "r").read().strip().replace(' ','-')
+ return model
+
def isMountedByDevName(devName):
ismounted = False
mounts = file('/proc/mounts').read().split('\n')
@@ -19,6 +34,13 @@ def isMountedByDevName(devName):
return ismounted
+def isUsbDevice(dev_base):
+ phyPath = os.path.realpath('/sys/block/' + dev_base)
+ for x in glob.glob("/sys/bus/usb/devices/usb*"):
+ if phyPath.find(os.path.realpath(x)) != -1:
+ return True
+ return False
+
def automount():
kernel = sys.argv[1]
dev_kernel = os.path.join("/dev/", kernel)
@@ -26,30 +48,31 @@ def automount():
dev_base = os.path.basename(kernel)[:-1]
removable=readFile("/sys/block/%s/removable" % dev_base).strip() == "1"
dev_real_path = os.path.realpath("/sys/block/%s/device" % dev_base)
- external = False
- if (dev_real_path.find("pci") != -1) or (dev_real_path.find("ahci") != -1) or (dev_real_path.find("sata") != -1):
- external = True
if isMountedByDevName(dev_kernel):
return
- deviceType = "hdd"
-# if removable or external:
- if removable:
- deviceType = "usb"
-
+ mountPoint = None
if dev_index == "1":
- mountPoint = "/media/" + deviceType
+ usbDevice = removable or isUsbDevice(dev_base)
+ if not usbDevice:
+ mountPoint = "/media/hdd"
- if os.path.ismount(mountPoint):
- mountPoint = "/media/" + kernel
+ if (mountPoint == None) or (os.path.ismount(mountPoint)):
+ label = getLabelFromDevName(dev_kernel)
+ if label:
+ mountPoint = "/media/" + label
+ if dev_index and dev_index != '1':
+ mountPoint += "_%s" % dev_index
- elif not os.access(mountPoint, os.F_OK):
- os.mkdir(mountPoint)
- if not os.access(mountPoint, os.F_OK):
- mountPoint = "/media/" + kernel
+ if (mountPoint == None) or (os.path.ismount(mountPoint)):
+ model = getModel(dev_base)
+ if model:
+ mountPoint = "/media/" + model
+ if dev_index and dev_index != '1':
+ mountPoint += "_%s" % dev_index
- else:
+ if (mountPoint == None) or (os.path.ismount(mountPoint)):
mountPoint = "/media/" + kernel
if not os.access(mountPoint, os.F_OK):
diff --git a/meta-openvuplus/recipes-core/udev/udev_182.bbappend b/meta-openvuplus/recipes-core/udev/udev_182.bbappend
index 4e285d8..f6a4d97 100644
--- a/meta-openvuplus/recipes-core/udev/udev_182.bbappend
+++ b/meta-openvuplus/recipes-core/udev/udev_182.bbappend
@@ -1,4 +1,4 @@
-PR .= "-vuplus3"
+PR .= "-vuplus4"
SRC_URI += " \
file://99_vuplus.rules \