patch-2.3.46 linux/drivers/cdrom/cdrom.c
Next file: linux/drivers/cdrom/cdu31a.c
Previous file: linux/drivers/cdrom/aztcd.c
Back to the patch index
Back to the overall index
- Lines: 75
- Date:
Wed Feb 16 15:42:05 2000
- Orig file:
v2.3.45/linux/drivers/cdrom/cdrom.c
- Orig date:
Fri Jan 28 15:09:07 2000
diff -u --recursive --new-file v2.3.45/linux/drivers/cdrom/cdrom.c linux/drivers/cdrom/cdrom.c
@@ -291,6 +291,7 @@
static void cdrom_sysctl_register(void);
#endif /* CONFIG_SYSCTL */
static struct cdrom_device_info *topCdromPtr = NULL;
+static devfs_handle_t devfs_handle = NULL;
struct block_device_operations cdrom_fops =
{
@@ -313,6 +314,8 @@
int major = MAJOR(cdi->dev);
struct cdrom_device_ops *cdo = cdi->ops;
int *change_capability = (int *)&cdo->capability; /* hack */
+ char vname[16];
+ static unsigned int cdrom_counter = 0;
cdinfo(CD_OPEN, "entering register_cdrom\n");
@@ -351,6 +354,31 @@
if (check_media_type==1)
cdi->options |= (int) CDO_CHECK_TYPE;
+ if (!devfs_handle)
+ devfs_handle = devfs_mk_dir (NULL, "cdroms", 6, NULL);
+ sprintf (vname, "cdrom%u", cdrom_counter++);
+ if (cdi->de) {
+ int pos;
+ devfs_handle_t slave;
+ char rname[64];
+
+ pos = devfs_generate_path (cdi->de, rname + 3,
+ sizeof rname - 3);
+ if (pos >= 0) {
+ strncpy (rname + pos, "../", 3);
+ devfs_mk_symlink (devfs_handle, vname, 0,
+ DEVFS_FL_DEFAULT,
+ rname + pos, 0, &slave, NULL);
+ devfs_auto_unregister (cdi->de, slave);
+ }
+ }
+ else {
+ cdi->de =
+ devfs_register (devfs_handle, vname, 0, DEVFS_FL_DEFAULT,
+ MAJOR (cdi->dev), MINOR (cdi->dev),
+ S_IFBLK | S_IRUGO | S_IWUGO, 0, 0,
+ &cdrom_fops, NULL);
+ }
cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
cdi->next = topCdromPtr;
topCdromPtr = cdi;
@@ -382,6 +410,7 @@
else
topCdromPtr = cdi->next;
cdi->ops->n_minors--;
+ devfs_unregister (cdi->de);
cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
return 0;
}
@@ -2483,6 +2512,7 @@
#ifdef CONFIG_SYSCTL
cdrom_sysctl_register();
#endif
+ devfs_handle = devfs_mk_dir (NULL, "cdroms", 6, NULL);
return 0;
}
@@ -2491,7 +2521,8 @@
printk(KERN_INFO "Uniform CD-ROM driver unloaded\n");
#ifdef CONFIG_SYSCTL
cdrom_sysctl_unregister();
-#endif /* CONFIG_SYSCTL */
+#endif /* CONFIG_SYSCTL */
+ devfs_unregister (devfs_handle);
}
#endif /* endif MODULE */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)