Re: Rescan IDE interfaces

Gadi Oxman (gadio@netvision.net.il)
Mon, 28 Sep 1998 21:15:22 +0300 (IDT)


On Mon, 28 Sep 1998, Andre M. Hedrick wrote:

> This is something to look into, but it would most likely be addressed in
> the next development kernel 2.3. With the push to get 2.2 out,
> I have had to restrict new additions like multi-slot cdroms that would
> begin to act like a jukebox in theory.
...
> > Reason? Because I'm in the habit of hot swapping ide drives and cdroms,
> > and I would like to be able to tell the kernel to look for the new drive,
> > so I can use it without rebooting.
> >
> > Can I do this, and if so, how?
>
> There is "NO-CODE", that I know of in the IDE-Driver that can even attempt
> this to date. However, I am game if you want to test-crash your system.
>
> Cheers,
> Andre Hedrick

Actually, I added this to the IDE driver in the early 2.1.x kernels. For
example, to rescan ide1 we can issue the HDIO_SCAN_HWIF ioctl to any IDE
drive which is not on ide1, as in the following example.

We can't issue the ioctl to a drive on the same channel which we wish to
rescan as that would hold the channel "busy". Now that we have the /proc/ide
interface, we can also add code which will call ide_register() from there.

Gadi

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/hdreg.h>

int main (void)
{
int args[3] = {0x170, 0, 0};
int fd;

if ((fd = open("/dev/hda", O_RDONLY)) == -1) {
perror("couldn't open /dev/hda");
return 1;
}
if ((ioctl(fd, HDIO_SCAN_HWIF, args)) == -1) {
perror("couldn't rescan IDE interface 0x170");
close(fd);
return 1;
}
return 0;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/