From ec41d6be34fc7046c7310d5bb2050831927b4e0d Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 28 Oct 1995 13:06:11 +0000 Subject: 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 _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. --- sbin/modload/modload.8 | 4 ++-- sbin/modload/modload.c | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'sbin/modload') 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 @@ -51,10 +51,6 @@ #include #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); /* -- cgit v1.1