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>
This commit is contained in:
parent
31bb588663
commit
4f2406545c
|
@ -1360,7 +1360,7 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
|
|||
if (ioctl(dev_fd, LOOP_CONFIGURE, &lc->config) < 0) {
|
||||
rc = -errno;
|
||||
errsv = errno;
|
||||
if (errno != EINVAL) {
|
||||
if (errno != EINVAL && errno != ENOTTY) {
|
||||
DBG(SETUP, ul_debugobj(lc, "LOOP_CONFIGURE failed: %m"));
|
||||
goto err;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue