Again from very old backlog.
This fixes my old error. The patch is against 2.4.20-2mdk, but it reverts DI92, so
Juan, if you intend to ever apply it :) just remove DI92 and skip drivers/ide/ide.c
chunk.
The patch fixes driver changing by writing into /proc/ide/hdX/driver. It does work to
some extent, but current code does not null-terminate written driver name so
ide_scan_device does not (always) find it.
DI92 must be removed in any case (it is buggy); this patch is optional as probably
nobody ever tried to play with IDE drivers this way :)) I repost it so it is not lost.
-andrey
--- linux-2.4.20-2mdk/drivers/ide/ide-proc.c.ide-proc-write-driver 2002-12-09
14:38:12.000000000 +0300
+++ linux-2.4.20-2mdk/drivers/ide/ide-proc.c 2003-01-01 15:43:06.000000000 +0300
@@ -640,14 +640,23 @@
PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
}
+#define DRIVER_REQ_SIZE (sizeof(((ide_drive_t *)0)->driver_req))
static int proc_ide_write_driver
(struct file *file, const char *buffer, unsigned long count, void *data)
{
ide_drive_t *drive = (ide_drive_t *) data;
+ char tmpbuf[DRIVER_REQ_SIZE];
+ size_t s = count < DRIVER_REQ_SIZE ? count : DRIVER_REQ_SIZE-1;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- if (ide_replace_subdriver(drive, buffer))
+ /*
+ * Driver name may be less than 9 characters
+ * Make sure it is properly NULL-terminated
+ */
+ strncpy(tmpbuf, buffer, s);
+ tmpbuf[s] = '\0';
+ if (ide_replace_subdriver(drive, tmpbuf))
return -EINVAL;
return count;
}
--- linux-2.4.20-2mdk/drivers/ide/ide.c.ide-proc-write-driver 2002-12-09
14:38:17.000000000 +0300
+++ linux-2.4.20-2mdk/drivers/ide/ide.c 2003-01-01 15:25:53.000000000 +0300
@@ -3843,7 +3843,7 @@
for (unit = 0; unit < MAX_DRIVES; ++unit) {
ide_drive_t *drive = &hwif->drives[unit];
char *req = drive->driver_req;
- if (*req && !strstr(req, name))
+ if (*req && !strstr(name, req))
continue;
if (drive->present && drive->media == media && drive->driver
== driver && ++i > n)
return drive;