Subject: Re: testing presence of a device (was sun-lamp CVS commits)
To: Rolf Grossmann <grossman@informatik.tu-muenchen.de>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: current-users
Date: 10/04/1995 18:42:15
On Thu, 5 Oct 1995 02:26:16 +0100 
 Rolf Grossmann <grossman@informatik.tu-muenchen.de> wrote:

 > > On a NetBSD/sparc machine with a bwtw0 but only one disk (sd0),
 > > [Callisto] 15> sh -c 'if ( < /dev/sd2a ) 2> /dev/null; then echo yes; else echo no; fi'
 > > no
 > > [Callisto] 16> sh -c 'if ( < /dev/bwtwo0 ) 2> /dev/null; then echo yes; else echo no; fi'
 > > yes
 > > [Callisto] 17>

I apparently missed this original mail...

The point is, doing this in shell to present a list like:

	You can install on the following devices:
		sd0
		sd1
		sd3

...is impractical.  My install.sh for the hp300 basically does:

	dmesg | grep "^sd" | grep "slave"
	dmesg | grep "^rd" | grep "slave"

This works fine since I know that the hp300 can only have sd (SCSI disks) 
and rd (HP-IB disks) hooked up to it.  Yes sometimes it can result in 
something like:

	You can install on the following devices:
		sd0
		rd0
		rd1
		sd0
		rd0
		rd1

...but that seems like a nit that could be cleaned up with a little 
clever shell coding (which I just don't have time to do :-).

Also, the technique of opening a device can be problematic in some 
circumstances ... maybe the disk is there but the partition has the wrong 
fstype, and thus the driver returns ENXIO?

--------------------------------------------------------------------------
Jason R. Thorpe                                       thorpej@nas.nasa.gov
NASA Ames Research Center                               Home: 408.866.1912
NAS: M/S 258-6                                          Work: 415.604.0935
Moffett Field, CA 94035                                Pager: 415.428.6939