ide modules fix

Greg Zornetzer (gaz@andrew.cmu.edu)
Fri, 6 Feb 1998 22:36:46 -0500 (EST)


Hi everyone,

I have a machine that boots off of scsi drives, and has an ide cdrom (yeah
I know, kind of weird). Anyway, I recently installed RH5.0, and then
proceeded to try out the new 2.1 series. Since 2.1 provided the new
feature of a modularized ide driver, I built the ide support as a module,
followed the suggestions made on this list to make the ide-cd autoload
with kerneld. Everything worked flawlessly, except that each time that
the main ide module was unloaded, the /proc/ide subdirectory did not
disappear, and /proc/ide/drivers was still around. When I tried to cat
/proc/ide/drivers, the system (predictably) dumped an oops. When the main
ide module driver was reloaded, an additional /proc/ide directory was
created. Eventually I had about 15 /proc/ide directories - bad.
The following patch adds a proc_ide_shutdown() function which is called by
cleanup_module to remove these hanging entries. This is my first kernel
patch, so I'd appreciate any pointers on making the code cleaner or
smarter. It works for me, so I just wanted to see if there were any
problems with it before sending it to Mark Lord.

Here it is:

--- linux/drivers/block/ide.h.old Thu Feb 5 20:42:09 1998
+++ linux/drivers/block/ide.h Thu Feb 5 20:44:04 1998
@@ -411,6 +411,7 @@
} ide_proc_entry_t;

void proc_ide_init(void);
+void proc_ide_shutdown(void);
void ide_add_proc_entries(ide_drive_t *drive, ide_proc_entry_t *p);
void ide_remove_proc_entries(ide_drive_t *drive, ide_proc_entry_t *p);
read_proc_t proc_ide_read_capacity;
--- linux/drivers/block/ide.c.old Thu Feb 5 20:40:05 1998
+++ linux/drivers/block/ide.c Fri Feb 6 21:25:56 1998
@@ -2877,5 +2877,12 @@

for (index = 0; index < MAX_HWIFS; ++index)
ide_unregister(index);
+
+#ifdef CONFIG_PROC_FS
+
+ proc_ide_shutdown();
+
+#endif
+
}
#endif /* MODULE */
--- linux/drivers/block/ide-proc.c.old Fri Feb 6 22:11:44 1998
+++ linux/drivers/block/ide-proc.c Thu Feb 5 20:41:00 1998
@@ -718,3 +718,9 @@
if (!ent) return;
ent->read_proc = proc_ide_read_drivers;
}
+
+void proc_ide_shutdown(void)
+{
+ remove_proc_entry("ide/drivers", 0);
+ remove_proc_entry("ide", 0);
+}

Greg Zornetzer - gaz+@andrew.cmu.edu
"Light shines brightest in the darkest night"
http://www.contrib.andrew.cmu.edu/~gaz

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu