summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic
diff options
context:
space:
mode:
authorDogukan Ergun <dogukan.ergun@gmail.com>2018-01-09 16:35:24 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-01-14 09:11:57 +0000
commitbab3b2e9390d632a190bb96fa161bd5554a72948 (patch)
treee4dae68f8d0ded869b5b1e016df5bd6ee54fe192 /scripts/lib/wic
parentef4caecccbce546734e0ccf62f560f77076586d2 (diff)
downloadpoky-bab3b2e9390d632a190bb96fa161bd5554a72948.tar.gz
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 (From OE-Core rev: d8f7cf2d38934c248be91101236f7537d0d31ea7) Signed-off-by: Dogukan Ergun <dogukan.ergun@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic')
-rw-r--r--scripts/lib/wic/filemap.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/scripts/lib/wic/filemap.py b/scripts/lib/wic/filemap.py
index 77e32b9add..a72fa09ef5 100644
--- a/scripts/lib/wic/filemap.py
+++ b/scripts/lib/wic/filemap.py
@@ -37,7 +37,15 @@ def get_block_size(file_obj):
37 # Get the block size of the host file-system for the image file by calling 37 # Get the block size of the host file-system for the image file by calling
38 # the FIGETBSZ ioctl (number 2). 38 # the FIGETBSZ ioctl (number 2).
39 binary_data = fcntl.ioctl(file_obj, 2, struct.pack('I', 0)) 39 binary_data = fcntl.ioctl(file_obj, 2, struct.pack('I', 0))
40 return struct.unpack('I', binary_data)[0] 40 bsize = struct.unpack('I', binary_data)[0]
41 if not bsize:
42 import os
43 stat = os.fstat(file_obj.fileno())
44 if hasattr(stat, 'st_blksize'):
45 bsize = stat.st_blksize
46 else:
47 raise IOError("Unable to determine block size")
48 return bsize
41 49
42class ErrorNotSupp(Exception): 50class ErrorNotSupp(Exception):
43 """ 51 """