]> code.ossystems Code Review - openembedded-core.git/commitdiff
wic/filemap: handle FIGETBSZ failing
authorRoss Burton <ross.burton@intel.com>
Fri, 7 Jun 2019 11:05:02 +0000 (12:05 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 8 Jun 2019 15:01:36 +0000 (16:01 +0100)
Some file systems don't support fetching the block size (notably the file system
Docker uses for containers), so handle the iotctl() failing and raise the
expected error.

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/lib/wic/filemap.py

index 244c07a71cf7768195268fdb5dcd462232c8bf02..a3919fbcad8bd06a26f0ca6e9cc8f4f1260f489c 100644 (file)
@@ -32,7 +32,10 @@ def get_block_size(file_obj):
     """
     # Get the block size of the host file-system for the image file by calling
     # the FIGETBSZ ioctl (number 2).
-    binary_data = fcntl.ioctl(file_obj, 2, struct.pack('I', 0))
+    try:
+        binary_data = fcntl.ioctl(file_obj, 2, struct.pack('I', 0))
+    except OSError:
+        raise IOError("Unable to determine block size")
     bsize = struct.unpack('I', binary_data)[0]
     if not bsize:
         import os