summaryrefslogtreecommitdiffstats
path: root/sbin/modload
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1995-10-28 13:06:11 +0000
committerpeter <peter@FreeBSD.org>1995-10-28 13:06:11 +0000
commitec41d6be34fc7046c7310d5bb2050831927b4e0d (patch)
treeba06a04afd38695a34cc98865f012071f51ab915 /sbin/modload
parent122041820b9387f55eb99628175b7a6e95999964 (diff)
downloadFreeBSD-src-ec41d6be34fc7046c7310d5bb2050831927b4e0d.zip
FreeBSD-src-ec41d6be34fc7046c7310d5bb2050831927b4e0d.tar.gz
Make modload calculate a reasonable default entry point name, in light
of the recent changes to bsd.kmod.mk, which enforces that the entry point be <modname>_mod, unless overridden. This means that when modloading "/lkm/foo_mod.o", it'll use "foo_mod" as the default entry point (instead of xxxinit) unless you specify another via the -e option.
Diffstat (limited to 'sbin/modload')
-rw-r--r--sbin/modload/modload.84
-rw-r--r--sbin/modload/modload.c18
2 files changed, 14 insertions, 8 deletions
diff --git a/sbin/modload/modload.8 b/sbin/modload/modload.8
index d2aaac6..b6fcc67 100644
--- a/sbin/modload/modload.8
+++ b/sbin/modload/modload.8
@@ -23,7 +23,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $Id: modload.8,v 1.4 1994/09/18 04:12:12 davidg Exp $
+.\" $Id: modload.8,v 1.5 1994/09/22 22:35:50 wollman Exp $
.\"
.Dd September 22, 1994
.Dt MODLOAD 8
@@ -73,7 +73,7 @@ This is passed by
to
.Xr ld 1
when the module is linked.
-The default module entry point name is `xxxinit'.
+The default module entry point name is the module name with `_mod' appended.
.It Fl p Ar postinstall
Specify the name of a shell script or program that will
be executed if the module is successfully loaded. It
diff --git a/sbin/modload/modload.c b/sbin/modload/modload.c
index 0efd0ea..96cb837 100644
--- a/sbin/modload/modload.c
+++ b/sbin/modload/modload.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: modload.c,v 1.7 1995/03/16 17:11:21 wollman Exp $
+ * $Id: modload.c,v 1.8 1995/05/30 06:09:20 rgrimes Exp $
*/
#include <stdio.h>
@@ -51,10 +51,6 @@
#include <sys/signal.h>
#include "pathnames.h"
-#ifndef DFLT_ENTRY
-#define DFLT_ENTRY "xxxinit"
-#endif /* !DFLT_ENTRY */
-
#define min(a, b) ((a) < (b) ? (a) : (b))
int debug = 0;
@@ -164,7 +160,7 @@ main(argc, argv)
{
int c;
char *kname = (char *)getbootfile();
- char *entry = DFLT_ENTRY;
+ char *entry = NULL;
char *post = NULL;
char *out = NULL;
char *modobj;
@@ -218,6 +214,16 @@ main(argc, argv)
modobj = argv[0];
+ if (!entry) { /* calculate default entry point */
+ entry = strrchr(modobj, '/');
+ if (entry)
+ entry++; /* skip over '/' */
+ else
+ entry = modobj;
+ entry = strdup(entry); /* so we can modify it */
+ entry[strlen(entry) - 2] = '\0'; /* chop off .o */
+ }
+
atexit(cleanup);
/*
OpenPOWER on IntegriCloud