[Buildroot] [PATCH v3 5/5] package/initscripts: add service to load kernel modules at boot

Angelo Compagnucci angelo at amarulasolutions.com
Mon Oct 3 15:53:18 UTC 2022


On Sun, Sep 18, 2022 at 12:10 PM Peter Korsgaard <peter at korsgaard.com>
wrote:

> >>>>> "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?
>

Yes, right, commit message must be fixed.


> How about supporting both /etc/modules and this directory instead?
>

It is doable, but if we are on par with systemd I cannot see why adding
/etc/modules. The same goal can be obtained easily dropping a file in
/etc/modules-load.d/ .


>
>
>  > +
>  > +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?
>

Nice catch.


>
> > +                     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?
>

Nice suggestion.


>
> --
> Bye, Peter Korsgaard
>


-- 

Angelo Compagnucci

Software Engineer

angelo at amarulasolutions.com
__________________________________
Amarula Solutions SRL

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
info at amarulasolutions.com

www.amarulasolutions.com
[`as] https://www.amarulasolutions.com|
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.buildroot.org/pipermail/buildroot/attachments/20221003/5592d347/attachment.html>


More information about the buildroot mailing list