busybox/libbb
Wouter Franken 4e82d99460 libbb/loop: fix existence check for LOOP_CONFIGURE ioctl
The LOOP_CONFIGURE ioctl is supported in 5.8 kernels and up. To have
backwards compatibility there is a config option CONFIG_TRY_LOOP_CONFIGURE
that will check if the ioctl exists and if not fall back to old way of
configuring loop devices.

Normally errno will be set to EINVAL when this ioctl does not exist.
However, when kernel config CONFIG_COMPAT is enabled, then compat_ioctl
is called. In that case -ENOIOCTLCMD is returned by loop device driver
and generic ioctl wrapper will set errno to ENOTTY. Because busybox
does not expect this it will fail to mount loop devices in this case.

This patch fixes the check for the existence of the ioctl LOOP_CONFIGURE
by checking if errno is one of both: EINVAL or ENOTTY.

function                                             old     new   delta
set_loop                                             809     821     +12

Signed-off-by: Wouter Franken <wouter.franken_ext@softathome.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-26 05:43:17 +01:00
..
yescrypt
alloc_affinity.c
appletlib.c
ask_confirmation.c
auto_string.c
bb_askpass.c
bb_bswap_64.c
bb_cat.c
bb_do_delay.c
bb_getgroups.c
bb_getsockname.c
bb_pwd.c
bb_qsort.c
bb_strtod.c
bb_strtonum.c
bbunit.c
bitops.c
c_escape.c
capability.c
change_identity.c
chomp.c
common_bufsiz.c
compare_string_array.c
concat_path_file.c
concat_subpath_file.c
Config.src
const_hack.c
copy_file.c
copyfd.c
correct_password.c
crc32.c
default_error_retval.c
device_open.c
die_if_bad_username.c
dump.c
duration.c
endofname.c
executable.c
fclose_nonstdin.c
fflush_stdout_and_exit.c
fgets_str.c
find_mount_point.c
find_pid_by_name.c
find_root_device.c
full_write.c
get_console.c
get_cpu_count.c
get_last_path_component.c
get_line_from_file.c
get_shell_name.c
get_volsize.c
getopt32.c
getopt_allopts.c
getpty.c
hash_hmac.c
hash_md5_sha.c
hash_md5prime.c
hash_sha1_hwaccel_x86-32.S
hash_sha1_hwaccel_x86-64.S
hash_sha1_x86-64.S
hash_sha1_x86-64.S.sh
hash_sha256_block.c
hash_sha256_hwaccel_x86-32.S
hash_sha256_hwaccel_x86-64.S
herror_msg.c
human_readable.c
in_ether.c
inet_cksum.c
inet_common.c
inode_hash.c
isdirectory.c
isqrt.c
iterate_on_dir.c
Kbuild.src
kernel_version.c
last_char_is.c
lineedit.c
lineedit_ptr_hack.c
llist.c
logenv.c
login.c
loop.c
make_directory.c
makedev.c
match_fstype.c
messages.c
missing_syscalls.c
mode_string.c
mtab.c
nuke_str.c
obscure.c
parse_config.c
parse_mode.c
percent_decode.c
perror_msg.c
perror_nomsg.c
perror_nomsg_and_die.c
pidfile.c
platform.c
poll_with_signals.c
popcnt.c
print_flags.c
print_numbered_lines.c
printable.c
printable_string.c
process_escape_sequence.c
procps.c
progress.c
ptr_to_globals.c
pw_ascii64.c
pw_encrypt.c
pw_encrypt_des.c
pw_encrypt_md5.c
pw_encrypt_sha.c
pw_encrypt_yes.c
read.c
read_key.c
read_printf.c
README
recursive_action.c
remove_file.c
replace.c
rtc.c
run_shell.c
safe_gethostname.c
safe_poll.c
safe_strncpy.c
safe_write.c
securetty.c
selinux_common.c
setup_environment.c
signals.c
simplify_path.c
single_argv.c
skip_whitespace.c
speed_table.c
str_tolower.c
strrstr.c
sysconf.c
time.c
trim.c
u_signal_names.c
ubi.c
udp_io.c
unicode.c
update_passwd.c
utmp.c
uuencode.c
verror_msg.c
vfork_daemon_rexec.c
warn_ignoring_args.c
wfopen.c
wfopen_input.c
write.c
xatonum.c
xatonum_template.c
xconnect.c
xfunc_die.c
xfuncs.c
xfuncs_printf.c
xgetcwd.c
xgethostbyname.c
xreadlink.c
xrealloc_vector.c
xregcomp.c

Please see the LICENSE file for copyright information (GPLv2)

libbb is BusyBox's utility library.  All of this stuff used to be stuffed into
a single file named utility.c.  When I split utility.c to create libbb, some of
the very oldest stuff ended up without their original copyright and licensing
information (which is now lost in the mists of time).  If you see something
that you wrote that is mis-attributed, do let me know so we can fix that up.

	Erik Andersen
	<andersen@codepoet.org>