# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# 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
|