]> code.ossystems Code Review - openembedded-core.git/commitdiff
wic/filemap: If FIGETBSZ iotctl fail, failback to os.stat
authorKalle Lampila <kalle.lampila@lempea.com>
Tue, 31 Dec 2019 15:10:49 +0000 (17:10 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 2 Jan 2020 16:39:04 +0000 (16:39 +0000)
Some file systems don't support fetching the block size (notably the
file system Docker uses for containers), so if iotctl() fail, try to use
failback via os.stat() to get block size.

Signed-off-by: Kalle lampila <kalle.lampila@lempea.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/lib/wic/filemap.py

index a3919fbcad8bd06a26f0ca6e9cc8f4f1260f489c..c53147c2f18e4fbd72505c0e407740fdfb8e2593 100644 (file)
@@ -34,9 +34,11 @@ def get_block_size(file_obj):
     # the FIGETBSZ ioctl (number 2).
     try:
         binary_data = fcntl.ioctl(file_obj, 2, struct.pack('I', 0))
+        bsize = struct.unpack('I', binary_data)[0]
     except OSError:
-        raise IOError("Unable to determine block size")
-    bsize = struct.unpack('I', binary_data)[0]
+        bsize = None
+
+    # If ioctl causes OSError or give bsize to zero failback to os.fstat
     if not bsize:
         import os
         stat = os.fstat(file_obj.fileno())