Subject: Re: testing presence of a device (was sun-lamp CVS commits)
To: Chris G Demetriou <Chris_G_Demetriou@BALVENIE.PDL.CS.CMU.EDU>
From: Tom Pavel <PAVEL@SLAC.Stanford.EDU>
List: current-users
Date: 10/07/1995 09:50:38
>>>>> On Thu, 5 Oct 1995, Chris G Demetriou <Chris_G_Demetriou@BALVENIE.PDL.CS.
CMU.EDU> writes:

> > Regarding checking for devices, would it be possible to make the
> > device tree information available to sysctl?  if the structure's
> > chosen well, subvariables could later be added to indicate other
> > information (ie, disk geometry, vendor info, perf stats, whatever
> > other bloat anyone wants and can be bothered to add)
> >
> > [ ... ]
> >
> > What do folks think of this as a concept?  How hard would it be to
> > implement?
> 
> I've thought about this a fair amount (surprise surprise 8-), and one
> of the conclusions that i came to is that there can't be a 'sane'
> implementation of it, unless sysctl takes "char *" arguments, rather
> than ints.
> 
> the big problem is, if sysctl doesn't take char *'s as args, then you
> need to query the kernel to see what the appropriate name->number
> mappings are, etc., and then convert them a possibly-endless string of
> ints.  i'd much rather give sysctl the string:
> 	"dev.isa0.foo.bar.baz"
> to pass to the kernel and have the kernel split it up, than have
> sysctl:

> ...


I had been thinking about an interface for getting device info also,
but within the context of KERNFS.  Now, I know that kernfs is
currently something of a toy and that sysctl() has the advantage that
it's there in all kernels regardless of config options.  But, on the
other hand, kernfs is rather cheap (it only adds 4k of code to my
i386 kernel when I compile it in or not), and one could certainly
arrange to compile it into the INSTALL kernel.

When I went about attacking this before, I ran into two problems: One
is that I ended up putting some arch-specific code into an area
(miscfs) that was supposed to be MI.  This could perhaps be worked out
with some better architecting.  The other is that when I was
done extracting info from the device structs, the best that I ended up
with was the same info that was in the boot messages.

But, I hadn't thought about adding a directory structure under /kern
that reflects the device/bus structure of the system.  For example:
	/kern/dev/isa/aha0/id0  [etc.]

[In other words, I had a solution in search of a problem, but I think
I see a useful application for it here.]


Anyway, it's just a thought.  Hope it might prove useful.


Tom Pavel

Stanford Linear Accelerator Center
pavel@slac.stanford.edu                 http://www.slac.stanford.edu/~pavel/