From 0770eb0090a7ad04bb2f5bca938be3453f71fe6e Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Tue, 21 Nov 2023 17:18:22 -0500 Subject: [PATCH] devices/loopback: make setting sector_size meaningful For the org.osbuild.loopback the user can set the sector size, but it had no effect on the underlying loopback device. Let's make it meaningful by passing along the given value to the underlying code. --- devices/org.osbuild.loopback | 1 + osbuild/loop.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/devices/org.osbuild.loopback b/devices/org.osbuild.loopback index cc104391..0b6591d0 100755 --- a/devices/org.osbuild.loopback +++ b/devices/org.osbuild.loopback @@ -82,6 +82,7 @@ class LoopbackService(devices.DeviceService): setup=self.setup_loop, offset=offset, sizelimit=sizelimit, + blocksize=self.sector_size, partscan=False, autoclear=True) diff --git a/osbuild/loop.py b/osbuild/loop.py index 675ea510..7f602191 100644 --- a/osbuild/loop.py +++ b/osbuild/loop.py @@ -385,7 +385,7 @@ class Loop: info = self._config_info(self.get_status(), offset, sizelimit, autoclear, partscan) fcntl.ioctl(self.fd, self.LOOP_SET_STATUS64, info) - def configure(self, fd: int, offset=None, sizelimit=None, autoclear=None, partscan=None): + def configure(self, fd: int, offset=None, sizelimit=None, blocksize=0, autoclear=None, partscan=None): """ Configure the loopback device Bind and configure in a single operation a file descriptor to the @@ -427,6 +427,8 @@ class Loop: sizelimit : int, optional The max size in bytes to make the loopback device, or None to leave unchanged (default is None) + blocksize : int, optional + Set the logical blocksize of the loopback device. Default is 0. autoclear : bool, optional Whether or not to enable autoclear, or None to leave unchanged (default is None) @@ -437,9 +439,7 @@ class Loop: # pylint: disable=attribute-defined-outside-init config = LoopConfig() config.fd = fd - # Previous implementation was not configuring the block size. - # Keep same behavior here by setting the value to 0. - config.block_size = 0 + config.block_size = int(blocksize) config.info = self._config_info(LoopInfo(), offset, sizelimit, autoclear, partscan) try: fcntl.ioctl(self.fd, self.LOOP_CONFIGURE, config)