diff -ur xen-2.0/linux-2.6.9-xen-sparse/drivers/xen/blkfront/vbd.c xen-2.0-new/linux-2.6.9-xen-sparse/drivers/xen/blkfront/vbd.c --- xen-2.0/linux-2.6.9-xen-sparse/drivers/xen/blkfront/vbd.c 2005-01-03 21:46:11.000000000 -0600 +++ xen-2.0-new/linux-2.6.9-xen-sparse/drivers/xen/blkfront/vbd.c 2005-01-05 14:08:26.000000000 -0600 @@ -31,6 +31,8 @@ #include "block.h" #include +#include +#include /* * For convenience we distinguish between ide, scsi and 'other' (i.e. @@ -281,6 +283,98 @@ return NULL; } +#define CDROM_STR_SIZE 1000 +static char info[CDROM_STR_SIZE]; + +int cdrom_sysctl_info(ctl_table *ctl, int write, struct file * filp, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + int pos; + + if (!*lenp || (*ppos && !write)) { + *lenp = 0; + return 0; + } + + pos = sprintf(info, + "CD-ROM information, Id: cdrom.c 3.20 2003/12/17\n" + "\ndrive name:\t\thdc1\n" + "drive speed:\t\t40\n" + "drive # of slots:\t1\n" + "Can close tray:\t\t0\n" + "Can open tray:\t\t0\n" + "Can lock tray:\t\t0\n" + "Can change speed:\t0\n" + "Can select disk:\t0\n" + "Can read multisession:\t0\n" + "Can read MCN:\t\t0\n" + "Reports media changed:\t0\n" + "Can play audio:\t\t0\n" + "Can write CD-R:\t\t0\n" + "Can write CD-RW:\t0\n" + "Can read DVD:\t\t0\n" + "Can write DVD-R:\t0\n" + "Can write DVD-RAM:\t0\n" + "Can read MRW:\t\t0\n" + "Can write MRW:\t\t0\n" + "Can write RAM:\t\t0\n" + "\n"); + + return proc_dostring(ctl, write, filp, buffer, lenp, ppos); +} + +/* Place files in /proc/sys/dev/cdrom */ +static ctl_table cdrom_table[] = { + { + .ctl_name = DEV_CDROM_INFO, + .procname = "info", + .data = &info, + .maxlen = CDROM_STR_SIZE, + .mode = 0444, + .proc_handler = &cdrom_sysctl_info, + }, + { .ctl_name = 0 } +}; + +static ctl_table cdrom_cdrom_table[] = { + { + .ctl_name = DEV_CDROM, + .procname = "cdrom", + .maxlen = 0, + .mode = 0555, + .child = cdrom_table, + }, + { .ctl_name = 0 } +}; + +static ctl_table cdrom_root_table[] = { +#ifdef CONFIG_PROC_FS + { + .ctl_name = CTL_DEV, + .procname = "dev", + .maxlen = 0, + .mode = 0555, + .child = cdrom_cdrom_table, + }, +#endif /* CONFIG_PROC_FS */ + { .ctl_name = 0 } +}; +static struct ctl_table_header *cdrom_sysctl_header; + +static void cdrom_sysctl_register(void) +{ + static int initialized; + + if (initialized == 1) + return; + + cdrom_sysctl_header = register_sysctl_table(cdrom_root_table, 1); + if (cdrom_root_table->ctl_name && cdrom_root_table->child->de) + cdrom_root_table->child->de->owner = THIS_MODULE; + + initialized = 1; +} + /* * xlvbd_init_device - initialise a VBD device * @disk: a vdisk_t describing the VBD @@ -323,13 +417,20 @@ goto out; } + printk(KERN_ALERT "XenLinux: init of %d %s\n", device, gd->disk_name); + if (VDISK_READONLY(xd->info)) set_disk_ro(gd, 1); + if (!strcmp(gd->disk_name, "hdc1")) { + xd->info = VDISK_TYPE_CDROM; + } + /* Some final fix-ups depending on the device type */ switch (VDISK_TYPE(xd->info)) { case VDISK_TYPE_CDROM: gd->flags |= GENHD_FL_REMOVABLE | GENHD_FL_CD; + cdrom_sysctl_register(); /* FALLTHROUGH */ case VDISK_TYPE_FLOPPY: case VDISK_TYPE_TAPE: