diff options
| author | ghost <andreas.monzner@multimedia-labs.de> | 2010-11-16 15:28:32 +0100 |
|---|---|---|
| committer | ghost <andreas.monzner@multimedia-labs.de> | 2010-11-16 15:28:32 +0100 |
| commit | 7d6ff22b6dd5b0f7b35fb35747109d70b6324d3e (patch) | |
| tree | 2cf92a22975052779b4cd6ad19f73aafd77adcad /lib/python/Components/Harddisk.py | |
| parent | bddf5dc4d95831ef714ab55e2f47b1ac114ebe01 (diff) | |
| parent | fb91533bb1d293bdb0691bfcc1d15da9268782fe (diff) | |
| download | enigma2-7d6ff22b6dd5b0f7b35fb35747109d70b6324d3e.tar.gz enigma2-7d6ff22b6dd5b0f7b35fb35747109d70b6324d3e.zip | |
Merge branch 'master' into experimental
Diffstat (limited to 'lib/python/Components/Harddisk.py')
| -rw-r--r--[-rwxr-xr-x] | lib/python/Components/Harddisk.py | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index e8e612a4..7f837565 100755..100644 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -5,6 +5,10 @@ from SystemInfo import SystemInfo import time from Components.Console import Console +def MajorMinor(path): + rdev = stat(path).st_rdev + return (major(rdev),minor(rdev)) + def readFile(filename): file = open(filename) data = file.read().strip() @@ -125,13 +129,15 @@ class Harddisk: for line in lines: parts = line.strip().split(" ") - if path.realpath(parts[0]).startswith(self.dev_path): - try: + real_path = path.realpath(parts[0]) + if not real_path[-1].isdigit(): + continue + try: + if MajorMinor(real_path) == MajorMinor(self.partitionPath(real_path[-1])): stat = statvfs(parts[1]) - except OSError: - continue - return stat.f_bfree/1000 * stat.f_bsize/1000 - + return stat.f_bfree/1000 * stat.f_bsize/1000 + except OSError: + pass return -1 def numPartitions(self): @@ -168,10 +174,17 @@ class Harddisk: cmd = "umount" - for line in lines: - parts = line.strip().split(" ") - if path.realpath(parts[0]).startswith(self.dev_path): - cmd = ' ' . join([cmd, parts[1]]) + for line in lines: + parts = line.strip().split(" ") + real_path = path.realpath(parts[0]) + if not real_path[-1].isdigit(): + continue + try: + if MajorMinor(real_path) == MajorMinor(self.partitionPath(real_path[-1])): + cmd = ' ' . join([cmd, parts[1]]) + break + except OSError: + pass res = system(cmd) return (res >> 8) @@ -201,10 +214,16 @@ class Harddisk: res = -1 for line in lines: parts = line.strip().split(" ") - if path.realpath(parts[0]) == self.partitionPath("1"): - cmd = "mount -t ext3 " + parts[0] - res = system(cmd) - break + real_path = path.realpath(parts[0]) + if not real_path[-1].isdigit(): + continue + try: + if MajorMinor(real_path) == MajorMinor(self.partitionPath(real_path[-1])): + cmd = "mount -t ext3 " + parts[0] + res = system(cmd) + break + except OSError: + pass return (res >> 8) |
