From 51607e5a4dd1d1ca9b56b73579617b1a876a91ba Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 20 Mar 2008 17:48:02 +0000 Subject: [PATCH] minios: get VBD CD/removable/RO info Signed-off-by: Samuel Thibault --- blkfront.c | 5 ++++- include/blkfront.h | 2 +- kernel.c | 11 ++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/blkfront.c b/blkfront.c index f5cf19c..3a6c22a 100644 --- a/blkfront.c +++ b/blkfront.c @@ -70,7 +70,7 @@ void blkfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data) 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; @@ -176,6 +176,9 @@ done: 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 *sectors = dev->sectors = xenbus_read_integer(path); diff --git a/include/blkfront.h b/include/blkfront.h index 034c793..687f843 100644 --- a/include/blkfront.h +++ b/include/blkfront.h @@ -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 --git a/kernel.c b/kernel.c index a9074fd..96535e5 100644 --- a/kernel.c +++ b/kernel.c @@ -207,10 +207,19 @@ static void blk_write_sector(uint64_t sector) 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) { blk_write_sector(0); -- 2.39.5