linux-dreambox-3.2: fix sha256sum after 'push to 3.2.54'
[opendreambox.git] / meta-opendreambox / recipes-dreambox / enigma2 / enigma2-3.999git20131118 / 0002-StorageManager-fix-sometimes-failing-manual-mount.patch
1 From 225bb35cfb2c42a84af0187f696729623a792d68 Mon Sep 17 00:00:00 2001
2 From: Mladen Horvat <acid-burn@opendreambox.org>
3 Date: Wed, 27 Nov 2013 10:33:45 +0100
4 Subject: [PATCH 2/4] StorageManager: - fix sometimes failing manual mount. -
5  add "Eject" quick-menu point to only unmount a device
6  so it can be securely unplugged.
7
8 ---
9  usr/lib/enigma2/python/Components/Harddisk.py   |   32 ++++++++++++++++++++++----------
10  usr/lib/enigma2/python/Screens/HarddiskSetup.py |   19 ++++++++++++++-----
11  2 files changed, 36 insertions(+), 15 deletions(-)
12
13 diff --git a/usr/lib/enigma2/python/Components/Harddisk.py b/usr/lib/enigma2/python/Components/Harddisk.py
14 index 5f04e2e..6501800 100644
15 --- a/usr/lib/enigma2/python/Components/Harddisk.py
16 +++ b/usr/lib/enigma2/python/Components/Harddisk.py
17 @@ -1406,7 +1406,7 @@ class HarddiskManager:
18                                                         self.unmountPartitionbyMountpoint(def_mp) #current partition is default, unmount!
19                                         if old_new_default_enabled and old_new_default_mp != "" and old_new_default_mp != def_mp and path.exists(old_new_default_mp) and self.isMount(old_new_default_mp):
20                                                 self.unmountPartitionbyMountpoint(old_new_default_mp, new_default_dev) #current partition is already mounted atm. unmount!
21 -                                       if not new_default_cfg["enabled"].value or old_new_default_mp == "" or (new_default_cfg["enabled"].value and path.exists(old_new_default_mp) and not self.isMount(old_new_default_mp)):
22 +                                       if not new_default_cfg["enabled"].value or old_new_default_mp == "" or not self.isMount(old_new_default_mp):
23                                                 new_default_cfg["enabled"].value = True
24                                                 new_default_cfg["mountpoint"].value = new_default_newmp
25                                                 if path.exists(new_default_newmp) and self.isMount(new_default_newmp):
26 @@ -1425,7 +1425,7 @@ class HarddiskManager:
27                                                         successfully = True
28                                                         if uuid == currentDefaultStorageUUID:
29                                                                 config.storage_options.default_device.value = "<undefined>"
30 -               if action == "unmount":
31 +               if action in ("unmount", "eject"):
32                         new_default = self.getPartitionbyUUID(uuid)
33                         new_default_cfg = config.storage.get(uuid, None)
34                         if new_default is not None:
35 @@ -1434,22 +1434,25 @@ class HarddiskManager:
36                                         old_new_default_mp = new_default_cfg["mountpoint"].value
37                                         old_new_default_enabled = new_default_cfg["enabled"].value
38                                         #[oldmountpath, oldenable, newmountpath, newenable]
39 -                                       if mountData is not None and isinstance(mountData, (list, tuple)):
40 -                                               old_new_default_enabled = mountData[1]
41 -                                               old_new_default_mp = mountData[0]
42 +                                       if action == "unmount":
43 +                                               if mountData is not None and isinstance(mountData, (list, tuple)):
44 +                                                       old_new_default_enabled = mountData[1]
45 +                                                       old_new_default_mp = mountData[0]
46                                 if new_default_cfg is not None and path.exists(old_new_default_mp) and self.isMount(old_new_default_mp):
47                                         if uuid == currentDefaultStorageUUID:
48                                                 self.unmountPartitionbyMountpoint(old_new_default_mp)
49                                         else:
50                                                 self.unmountPartitionbyMountpoint(old_new_default_mp, new_default_dev)
51                                 if path.exists(old_new_default_mp) and not self.isMount(old_new_default_mp):
52 -                                       new_default_cfg["mountpoint"].value = ""
53 -                                       new_default_cfg["enabled"].value = False
54 -                                       self.setupConfigEntries(initial_call = False, dev = new_default_dev)
55 +                                       if action == "unmount":
56 +                                               new_default_cfg["mountpoint"].value = ""
57 +                                               new_default_cfg["enabled"].value = False
58 +                                               self.setupConfigEntries(initial_call = False, dev = new_default_dev)
59                                         if path.exists(old_new_default_mp) and not self.isMount(old_new_default_mp):
60                                                 successfully = True
61 -                                               if uuid == currentDefaultStorageUUID:
62 -                                                       config.storage_options.default_device.value = "<undefined>"
63 +                                               if action == "unmount":
64 +                                                       if uuid == currentDefaultStorageUUID:
65 +                                                               config.storage_options.default_device.value = "<undefined>"
66                 if not successfully:
67                         print "[changeStorageDevice]: << not successfully >>"
68                         if cur_default_cfg is not None:
69 @@ -1496,6 +1499,15 @@ class HarddiskManager:
70                                                         devpath = "/dev/disk/by-uuid/" + oldcurrentDefaultStorageUUID
71                                                         if not self.is_fstab_mountpoint(devpath, cur_default_newmp):
72                                                                 self.modifyFstabEntry(devpath, cur_default_newmp, mode = "add_activated")
73 +                       if action == "mount_only":
74 +                               if (cur_default_dev is None and new_default_dev is not None):
75 +                                       if (cur_default is None and new_default is not None):
76 +                                               if old_new_default_mp != "":
77 +                                                       devpath = "/dev/disk/by-uuid/" + uuid
78 +                                                       if self.is_fstab_mountpoint(devpath, old_new_default_mp):
79 +                                                               self.modifyFstabEntry(devpath, old_new_default_mp, mode = "remove")
80 +                                                       if self.isMount(old_new_default_mp):
81 +                                                               self.unmountPartitionbyMountpoint(old_new_default_mp)
82                 config.storage_options.save()
83                 config.storage.save()
84                 configfile.save()
85 diff --git a/usr/lib/enigma2/python/Screens/HarddiskSetup.py b/usr/lib/enigma2/python/Screens/HarddiskSetup.py
86 index e61e4f7..7847819 100644
87 --- a/usr/lib/enigma2/python/Screens/HarddiskSetup.py
88 +++ b/usr/lib/enigma2/python/Screens/HarddiskSetup.py
89 @@ -581,6 +581,7 @@ class HarddiskDriveSelection(Screen, HelpableScreen):
90                 multiplepartmsg = _("Multiple partitions found!")
91                 needsattention_msg = _("Needs attention!")
92                 systemountpoint_msg = _("Mounted by system!")
93 +               notmounted_msg = _("Not mounted!")
94  
95                 if isOfflineStorageDevice:
96                         uuid = hd
97 @@ -699,7 +700,14 @@ class HarddiskDriveSelection(Screen, HelpableScreen):
98                                                                                 except OSError:
99                                                                                         isReadable = False
100                                                                                 if isReadable:
101 -                                                                                       device_info += " - " + nomountpoint_msg
102 +                                                                                       if cfg_uuid is not None and cfg_uuid["enabled"].value:
103 +                                                                                               devicepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/device_harddisk-attention.png"))
104 +                                                                                               if hd.isRemovable:
105 +                                                                                                       devicepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/device_removable-attention.png"))
106 +                                                                                               device_info += " - " + currentMountpoint
107 +                                                                                               device_info += " - " + notmounted_msg
108 +                                                                                       else:
109 +                                                                                               device_info += " - " + nomountpoint_msg
110                                                                                 else:
111                                                                                         device_info += " - " + unsupportetpart_msg
112                                                                         else:
113 @@ -963,7 +971,7 @@ class HarddiskDriveSelection(Screen, HelpableScreen):
114                                 self.session.openWithCallback(self.mainMenuClosed, HarddiskDriveSetup, device = hd, partition = partNum)
115                         else:
116                                 self.session.openWithCallback(self.mainMenuClosed, HarddiskDriveSetup, device = hd)
117 -               elif answer == "unmount":
118 +               elif answer in ("unmount", "eject"):
119                         self.confirmApplyAnswer(True, answer, selection)
120                 elif answer == "remove":
121                         if isinstance(selection[1], (basestring, str)):
122 @@ -1112,6 +1120,7 @@ class HarddiskDriveSelection(Screen, HelpableScreen):
123                         unmountmsg = (_("Unmount this %(desc)s.") % self.devicedescription, "unmount")
124                         removemsg = (_("Remove this %(desc)s configuration.") % self.devicedescription, "remove")
125                         initmsg = (_("Initialize this %(desc)s.") % self.devicedescription, "init")
126 +                       ejectmsg = (_("Eject."), "eject")
127  
128                         choices = [ ]
129                         if uuid_cfg is None: # uninitialized drive
130 @@ -1142,14 +1151,14 @@ class HarddiskDriveSelection(Screen, HelpableScreen):
131                         elif uuid_cfg is not None and uuid_cfg['enabled'].value: # configured drive
132                                 if selectedPart is not None and selectedPart.isInitialized:
133                                         if defaultStorageDevice() != uuid:
134 -                                               choices.extend([unmountmsg, defaultmsg, manualmsg])
135 +                                               choices.extend([unmountmsg, defaultmsg, manualmsg, ejectmsg])
136                                         elif defaultStorageDevice() == uuid:
137 -                                               choices.extend([unmountmsg, mountmsg, manualmsg])
138 +                                               choices.extend([unmountmsg, mountmsg, manualmsg, ejectmsg])
139                                 else:
140                                         if offline:
141                                                 choices.extend([removemsg])
142                                         else:
143 -                                               choices.extend([unmountmsg, manualmsg])
144 +                                               choices.extend([unmountmsg, manualmsg, ejectmsg])
145                         choices.append((_("Do nothing."), "nothing"))
146  
147                         if uuid_cfg is not None and not uuid_cfg['enabled'].value:
148 -- 
149 1.7.10.4
150