From 8963bae9922462d21c94cea18d1e257caefe1683 Mon Sep 17 00:00:00 2001 From: hschang Date: Fri, 10 Oct 2014 19:48:03 +0900 Subject: [PATCH] [DeviceManager] fix checkSwapExtended (use parted instead of fdisk). --- .../Plugins/SystemPlugins/DeviceManager/plugin.py | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/python/Plugins/SystemPlugins/DeviceManager/plugin.py b/lib/python/Plugins/SystemPlugins/DeviceManager/plugin.py index c83d161..6d5860f 100755 --- a/lib/python/Plugins/SystemPlugins/DeviceManager/plugin.py +++ b/lib/python/Plugins/SystemPlugins/DeviceManager/plugin.py @@ -1312,27 +1312,27 @@ class DeviceInfo(): if not x.startswith('/'): continue _devPart, _mountpoint = x.split()[:2] - if devPart == _devPart: + if devpath == _devPart: return True except: pass return False - # check partition ID in extended or swap. + # check partition type is extended or swap. def checkSwapExtended(self, partition): - partID_Extended = ("5", "0f", "85", "c5", "d5") - partID_swap = ("82", "42") - data = os.popen("fdisk -l /dev/%s |grep %s" % (partition[:-1], partition )).readline().split() - if data[1] == '*': - partID = str(data[5]) - else: - partID = str(data[4]) -# print "partID: " ,partID -# print "checkIDS : ", partID_Extended + partID_swap - if partID in partID_Extended + partID_swap: - return True - else: - return False + blockName = partition[:-1] + partNum = partition[-1] + data = os.popen("parted /dev/%s print" % blockName).readlines() + for x in data: + info = x.strip().split() + + if len(info) > 0 and info[0] == str(partNum): + if len(info) >= 5 and info[4].find('extended') != -1: # check Type is extended + return True + elif len(info) >= 6 and info[5].find('swap') != -1: # check File System is swap + return True + + return False def isMountable(self, partition): if self.checkSwapExtended(partition): -- 2.7.4