On Fri, Mar 14, 2003 at 07:27:42PM -0800, Peter Wemm wrote:
> "Crist J. Clark" wrote:
> > 
> > --C7zPtVaVf+AK4Oqc
> > Content-Type: text/plain; charset=us-ascii
> > Content-Disposition: inline
> > 
> > Perhaps it would be a good idea to build a linker.hints file with
> > kldxref(8) at boot time. At least, I can't think of any really good
> > reasons why _not_ to do it.
> 
> Yes, we need to do this, but your patch needs a little more work.
> 
> Specifically.. There is a linker.hints file in each directory in the module
> path, not just /boot/kernel.  You need to look at the kern.module_path
> sysctl to find the search path.
> 
> [EMAIL PROTECTED]:26pm]~-101> sysctl -n kern.module_path
> /boot/kernel;/boot/kernel;/boot/modules;/modules

Ah. There that is.

> This also needs to be robust in the case where /boot might be another file
> system or readonly or NFSROOT or not even mounted, or something.  

I think the easiest thing to do here is if the kldxref(8) command
fails, it shouldn't kill the boot. Specifically, force the script to
always exit on success. Anything failing here is simply not bad enough
that we should interupt the boot.

In the case of a read-only filesystem, we get an error message like,

  Building /foo/modules/linker.hints
  kldxref: /foo/lhint.caF5Wl: Read-only file system

For non-existent directories, kldxref(8) actually doesn't return a
failure anyway,

  # kldxref /nonexistent
  # echo $?
  0

Someone who's mount root read-only or booting from a partition that
doesn't get mounted is someone who better know what they are doing. If
they don't like the error messages they have the knob to completely
disable the script or I have added an option for a rc.conf(5)
specified directory listing rather than kern.module_path.

There are always going to be that small fraction of real or imagined
users doing some wild things that won't fit into the startup scripts
no matter how many knobs we give them. Making things overly
complicated for that small percentile just confuses the bulk of the
users and makes more room for more bugs. KISS. Just turn this off if
you don't want to or can't use it.
-- 
Crist J. Clark                     |     [EMAIL PROTECTED]
                                   |     [EMAIL PROTECTED]
http://people.freebsd.org/~cjc/    |     [EMAIL PROTECTED]
Index: src/etc/defaults/rc.conf
===================================================================
RCS file: /export/freebsd/ncvs/src/etc/defaults/rc.conf,v
retrieving revision 1.170
diff -u -r1.170 rc.conf
--- src/etc/defaults/rc.conf    15 Mar 2003 08:14:42 -0000      1.170
+++ src/etc/defaults/rc.conf    17 Mar 2003 08:25:09 -0000
@@ -28,6 +28,9 @@
 apmd_enable="NO"       # Run apmd to handle APM event from userland.
 apmd_flags=""          # Flags to apmd (if enabled).
 devd_enable="NO"       # Run devd, to trigger programs on device tree changes.
+kldxref_enable="NO"    # Build linker.hints files with kldxref(8).
+kldxref_clobber="NO"   # Overwrite old linker.hints at boot.
+kldxref_module_path="" # Override kern.module_path. A ';'-delimited list.
 pccard_enable="NO"     # Set to YES if you want to configure PCCARD devices.
 pccard_mem="DEFAULT"   # If pccard_enable=YES, this is card memory address.
 pccard_beep="2"                # pccard beep type.
Index: src/etc/rc.d/network1
===================================================================
RCS file: /export/freebsd/ncvs/src/etc/rc.d/network1,v
retrieving revision 1.145
diff -u -r1.145 network1
--- src/etc/rc.d/network1       12 Feb 2003 04:26:10 -0000      1.145
+++ src/etc/rc.d/network1       15 Mar 2003 00:36:05 -0000
@@ -4,7 +4,7 @@
 #
 
 # PROVIDE: network1
-# REQUIRE: atm1 ipfilter mountcritlocal pccard serial sppp sysctl tty
+# REQUIRE: atm1 ipfilter kldxref mountcritlocal pccard serial sppp sysctl tty
 # KEYWORD: FreeBSD
 
 . /etc/rc.subr
Index: src/etc/rc.d/kldxref
===================================================================
RCS file: src/etc/rc.d/kldxref
diff -N src/etc/rc.d/kldxref
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/etc/rc.d/kldxref        17 Mar 2003 08:23:09 -0000
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# $FreeBSD:$
+#
+
+# PROVIDE: kldxref
+# REQUIRE: root
+# BEFORE:  network1
+# KEYWORD: FreeBSD
+
+. /etc/rc.subr
+
+rcvar="kldxref_enable"
+name="kldxref"
+stop_cmd=":"
+start_cmd="kldxref_start"
+
+kldxref_start () {
+       if [ -z "$kldxref_module_path" ]; then
+               MODULE_PATHS=`sysctl -n kern.module_path`
+       else
+               MODULE_PATHS="$kldxref_module_path"
+       fi
+       IFS=';'
+       for KERNDIR in $MODULE_PATHS; do
+               if [ ! -f "$KERNDIR/linker.hints" ] ||
+                   checkyesno kldxref_clobber; then
+                       echo "Building $KERNDIR/linker.hints"
+                       kldxref "$KERNDIR"
+               fi
+       done
+}
+
+load_rc_config $name
+run_rc_command "$1"

Reply via email to