bug-txsd4tdmn3 at kristof-koehler.de
2025-Dec-23 08:08 UTC
[klibc] mount: Error message in case of missing -t should identify the cause
Calling klibc's mount utility without specifying the filesystem type | mount /dev/sdb1 /mnt/ fails with the error message | Usage: mount [-r] [-w] [-o options] [-t type] [-f] [-i] [-n] device directory This message is a bit confusing, because that is exactly how I am calling mount. There is no indication that the program misses the filesystem type, instead the message seems to confirm that -t is optional. This stumped me for a while when debugging an initramfs problem. I'd suggest ... ... either changing to a multi-variant usage text such as | Usage: | mount [-r] [-w] [-o options] [-f] [-i] [-n] -t type device directory | mount -o bind|move|remount[,options] [-r] [-w] [-f] [-i] [-n] device directory to indicate when the type is mandatory, ... or splitting the argument check in https://git.kernel.org/pub/scm/libs/klibc/klibc.git/tree/usr/utils/mount_main.c?id=1d27e1732f1326eaf98f4624100f83232d843616#n151 in the following way: - not exactly two positional arguments -> show the normal usage message - two positional arguments, but type is NULL -> show a specific error message such as "missing -t type" or "filesystem type required, except for -o bind/move/remount" (Another course of action would be to actually make -t optional and, if unspecified, try the non-nodev filesystems from /proc/filesystems until one works - like busybox does.? However I understand that this is probably beyond the scope of klibc's minimalistic design.) Best regards, Kristof