add 'progress' source, 'progress to text' converter
[enigma2.git] / lib / python / Components / Harddisk.py
index 8455b865e9145a7ab188627432fba7769625387c..74736a081872e6136c6902b3656d3eebd821a910 100644 (file)
@@ -42,24 +42,29 @@ class Harddisk:
                else:
                        return ret + "Master"
 
-       def capacity(self):
+       def diskSize(self):
                procfile = tryOpen(self.prochdx + "capacity")
-               
+
                if procfile == "":
-                       return ""
+                       return 0
 
                line = procfile.readline()
                procfile.close()
-               
+
                try:
                        cap = int(line)
                except:
+                       return 0
+
+               return cap / 1000 * 512 / 1000
+
+       def capacity(self):
+               cap = self.diskSize()
+               if cap == 0:
                        return ""
                
-               cap = cap / 1000 * 512 / 1000
-               
                return "%d.%03d GB" % (cap/1024, cap%1024)
-                                                               
+
        def model(self):
                procfile = tryOpen(self.prochdx + "model")
 
@@ -132,7 +137,10 @@ class Harddisk:
                return 0
 
        def mkfs(self):
-               cmd = "/sbin/mkfs.ext3 -T largefile -m0 " + self.devidex + "part1"
+               cmd = "/sbin/mkfs.ext3 "
+               if self.diskSize() > 4 * 1024:
+                       cmd += "-T largefile "
+               cmd += "-m0 " + self.devidex + "part1"
                res = system(cmd)
                return (res >> 8)
 
@@ -213,6 +221,7 @@ class Partition:
                self.mountpoint = mountpoint
                self.description = description
                self.force_mounted = force_mounted
+               self.is_hotplug = force_mounted # so far; this might change.
 
        def stat(self):
                return statvfs(self.mountpoint)
@@ -308,7 +317,7 @@ class HarddiskManager:
 
                return list
 
-       def getMountedPartitions(self):
-               return [x for x in self.partitions if x.mounted()]
+       def getMountedPartitions(self, onlyhotplug = False):
+               return [x for x in self.partitions if (x.is_hotplug or not onlyhotplug) and x.mounted()]
 
 harddiskmanager = HarddiskManager()