[oe-commits] [openembedded-core] 06/09: wic/filemap: If FIGETBSZ iotctl fail, failback to os.stat

git at git.openembedded.org git at git.openembedded.org
Thu Jan 2 16:40:48 UTC 2020


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master
in repository openembedded-core.

commit e219f5175177a640dd62833082ea19adc1c13d42
Author: Kalle Lampila <kalle.lampila at lempea.com>
AuthorDate: Tue Dec 31 17:10:49 2019 +0200

    wic/filemap: If FIGETBSZ iotctl fail, failback to os.stat
    
    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 at lempea.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 scripts/lib/wic/filemap.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/wic/filemap.py b/scripts/lib/wic/filemap.py
index a3919fb..c53147c 100644
--- a/scripts/lib/wic/filemap.py
+++ b/scripts/lib/wic/filemap.py
@@ -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())

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list