summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorKalle Lampila <kalle.lampila@lempea.com>2019-12-31 17:10:49 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-01-28 11:51:03 +0000
commit88448accde35fc6ffd39091617acb904cfbae6d1 (patch)
tree3b2968319ac12084e0376605eea8c2079cd4cdf9 /scripts
parent297debd5ea610aeffe4fe099fee893063115e437 (diff)
downloadpoky-88448accde35fc6ffd39091617acb904cfbae6d1.tar.gz
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. (From OE-Core rev: 996013b4e5d3cd1c054e87539ac1a8d95581a87f) Signed-off-by: Kalle lampila <kalle.lampila@lempea.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit e219f5175177a640dd62833082ea19adc1c13d42) Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/wic/filemap.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/scripts/lib/wic/filemap.py b/scripts/lib/wic/filemap.py
index a3919fbcad..c53147c2f1 100644
--- a/scripts/lib/wic/filemap.py
+++ b/scripts/lib/wic/filemap.py
@@ -34,9 +34,11 @@ def get_block_size(file_obj):
34 # the FIGETBSZ ioctl (number 2). 34 # the FIGETBSZ ioctl (number 2).
35 try: 35 try:
36 binary_data = fcntl.ioctl(file_obj, 2, struct.pack('I', 0)) 36 binary_data = fcntl.ioctl(file_obj, 2, struct.pack('I', 0))
37 bsize = struct.unpack('I', binary_data)[0]
37 except OSError: 38 except OSError:
38 raise IOError("Unable to determine block size") 39 bsize = None
39 bsize = struct.unpack('I', binary_data)[0] 40
41 # If ioctl causes OSError or give bsize to zero failback to os.fstat
40 if not bsize: 42 if not bsize:
41 import os 43 import os
42 stat = os.fstat(file_obj.fileno()) 44 stat = os.fstat(file_obj.fileno())