minios: get VBD CD/removable/RO info
Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
diff -r b0527d995dee extras/mini-os/blkfront.c
--- a/extras/mini-os/blkfront.c Thu Mar 20 17:12:39 2008 +0000
+++ b/extras/mini-os/blkfront.c Thu Mar 20 17:14:36 2008 +0000
@@ -70,7 +70,7 @@ void blkfront_handler(evtchn_port_t port
wake_up(&blkfront_queue);
}
-struct blkfront_dev *init_blkfront(char *nodename, uint64_t *sectors, unsigned
*sector_size, int *mode)
+struct blkfront_dev *init_blkfront(char *nodename, uint64_t *sectors, unsigned
*sector_size, int *mode, int *info)
{
xenbus_transaction_t xbt;
char* err;
@@ -175,6 +175,9 @@ done:
xenbus_wait_for_value(path,"4");
xenbus_unwatch_path(XBT_NIL, path);
+
+ snprintf(path, sizeof(path), "%s/info", dev->backend);
+ *info = xenbus_read_integer(path);
snprintf(path, sizeof(path), "%s/sectors", dev->backend);
// FIXME: read_integer returns an int, so disk size limited to 1TB for
now
diff -r b0527d995dee extras/mini-os/include/blkfront.h
--- a/extras/mini-os/include/blkfront.h Thu Mar 20 17:12:39 2008 +0000
+++ b/extras/mini-os/include/blkfront.h Thu Mar 20 17:14:36 2008 +0000
@@ -15,7 +15,7 @@ struct blkfront_aiocb
void (*aio_cb)(struct blkfront_aiocb *aiocb, int ret);
};
-struct blkfront_dev *init_blkfront(char *nodename, uint64_t *sectors, unsigned
*sector_size, int *mode);
+struct blkfront_dev *init_blkfront(char *nodename, uint64_t *sectors, unsigned
*sector_size, int *mode, int *info);
#ifdef HAVE_LIBC
int blkfront_open(struct blkfront_dev *dev);
#endif
diff -r b0527d995dee extras/mini-os/kernel.c
--- a/extras/mini-os/kernel.c Thu Mar 20 17:12:39 2008 +0000
+++ b/extras/mini-os/kernel.c Thu Mar 20 17:14:36 2008 +0000
@@ -207,9 +207,18 @@ static void blkfront_thread(void *p)
static void blkfront_thread(void *p)
{
time_t lasttime = 0;
- blk_dev = init_blkfront(NULL, &blk_sectors, &blk_sector_size, &blk_mode);
+ int blk_info;
+
+ blk_dev = init_blkfront(NULL, &blk_sectors, &blk_sector_size, &blk_mode,
&blk_info);
if (!blk_dev)
return;
+
+ if (blk_info & VDISK_CDROM)
+ printk("Block device is a CDROM\n");
+ if (blk_info & VDISK_REMOVABLE)
+ printk("Block device is removable\n");
+ if (blk_info & VDISK_READONLY)
+ printk("Block device is read-only\n");
#ifdef BLKTEST_WRITE
if (blk_mode == O_RDWR) {
diff -r b0527d995dee tools/ioemu/block-vbd.c
--- a/tools/ioemu/block-vbd.c Thu Mar 20 17:12:39 2008 +0000
+++ b/tools/ioemu/block-vbd.c Thu Mar 20 17:14:36 2008 +0000
@@ -51,6 +51,7 @@ typedef struct BDRVVbdState {
int fd;
int type;
int mode;
+ int info;
uint64_t sectors;
unsigned sector_size;
QEMU_LIST_ENTRY(BDRVVbdState) list;
@@ -80,7 +81,7 @@ static int vbd_open(BlockDriverState *bs
//handy to test posix access
//return -EIO;
- s->dev = init_blkfront((char *) filename, &s->sectors, &s->sector_size,
&s->mode);
+ s->dev = init_blkfront((char *) filename, &s->sectors, &s->sector_size,
&s->mode, &s->info);
if (!s->dev)
return -EIO;
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|