mirror of
https://git.yoctoproject.org/poky
synced 2026-04-13 14:02:21 +02:00
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:
17365f4fe9
(From OE-Core rev: d8f7cf2d38934c248be91101236f7537d0d31ea7)
(From OE-Core rev: 4f528a93352c6301d57a9aaeb082d0cc313d91c3)
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>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
9ed1178c87
commit
53d5f01d2d
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user