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-changelog

[Xen-changelog] [xen-3.0.3-testing] [BLKTAP] Find major number by search

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-3.0.3-testing] [BLKTAP] Find major number by searching sysfs
From: "Xen patchbot-3.0.3-testing" <patchbot-3.0.3-testing@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 02 Oct 2006 12:40:58 -0700
Delivery-date: Tue, 03 Oct 2006 01:23:32 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1159538157 -3600
# Node ID 2835083c9c916fdad11110c4810ee271943c1cf6
# Parent  509ff527c59d2ea8aca36f901d0f3fe67f4d52c8
[BLKTAP] Find major number by searching sysfs
instead of reading /proc/devices.

Signed-off-by: Steven Rostedt <srostedt@xxxxxxxxxx>
---
 tools/blktap/drivers/Makefile     |    2 +-
 tools/blktap/drivers/blktapctrl.c |   30 +++---------------------------
 2 files changed, 4 insertions(+), 28 deletions(-)

diff -r 509ff527c59d -r 2835083c9c91 tools/blktap/drivers/Makefile
--- a/tools/blktap/drivers/Makefile     Fri Sep 29 14:42:49 2006 +0100
+++ b/tools/blktap/drivers/Makefile     Fri Sep 29 14:55:57 2006 +0100
@@ -28,7 +28,7 @@ THREADLIB := -lpthread -lz
 THREADLIB := -lpthread -lz
 LIBS      := -L. -L.. -L../lib
 LIBS      += -L$(XEN_LIBXC)
-LIBS      += -lblktap
+LIBS      += -lblktap -lxenctrl
 LIBS      += -lcrypto
 LIBS      += -lz
 LIBS      += -L$(XEN_XENSTORE) -lxenstore
diff -r 509ff527c59d -r 2835083c9c91 tools/blktap/drivers/blktapctrl.c
--- a/tools/blktap/drivers/blktapctrl.c Fri Sep 29 14:42:49 2006 +0100
+++ b/tools/blktap/drivers/blktapctrl.c Fri Sep 29 14:55:57 2006 +0100
@@ -636,30 +636,6 @@ static void print_drivers(void)
                DPRINTF("Found driver: [%s]\n",dtypes[i]->name);
 } 
 
-static int find_blktap_major(void)
-{
-       FILE *fp;
-       int major;
-       char device[256];
-
-       if ((fp = fopen("/proc/devices", "r")) == NULL)
-               return -1;
-
-       /* Skip title */
-       fscanf(fp,"%*s %*s\n");
-       while (fscanf(fp, "%d %255s\n", &major, device) == 2) {
-               if (strncmp("blktap", device, 6) == 0)
-                       break;
-       }
-
-       fclose(fp);
-
-       if (strncmp("blktap", device, 6) == 0)
-               return major;
-
-       return -1;
-}
-
 int main(int argc, char *argv[])
 {
        char *devname;
@@ -681,11 +657,11 @@ int main(int argc, char *argv[])
        register_new_devmap_hook(map_new_blktapctrl);
        register_new_unmap_hook(unmap_blktapctrl);
 
-       /*Attach to blktap0 */  
+       /* Attach to blktap0 */
        asprintf(&devname,"%s/%s0", BLKTAP_DEV_DIR, BLKTAP_DEV_NAME);
-       blktap_major = find_blktap_major();
-       if (blktap_major < 0)
+       if ((ret = xc_find_device_number("blktap0")) < 0)
                goto open_failed;
+       blktap_major = major(ret);
        make_blktap_dev(devname,blktap_major,0);
        ctlfd = open(devname, O_RDWR);
        if (ctlfd == -1) {

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-3.0.3-testing] [BLKTAP] Find major number by searching sysfs, Xen patchbot-3.0.3-testing <=