Subject: bin/481: modload doesn't do postloading; modload doesn't fix up symbol output file name
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: John Kohl <jtk@kolvir.blrc.ma.us>
List: netbsd-bugs
Date: 09/17/1994 07:50:03
>Number:         481
>Category:       bin
>Synopsis:       modload doesn't do post-load work, nor does it fix the symbol output file name
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 17 07:50:01 1994
>Originator:     John Kohl
>Organization:
>Release:        NetBSD-1.0_BETA
>Environment:
i486/33, NetBSD-1.0_BETA (Sep 17th), i486/33
System: NetBSD kolvir 1.0_BETA NetBSD 1.0_BETA (KOLVIR) #16: Thu Sep 15 22:03:20 EDT 1994 jtk@kolvir:/u1/NetBSD-1.0/src/sys/arch/i386/compile/KOLVIR i386


>Description:
modload doesn't honor it's -p argument.

It also will destroy the input file when you don't specify an output
symbol file with -o.

>How-To-Repeat:
run modload -o symfile -p post_script module.o.  Note that post_script
isn't called.

run modload module.o.  Note that module.o gets unlinked and you get an
error.

>Fix:
Apply these patches:

===================================================================
RCS file: sbin/modload/RCS/modload.c,v
retrieving revision 1.1
diff -c -r1.1 sbin/modload/modload.c
*** 1.1	1994/09/17 13:46:43
--- sbin/modload/modload.c	1994/09/17 14:22:42
***************
*** 212,218 ****
  		errx(2, "module object must end in .o");
  	if (out == NULL) {
  		out = modout;
! 		*p == 0;
  	}
  
  	/*
--- 212,218 ----
  		errx(2, "module object must end in .o");
  	if (out == NULL) {
  		out = modout;
! 		*p = 0;
  	}
  
  	/*
***************
*** 331,335 ****
--- 331,350 ----
  	fileopen &= ~PART_RESRV;	/* loaded */
  	printf("Module loaded as ID %d\n", resrv.slot);
  
+ 	if (post) {
+ 	    struct lmc_stat sbuf;
+ 	    char id[16], type[16], offset[16];
+ 
+ 	    sbuf.id = resrv.slot;
+ 	    if (ioctl(devfd, LMSTAT, &sbuf) == -1)
+ 		err(15, "error fetching module stats for post-install");
+ 	    sprintf(id, "%d", sbuf.id);
+ 	    sprintf(type, "0x%x", sbuf.type);
+ 	    sprintf(offset, "%d", sbuf.offset);
+ 	    /* XXX the modload docs say that drivers can install bdevsw &
+ 	       cdevsw, but the interface only supports one at a time.  sigh. */
+ 	    execl(post, post, id, type, offset, 0);
+ 	    err(16, "can't exec '%s'", post);
+ 	}
  	return 0;
  }
===================================================================
RCS file: sbin/modload/RCS/modload.8,v
retrieving revision 1.1
diff -c -r1.1 sbin/modload/modload.8
*** 1.1	1994/09/17 14:00:37
--- sbin/modload/modload.8	1994/09/17 14:22:50
***************
*** 73,80 ****
  be executed if the module is successfully loaded. It
  is always passed the module id (in decimal) and module
  type (in hexadecimal) as the first two arguments.
! For loadable drivers, the third and fourth arguments are
! the block major and character major numbers respectively.
  For a loadable system call, the third argument is the system
  call number.
  .It Fl o Ar output_file
--- 73,80 ----
  be executed if the module is successfully loaded. It
  is always passed the module id (in decimal) and module
  type (in hexadecimal) as the first two arguments.
! For loadable drivers, the third argument is
! the block or character major device number.
  For a loadable system call, the third argument is the system
  call number.
  .It Fl o Ar output_file
***************
*** 112,115 ****
  .El
  .Sh BUGS
  Loadable streams modules and loadable execution interpreters
! are not currently supported.
--- 112,116 ----
  .El
  .Sh BUGS
  Loadable streams modules and loadable execution interpreters
! are not currently supported.  The loadable device driver framework can
! only reserve either a character or block device entry, not both.

>Audit-Trail:
>Unformatted: