40 Commits

Author SHA1 Message Date
Emil Velikov
0c4ebd45bd Remove unused errno.h include
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/368
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2025-06-11 08:03:26 -05:00
Emil Velikov
affec6677a tools/kmod: silence unused parameter warnings
kmod_help() does not use neither argc nor argv although due to the
dispatch mechanism they are part of the function signature.

Not much we can do here - silence the compiler warnings.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2025-06-11 07:54:40 -05:00
Emil Velikov
219be963e9 tools: move a few more symbols to data.rel.ro
Annotate the arrays (not the data) as constant, so the compiler can
store it in the RO segment.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/358
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2025-05-29 21:16:00 -05:00
Tobias Stoeckmann
3e33ca0881 kmod: use program_invocation_short_name more often
Remove the explicit basename(argv[0]) calls because we already
rely on program_invocation_short_name even before reaching
these lines. Unifies code and slightly reduces binary size.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/284
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2025-02-21 13:59:03 -06:00
Tobias Stoeckmann
38641ee477 tools: Unify help messages
Unify help messages shown when kmod is called without any arguments
to use the same grammar and capitalisation.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/265
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-12-04 11:35:22 -06:00
Emil Velikov
f34d115d09 tools: mass convert with clang-format
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-24 09:59:20 -05:00
Emil Velikov
b644b8d784 tools: add kmod_version() helper
Add a trivial helper that prints the version + features combo. I will be
adding another instance of those, so I'm aiming to keep the boilerplate
code to a minimum.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-21 10:53:12 -05:00
Tobias Stoeckmann
9bc8dfb173 kmod: Avoid negative exit codes
Exit codes shall be non-negative to comply with standards.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/124
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-10 23:36:09 -05:00
Emil Velikov
e0180cb0e4 tools: reformat and clang-format off arrays
For some arrays, clang-format does far than ideal jobs reformatting. Do
so manually and ban clang-format from interfering.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-08 23:39:19 -05:00
Emil Velikov
2b355954cb tools: add trailing comma for multi-line arrays
... otherwise the upcoming clang-format will try to fold them on single
line, making the end result far from ideal.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/114
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-07 10:13:51 -05:00
Lucas De Marchi
d4f659e12a Drop the one line short description on sources
Some are outdated, misleading or just repeat the same thing over and
over. Remove them as they are not needed.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://lore.kernel.org/r/20240723185921.1005569-3-lucas.de.marchi@gmail.com
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-26 13:41:56 -05:00
Lucas De Marchi
b5a2cd070d Use SPDX header for license
Drop the lengthy license from each file and just use SPDX like most
projects nowadays. This doesn't have any change to license, just how
they are recorded in each file.

This follows the kernel approach: header files use '/*' for comments
while .c files use '//'. For .m4, use "#".

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://lore.kernel.org/r/20240723185921.1005569-2-lucas.de.marchi@gmail.com
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-26 13:41:56 -05:00
Khem Raj
11eb9bc67c Use portable implementation for basename API
musl has removed the non-prototype declaration of basename from
string.h [1] which now results in build errors with clang-17+ compiler

Implement GNU basename behavior using strchr which is portable across libcs

Fixes
../git/tools/kmod.c:71:19: error: call to undeclared function 'basename'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
71 | "Commands:\n", basename(argv[0]));
| ^

[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7

Suggested-by: Rich Felker

Signed-off-by: Khem Raj <raj.khem@gmail.com>
[ Implement a basename() function in missing.h and ensure we always use
  the right include rather than having a separate gnu_basename() ]
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-06-10 18:15:39 -05:00
Emil Velikov
dc2440ee31 Remove unmaintained experimental tools
The kmod insert/remove tools were introduced back in 2015. Since then
they have recieved zero attention, unlike the insmod/rmmod variants.

Glancing around - neither of the following distributions (Arch, Fedora,
Gentoo, Debian) build them, so we're safe to say they have no users.

Remove them and alongside it the --enable-experimental toggle, which no
longer controls anything.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://lore.kernel.org/r/20240212-rm-experimental-v1-1-b97ab3004ae3@gmail.com
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-02-20 16:10:55 -06:00
Lucas De Marchi
655de2751d tools: display features in --version
Reviewed-by: Andreas Mohr <andim2@users.sf.net>
2015-06-08 22:38:02 -03:00
Lucas De Marchi
b1499094c6 tools: add PACKAGE definition in message
Reported-by: Andreas Mohr <andim2@users.sf.net>
2015-06-08 21:33:06 -03:00
Lucas De Marchi
013e855043 tools: Hide new commands behind experimental flag
Hide the commands behind a flag so we can continue doing releases while
the commands aren't ready.
2015-06-06 23:26:31 -03:00
Caio Marcelo de Oliveira Filho
037618816c tools: add basic versions of insert and remove 2015-03-07 12:09:51 -03:00
Lucas De Marchi
7db094c050 tools: kmod: use streq 2015-01-14 12:35:04 -02:00
Caio Marcelo de Oliveira Filho
ace71985fc tools: kmod: break iteration once a command is executed 2015-01-14 12:24:31 -02:00
Lucas De Marchi
f357866d97 Fix includes after change to build-sys
Make the includes be libkmod/libkmod.h for code outside of library. This
fixes the broken build after 1315123 ('build-sys: Don't add libkmod
subdirectory to include path').
2015-01-02 12:41:01 -02:00
Lucas De Marchi
c2e4286bb9 Reorder and reorganize header files
Let the includes in the following order:

< system headers >
< libkmod >
< tool >
< local headers >
2014-10-03 01:43:15 -03:00
Tom Gundersen
db6f2fc7e1 tools: add static-nodes tool
This tool reads modules.devname from the current kernel directory and outputs
the information. By default in a human-readable format, and optionally in
machine-readable formats.

For now only the tmpfiles.d(5) format is supported, but more could easily be
added in the future if there is a need.

This means nothing but kmod needs to reads the private files under
/lib/modules/. In particular systemd-udevd can stop reading modules.devname.

Tools that used to read /lib/modules/`uname -r`/modules.devname directly, can
now move to reading 'kmod static-nodes devname'.
2013-04-16 23:10:36 -03:00
Lucas De Marchi
e6b0e49b4e Update copyright notices 2013-01-16 11:27:45 -02:00
Lucas De Marchi
7c04aeee40 tools: use program_invocation_short_name provided by libc
Thanks to Dave Reisner for pointing this out.
2012-11-06 19:30:16 -02:00
Lucas De Marchi
4a2e20dfb3 tools: share getting program name from argv for all tools 2012-11-06 16:55:00 -02:00
Lucas De Marchi
a66a6a999f Update copyright 2012-01-09 00:41:07 -02:00
Lucas De Marchi
f6cf14ce13 tools: kmod: bundle depmod together with the others 2011-12-27 19:56:33 -02:00
Leandro Pereira
4783d69e48 kmod tool: don't keep iterating when command has been executed 2011-12-27 19:46:44 -02:00
Lucas De Marchi
9b966da87e tools: kmod: show wrong command in err message 2011-12-23 11:44:28 -02:00
Lucas De Marchi
a458e36738 tools: kmod: print help message when no commands given 2011-12-23 11:35:48 -02:00
Lucas De Marchi
252c51a996 tools: kmod: add list command
It's the same of lsmod since there's not much to change on its format.
2011-12-23 11:33:02 -02:00
Lucas De Marchi
fa29c0ee96 tools: kmod: Add handling of compat modprobe 2011-12-23 03:09:05 -02:00
Lucas De Marchi
769becb5db tools: kmod: Add handling of compat modinfo 2011-12-23 03:09:05 -02:00
Lucas De Marchi
ad6026965f tools: kmod: Add handling of compat insmod 2011-12-23 03:09:05 -02:00
Lucas De Marchi
f712ebc429 tools: kmod: Add handling of compat rmmod 2011-12-23 03:09:05 -02:00
Lucas De Marchi
6fcf69e62b tools: kmod: Add handling of compat lsmod 2011-12-23 03:09:05 -02:00
Lucas De Marchi
35a29aa519 tools: kmod: check progname for handling compat commands 2011-12-23 03:09:05 -02:00
Lucas De Marchi
bc85432aa3 tools: kmod: Add global options 2011-12-23 03:03:23 -02:00
Lucas De Marchi
8900b9166b tools: add skeleton of kmod tool
If using libtool 2.4.2, running the script generated by libtool will not
work because libtool changes argv[0] to lt-progname.

To test this is necessary to either fix the installed
build-aux/ltmain.sh file or run the binary directly like in:

$ export LD_LIBRARY_PATH=$PWD/libkmod/.libs/
$ ./tools/.libs/kmod help
2011-12-23 03:01:58 -02:00