Subject: ot: rescan of scsi bus
To: None <current-users@netbsd.org>
From: nm <nmanisca@vt.edu>
List: current-users
Date: 02/09/2000 14:48:49
A while back I requested some code that would rescan
the scsi bus on a 1.3.3 system. The code that was
provided (sorry I cannot credit the author here, I
cannot find the original piece of code) worked great.
It seems that I need a new scanscsi.c for 1.4.1.
Would something like the following do it 'the right
way?'
The goal here is to be able to plug in a new hard disk,
tape, or cdrom drive, and then run 'scanscsi' and have
the device work without requiring a reboot. (yes, this
may be dangerous as far as the hardware goes...)
Thanks,
Nick Maniscalco
nmanisca@vt.edu
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <strings.h>
#include <sys/scsiio.h>
int main(int argc, char *argv[]) {
struct scbusioscan_args s;
int fd;
s.sa_target = -1;
s.sa_lun = -1;
fd = open("/dev/scsibus0",O_RDWR,0);
if (fd < 0) {
fprintf(stderr,"could not open. %s\n",strerror(errno));
exit(1);
}
if(ioctl(fd,SCBUSIOSCAN,&s) < 0) {
fprintf(stderr,"%s\n",strerror(errno));
exit(1);
}
exit(0);
}
// Yes the code is ugly, but for now I am just feeling around.