Restore LOOP_CONFIGURE fallback for kernel < 5.8
The fallback that was initially present in #1253 is needed for the current GitLab runners which have a Container-Optimized OS [1] with kernel 5.4 [2] without support for LOOP_CONFIGURE [3]. [1] https://docs.gitlab.com/ee/ci/runners/saas/linux_saas_runner.html [2] https://gitlab.com/cki-project/containers/-/jobs/4381560305#L31 [3] https://gitlab.com/cki-project/containers/-/jobs/4381560305#L1166 Signed-off-by: Michael Hofmann <mhofmann@redhat.com>
This commit is contained in:
parent
4bfd646b0d
commit
840df1dc92
1 changed files with 8 additions and 1 deletions
|
|
@ -381,6 +381,7 @@ class Loop:
|
||||||
Bind and configure in a single operation a file descriptor to the
|
Bind and configure in a single operation a file descriptor to the
|
||||||
loopback device.
|
loopback device.
|
||||||
Only supported for kenel >= 5.8
|
Only supported for kenel >= 5.8
|
||||||
|
Will fall back to set_fd/set_status otherwise.
|
||||||
|
|
||||||
The loopback device must be unbound. The backing file must be
|
The loopback device must be unbound. The backing file must be
|
||||||
either a regular file or a block device. If the backing file is
|
either a regular file or a block device. If the backing file is
|
||||||
|
|
@ -430,7 +431,13 @@ class Loop:
|
||||||
# Keep same behavior here by setting the value to 0.
|
# Keep same behavior here by setting the value to 0.
|
||||||
config.block_size = 0
|
config.block_size = 0
|
||||||
config.info = self._config_info(LoopInfo(), offset, sizelimit, autoclear, partscan)
|
config.info = self._config_info(LoopInfo(), offset, sizelimit, autoclear, partscan)
|
||||||
fcntl.ioctl(self.fd, self.LOOP_CONFIGURE, config)
|
try:
|
||||||
|
fcntl.ioctl(self.fd, self.LOOP_CONFIGURE, config)
|
||||||
|
except OSError as e:
|
||||||
|
if e.errno != errno.EINVAL:
|
||||||
|
raise
|
||||||
|
fcntl.ioctl(self.fd, self.LOOP_SET_FD, config.fd)
|
||||||
|
fcntl.ioctl(self.fd, self.LOOP_SET_STATUS64, config.info)
|
||||||
|
|
||||||
def get_status(self) -> LoopInfo:
|
def get_status(self) -> LoopInfo:
|
||||||
"""Get properties of the loopback device
|
"""Get properties of the loopback device
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue