Subject: Re: Rescanning SCSI bus?
To: Lindgren, Jon <jlindgren@SLK.com>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: port-sparc
Date: 04/23/1999 14:15:29
>> Is there a way to rescan the SCSI bus under 1.3.3 or 1.4?  For
>> instance, if I had a SCSI bus which could electrically support hot
>> swap, how can I get the kernel to recognize the new devices?

As Bill Sommerfeld says, under 1.4 (and somewhat-pre-1.4 -current)
there's scsictl to do that.

But even before that, SCIOCREPROBE provided the underlying support,
though I don't think /dev/scsibus* existed at the time (which means you
have to have an existing device on the bus in order to reprobe it).

Enclosed below is a program I wrote for the purpose, which you may be
able to adapt if you can't use 1.4.

One thing I wish scsictl scan did that it doesn't is remove devices
that have disappeared.  As it stands, after adding a full bus of
devices, you have to reboot to add more even if you've taken off the
devices that were there.  (Yeah, I know, it's a volunteer project.
This isn't a complaint; this item is something I've been meaning to
look at, in my Copious Spare Time.)

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

static const char *somescsidev = "/dev/rsd1c";

#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <strings.h>
#include <sys/scsiio.h>

extern const char *__progname;

int main(void);
int main(void)
{
 int fd;
 struct scsi_addr a;

 a.type = TYPE_SCSI;
 a.addr.scsi.scbus = -1;
 a.addr.scsi.target = -1;
 a.addr.scsi.lun = -1;
 fd = open(somescsidev,O_RDWR,0);
 if (fd < 0)
  { fprintf(stderr,"%s: %s: %s\n",__progname,somescsidev,strerror(errno));
    exit(1);
  }
 if (ioctl(fd,SCIOCREPROBE,&a) < 0)
  { fprintf(stderr,"%s: SCIOCREPROBE: %s\n",__progname,strerror(errno));
    exit(1);
  }
 exit(0);
}