WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] minios: get VBD CD/removable/RO info

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] minios: get VBD CD/removable/RO info
From: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
Date: Thu, 20 Mar 2008 17:17:04 +0000
Delivery-date: Thu, 20 Mar 2008 10:18:13 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Mail-followup-to: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.12-2006-07-14
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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] minios: get VBD CD/removable/RO info, Samuel Thibault <=