diff options
author | Adriana Kobylak <anoo@us.ibm.com> | 2020-03-18 18:08:00 +0300 |
---|---|---|
committer | Andrew Geissler <geissonator@yahoo.com> | 2020-03-30 23:03:39 +0300 |
commit | c33a02dc9699441aeaa88e2e8dc546667e05ad80 (patch) | |
tree | e9fd9aa9fb5f660918f50e58ccd6518b1a73d3a5 /poky | |
parent | 08e5948ba83ab7fd332bb5e794d7a4610aeba59d (diff) | |
download | openbmc-c33a02dc9699441aeaa88e2e8dc546667e05ad80.tar.xz |
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: e219f5175177a640dd62833082ea19adc1c13d42)
Signed-off-by: Kalle lampila <kalle.lampila@lempea.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Change-Id: I25a4c0c70f68a4801abf8f8ca2408aab14fc4b78
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
Diffstat (limited to 'poky')
-rw-r--r-- | poky/scripts/lib/wic/filemap.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/poky/scripts/lib/wic/filemap.py b/poky/scripts/lib/wic/filemap.py index a3919fbca..c53147c2f 100644 --- a/poky/scripts/lib/wic/filemap.py +++ b/poky/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()) |