]> git.ipfire.org Git - thirdparty/util-linux.git/commit
losetup: use LOOP_CONFIGURE in a more robust way
authorKarel Zak <kzak@redhat.com>
Wed, 28 Jul 2021 09:05:36 +0000 (11:05 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 29 Jul 2021 09:57:17 +0000 (11:57 +0200)
commit4f2406545c86d27194046f40b0c05903d2c754d0
treefe508279b09d280a7b2b5b0a0111f83e8ea7a9f1
parent31bb5886639df1e3307ffa11255dea2fa3e1bd63
losetup: use LOOP_CONFIGURE in a more robust way

32-bit userspace returns ENOTTY:
 ioctl(4, LOOP_CONFIGURE, {fd=3, block_size=0, info={lo_offset=0, lo_number=0, lo_flags=LO_FLAGS_AUTOCLEAR, lo_file_name="/usr/install/iso/systemrescue-8.04-amd64.iso", ...}}) = -1 ENOTTY (Inappropriate ioctl for device)

64-bit userspace returns EINVAL:
 ioctl(4, LOOP_CONFIGURE, {fd=3, block_size=0, info={lo_offset=0, lo_number=0, lo_flags=LO_FLAGS_AUTOCLEAR, lo_file_name="/usr/src/PACKAGES/systemrescue-8.04-amd64.iso", ...}}) = -1 EINVAL (Invalid argument)

The correct return value for an unknown ioctl is ENOTTY, but we need
to support already released kernels, so let's support both errnos.

Reported-by: Krzysztof Olędzki <ole@ans.pl>
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/loopdev.c