Merge pull request #148 from kinvolk/t-lo/disk-util-use-bytearray

build_library/disk_util: use byte array for conversion, not chr()
This commit is contained in:
Thilo Fromm 2021-08-30 09:16:16 +02:00 committed by GitHub
commit 1570708e40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -711,9 +711,9 @@ def Tune2fsReadWrite(options, partition, disable_rw):
# offset of ro_compat, highest order byte (le 32 bit field)
flag_offset = 0x464 + 3
flag_value = 0xff if disable_rw else 0x00
with open(options.disk_image, 'r+') as image:
with open(options.disk_image, 'br+') as image:
image.seek(partition['first_byte'] + flag_offset)
image.write(chr(flag_value))
image.write(bytes([flag_value]))
def IsE2fsReadWrite(options, partition):