ia64/xen-unstable

changeset 16526:1b863ae2bf1e

blktap: cleanups for *BSD.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Dec 05 09:59:23 2007 +0000 (2007-12-05)
parents eb4aa1a07e21
children e39931a314c8
files 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
line diff
     1.1 --- a/tools/blktap/drivers/blktapctrl.c	Wed Dec 05 09:57:32 2007 +0000
     1.2 +++ b/tools/blktap/drivers/blktapctrl.c	Wed Dec 05 09:59:23 2007 +0000
     1.3 @@ -37,7 +37,7 @@
     1.4  #include <stdio.h>
     1.5  #include <stdlib.h>
     1.6  #include <sys/mman.h>
     1.7 -#include <sys/user.h>
     1.8 +#include <sys/stat.h>
     1.9  #include <err.h>
    1.10  #include <errno.h>
    1.11  #include <sys/types.h>
    1.12 @@ -684,7 +684,7 @@ static void write_pidfile(long pid)
    1.13  		exit(1);
    1.14  	}
    1.15  
    1.16 -	len = sprintf(buf, "%ld\n", pid);
    1.17 +	len = snprintf(buf, sizeof(buf), "%ld\n", pid);
    1.18  	if (write(fd, buf, len) != len) {
    1.19  		DPRINTF("Writing pid file failed (%d)\n", errno);
    1.20  		exit(1);
     2.1 --- a/tools/blktap/drivers/bswap.h	Wed Dec 05 09:57:32 2007 +0000
     2.2 +++ b/tools/blktap/drivers/bswap.h	Wed Dec 05 09:59:23 2007 +0000
     2.3 @@ -5,9 +5,14 @@
     2.4  
     2.5  #include <inttypes.h>
     2.6  
     2.7 -#if defined(__NetBSD__) || defined(__OpenBSD__)
     2.8 +#if defined(__NetBSD__)
     2.9  #include <sys/endian.h>
    2.10  #include <sys/types.h>
    2.11 +#elif defined(__OpenBSD__)
    2.12 +#include <machine/endian.h>
    2.13 +#define bswap_16(x) swap16(x)
    2.14 +#define bswap_32(x) swap32(x)
    2.15 +#define bswap_64(x) swap64(x)
    2.16  #else
    2.17  
    2.18  #ifdef HAVE_BYTESWAP_H
     3.1 --- a/tools/blktap/lib/blktaplib.h	Wed Dec 05 09:57:32 2007 +0000
     3.2 +++ b/tools/blktap/lib/blktaplib.h	Wed Dec 05 09:59:23 2007 +0000
     3.3 @@ -33,6 +33,7 @@
     3.4  #define __BLKTAPLIB_H__
     3.5  
     3.6  #include <xenctrl.h>
     3.7 +#include <sys/param.h>
     3.8  #include <sys/user.h>
     3.9  #include <xen/xen.h>
    3.10  #include <xen/io/blkif.h>
     4.1 --- a/tools/blktap/lib/list.h	Wed Dec 05 09:57:32 2007 +0000
     4.2 +++ b/tools/blktap/lib/list.h	Wed Dec 05 09:59:23 2007 +0000
     4.3 @@ -8,6 +8,10 @@
     4.4  #ifndef __LIST_H__
     4.5  #define __LIST_H__
     4.6  
     4.7 +#ifdef LIST_HEAD
     4.8 +#undef LIST_HEAD
     4.9 +#endif
    4.10 +
    4.11  #define LIST_POISON1  ((void *) 0x00100100)
    4.12  #define LIST_POISON2  ((void *) 0x00200200)
    4.13  
     5.1 --- a/tools/blktap/lib/xs_api.c	Wed Dec 05 09:57:32 2007 +0000
     5.2 +++ b/tools/blktap/lib/xs_api.c	Wed Dec 05 09:59:23 2007 +0000
     5.3 @@ -282,7 +282,7 @@ int register_xenbus_watch(struct xs_hand
     5.4  	/* Pointer in ascii is the token. */
     5.5  	char token[sizeof(watch) * 2 + 1];
     5.6  
     5.7 -	sprintf(token, "%lX", (long)watch);
     5.8 +	snprintf(token, sizeof(token), "%lX", (long)watch);
     5.9  	if (find_watch(token)) {
    5.10  		DPRINTF("watch collision!\n");
    5.11  		return -EINVAL;
    5.12 @@ -302,7 +302,7 @@ int unregister_xenbus_watch(struct xs_ha
    5.13  {
    5.14  	char token[sizeof(watch) * 2 + 1];
    5.15  	
    5.16 -	sprintf(token, "%lX", (long)watch);
    5.17 +	snprintf(token, sizeof(token), "%lX", (long)watch);
    5.18  	if (!find_watch(token)) {
    5.19  		DPRINTF("no such watch!\n");
    5.20  		return -EINVAL;
    5.21 @@ -326,7 +326,7 @@ void reregister_xenbus_watches(struct xs
    5.22  	char token[sizeof(watch) * 2 + 1];
    5.23  	
    5.24  	list_for_each_entry(watch, &watches, list) {
    5.25 -		sprintf(token, "%lX", (long)watch);
    5.26 +		snprintf(token, sizeof(token), "%lX", (long)watch);
    5.27  		xs_watch(h, watch->node, token);
    5.28  	}
    5.29  }