blktap: cleanups for *BSD.
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 5 Dec 2007 09:59:23 +0000 (09:59 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 5 Dec 2007 09:59:23 +0000 (09:59 +0000)
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
tools/blktap/drivers/blktapctrl.c
tools/blktap/drivers/bswap.h
tools/blktap/lib/blktaplib.h
tools/blktap/lib/list.h
tools/blktap/lib/xs_api.c

index 8e630aeeee1c4828c56f060c795f6cbfb61ba65a..b3f59ec58be796c1b073930e9701351feaa64a36 100644 (file)
@@ -37,7 +37,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/mman.h>
-#include <sys/user.h>
+#include <sys/stat.h>
 #include <err.h>
 #include <errno.h>
 #include <sys/types.h>
@@ -684,7 +684,7 @@ static void write_pidfile(long pid)
                exit(1);
        }
 
-       len = sprintf(buf, "%ld\n", pid);
+       len = snprintf(buf, sizeof(buf), "%ld\n", pid);
        if (write(fd, buf, len) != len) {
                DPRINTF("Writing pid file failed (%d)\n", errno);
                exit(1);
index 51251505d32e8623da90547131c01da80abbd217..45016b978bee88e1a5144bed59985b629cc7decf 100644 (file)
@@ -5,9 +5,14 @@
 
 #include <inttypes.h>
 
-#if defined(__NetBSD__) || defined(__OpenBSD__)
+#if defined(__NetBSD__)
 #include <sys/endian.h>
 #include <sys/types.h>
+#elif defined(__OpenBSD__)
+#include <machine/endian.h>
+#define bswap_16(x) swap16(x)
+#define bswap_32(x) swap32(x)
+#define bswap_64(x) swap64(x)
 #else
 
 #ifdef HAVE_BYTESWAP_H
index 9d17c6152ecaf0f85e0e1232092aec5b3e86960b..d31a7fac92650132c185f7d7342cb457e7a55160 100644 (file)
@@ -33,6 +33,7 @@
 #define __BLKTAPLIB_H__
 
 #include <xenctrl.h>
+#include <sys/param.h>
 #include <sys/user.h>
 #include <xen/xen.h>
 #include <xen/io/blkif.h>
index bda5f46a38dfe12f6876a0909959393644f800b6..c82242f56f3f0e91308a0345f040616bb8ef30f1 100644 (file)
@@ -8,6 +8,10 @@
 #ifndef __LIST_H__
 #define __LIST_H__
 
+#ifdef LIST_HEAD
+#undef LIST_HEAD
+#endif
+
 #define LIST_POISON1  ((void *) 0x00100100)
 #define LIST_POISON2  ((void *) 0x00200200)
 
index 41bbd47bb23bf11aed1ae6d045681c9eb73a8973..370a44aa4d69ae0ce7f93ab66afa67578c30761c 100644 (file)
@@ -282,7 +282,7 @@ int register_xenbus_watch(struct xs_handle *h, struct xenbus_watch *watch)
        /* Pointer in ascii is the token. */
        char token[sizeof(watch) * 2 + 1];
 
-       sprintf(token, "%lX", (long)watch);
+       snprintf(token, sizeof(token), "%lX", (long)watch);
        if (find_watch(token)) {
                DPRINTF("watch collision!\n");
                return -EINVAL;
@@ -302,7 +302,7 @@ int unregister_xenbus_watch(struct xs_handle *h, struct xenbus_watch *watch)
 {
        char token[sizeof(watch) * 2 + 1];
        
-       sprintf(token, "%lX", (long)watch);
+       snprintf(token, sizeof(token), "%lX", (long)watch);
        if (!find_watch(token)) {
                DPRINTF("no such watch!\n");
                return -EINVAL;
@@ -326,7 +326,7 @@ void reregister_xenbus_watches(struct xs_handle *h)
        char token[sizeof(watch) * 2 + 1];
        
        list_for_each_entry(watch, &watches, list) {
-               sprintf(token, "%lX", (long)watch);
+               snprintf(token, sizeof(token), "%lX", (long)watch);
                xs_watch(h, watch->node, token);
        }
 }