From 314ae3dc781d7ae8fc26c276a85b0dc6ab6bc326 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Sun, 17 Jul 2016 14:53:12 -0500 Subject: [PATCH] modules: add support for FreeBSD This is based on a patch submitted by Joe Maloney . This fixes #91. --- conf.d/Makefile | 2 +- conf.d/modules | 12 ++++++++---- init.d/Makefile | 4 ++-- init.d/modules.in | 22 +++++++++++++++++++++- runlevels/Makefile | 2 +- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/conf.d/Makefile b/conf.d/Makefile index b8da0e04..fb54fc57 100644 --- a/conf.d/Makefile +++ b/conf.d/Makefile @@ -13,7 +13,7 @@ endif MK= ../mk include ${MK}/os.mk -CONF-FreeBSD= ipfw moused powerd rarpd savecore syscons +CONF-FreeBSD= ipfw modules moused powerd rarpd savecore syscons CONF-Linux= consolefont devfs dmesg hwclock keymaps killprocs modules mtab \ net-online diff --git a/conf.d/modules b/conf.d/modules index a062a620..c35b9edf 100644 --- a/conf.d/modules +++ b/conf.d/modules @@ -1,18 +1,22 @@ -# You can define a list modules for a specific kernel version, -# a released kernel version, a main kernel version or just a list. +# Linux users can define a list of modules for a specific kernel version, +# a released kernel version, a main kernel version or all kernel versions. # The most specific versioned variable will take precedence. +# FreeBSD users can only use the modules="foo bar" setting. #modules_2_6_23_gentoo_r5="ieee1394 ohci1394" #modules_2_6_23="tun ieee1394" #modules_2_6="tun" #modules_2="ipv6" #modules="ohci1394" -# You can give modules a different name when they load - the new name +# Linux users can give modules a different name when they load - the new name # will also be used to pick arguments below. +# This is not supported on FreeBSD. #modules="dummy:dummy1" -# Give the modules some arguments if needed, per version if necessary. +# Linux users can give the modules some arguments if needed, per version +# if necessary. # Again, the most specific versioned variable will take precedence. +# This is not supported on FreeBSD. #module_ieee1394_args="debug" #module_ieee1394_args_2_6_23_gentoo_r5="debug2" #module_ieee1394_args_2_6_23="debug3" diff --git a/init.d/Makefile b/init.d/Makefile index f2560956..55db3d14 100644 --- a/init.d/Makefile +++ b/init.d/Makefile @@ -15,8 +15,8 @@ MK= ../mk include ${MK}/os.mk # Generic BSD scripts -SRCS-FreeBSD= hostid.in moused.in newsyslog.in pf.in rarpd.in rc-enabled.in \ - rpcbind.in savecore.in syslogd.in +SRCS-FreeBSD= hostid.in modules.in moused.in newsyslog.in pf.in rarpd.in \ + rc-enabled.in rpcbind.in savecore.in syslogd.in # These are FreeBSD specific SRCS-FreeBSD+= adjkerntz.in devd.in dumpon.in encswap.in ipfw.in \ mixer.in nscd.in powerd.in syscons.in diff --git a/init.d/modules.in b/init.d/modules.in index 6ff90d68..7a02c3a5 100644 --- a/init.d/modules.in +++ b/init.d/modules.in @@ -17,7 +17,18 @@ depend() keyword -openvz -prefix -systemd-nspawn -vserver -lxc } -start() +FreeBSD_modules() +{ + local cnt=0 x + for x in $modules; do + ebegin "Loading module $x" + kldload "$x" + eend $? "Failed to load $x" && : $(( cnt += 1 )) + done + einfo "Autoloaded $cnt module(s)" +} + +Linux_modules() { # Should not fail if kernel do not have module # support compiled in ... @@ -68,3 +79,12 @@ start() done einfo "Autoloaded $cnt module(s)" } + +start() +{ + case "$RC_UNAME" in + FreeBSD|Linux) ${RC_UNAME}_modules ;; + *) ;; + esac + return 0 +} diff --git a/runlevels/Makefile b/runlevels/Makefile index df6b53a2..d367147e 100644 --- a/runlevels/Makefile +++ b/runlevels/Makefile @@ -32,7 +32,7 @@ SYSINIT-${OS}= BOOT-BSD= hostid newsyslog savecore syslogd swap-blk # Generic BSD stuff -BOOT-FreeBSD+= hostid newsyslog savecore syslogd +BOOT-FreeBSD+= hostid modules newsyslog savecore syslogd # FreeBSD specific stuff BOOT-FreeBSD+= adjkerntz dumpon syscons