X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FComponents%2FHarddisk.py;h=9f69d2692da713676ef27423aafef4d7d056b3bd;hp=03f574f3dbb207e60e6f1c6a7e5ad6796461c0bc;hb=7ff2c7908114488178ad574b23fcee718515f4fb;hpb=7fd6d75b6c77621a8538cb9a5e1999c3266ac3f4 diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index 03f574f..9f69d26 100755 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -1,5 +1,7 @@ from os import system, listdir, statvfs, popen, makedirs, stat, major, minor, path, access -from Tools.Directories import SCOPE_HDD, resolveFilename +# ikseong +from Tools.Directories import SCOPE_HDD, resolveFilename, fileExists + from Tools.CList import CList from SystemInfo import SystemInfo import time @@ -91,7 +93,13 @@ class Harddisk: return ret def diskSize(self): - line = readFile(self.sysfsPath('size')) + # ikseong + try: + line = readFile(self.sysfsPath('size')) + except: + harddiskmanager.removeHotplugPartition(self.device) + print "error remove",self.device + return -1 try: cap = int(line) except: @@ -105,14 +113,20 @@ class Harddisk: return "%d.%03d GB" % (cap/1000, cap%1000) def model(self): - if self.device[:2] == "hd": - return readFile('/proc/ide/' + self.device + '/model') - elif self.device[:2] == "sd": - vendor = readFile(self.sysfsPath('device/vendor')) - model = readFile(self.sysfsPath('device/model')) - return vendor + '(' + model + ')' - else: - assert False, "no hdX or sdX" + # ikseong + try: + if self.device[:2] == "hd": + return readFile('/proc/ide/' + self.device + '/model') + elif self.device[:2] == "sd": + vendor = readFile(self.sysfsPath('device/vendor')) + model = readFile(self.sysfsPath('device/model')) + return vendor + '(' + model + ')' + else: + assert False, "no hdX or sdX" + except: + harddiskmanager.removeHotplugPartition(self.device) + print "error remove",self.device + return -1 def free(self): try: @@ -166,7 +180,7 @@ class Harddisk: lines = mounts.readlines() mounts.close() - cmd = "/bin/umount" + cmd = "umount" for line in lines: parts = line.strip().split(" ") @@ -177,12 +191,12 @@ class Harddisk: return (res >> 8) def createPartition(self): - cmd = 'printf "0,\n;\n;\n;\ny\n" | /sbin/sfdisk -f ' + self.disk_path + cmd = 'printf "0,\n;\n;\n;\ny\n" | sfdisk -f ' + self.disk_path res = system(cmd) return (res >> 8) def mkfs(self): - cmd = "/sbin/mkfs.ext3 " + cmd = "mkfs.ext3 " if self.diskSize() > 4 * 1024: cmd += "-T largefile " cmd += "-m0 -O dir_index " + self.partitionPath("1") @@ -202,14 +216,19 @@ class Harddisk: for line in lines: parts = line.strip().split(" ") if path.realpath(parts[0]) == self.partitionPath("1"): - cmd = "/bin/mount -t ext3 " + parts[0] + cmd = "mount -t ext3 " + parts[0] res = system(cmd) break return (res >> 8) def createMovieFolder(self): +# ikseong try: + if not fileExists("/hdd", 0): + print "not found /hdd" + system("ln -s /media/hdd /hdd") +# makedirs(resolveFilename(SCOPE_HDD)) except OSError: return -1 @@ -218,7 +237,7 @@ class Harddisk: def fsck(self): # We autocorrect any failures # TODO: we could check if the fs is actually ext3 - cmd = "/sbin/fsck.ext3 -f -p " + self.partitionPath("1") + cmd = "fsck.ext3 -f -p " + self.partitionPath("1") res = system(cmd) return (res >> 8) @@ -226,7 +245,7 @@ class Harddisk: part = self.partitionPath(n) if access(part, 0): - cmd = '/bin/dd bs=512 count=3 if=/dev/zero of=' + part + cmd = 'dd bs=512 count=3 if=/dev/zero of=' + part res = system(cmd) else: res = 0 @@ -318,6 +337,10 @@ class Harddisk: idle_time = t - self.last_access stats = self.readStats() + # ikseong + if stats == -1: + self.setIdleTime(0) + return print "nr_read", stats[0], "nr_write", stats[1] l = sum(stats) print "sum", l, "prev_sum", self.last_stat @@ -505,7 +528,8 @@ class HarddiskManager: self.addHotplugPartition(part) def getAutofsMountpoint(self, device): - return "/autofs/%s/" % (device) + return "/media/%s/" % (device) + def addHotplugPartition(self, device, physdev = None): if not physdev: @@ -554,6 +578,9 @@ class HarddiskManager: def HDDList(self): list = [ ] for hd in self.hdd: + # ikseong + if hd.model() == -1: + continue hdd = hd.model() + " - " + hd.bus() cap = hd.capacity() if cap != "":