diff options
author | Dogukan Ergun <dogukan.ergun@gmail.com> | 2018-01-09 16:35:24 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-01-14 09:11:26 +0000 |
commit | d8f7cf2d38934c248be91101236f7537d0d31ea7 (patch) | |
tree | 3e5be1fb34bbc35f7f798bfc25ed12897689b6d9 /scripts/lib | |
parent | 9d82fffd24742a5eb40bcb9b9ecea01a42be0be6 (diff) | |
download | openembedded-core-contrib-d8f7cf2d38934c248be91101236f7537d0d31ea7.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
Signed-off-by: Dogukan Ergun <dogukan.ergun@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/wic/filemap.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/scripts/lib/wic/filemap.py b/scripts/lib/wic/filemap.py index 77e32b9addb..a72fa09ef55 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): """ |