[Buildroot] [PATCH v3 5/5] package/initscripts: add service to load kernel modules at boot
Peter Korsgaard
peter at korsgaard.com
Sun Sep 18 10:10:45 UTC 2022
>>>>> "Angelo" == Angelo Compagnucci <angelo at amarulasolutions.com> writes:
> In cases where no hotplug is available (by choice or by the lack of a
> proper hotplug method for a device), this service can be used to load
> kernel module drivers by reading the /etc/modules file.
> The modules files matches the one used by systemd, which in turn has
> a builtin mechanism to load a module at boot, therefore making systemv
> init on par with systemd features.
> Signed-off-by: Angelo Compagnucci <angelo at amarulasolutions.com>
> ---
> Changes
> v2:
> * Moved script to initscripts (Arnout)
> * Moved script to S11modules, after S10[mu]dev (Andreas)
> * Use /etc/modules-load.d/ to share the same setup with systemd (me)
> package/initscripts/init.d/S11modules | 59 +++++++++++++++++++++++++++
> 1 file changed, 59 insertions(+)
> create mode 100644 package/initscripts/init.d/S11modules
> diff --git a/package/initscripts/init.d/S11modules b/package/initscripts/init.d/S11modules
> new file mode 100644
> index 0000000000..3937945596
> --- /dev/null
> +++ b/package/initscripts/init.d/S11modules
> @@ -0,0 +1,59 @@
> +#!/bin/sh
> +
> +MODULES="*.conf"
> +MODULES_DIR="/etc/modules-load.d"
> +
> +[ -z "$(ls -A ${MODULES_DIR}/${MODULES} 2> /dev/null)" ] && exit 0
The commit message talks about /etc/modules, but you are reading from
/etc/modules-load.d/*.conf?
How about supporting both /etc/modules and this directory instead?
> +
> +load_unload() {
> + for module_file in $(ls -1 ${MODULES_DIR}); do
And here you take all files in /etc/modules-load.d, even if they don't
have a .conf extension?
> + esac
> +
> + if [ "$1" = "load" ]; then
> + modprobe -q ${module} ${args} >/dev/null && \
> + printf ' %s success,' "$module" ||
> + printf ' %s failed,' "$module"
success/failed are quite long strings, how about only printing the
module name on success and a big scary FAIL like we do elsewhere on
failures?
--
Bye, Peter Korsgaard
More information about the buildroot
mailing list