Filemap: simplify the FIEMAP failure error path
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Thu, 16 Jan 2014 11:45:35 +0000 (13:45 +0200)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Thu, 16 Jan 2014 11:45:35 +0000 (13:45 +0200)
Simplify the FIEMAP ioctl error handling by removing the 'looks like your
kernel does not support FIEMAP' note. I've recently got a bug report from the
field where people hit this error, and that line not was not actually appended
to the error message because the error code was something like ENOTSUPP. And
the error was anyway very clear and readable.

So let's just remove that part and simplify the code.

Change-Id: Ib098c814d70980bdcb60402eafd213c08f8c9dbd
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
bmaptools/Filemap.py

index 4dcb0cb8e7ba9d3121d3ddc51ef29a423ceb1ff1..6375a5ea0b812be5e59a950ab557ce805ee5b0e8 100644 (file)
@@ -158,13 +158,10 @@ class Fiemap:
         try:
             fcntl.ioctl(self._f_image, _FIEMAP_IOCTL, self._buf, 1)
         except IOError as err:
-            error_msg = "the FIEMAP ioctl failed for '%s': %s" \
-                        % (self._image_path, err)
-            if err.errno == os.errno.EPERM or err.errno == os.errno.EACCES:
-                # The FIEMAP ioctl was added in kernel version 2.6.28 in 2008
-                error_msg += " (looks like your kernel does not support FIEMAP)"
-
-            raise Error(error_msg)
+            # Note, the FIEMAP ioctl is supported by the Linux kernel starting
+            # from version 2.6.28 (year 2008).
+            raise Error("the FIEMAP ioctl failed for '%s': %s"
+                        % (self._image_path, err))
 
         return struct.unpack(_FIEMAP_FORMAT, self._buf[:_FIEMAP_SIZE])