summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDohyung Kim <dohyung2.kim@samsung.com>2015-07-06 21:34:30 +0900
committerXiao Jin <jin.xiao@samsung.com>2018-03-29 22:29:24 +0800
commite9f91bbebe66b316ba80b71fdb2be000bbdc68e4 (patch)
tree782cf51581775c02641af4965335c8ba1bec4b26
parentdd404ed2260c89d758f485144396bfbccb98684b (diff)
downloadmic-e9f91bbebe66b316ba80b71fdb2be000bbdc68e4.tar.gz
mic-e9f91bbebe66b316ba80b71fdb2be000bbdc68e4.tar.bz2
mic-e9f91bbebe66b316ba80b71fdb2be000bbdc68e4.zip
fix invalid ExtDiskMount.blocksize when "-b [BLOCKSIZE]" extoption is passed
To set blocksize by parsing "-b [BLOCKSIZE]" from extoptions in ks file Change-Id: I0328cdae59a3466bde4d9a3bccb22026118544a1 Signed-off-by: Dohyung Kim <dohyung2.kim@samsung.com>
-rwxr-xr-xmic/utils/fs_related.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/mic/utils/fs_related.py b/mic/utils/fs_related.py
index 9be1a10..ce3d214 100755
--- a/mic/utils/fs_related.py
+++ b/mic/utils/fs_related.py
@@ -18,6 +18,7 @@
from __future__ import with_statement
import os
+import re
import sys
import errno
import stat
@@ -362,7 +363,7 @@ class SparseLoopbackDisk(LoopbackDisk):
self.expand(create = True)
LoopbackDisk.create(self)
-class Mount:
+class Mount(object):
"""A generic base class to deal with mounting things."""
def __init__(self, mountdir):
self.mountdir = mountdir
@@ -454,10 +455,25 @@ class ExtDiskMount(DiskMount):
self.uuid = fsuuid or str(uuid.uuid4())
self.skipformat = skipformat
self.fsopts = fsopts
- self.extopts = None
+ self.__extopts = None
self.dumpe2fs = find_binary_path("dumpe2fs")
self.tune2fs = find_binary_path("tune2fs")
+ def __get_extopts(self):
+ return self.__extopts
+
+ def __set_extopts(self, val):
+ if val is None:
+ self.__extopts = None
+ else:
+ m = re.search(r'-b\s*(?P<blocksize>\d+)', val)
+ if m:
+ self.blocksize = int(m.group('blocksize'))
+ val = val.replace(m.group(), '')
+ self.__extopts = val
+
+ extopts = property(__get_extopts, __set_extopts)
+
def __parse_field(self, output, field):
for line in output.split("\n"):
if line.startswith(field + ":"):
@@ -473,8 +489,8 @@ class ExtDiskMount(DiskMount):
msger.verbose("Formating %s filesystem on %s" % (self.fstype, self.disk.device))
cmdlist = [self.mkfscmd, "-F", "-L", self.fslabel, "-m", "1", "-b",
str(self.blocksize), "-U", self.uuid]
- if self.extopts:
- cmdlist.extend(self.extopts.split())
+ if self.__extopts:
+ cmdlist.extend(self.__extopts.split())
cmdlist.extend([self.disk.device])
rc, errout = runner.runtool(cmdlist, catch=2)
@@ -482,7 +498,7 @@ class ExtDiskMount(DiskMount):
raise MountError("Error creating %s filesystem on disk %s:\n%s" %
(self.fstype, self.disk.device, errout))
- if not self.extopts:
+ if not self.__extopts:
msger.debug("Tuning filesystem on %s" % self.disk.device)
runner.show([self.tune2fs, "-c0", "-i0", "-Odir_index", "-ouser_xattr,acl", self.disk.device])