From 95cf84a7a8aa4b1027084e1030bfbc5a8f571fe0 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 10 Aug 2009 14:38:08 +0200 Subject: booty: Do not strip the trailing p from a devicename like mapper/isw_Vol0_tmp While fixing bug 505205, I noticed that the code for removing the trailing p in a name like: mapper/isw_Vol0p1 which becomes mapper/isw_Vol0p after cutting is rather interesting, for example it will wrongly change the whole diskname mapper/isw_Vol0_tmp to mapper/isw_Vol0_tm. This patch fixes this by removing the trailing p as part of the partition cutting code instead of always removing it. --- booty/util.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/booty/util.py b/booty/util.py index 2b7973015..48c31945d 100644 --- a/booty/util.py +++ b/booty/util.py @@ -10,9 +10,9 @@ def getDiskPart(dev, storage): path.startswith('mapper/') or path.startswith('mmcblk') or path.startswith('md')): if dev[-2] == 'p': - cut = -1 - elif dev[-3] == 'p' and dev[-2] in string.digits: cut = -2 + elif dev[-3] == 'p' and dev[-2] in string.digits: + cut = -3 else: if dev[-2] in string.digits: cut = -2 @@ -21,15 +21,11 @@ def getDiskPart(dev, storage): name = dev[:cut] - # hack off the trailing 'p' from /dev/cciss/*, for example - if name[-1] == 'p': - for letter in name: - if letter not in string.letters and letter != "/": - name = name[:-1] - break - if cut < 0: - partNum = int(dev[cut:]) - 1 + part = dev[cut:] + if part[0] == 'p': + part = part[1:] + partNum = int(part) - 1 else: partNum = None -- cgit