Subject: modload with post-install diffs / enhancement
To: None <current-users@sun-lamp.cs.berkeley.edu>
From: Havard Eidnes <Havard.Eidnes@runit.sintef.no>
List: current-users
Date: 06/18/1994 15:00:37
------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"

Hi,

the following patches to modload make the distance between the
documentation and what's implemented a little smaller, in that the
post-install script will now be run if it is specified.

I realize the magic constant 100 is a hack and that it should be replaced
by a reasonable constant.

Regards,

- Havard

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"

*** modload.c.old	Mon May 23 12:28:40 1994
--- modload.c	Mon Jun 13 20:17:45 1994
***************
*** 140,143 ****
--- 140,175 ----
  }
  
+ 
+ int
+ do_post(fd, module_id, post)
+ 	int fd, module_id;
+ 	char *post;
+ {
+ 	struct lmc_stat sbuf;
+ 	char cmd[100], *cp;
+ 	int cc, size = sizeof(cmd);
+ 
+ 	sbuf.id = module_id;
+ 	if (ioctl(fd, LMSTAT, &sbuf) == -1) {
+ 			errx(1, "LMSTAT");
+ 	}
+ 	
+ 	cc = snprintf(cmd, size, "%s %d %x", post, module_id, sbuf.type);
+ 	cp = cmd + cc;
+ 	size -= cc;
+ 
+ 	switch (sbuf.type) {
+ 	case LM_SYSCALL:
+ 	case LM_DEV:
+ 		snprintf(cp, size, " %d", sbuf.offset);
+ 		break;
+ 	}
+ 
+ 	if (verbose)
+ 		printf("executing: %s\n", cmd);
+ 	return system(cmd);
+ }
+ 
+ 
  int
  main(argc, argv)
***************
*** 325,328 ****
--- 357,367 ----
  	if (ioctl(devfd, LMREADY, &modentry) == -1)
  		err(14, "error initializing module");
+ 
+ 	/*
+ 	 * Do post-install script if specified.
+ 	 */
+ 	if (post != NULL) {
+ 		return do_post(devfd, resrv.slot, post);
+ 	}
  
  	/*
*** modload.8.old	Sat Jan 29 11:30:53 1994
--- modload.8	Mon Jun 13 20:14:08 1994
***************
*** 74,79 ****
  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.
--- 74,79 ----
  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 number.
  For a loadable system call, the third argument is the system
  call number.

------- =_aaaaaaaaaa0--

------------------------------------------------------------------------------