Subject: Orphaned devices in config(8)
To: None <>
From: Jason R Thorpe <>
List: tech-userlevel
Date: 10/09/2002 13:58:22
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

[ I have BCC'd tech-kern to notify that list of the discussion, but
  since this is a purely userland issue, I'd like to conduct this
  on tech-userlevel.  --thorpej ]

With all the recent changes to config, it is now possible to completely
orphan devices in the kernel configuration file.  Previously, this was
not possible because of the internal data representation.  However, now
that everything is done with strings, there is no reason to disallow
orphaned devices.

Consider the following:

scsibus* at scsi?
sd* at scsibus? target ? lun ?

Right now, this is illegal because there is not a device with the "scsi"
attribute in the config file.  However, it's possible that a device with
the "scsi" attribute might appear later (see the "iscsi" example LKM I
posted on tech-kern recently).

Attached is a two line change (an "#if 0" and an "#endif") that makes
orphaned devices work.  However, it's a pretty major semantic change,
since previously e.g. removing all SCSI HBAs from a config file would
cause an orphaned "scsibus" to cause an error.

On the other hand, I don't really think that adding a new keyword like
"orphan" is a natural way to describe a system's devie configuration.

What are people's thoughts on this?

        -- Jason R. Thorpe <>

Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=orphan-patch

Index: main.c
RCS file: /cvsroot/syssrc/usr.sbin/config/main.c,v
retrieving revision 1.71
diff -c -r1.71 main.c
*** main.c	2002/09/26 04:07:36	1.71
--- main.c	2002/10/09 20:42:06
*** 957,968 ****
--- 957,970 ----
  	TAILQ_FOREACH(i, &alldevi, i_next) {
  		if ((p = i->i_pspec) == NULL || hasparent(i))
+ #if 0
  		xerror(conffile, i->i_lineno,
  		    "%s at %s is orphaned", i->i_name, i->i_at);
  		(void)fprintf(stderr, " (%s %s declared)\n",
  		    p->p_atunit == WILD ? "nothing matching" : "no",
+ #endif
  	if (TAILQ_EMPTY(&allcf)) {
  		(void)fprintf(stderr, "%s has no configurations!\n",