From: Artem Bityutskiy Date: Thu, 21 Feb 2013 11:28:40 +0000 (+0200) Subject: BmapCopy: fix writitng to a dm-zero device X-Git-Tag: v2.5~60 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=63e53c369731d4bf36d0d6a854cf9748f957585f;p=tools%2Fbmap-tools.git BmapCopy: fix writitng to a dm-zero device Dm-zero devices expose "none" in their '/sys/block//queue/scheduler' file and there is no current scheduler. Our code was assuming there is always the current scheduler in brackets (e.g., "noop deadline [cfq]"), which lead to a crash when writing to a dm-zero device: Traceback (most recent call last): File "./bmaptool", line 389, in sys.exit(main()) File "./bmaptool", line 373, in main args.func(args, log) File "./bmaptool", line 192, in copy_command writer.copy(False, not args.no_verify) File "/mnt/bigssd/dedekind/work/tizen/tools/git/bmap-tools/bmaptools/BmapCopy.py", line 578, in copy self._tune_block_device() File "/mnt/bigssd/dedekind/work/tizen/tools/git/bmap-tools/bmaptools/BmapCopy.py", line 535, in _tune_block_device self._old_scheduler_value = match.group(1) AttributeError: 'NoneType' object has no attribute 'group' This patch fixes the crash. Signed-off-by: Artem Bityutskiy Change-Id: Ic13f4f69ee859244e5413d4b0b890d6c599becae --- diff --git a/bmaptools/BmapCopy.py b/bmaptools/BmapCopy.py index 7082287..580d318 100644 --- a/bmaptools/BmapCopy.py +++ b/bmaptools/BmapCopy.py @@ -531,7 +531,8 @@ class BmapBdevCopy(BmapCopy): import re match = re.match(r'.*\[(.+)\].*', contents) - self._old_scheduler_value = match.group(1) + if match: + self._old_scheduler_value = match.group(1) # Limit the write buffering try: