aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2007-06-11 20:10:31 +0000
committerFelix Domke <tmbinc@elitedvb.net>2007-06-11 20:10:31 +0000
commitb6fb1984add5d1fbc08686d510d6aa46efa7f3bd (patch)
treea8b67772aa3b96c993daf5fcb844ed986be95b38 /lib
parent06935bb4a7b5567193a26504de047df836a46acc (diff)
downloadenigma2-b6fb1984add5d1fbc08686d510d6aa46efa7f3bd.tar.gz
enigma2-b6fb1984add5d1fbc08686d510d6aa46efa7f3bd.zip
add support for hotplug partitions. partitions/filesystems are dynamically added and removed by an external plugin.
Diffstat (limited to 'lib')
-rw-r--r--lib/python/Components/FileList.py13
-rw-r--r--lib/python/Components/Harddisk.py23
2 files changed, 35 insertions, 1 deletions
diff --git a/lib/python/Components/FileList.py b/lib/python/Components/FileList.py
index 3091436f..09756e3c 100644
--- a/lib/python/Components/FileList.py
+++ b/lib/python/Components/FileList.py
@@ -190,3 +190,16 @@ class FileList(MenuList, HTMLComponent, GUIComponent):
def postWidgetCreate(self, instance):
instance.setContent(self.l)
+
+ def execBegin(self):
+ harddiskmanager.on_partition_list_change.append(self.partitionListChanged)
+
+ def execEnd(self):
+ harddiskmanager.on_partition_list_change.remove(self.partitionListChanged)
+
+ def refresh(self):
+ self.changeDir(self.current_directory, self.getFilename())
+
+ def partitionListChanged(self, action, device):
+ if self.current_directory is None:
+ self.refresh()
diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py
index 72093701..79c0d6f8 100644
--- a/lib/python/Components/Harddisk.py
+++ b/lib/python/Components/Harddisk.py
@@ -1,6 +1,7 @@
from os import system, listdir, statvfs, popen
from Tools.Directories import SCOPE_HDD, resolveFilename
+from Tools.CList import CList
def tryOpen(filename):
try:
@@ -163,9 +164,10 @@ def existHDD(num):
return -1
class Partition:
- def __init__(self, mountpoint, description = ""):
+ def __init__(self, mountpoint, description = "", force_mounted = False):
self.mountpoint = mountpoint
self.description = description
+ self.force_mounted = force_mounted
def stat(self):
return statvfs(self.mountpoint)
@@ -187,6 +189,8 @@ class Partition:
def mounted(self):
# THANK YOU PYTHON FOR STRIPPING AWAY f_fsid.
# TODO: can os.path.ismount be used?
+ if self.force_mounted:
+ return True
procfile = tryOpen("/proc/mounts")
for n in procfile.readlines():
if n.split(' ')[1] == self.mountpoint:
@@ -200,6 +204,8 @@ class HarddiskManager:
self.partitions = [ ]
+ self.on_partition_list_change = CList()
+
for hddNum in range(8):
if existHDD(hddNum):
hdd = Harddisk(hddNum)
@@ -224,6 +230,21 @@ class HarddiskManager:
for x in p:
self.partitions.append(Partition(mountpoint = x[0], description = x[1]))
+ def getAutofsMountpoint(self, device):
+ return "/autofs/%s/" % (device)
+
+ def addHotplugPartition(self, device, description):
+ p = Partition(mountpoint = self.getAutofsMountpoint(device), description = description, force_mounted = True)
+ self.partitions.append(p)
+ self.on_partition_list_change("add", p)
+
+ def removeHotplugPartition(self, device):
+ mountpoint = self.getAutofsMountpoint(device)
+ for x in self.partitions[:]:
+ if x.mountpoint == mountpoint:
+ self.partitions.remove(x)
+ self.on_partition_list_change("remove", x)
+
def HDDCount(self):
return len(self.hdd)