#endif
+static int hdev_probe_device(const char *filename)
+{
+ struct stat st;
+
+ /* allow a dedicated CD-ROM driver to match with a higher priority */
+ if (strstart(filename, "/dev/cdrom", NULL))
+ return 50;
+
+ if (stat(filename, &st) >= 0 &&
+ (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) {
+ return 100;
+ }
+
+ return 0;
+}
+
static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
{
BDRVRawState *s = bs->opaque;
static BlockDriver bdrv_host_device = {
.format_name = "host_device",
.instance_size = sizeof(BDRVRawState),
+ .bdrv_probe_device = hdev_probe_device,
.bdrv_open = hdev_open,
.bdrv_close = raw_close,
.bdrv_create = hdev_create,
return 0;
}
+static int floppy_probe_device(const char *filename)
+{
+ if (strstart(filename, "/dev/fd", NULL))
+ return 100;
+ return 0;
+}
+
+
static int floppy_is_inserted(BlockDriverState *bs)
{
return fd_open(bs) >= 0;
static BlockDriver bdrv_host_floppy = {
.format_name = "host_floppy",
.instance_size = sizeof(BDRVRawState),
+ .bdrv_probe_device = floppy_probe_device,
.bdrv_open = floppy_open,
.bdrv_close = raw_close,
.bdrv_create = hdev_create,
return raw_open_common(bs, filename, flags);
}
+static int cdrom_probe_device(const char *filename)
+{
+ if (strstart(filename, "/dev/cd", NULL))
+ return 100;
+ return 0;
+}
+
static int cdrom_is_inserted(BlockDriverState *bs)
{
BDRVRawState *s = bs->opaque;
static BlockDriver bdrv_host_cdrom = {
.format_name = "host_cdrom",
.instance_size = sizeof(BDRVRawState),
+ .bdrv_probe_device = cdrom_probe_device,
.bdrv_open = cdrom_open,
.bdrv_close = raw_close,
.bdrv_create = hdev_create,
return 0;
}
+static int cdrom_probe_device(const char *filename)
+{
+ if (strstart(filename, "/dev/cd", NULL) ||
+ strstart(filename, "/dev/acd", NULL))
+ return 100;
+ return 0;
+}
+
static int cdrom_reopen(BlockDriverState *bs)
{
BDRVRawState *s = bs->opaque;
static BlockDriver bdrv_host_cdrom = {
.format_name = "host_cdrom",
.instance_size = sizeof(BDRVRawState),
+ .bdrv_probe_device = cdrom_probe_device,
.bdrv_open = cdrom_open,
.bdrv_close = raw_close,
.bdrv_create = hdev_create,
static void bdrv_raw_init(void)
{
+ /*
+ * Register all the drivers. Note that order is important, the driver
+ * registered last will get probed first.
+ */
bdrv_register(&bdrv_raw);
bdrv_register(&bdrv_host_device);
#ifdef __linux__