projects
/
vuplus_dvbapp
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fe619db
)
[Harddisk] add findMount for OpenWebif.
author
hschang
<chang@dev3>
Wed, 12 Nov 2014 05:29:01 +0000
(14:29 +0900)
committer
hschang
<chang@dev3>
Wed, 12 Nov 2014 06:17:15 +0000
(15:17 +0900)
lib/python/Components/Harddisk.py
patch
|
blob
|
history
diff --git
a/lib/python/Components/Harddisk.py
b/lib/python/Components/Harddisk.py
index
16b904c
..
ca4ef9e
100755
(executable)
--- a/
lib/python/Components/Harddisk.py
+++ b/
lib/python/Components/Harddisk.py
@@
-17,6
+17,18
@@
def readFile(filename):
file.close()
return data
file.close()
return data
+def getProcMounts():
+ try:
+ mounts = open("/proc/mounts", 'r')
+ except IOError, ex:
+ print "[Harddisk] Failed to open /proc/mounts", ex
+ return []
+ result = [line.strip().split(' ') for line in mounts]
+ for item in result:
+ # Spaces are encoded as \040 in mounts
+ item[1] = item[1].replace('\\040', ' ')
+ return result
+
DEVTYPE_UDEV = 0
DEVTYPE_DEVFS = 1
DEVTYPE_UDEV = 0
DEVTYPE_DEVFS = 1
@@
-37,6
+49,8
@@
class Harddisk:
self.dev_path = ''
self.disk_path = ''
self.dev_path = ''
self.disk_path = ''
+ self.mount_path = None
+ self.mount_device = None
self.phys_path = path.realpath(self.sysfsPath('device'))
if self.type == DEVTYPE_UDEV:
self.phys_path = path.realpath(self.sysfsPath('device'))
if self.type == DEVTYPE_UDEV:
@@
-175,6
+189,18
@@
class Harddisk:
numPart += 1
return numPart
numPart += 1
return numPart
+ def mountDevice(self):
+ for parts in getProcMounts():
+ if path.realpath(parts[0]).startswith(self.dev_path):
+ self.mount_device = parts[0]
+ self.mount_path = parts[1]
+ return parts[1]
+
+ def findMount(self):
+ if self.mount_path is None:
+ return self.mountDevice()
+ return self.mount_path
+
def unmount(self):
try:
mounts = open("/proc/mounts")
def unmount(self):
try:
mounts = open("/proc/mounts")