[oe-commits] [openembedded-core] 09/20: wic: if we can't get from ioctl, try from os.stat()

git at git.openembedded.org git at git.openembedded.org
Sat Jan 13 18:12:45 UTC 2018


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

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

commit 1e0954a49e401df9657bdc0ae20a30b8943e36d8
Author: Dogukan Ergun <dogukan.ergun at gmail.com>
AuthorDate: Tue Jan 9 16:35:24 2018 +0300

    wic: if we can't get from ioctl, try from os.stat()
    
    Under some conditions, ioctl FIGETBSZ can't return real value.
    We can try to use fallback via os.stat() to get block size.
    
    Source of patch:
    https://github.com/intel/bmap-tools/commit/17365f4fe9089df7ee9800a2a0ced177ec4798a4
    
    Signed-off-by: Dogukan Ergun <dogukan.ergun at gmail.com>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 scripts/lib/wic/filemap.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/wic/filemap.py b/scripts/lib/wic/filemap.py
index 77e32b9..a72fa09 100644
--- a/scripts/lib/wic/filemap.py
+++ b/scripts/lib/wic/filemap.py
@@ -37,7 +37,15 @@ 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))
-    return struct.unpack('I', binary_data)[0]
+    bsize = struct.unpack('I', binary_data)[0]
+    if not bsize:
+        import os
+        stat = os.fstat(file_obj.fileno())
+        if hasattr(stat, 'st_blksize'):
+            bsize = stat.st_blksize
+        else:
+            raise IOError("Unable to determine block size")
+    return bsize
 
 class ErrorNotSupp(Exception):
     """

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


More information about the Openembedded-commits mailing list