Skip to content

Commit fd394bc

Browse files
codewizreinauer
authored andcommitted
fuse_fs: Fix partition size check for block devices
os.path.getsize() returns 0 for block devices like /dev/sda4, causing a spurious "image appears to be truncated" error. Use the size already computed by ImageFile.open(), which correctly handles block devices via ioctl.
1 parent 7edd50f commit fd394bc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

amifuse/fuse_fs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def __init__(
137137
dos_env = boot["part"].part_blk.dos_env
138138
blk_per_cyl = dos_env.surfaces * dos_env.blk_per_trk
139139
part_end_byte = (dos_env.high_cyl + 1) * blk_per_cyl * self.backend.block_size
140-
image_size = os.path.getsize(str(image))
140+
image_size = self.backend.blkdev.img_file.size
141141
if part_end_byte > image_size:
142142
part_start_byte = dos_env.low_cyl * blk_per_cyl * self.backend.block_size
143143
part_name = partition or f"#{boot['part'].num}"

0 commit comments

Comments
 (0)