ia64/xen-unstable

changeset 19817:b7f73a7f3078

blktap2: portability fixes for NetBSD

- Use standard off_t and lseek() instead of non-portable off64_t and
lseek64()
- Use uuid API as documented in DCE 1.1 RPC specification
- Add NetBSD implementation for blk_getimagesize() and
blk_getsectorsize()
- Use blk_getimagesize() and blk_getsectorsize()
- Fix uuid header check

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jun 23 17:24:14 2009 +0100 (2009-06-23)
parents 5f5112a7d2ff
children 415505139333
files tools/Makefile tools/blktap2/drivers/Makefile tools/blktap2/drivers/blk.h tools/blktap2/drivers/blk_netbsd.c tools/blktap2/drivers/block-aio.c tools/blktap2/drivers/block-log.c tools/blktap2/drivers/block-qcow.c tools/blktap2/drivers/block-ram.c tools/blktap2/drivers/block-vhd.c tools/blktap2/drivers/tapdisk-client.c tools/blktap2/drivers/tapdisk-diff.c tools/blktap2/drivers/tapdisk-filter.c tools/blktap2/drivers/tapdisk-log.c tools/blktap2/drivers/tapdisk-queue.c tools/blktap2/drivers/tapdisk-utils.c tools/blktap2/drivers/tapdisk-vbd.c tools/blktap2/drivers/tapdisk.h tools/blktap2/include/libvhd.h tools/blktap2/include/list.h tools/blktap2/include/uuid.h tools/blktap2/include/vhd.h tools/blktap2/vhd/Makefile tools/blktap2/vhd/lib/Makefile tools/blktap2/vhd/lib/libvhd-journal.c tools/blktap2/vhd/lib/libvhd.c tools/blktap2/vhd/lib/vhd-util-check.c tools/blktap2/vhd/lib/vhd-util-coalesce.c tools/blktap2/vhd/lib/vhd-util-modify.c tools/blktap2/vhd/lib/vhd-util-query.c tools/blktap2/vhd/lib/vhd-util-read.c tools/blktap2/vhd/lib/vhd-util-repair.c tools/blktap2/vhd/lib/vhd-util-resize.c tools/blktap2/vhd/lib/vhd-util-scan.c tools/blktap2/vhd/lib/vhd-util-set-field.c tools/blktap2/vhd/vhd-update.c tools/check/check_uuid_devel
line diff
     1.1 --- a/tools/Makefile	Tue Jun 23 11:27:54 2009 +0100
     1.2 +++ b/tools/Makefile	Tue Jun 23 17:24:14 2009 +0100
     1.3 @@ -23,9 +23,12 @@ SUBDIRS-y += xenstat
     1.4  SUBDIRS-$(CONFIG_Linux) += libaio
     1.5  SUBDIRS-$(CONFIG_Linux) += blktap
     1.6  SUBDIRS-$(CONFIG_Linux) += blktap2
     1.7 +SUBDIRS-$(CONFIG_NetBSD) += libaio
     1.8 +SUBDIRS-$(CONFIG_NetBSD) += blktap2
     1.9  SUBDIRS-y += libfsimage
    1.10  SUBDIRS-$(LIBXENAPI_BINDINGS) += libxen
    1.11  SUBDIRS-$(CONFIG_Linux) += fs-back
    1.12 +SUBDIRS-$(CONFIG_NetBSD) += fs-back
    1.13  SUBDIRS-$(CONFIG_IOEMU) += ioemu-dir
    1.14  SUBDIRS-y += xenpmd
    1.15  
     2.1 --- a/tools/blktap2/drivers/Makefile	Tue Jun 23 11:27:54 2009 +0100
     2.2 +++ b/tools/blktap2/drivers/Makefile	Tue Jun 23 17:24:14 2009 +0100
     2.3 @@ -24,6 +24,7 @@ endif
     2.4  
     2.5  LIBS      += -lrt -lz
     2.6  
     2.7 +ifeq ($(CONFIG_Linux),y)
     2.8  ifeq ($(shell . ./check_gcrypt $(CC)),yes)
     2.9  CFLAGS += -DUSE_GCRYPT
    2.10  CRYPT_LIB += -lgcrypt
    2.11 @@ -31,10 +32,17 @@ else
    2.12  CRYPT_LIB += -lcrypto
    2.13  $(warning === libgcrypt not installed: falling back to libcrypto ===)
    2.14  endif
    2.15 +else
    2.16 +CRYPT_LIB += -lcrypto
    2.17 +endif
    2.18  
    2.19  LDFLAGS_img := $(CRYPT_LIB) -lpthread -lz
    2.20  
    2.21 -tapdisk2 td-util tapdisk-stream tapdisk-diff $(QCOW_UTIL): LIBS += -L$(LIBVHDDIR) -lvhd -luuid
    2.22 +LIBS += -L$(LIBVHDDIR) -lvhd
    2.23 +
    2.24 +ifeq ($(CONFIG_Linux),y)
    2.25 +LIBS += -luuid
    2.26 +endif
    2.27  
    2.28  LIBAIO_DIR = $(XEN_ROOT)/tools/libaio/src
    2.29  tapdisk2 tapdisk-stream tapdisk-diff $(QCOW_UTIL): AIOLIBS := $(LIBAIO_DIR)/libaio.a
    2.30 @@ -44,6 +52,10 @@ ifeq ($(VHD_STATIC),y)
    2.31  td-util: CFLAGS += -static
    2.32  endif
    2.33  
    2.34 +PORTABLE-OBJS-y :=
    2.35 +PORTABLE-OBJS-$(CONFIG_Linux)  += blk_linux.o
    2.36 +PORTABLE-OBJS-$(CONFIG_NetBSD) += blk_netbsd.o
    2.37 +
    2.38  TAP-OBJS-y  := scheduler.o
    2.39  TAP-OBJS-y  += tapdisk-ipc.o
    2.40  TAP-OBJS-y  += tapdisk-vbd.o
    2.41 @@ -57,7 +69,7 @@ TAP-OBJS-y  += tapdisk-log.o
    2.42  TAP-OBJS-y  += tapdisk-utils.o
    2.43  TAP-OBJS-y  += io-optimize.o
    2.44  TAP-OBJS-y  += lock.o
    2.45 -TAP-OBJS-$(CONFIG_Linux)  += blk_linux.o
    2.46 +TAP-OBJS-y  += $(PORTABLE-OBJS-y)
    2.47  
    2.48  MISC-OBJS-y := atomicio.o
    2.49  
    2.50 @@ -68,6 +80,7 @@ BLK-OBJS-y  += block-vhd.o
    2.51  BLK-OBJS-y  += block-log.o
    2.52  BLK-OBJS-y  += block-qcow.o
    2.53  BLK-OBJS-y  += aes.o
    2.54 +BLK-OBJS-y  += $(PORTABLE-OBJS-y)
    2.55  
    2.56  all: $(IBIN) lock-util qcow-util
    2.57  
    2.58 @@ -81,7 +94,7 @@ tapdisk-client: tapdisk-client.o
    2.59  tapdisk-stream tapdisk-diff: %: %.o $(TAP-OBJS-y) $(BLK-OBJS-y)
    2.60  	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS)  $(LDFLAGS_img)
    2.61  
    2.62 -td-util: td.o tapdisk-utils.o tapdisk-log.o
    2.63 +td-util: td.o tapdisk-utils.o tapdisk-log.o $(PORTABLE-OBJS-y)
    2.64  	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)  $(LDFLAGS_img)
    2.65  
    2.66  lock-util: lock.c
     3.1 --- a/tools/blktap2/drivers/blk.h	Tue Jun 23 11:27:54 2009 +0100
     3.2 +++ b/tools/blktap2/drivers/blk.h	Tue Jun 23 17:24:14 2009 +0100
     3.3 @@ -26,5 +26,11 @@
     3.4   * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     3.5  */
     3.6  
     3.7 +#include <inttypes.h>
     3.8 +
     3.9  int blk_getimagesize(int fd, uint64_t *size);
    3.10  int blk_getsectorsize(int fd, uint64_t *sector_size);
    3.11 +
    3.12 +#ifndef O_LARGEFILE
    3.13 +#define O_LARGEFILE	0
    3.14 +#endif
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/tools/blktap2/drivers/blk_netbsd.c	Tue Jun 23 17:24:14 2009 +0100
     4.3 @@ -0,0 +1,41 @@
     4.4 +#include <sys/param.h>
     4.5 +#include <sys/ioctl.h>
     4.6 +#include <sys/disklabel.h>
     4.7 +#include <errno.h>
     4.8 +#include <inttypes.h>
     4.9 +#include "tapdisk.h"
    4.10 +#include "blk.h"
    4.11 +
    4.12 +int blk_getimagesize(int fd, uint64_t *size)
    4.13 +{
    4.14 +	int rc;
    4.15 +	struct disklabel dl;
    4.16 +
    4.17 +	*size = 0;
    4.18 +	rc = ioctl(fd, DIOCGDINFO, &dl);
    4.19 +	if (rc) {
    4.20 +		DPRINTF("ERR: DIOCGDINFO failed, couldn't stat image");
    4.21 +		return -EINVAL;
    4.22 +	}
    4.23 +
    4.24 +	*size = dl.d_secsize * dl.d_secpercyl;
    4.25 +
    4.26 +	return 0;
    4.27 +}
    4.28 +
    4.29 +int blk_getsectorsize(int fd, uint64_t *sector_size)
    4.30 +{
    4.31 +	int rc;
    4.32 +	struct disklabel dl;
    4.33 +
    4.34 +	*sector_size = DEV_BSIZE;
    4.35 +	rc = ioctl(fd, DIOCGDINFO, &dl);
    4.36 +	if (rc) {
    4.37 +		DPRINTF("ERR: DIOCGDINFO failed, couldn't stat image");
    4.38 +		return 0; /* fallback to DEV_BSIZE */
    4.39 +	}
    4.40 +
    4.41 +	*sector_size = dl.d_secsize;
    4.42 +	return 0;
    4.43 +}
    4.44 +
     5.1 --- a/tools/blktap2/drivers/block-aio.c	Tue Jun 23 11:27:54 2009 +0100
     5.2 +++ b/tools/blktap2/drivers/block-aio.c	Tue Jun 23 17:24:14 2009 +0100
     5.3 @@ -36,8 +36,8 @@
     5.4  #include <sys/statvfs.h>
     5.5  #include <sys/stat.h>
     5.6  #include <sys/ioctl.h>
     5.7 -#include <linux/fs.h>
     5.8  
     5.9 +#include "blk.h"
    5.10  #include "tapdisk.h"
    5.11  #include "tapdisk-driver.h"
    5.12  #include "tapdisk-interface.h"
    5.13 @@ -79,10 +79,8 @@ static int tdaio_get_image_info(int fd, 
    5.14  	if (S_ISBLK(stat.st_mode)) {
    5.15  		/*Accessing block device directly*/
    5.16  		info->size = 0;
    5.17 -		if (ioctl(fd,BLKGETSIZE,&info->size)!=0) {
    5.18 -			DPRINTF("ERR: BLKGETSIZE failed, couldn't stat image");
    5.19 +		if (blk_getimagesize(fd, &info->size) != 0)
    5.20  			return -EINVAL;
    5.21 -		}
    5.22  
    5.23  		DPRINTF("Image size: \n\tpre sector_shift  [%llu]\n\tpost "
    5.24  			"sector_shift [%llu]\n",
    5.25 @@ -90,19 +88,8 @@ static int tdaio_get_image_info(int fd, 
    5.26  			(long long unsigned)info->size);
    5.27  
    5.28  		/*Get the sector size*/
    5.29 -#if defined(BLKSSZGET)
    5.30 -		{
    5.31 -			int arg;
    5.32 +		if (blk_getsectorsize(fd, &info->sector_size) != 0)
    5.33  			info->sector_size = DEFAULT_SECTOR_SIZE;
    5.34 -			ioctl(fd, BLKSSZGET, &info->sector_size);
    5.35 -			
    5.36 -			if (info->sector_size != DEFAULT_SECTOR_SIZE)
    5.37 -				DPRINTF("Note: sector size is %ld (not %d)\n",
    5.38 -					info->sector_size, DEFAULT_SECTOR_SIZE);
    5.39 -		}
    5.40 -#else
    5.41 -		info->sector_size = DEFAULT_SECTOR_SIZE;
    5.42 -#endif
    5.43  
    5.44  	} else {
    5.45  		/*Local file? try fstat instead*/
     6.1 --- a/tools/blktap2/drivers/block-log.c	Tue Jun 23 11:27:54 2009 +0100
     6.2 +++ b/tools/blktap2/drivers/block-log.c	Tue Jun 23 17:24:14 2009 +0100
     6.3 @@ -314,7 +314,7 @@ static int ctl_open(struct tdlog_state* 
     6.4      goto err_sock;
     6.5    }
     6.6      
     6.7 -  if (bind(s->ctl.fd, &saddr, sizeof(saddr)) < 0) {
     6.8 +  if (bind(s->ctl.fd, (const struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
     6.9      BWPRINTF("error binding control socket to %s: %s", s->ctlpath,
    6.10  	     strerror(errno));
    6.11      goto err_sock;
     7.1 --- a/tools/blktap2/drivers/block-qcow.c	Tue Jun 23 11:27:54 2009 +0100
     7.2 +++ b/tools/blktap2/drivers/block-qcow.c	Tue Jun 23 17:24:14 2009 +0100
     7.3 @@ -29,7 +29,6 @@
     7.4  #include <sys/statvfs.h>
     7.5  #include <sys/stat.h>
     7.6  #include <sys/ioctl.h>
     7.7 -#include <linux/fs.h>
     7.8  #include <string.h>
     7.9  #include <zlib.h>
    7.10  #include <inttypes.h>
    7.11 @@ -990,8 +989,8 @@ int tdqcow_open (td_driver_t *driver, co
    7.12  		s->fd_end = s->l1_table_offset +
    7.13  			((s->l1_size * sizeof(uint64_t) + 4095) & ~4095);
    7.14  	else {
    7.15 -		s->fd_end = lseek64(fd, 0, SEEK_END);
    7.16 -		if (s->fd_end == (off64_t)-1)
    7.17 +		s->fd_end = lseek(fd, 0, SEEK_END);
    7.18 +		if (s->fd_end == (off_t)-1)
    7.19  			goto fail;
    7.20  	}
    7.21  
     8.1 --- a/tools/blktap2/drivers/block-ram.c	Tue Jun 23 11:27:54 2009 +0100
     8.2 +++ b/tools/blktap2/drivers/block-ram.c	Tue Jun 23 17:24:14 2009 +0100
     8.3 @@ -34,9 +34,9 @@
     8.4  #include <sys/statvfs.h>
     8.5  #include <sys/stat.h>
     8.6  #include <sys/ioctl.h>
     8.7 -#include <linux/fs.h>
     8.8  #include <string.h>
     8.9  
    8.10 +#include "blk.h"
    8.11  #include "tapdisk.h"
    8.12  #include "tapdisk-driver.h"
    8.13  #include "tapdisk-interface.h"
    8.14 @@ -69,10 +69,8 @@ static int get_image_info(int fd, td_dis
    8.15  	if (S_ISBLK(stat.st_mode)) {
    8.16  		/*Accessing block device directly*/
    8.17  		info->size = 0;
    8.18 -		if (ioctl(fd,BLKGETSIZE,&info->size)!=0) {
    8.19 -			DPRINTF("ERR: BLKGETSIZE failed, couldn't stat image");
    8.20 +		if (blk_getimagesize(fd, &info->size) != 0)
    8.21  			return -EINVAL;
    8.22 -		}
    8.23  
    8.24  		DPRINTF("Image size: \n\tpre sector_shift  [%llu]\n\tpost "
    8.25  			"sector_shift [%llu]\n",
    8.26 @@ -80,19 +78,8 @@ static int get_image_info(int fd, td_dis
    8.27  			(long long unsigned)info->size);
    8.28  
    8.29  		/*Get the sector size*/
    8.30 -#if defined(BLKSSZGET)
    8.31 -		{
    8.32 -			int arg;
    8.33 +		if (blk_getsectorsize(fd, &info->sector_size) != 0)
    8.34  			info->sector_size = DEFAULT_SECTOR_SIZE;
    8.35 -			ioctl(fd, BLKSSZGET, &info->sector_size);
    8.36 -			
    8.37 -			if (info->sector_size != DEFAULT_SECTOR_SIZE)
    8.38 -				DPRINTF("Note: sector size is %ld (not %d)\n",
    8.39 -					info->sector_size, DEFAULT_SECTOR_SIZE);
    8.40 -		}
    8.41 -#else
    8.42 -		info->sector_size = DEFAULT_SECTOR_SIZE;
    8.43 -#endif
    8.44  
    8.45  	} else {
    8.46  		/*Local file? try fstat instead*/
     9.1 --- a/tools/blktap2/drivers/block-vhd.c	Tue Jun 23 11:27:54 2009 +0100
     9.2 +++ b/tools/blktap2/drivers/block-vhd.c	Tue Jun 23 17:24:14 2009 +0100
     9.3 @@ -50,8 +50,6 @@
     9.4  #include <unistd.h>
     9.5  #include <sys/stat.h>
     9.6  #include <sys/ioctl.h>
     9.7 -#include <uuid/uuid.h> /* For whatever reason, Linux packages this in */
     9.8 -                       /* e2fsprogs-devel.                            */
     9.9  #include <string.h>    /* for memset.                                 */
    9.10  #include <libaio.h>
    9.11  #include <sys/mman.h>
    9.12 @@ -275,7 +273,7 @@ vhd_initialize(struct vhd_state *s)
    9.13  		_vhd_zsize += VHD_BLOCK_SIZE;
    9.14  
    9.15  	_vhd_zeros = mmap(0, _vhd_zsize, PROT_READ,
    9.16 -			  MAP_SHARED | MAP_ANONYMOUS, -1, 0);
    9.17 +			  MAP_SHARED | MAP_ANON, -1, 0);
    9.18  	if (_vhd_zeros == MAP_FAILED) {
    9.19  		EPRINTF("vhd_initialize failed: %d\n", -errno);
    9.20  		_vhd_zeros = NULL;
    9.21 @@ -334,7 +332,7 @@ static int
    9.22  vhd_kill_footer(struct vhd_state *s)
    9.23  {
    9.24  	int err;
    9.25 -	off64_t end;
    9.26 +	off_t end;
    9.27  	char *zeros;
    9.28  
    9.29  	if (s->vhd.footer.type == HD_TYPE_FIXED)
    9.30 @@ -347,10 +345,10 @@ vhd_kill_footer(struct vhd_state *s)
    9.31  	err = 1;
    9.32  	memset(zeros, 0xc7c7c7c7, 512);
    9.33  
    9.34 -	if ((end = lseek64(s->vhd.fd, 0, SEEK_END)) == -1)
    9.35 +	if ((end = lseek(s->vhd.fd, 0, SEEK_END)) == -1)
    9.36  		goto fail;
    9.37  
    9.38 -	if (lseek64(s->vhd.fd, (end - 512), SEEK_SET) == -1)
    9.39 +	if (lseek(s->vhd.fd, (end - 512), SEEK_SET) == -1)
    9.40  		goto fail;
    9.41  
    9.42  	if (write(s->vhd.fd, zeros, 512) != 512)
    9.43 @@ -369,7 +367,7 @@ static inline int
    9.44  find_next_free_block(struct vhd_state *s)
    9.45  {
    9.46  	int err;
    9.47 -	off64_t eom;
    9.48 +	off_t eom;
    9.49  	uint32_t i, entry;
    9.50  
    9.51  	err = vhd_end_of_headers(&s->vhd, &eom);
    9.52 @@ -772,6 +770,7 @@ int
    9.53  vhd_validate_parent(td_driver_t *child_driver,
    9.54  		    td_driver_t *parent_driver, td_flag_t flags)
    9.55  {
    9.56 +	uint32_t status;
    9.57  	struct stat stats;
    9.58  	struct vhd_state *child  = (struct vhd_state *)child_driver->data;
    9.59  	struct vhd_state *parent;
    10.1 --- a/tools/blktap2/drivers/tapdisk-client.c	Tue Jun 23 11:27:54 2009 +0100
    10.2 +++ b/tools/blktap2/drivers/tapdisk-client.c	Tue Jun 23 17:24:14 2009 +0100
    10.3 @@ -109,7 +109,7 @@ static int tdctl_open(const char* sockpa
    10.4    saddr.sun_family = AF_UNIX;
    10.5    memcpy(saddr.sun_path, sockpath, strlen(sockpath));
    10.6  
    10.7 -  if (connect(fd, &saddr, sizeof(saddr)) < 0) {
    10.8 +  if (connect(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
    10.9      BWPRINTF("error connecting to socket %s: %s", sockpath, strerror(errno));
   10.10      close(fd);
   10.11      return -1;
    11.1 --- a/tools/blktap2/drivers/tapdisk-diff.c	Tue Jun 23 11:27:54 2009 +0100
    11.2 +++ b/tools/blktap2/drivers/tapdisk-diff.c	Tue Jun 23 17:24:14 2009 +0100
    11.3 @@ -31,6 +31,7 @@
    11.4  #include <stdlib.h>
    11.5  #include <string.h>
    11.6  #include <assert.h>
    11.7 +#include <libgen.h>	/* for basename(3) */
    11.8  #include <unistd.h>
    11.9  
   11.10  #include "list.h"
    12.1 --- a/tools/blktap2/drivers/tapdisk-filter.c	Tue Jun 23 11:27:54 2009 +0100
    12.2 +++ b/tools/blktap2/drivers/tapdisk-filter.c	Tue Jun 23 17:24:14 2009 +0100
    12.3 @@ -113,10 +113,11 @@ check_hash(struct tfilter *filter, uint6
    12.4  	if (hash->hash != chksum(buf)) {
    12.5  		struct timeval now;
    12.6  		gettimeofday(&now, NULL);
    12.7 -		DBG("%s: hash table: 0x%020" PRIx64 " at %012lu.%06lu, "
    12.8 -		    "from disk: 0x%020" PRIx64 " at %012lu.%06lu\n",
    12.9 +		DBG("%s: hash table: 0x%020" PRIx64 " at %012lu.%06llu, "
   12.10 +		    "from disk: 0x%020" PRIx64 " at %012lu.%06llu\n",
   12.11  		    type, hash->hash, hash->time.tv_sec,
   12.12 -		    hash->time.tv_usec, sum, now.tv_sec, now.tv_usec);
   12.13 +		    (unsigned long long)hash->time.tv_usec, sum,
   12.14 +		    now.tv_sec, (unsigned long long)now.tv_usec);
   12.15  	}
   12.16  }
   12.17  
    13.1 --- a/tools/blktap2/drivers/tapdisk-log.c	Tue Jun 23 11:27:54 2009 +0100
    13.2 +++ b/tools/blktap2/drivers/tapdisk-log.c	Tue Jun 23 17:24:14 2009 +0100
    13.3 @@ -126,8 +126,9 @@ void
    13.4  
    13.5  	buf = tapdisk_log.p;
    13.6  	gettimeofday(&t, NULL);
    13.7 -	len = snprintf(buf, MAX_ENTRY_LEN - 1, "%08"PRIu64":%010ld.%06ld:"
    13.8 -		       "%s ", tapdisk_log.cnt, t.tv_sec, t.tv_usec, func);
    13.9 +	len = snprintf(buf, MAX_ENTRY_LEN - 1, "%08"PRIu64":%010ld.%06lld:"
   13.10 +		       "%s ", tapdisk_log.cnt,
   13.11 +			t.tv_sec, (unsigned long long)t.tv_usec, func);
   13.12  
   13.13  	va_start(ap, fmt);
   13.14  	ret = vsnprintf(buf + len, MAX_ENTRY_LEN - (len + 1), fmt, ap);
   13.15 @@ -167,8 +168,8 @@ void
   13.16  	gettimeofday(&t, NULL);
   13.17  	e = &tapdisk_err.errors[tapdisk_err.cnt];
   13.18  
   13.19 -	len = snprintf(e->msg, MAX_ENTRY_LEN - 1, "%010ld.%06ld:%s ",
   13.20 -		       t.tv_sec, t.tv_usec, func);
   13.21 +	len = snprintf(e->msg, MAX_ENTRY_LEN - 1, "%010ld.%06lld:%s ",
   13.22 +		       t.tv_sec, (unsigned long long)t.tv_usec, func);
   13.23  
   13.24  	va_start(ap, fmt);
   13.25  	ret = vsnprintf(e->msg + len, MAX_ENTRY_LEN - (len + 1), fmt, ap);
   13.26 @@ -237,7 +238,7 @@ tlog_flush(void)
   13.27  		return;
   13.28  
   13.29  	if (tapdisk_log.append)
   13.30 -		if (lseek64(fd, 0, SEEK_END) == (loff_t)-1)
   13.31 +		if (lseek(fd, 0, SEEK_END) == (off_t)-1)
   13.32  			goto out;
   13.33  
   13.34  	tlog_flush_errors();
    14.1 --- a/tools/blktap2/drivers/tapdisk-queue.c	Tue Jun 23 11:27:54 2009 +0100
    14.2 +++ b/tools/blktap2/drivers/tapdisk-queue.c	Tue Jun 23 17:24:14 2009 +0100
    14.3 @@ -174,7 +174,7 @@ iocb_rw(struct iocb *iocb)
    14.4  	ssize_t (*func)(int, void *, size_t) = 
    14.5  		(iocb->aio_lio_opcode == IO_CMD_PWRITE ? vwrite : read);
    14.6  
    14.7 -	if (lseek64(fd, off, SEEK_SET) == (off64_t)-1)
    14.8 +	if (lseek(fd, off, SEEK_SET) == (off_t)-1)
    14.9  		return -errno;
   14.10  	
   14.11  	if (atomicio(func, fd, buf, size) != size)
    15.1 --- a/tools/blktap2/drivers/tapdisk-utils.c	Tue Jun 23 11:27:54 2009 +0100
    15.2 +++ b/tools/blktap2/drivers/tapdisk-utils.c	Tue Jun 23 17:24:14 2009 +0100
    15.3 @@ -29,12 +29,12 @@
    15.4  #include <stdio.h>
    15.5  #include <string.h>
    15.6  #include <unistd.h>
    15.7 -#include <linux/fs.h>
    15.8  #include <sys/stat.h>
    15.9  #include <sys/mman.h>
   15.10  #include <sys/ioctl.h>
   15.11  #include <sys/resource.h>
   15.12  
   15.13 +#include "blk.h"
   15.14  #include "tapdisk.h"
   15.15  #include "disktypes.h"
   15.16  #include "blktaplib.h"
   15.17 @@ -150,7 +150,7 @@ tapdisk_get_image_size(int fd, uint64_t 
   15.18  	int ret;
   15.19  	struct stat stat;
   15.20  	uint64_t sectors;
   15.21 -	uint32_t sector_size;
   15.22 +	uint64_t sector_size;
   15.23  
   15.24  	sectors       = 0;
   15.25  	sector_size   = 0;
   15.26 @@ -164,26 +164,12 @@ tapdisk_get_image_size(int fd, uint64_t 
   15.27  
   15.28  	if (S_ISBLK(stat.st_mode)) {
   15.29  		/*Accessing block device directly*/
   15.30 -		if (ioctl(fd, BLKGETSIZE, &sectors)) {
   15.31 -			DPRINTF("ERR: BLKGETSIZE failed, couldn't stat image");
   15.32 +		if (blk_getimagesize(fd, &sectors) != 0)
   15.33  			return -EINVAL;
   15.34 -		}
   15.35  
   15.36  		/*Get the sector size*/
   15.37 -#if defined(BLKSSZGET)
   15.38 -		{
   15.39 -			int arg;
   15.40 +		if (blk_getsectorsize(fd, &sector_size) != 0)
   15.41  			sector_size = DEFAULT_SECTOR_SIZE;
   15.42 -			ioctl(fd, BLKSSZGET, &sector_size);
   15.43 -
   15.44 -			if (sector_size != DEFAULT_SECTOR_SIZE)
   15.45 -				DPRINTF("Note: sector size is %u (not %d)\n",
   15.46 -					sector_size, DEFAULT_SECTOR_SIZE);
   15.47 -		}
   15.48 -#else
   15.49 -		sector_size = DEFAULT_SECTOR_SIZE;
   15.50 -#endif
   15.51 -
   15.52  	} else {
   15.53  		/*Local file? try fstat instead*/
   15.54  		sectors     = (stat.st_size >> SECTOR_SHIFT);
    16.1 --- a/tools/blktap2/drivers/tapdisk-vbd.c	Tue Jun 23 11:27:54 2009 +0100
    16.2 +++ b/tools/blktap2/drivers/tapdisk-vbd.c	Tue Jun 23 17:24:14 2009 +0100
    16.3 @@ -826,10 +826,10 @@ tapdisk_vbd_shutdown(td_vbd_t *vbd)
    16.4  	DPRINTF("%s: state: 0x%08x, new: 0x%02x, pending: 0x%02x, "
    16.5  		"failed: 0x%02x, completed: 0x%02x\n", 
    16.6  		vbd->name, vbd->state, new, pending, failed, completed);
    16.7 -	DPRINTF("last activity: %010ld.%06ld, errors: 0x%04"PRIx64", "
    16.8 +	DPRINTF("last activity: %010ld.%06lld, errors: 0x%04"PRIx64", "
    16.9  		"retries: 0x%04"PRIx64", received: 0x%08"PRIx64", "
   16.10  		"returned: 0x%08"PRIx64", kicked: 0x%08"PRIx64"\n",
   16.11 -		vbd->ts.tv_sec, vbd->ts.tv_usec,
   16.12 +		vbd->ts.tv_sec, (unsigned long long)vbd->ts.tv_usec,
   16.13  		vbd->errors, vbd->retries, vbd->received, vbd->returned,
   16.14  		vbd->kicked);
   16.15  
   16.16 @@ -886,11 +886,12 @@ tapdisk_vbd_debug(td_vbd_t *vbd)
   16.17  	tapdisk_vbd_queue_count(vbd, &new, &pending, &failed, &completed);
   16.18  
   16.19  	DBG(TLOG_WARN, "%s: state: 0x%08x, new: 0x%02x, pending: 0x%02x, "
   16.20 -	    "failed: 0x%02x, completed: 0x%02x, last activity: %010ld.%06ld, "
   16.21 +	    "failed: 0x%02x, completed: 0x%02x, last activity: %010ld.%06lld, "
   16.22  	    "errors: 0x%04"PRIx64", retries: 0x%04"PRIx64", received: 0x%08"PRIx64", "
   16.23  	    "returned: 0x%08"PRIx64", kicked: 0x%08"PRIx64"\n",
   16.24  	    vbd->name, vbd->state, new, pending, failed, completed,
   16.25 -	    vbd->ts.tv_sec, vbd->ts.tv_usec, vbd->errors, vbd->retries,
   16.26 +	    vbd->ts.tv_sec, (unsigned long long)vbd->ts.tv_usec,
   16.27 +	    vbd->errors, vbd->retries,
   16.28  	    vbd->received, vbd->returned, vbd->kicked);
   16.29  
   16.30  	tapdisk_vbd_for_each_image(vbd, image, tmp)
    17.1 --- a/tools/blktap2/drivers/tapdisk.h	Tue Jun 23 11:27:54 2009 +0100
    17.2 +++ b/tools/blktap2/drivers/tapdisk.h	Tue Jun 23 17:24:14 2009 +0100
    17.3 @@ -111,7 +111,7 @@ struct td_disk_id {
    17.4  
    17.5  struct td_disk_info {
    17.6  	td_sector_t                  size;
    17.7 -        long                         sector_size;
    17.8 +        uint64_t                     sector_size;
    17.9  	uint32_t                     info;
   17.10  };
   17.11  
    18.1 --- a/tools/blktap2/include/libvhd.h	Tue Jun 23 11:27:54 2009 +0100
    18.2 +++ b/tools/blktap2/include/libvhd.h	Tue Jun 23 17:24:14 2009 +0100
    18.3 @@ -28,19 +28,37 @@
    18.4  #define _VHD_LIB_H_
    18.5  
    18.6  #include <string.h>
    18.7 +#if defined(__linux__) || defined(__Linux__)
    18.8  #include <endian.h>
    18.9  #include <byteswap.h>
   18.10 -#include <uuid/uuid.h>
   18.11 +#elif defined(__NetBSD__)
   18.12 +#include <sys/endian.h>
   18.13 +#include <sys/bswap.h>
   18.14 +#endif
   18.15  
   18.16 +#include "uuid.h"
   18.17  #include "vhd.h"
   18.18  
   18.19 +#ifndef O_LARGEFILE
   18.20 +#define O_LARGEFILE	0
   18.21 +#endif
   18.22 +
   18.23  #if BYTE_ORDER == LITTLE_ENDIAN
   18.24 +#if defined(__linux__) || defined(__Linux__)
   18.25    #define BE16_IN(foo)             (*(foo)) = bswap_16(*(foo))
   18.26    #define BE32_IN(foo)             (*(foo)) = bswap_32(*(foo))
   18.27    #define BE64_IN(foo)             (*(foo)) = bswap_64(*(foo))
   18.28    #define BE16_OUT(foo)            (*(foo)) = bswap_16(*(foo))
   18.29    #define BE32_OUT(foo)            (*(foo)) = bswap_32(*(foo))
   18.30    #define BE64_OUT(foo)            (*(foo)) = bswap_64(*(foo))
   18.31 +#elif defined(__NetBSD__)
   18.32 +  #define BE16_IN(foo)             (*(foo)) = bswap16(*(foo))
   18.33 +  #define BE32_IN(foo)             (*(foo)) = bswap32(*(foo))
   18.34 +  #define BE64_IN(foo)             (*(foo)) = bswap64(*(foo))
   18.35 +  #define BE16_OUT(foo)            (*(foo)) = bswap16(*(foo))
   18.36 +  #define BE32_OUT(foo)            (*(foo)) = bswap32(*(foo))
   18.37 +  #define BE64_OUT(foo)            (*(foo)) = bswap64(*(foo))
   18.38 +#endif
   18.39  #else
   18.40    #define BE16_IN(foo)
   18.41    #define BE32_IN(foo)
   18.42 @@ -239,16 +257,16 @@ int vhd_snapshot(const char *snapshot, u
   18.43  int vhd_hidden(vhd_context_t *, int *);
   18.44  int vhd_chain_depth(vhd_context_t *, int *);
   18.45  
   18.46 -off64_t vhd_position(vhd_context_t *);
   18.47 -int vhd_seek(vhd_context_t *, off64_t, int);
   18.48 +off_t vhd_position(vhd_context_t *);
   18.49 +int vhd_seek(vhd_context_t *, off_t, int);
   18.50  int vhd_read(vhd_context_t *, void *, size_t);
   18.51  int vhd_write(vhd_context_t *, void *, size_t);
   18.52  
   18.53  int vhd_offset(vhd_context_t *, uint32_t, uint32_t *);
   18.54  
   18.55 -int vhd_end_of_headers(vhd_context_t *ctx, off64_t *off);
   18.56 -int vhd_end_of_data(vhd_context_t *ctx, off64_t *off);
   18.57 -int vhd_batmap_header_offset(vhd_context_t *ctx, off64_t *off);
   18.58 +int vhd_end_of_headers(vhd_context_t *ctx, off_t *off);
   18.59 +int vhd_end_of_data(vhd_context_t *ctx, off_t *off);
   18.60 +int vhd_batmap_header_offset(vhd_context_t *ctx, off_t *off);
   18.61  
   18.62  int vhd_get_header(vhd_context_t *);
   18.63  int vhd_get_footer(vhd_context_t *);
   18.64 @@ -265,8 +283,8 @@ int vhd_batmap_test(vhd_context_t *, vhd
   18.65  void vhd_batmap_set(vhd_context_t *, vhd_batmap_t *, uint32_t);
   18.66  void vhd_batmap_clear(vhd_context_t *, vhd_batmap_t *, uint32_t);
   18.67  
   18.68 -int vhd_get_phys_size(vhd_context_t *, off64_t *);
   18.69 -int vhd_set_phys_size(vhd_context_t *, off64_t);
   18.70 +int vhd_get_phys_size(vhd_context_t *, off_t *);
   18.71 +int vhd_set_phys_size(vhd_context_t *, off_t);
   18.72  
   18.73  int vhd_bitmap_test(vhd_context_t *, char *, uint32_t);
   18.74  void vhd_bitmap_set(vhd_context_t *, char *, uint32_t);
   18.75 @@ -277,26 +295,26 @@ int vhd_parent_locator_get(vhd_context_t
   18.76  int vhd_parent_locator_read(vhd_context_t *, vhd_parent_locator_t *, char **);
   18.77  int vhd_find_parent(vhd_context_t *, const char *, char **);
   18.78  int vhd_parent_locator_write_at(vhd_context_t *, const char *,
   18.79 -				off64_t, uint32_t, size_t,
   18.80 +				off_t, uint32_t, size_t,
   18.81  				vhd_parent_locator_t *);
   18.82  
   18.83  int vhd_header_decode_parent(vhd_context_t *, vhd_header_t *, char **);
   18.84  int vhd_change_parent(vhd_context_t *, char *parent_path, int raw);
   18.85  
   18.86  int vhd_read_footer(vhd_context_t *, vhd_footer_t *);
   18.87 -int vhd_read_footer_at(vhd_context_t *, vhd_footer_t *, off64_t);
   18.88 +int vhd_read_footer_at(vhd_context_t *, vhd_footer_t *, off_t);
   18.89  int vhd_read_footer_strict(vhd_context_t *, vhd_footer_t *);
   18.90  int vhd_read_header(vhd_context_t *, vhd_header_t *);
   18.91 -int vhd_read_header_at(vhd_context_t *, vhd_header_t *, off64_t);
   18.92 +int vhd_read_header_at(vhd_context_t *, vhd_header_t *, off_t);
   18.93  int vhd_read_bat(vhd_context_t *, vhd_bat_t *);
   18.94  int vhd_read_batmap(vhd_context_t *, vhd_batmap_t *);
   18.95  int vhd_read_bitmap(vhd_context_t *, uint32_t block, char **bufp);
   18.96  int vhd_read_block(vhd_context_t *, uint32_t block, char **bufp);
   18.97  
   18.98  int vhd_write_footer(vhd_context_t *, vhd_footer_t *);
   18.99 -int vhd_write_footer_at(vhd_context_t *, vhd_footer_t *, off64_t);
  18.100 +int vhd_write_footer_at(vhd_context_t *, vhd_footer_t *, off_t);
  18.101  int vhd_write_header(vhd_context_t *, vhd_header_t *);
  18.102 -int vhd_write_header_at(vhd_context_t *, vhd_header_t *, off64_t);
  18.103 +int vhd_write_header_at(vhd_context_t *, vhd_header_t *, off_t);
  18.104  int vhd_write_bat(vhd_context_t *, vhd_bat_t *);
  18.105  int vhd_write_batmap(vhd_context_t *, vhd_batmap_t *);
  18.106  int vhd_write_bitmap(vhd_context_t *, uint32_t block, char *bitmap);
    19.1 --- a/tools/blktap2/include/list.h	Tue Jun 23 11:27:54 2009 +0100
    19.2 +++ b/tools/blktap2/include/list.h	Tue Jun 23 17:24:14 2009 +0100
    19.3 @@ -2,6 +2,7 @@
    19.4   * list.h
    19.5   * 
    19.6   * This is a subset of linux's list.h intended to be used in user-space.
    19.7 + * XXX The namespace conflicts with NetBSD's <sys/queue.h>
    19.8   * 
    19.9   */
   19.10  
   19.11 @@ -15,6 +16,16 @@ struct list_head {
   19.12          struct list_head *next, *prev;
   19.13  };
   19.14   
   19.15 +/* XXX workaround for conflicts. The list API should use its own
   19.16 + * namespace prefix, i.e. BLK_
   19.17 + */
   19.18 +#ifdef LIST_HEAD_INIT
   19.19 +#undef LIST_HEAD_INIT
   19.20 +#endif
   19.21 +#ifndef LIST_HEAD
   19.22 +#undef LIST_HEAD
   19.23 +#endif
   19.24 +
   19.25  #define LIST_HEAD_INIT(name) { &(name), &(name) }
   19.26   
   19.27  #define LIST_HEAD(name) \
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/tools/blktap2/include/uuid.h	Tue Jun 23 17:24:14 2009 +0100
    20.3 @@ -0,0 +1,73 @@
    20.4 +/* Copyright (c) 2008, XenSource Inc.
    20.5 + * All rights reserved.
    20.6 + *
    20.7 + * Redistribution and use in source and binary forms, with or without
    20.8 + * modification, are permitted provided that the following conditions are met:
    20.9 + *     * Redistributions of source code must retain the above copyright
   20.10 + *       notice, this list of conditions and the following disclaimer.
   20.11 + *     * Redistributions in binary form must reproduce the above copyright
   20.12 + *       notice, this list of conditions and the following disclaimer in the
   20.13 + *       documentation and/or other materials provided with the distribution.
   20.14 + *     * Neither the name of XenSource Inc. nor the names of its contributors
   20.15 + *       may be used to endorse or promote products derived from this software
   20.16 + *       without specific prior written permission.
   20.17 + *
   20.18 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   20.19 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   20.20 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   20.21 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
   20.22 + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
   20.23 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   20.24 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
   20.25 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   20.26 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   20.27 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   20.28 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   20.29 +*/
   20.30 +#ifndef __BLKTAP2_UUID_H__
   20.31 +#define __BLKTAP2_UUID_H__
   20.32 +
   20.33 +#if defined(__linux__) || defined(__Linux__)
   20.34 +
   20.35 +#include <uuid/uuid.h>
   20.36 +
   20.37 +#else
   20.38 +
   20.39 +#include <inttypes.h>
   20.40 +#include <string.h>
   20.41 +#include <uuid.h>
   20.42 +
   20.43 +static inline int uuid_is_null(uuid_t uuid)
   20.44 +{
   20.45 +    uint32_t status;
   20.46 +    return uuid_is_nil(&uuid, &status);
   20.47 +}
   20.48 +
   20.49 +static inline void uuid_generate(uuid_t uuid)
   20.50 +{
   20.51 +    uint32_t status;
   20.52 +    uuid_create(&uuid, &status);
   20.53 +}
   20.54 +
   20.55 +static inline void uuid_unparse(uuid_t uuid, char *out)
   20.56 +{
   20.57 +    uint32_t status;
   20.58 +    uuid_to_string(&uuid, (char **)&out, &status);
   20.59 +}
   20.60 +
   20.61 +static inline void uuid_copy(uuid_t dst, uuid_t src)
   20.62 +{
   20.63 +    memcpy(dst, src, sizeof(dst));
   20.64 +}
   20.65 +
   20.66 +static inline void uuid_clear(uuid_t uu)
   20.67 +{
   20.68 +    memset(uu, 0, sizeof(uu));
   20.69 +}
   20.70 +
   20.71 +#define uuid_compare(x,y) \
   20.72 +    ({ uint32_t status; uuid_compare(&(x),&(y),&status); })
   20.73 +
   20.74 +#endif
   20.75 +
   20.76 +#endif /* __BLKTAP2_UUID_H__ */
    21.1 --- a/tools/blktap2/include/vhd.h	Tue Jun 23 11:27:54 2009 +0100
    21.2 +++ b/tools/blktap2/include/vhd.h	Tue Jun 23 17:24:14 2009 +0100
    21.3 @@ -27,9 +27,8 @@
    21.4  #ifndef __VHD_H__
    21.5  #define __VHD_H__
    21.6  
    21.7 -#include <asm/types.h>
    21.8 -#include <uuid/uuid.h>
    21.9  #include <inttypes.h>
   21.10 +#include "uuid.h"
   21.11  
   21.12  typedef uint32_t u32;
   21.13  typedef uint64_t u64;
    22.1 --- a/tools/blktap2/vhd/Makefile	Tue Jun 23 11:27:54 2009 +0100
    22.2 +++ b/tools/blktap2/vhd/Makefile	Tue Jun 23 17:24:14 2009 +0100
    22.3 @@ -22,7 +22,9 @@ CFLAGS            += -static
    22.4  endif
    22.5  
    22.6  LIBS              := -Llib -lvhd
    22.7 +ifeq ($(CONFIG_Linux),y)
    22.8  LIBS              += -luuid
    22.9 +endif
   22.10  
   22.11  # Get gcc to generate the dependencies for us.
   22.12  CFLAGS            += -Wp,-MD,.$(@F).d
    23.1 --- a/tools/blktap2/vhd/lib/Makefile	Tue Jun 23 11:27:54 2009 +0100
    23.2 +++ b/tools/blktap2/vhd/lib/Makefile	Tue Jun 23 17:24:14 2009 +0100
    23.3 @@ -19,7 +19,9 @@ CFLAGS          += -D_GNU_SOURCE
    23.4  CFLAGS          += -fPIC
    23.5  CFLAGS          += -g
    23.6  
    23.7 +ifeq ($(CONFIG_Linux),y)
    23.8  LIBS            := -luuid
    23.9 +endif
   23.10  
   23.11  # Get gcc to generate the dependencies for us.
   23.12  CFLAGS          += -Wp,-MD,.$(@F).d
    24.1 --- a/tools/blktap2/vhd/lib/libvhd-journal.c	Tue Jun 23 11:27:54 2009 +0100
    24.2 +++ b/tools/blktap2/vhd/lib/libvhd-journal.c	Tue Jun 23 17:24:14 2009 +0100
    24.3 @@ -52,21 +52,21 @@ typedef struct vhd_journal_entry {
    24.4  } vhd_journal_entry_t;
    24.5  
    24.6  static inline int
    24.7 -vhd_journal_seek(vhd_journal_t *j, off64_t offset, int whence)
    24.8 +vhd_journal_seek(vhd_journal_t *j, off_t offset, int whence)
    24.9  {
   24.10 -	off64_t off;
   24.11 +	off_t off;
   24.12  
   24.13 -	off = lseek64(j->jfd, offset, whence);
   24.14 -	if (off == (off64_t)-1)
   24.15 +	off = lseek(j->jfd, offset, whence);
   24.16 +	if (off == (off_t)-1)
   24.17  		return -errno;
   24.18  
   24.19  	return 0;
   24.20  }
   24.21  
   24.22 -static inline off64_t
   24.23 +static inline off_t
   24.24  vhd_journal_position(vhd_journal_t *j)
   24.25  {
   24.26 -	return lseek64(j->jfd, 0, SEEK_CUR);
   24.27 +	return lseek(j->jfd, 0, SEEK_CUR);
   24.28  }
   24.29  
   24.30  static inline int
   24.31 @@ -98,7 +98,7 @@ vhd_journal_write(vhd_journal_t *j, void
   24.32  }
   24.33  
   24.34  static inline int
   24.35 -vhd_journal_truncate(vhd_journal_t *j, off64_t length)
   24.36 +vhd_journal_truncate(vhd_journal_t *j, off_t length)
   24.37  {
   24.38  	int err;
   24.39  
   24.40 @@ -145,7 +145,7 @@ static int
   24.41  vhd_journal_validate_header(vhd_journal_t *j, vhd_journal_header_t *header)
   24.42  {
   24.43  	int err;
   24.44 -	off64_t eof;
   24.45 +	off_t eof;
   24.46  
   24.47  	if (memcmp(header->cookie,
   24.48  		   VHD_JOURNAL_HEADER_COOKIE, sizeof(header->cookie)))
   24.49 @@ -156,7 +156,7 @@ vhd_journal_validate_header(vhd_journal_
   24.50  		return err;
   24.51  
   24.52  	eof = vhd_journal_position(j);
   24.53 -	if (eof == (off64_t)-1)
   24.54 +	if (eof == (off_t)-1)
   24.55  		return -errno;
   24.56  
   24.57  	if (j->header.journal_data_offset > j->header.journal_eof)
   24.58 @@ -219,7 +219,7 @@ static int
   24.59  vhd_journal_add_journal_header(vhd_journal_t *j)
   24.60  {
   24.61  	int err;
   24.62 -	off64_t off;
   24.63 +	off_t off;
   24.64  	vhd_context_t *vhd;
   24.65  
   24.66  	vhd = &j->vhd;
   24.67 @@ -230,7 +230,7 @@ vhd_journal_add_journal_header(vhd_journ
   24.68  		return err;
   24.69  
   24.70  	off = vhd_position(vhd);
   24.71 -	if (off == (off64_t)-1)
   24.72 +	if (off == (off_t)-1)
   24.73  		return -errno;
   24.74  
   24.75  	err = vhd_get_footer(vhd);
   24.76 @@ -353,11 +353,11 @@ vhd_journal_validate_entry_data(vhd_jour
   24.77  }
   24.78  
   24.79  static int
   24.80 -vhd_journal_update(vhd_journal_t *j, off64_t offset,
   24.81 +vhd_journal_update(vhd_journal_t *j, off_t offset,
   24.82  		   char *buf, size_t size, uint32_t type)
   24.83  {
   24.84  	int err;
   24.85 -	off64_t eof;
   24.86 +	off_t eof;
   24.87  	uint64_t *off, off_bak;
   24.88  	uint32_t *entries;
   24.89  	vhd_journal_entry_t entry;
   24.90 @@ -413,7 +413,7 @@ static int
   24.91  vhd_journal_add_footer(vhd_journal_t *j)
   24.92  {
   24.93  	int err;
   24.94 -	off64_t off;
   24.95 +	off_t off;
   24.96  	vhd_context_t *vhd;
   24.97  	vhd_footer_t footer;
   24.98  
   24.99 @@ -424,7 +424,7 @@ vhd_journal_add_footer(vhd_journal_t *j)
  24.100  		return err;
  24.101  
  24.102  	off = vhd_position(vhd);
  24.103 -	if (off == (off64_t)-1)
  24.104 +	if (off == (off_t)-1)
  24.105  		return -errno;
  24.106  
  24.107  	err = vhd_read_footer_at(vhd, &footer, off - sizeof(vhd_footer_t));
  24.108 @@ -459,7 +459,7 @@ static int
  24.109  vhd_journal_add_header(vhd_journal_t *j)
  24.110  {
  24.111  	int err;
  24.112 -	off64_t off;
  24.113 +	off_t off;
  24.114  	vhd_context_t *vhd;
  24.115  	vhd_header_t header;
  24.116  
  24.117 @@ -495,7 +495,7 @@ vhd_journal_add_locators(vhd_journal_t *
  24.118  	n = sizeof(vhd->header.loc) / sizeof(vhd_parent_locator_t);
  24.119  	for (i = 0; i < n; i++) {
  24.120  		char *buf;
  24.121 -		off64_t off;
  24.122 +		off_t off;
  24.123  		size_t size;
  24.124  		vhd_parent_locator_t *loc;
  24.125  
  24.126 @@ -542,7 +542,7 @@ static int
  24.127  vhd_journal_add_bat(vhd_journal_t *j)
  24.128  {
  24.129  	int err;
  24.130 -	off64_t off;
  24.131 +	off_t off;
  24.132  	size_t size;
  24.133  	vhd_bat_t bat;
  24.134  	vhd_context_t *vhd;
  24.135 @@ -572,7 +572,7 @@ static int
  24.136  vhd_journal_add_batmap(vhd_journal_t *j)
  24.137  {
  24.138  	int err;
  24.139 -	off64_t off;
  24.140 +	off_t off;
  24.141  	size_t size;
  24.142  	vhd_context_t *vhd;
  24.143  	vhd_batmap_t batmap;
  24.144 @@ -611,7 +611,7 @@ static int
  24.145  vhd_journal_add_metadata(vhd_journal_t *j)
  24.146  {
  24.147  	int err;
  24.148 -	off64_t eof;
  24.149 +	off_t eof;
  24.150  	vhd_context_t *vhd;
  24.151  
  24.152  	vhd = &j->vhd;
  24.153 @@ -930,7 +930,7 @@ vhd_journal_restore_footer_copy(vhd_jour
  24.154  static int
  24.155  vhd_journal_restore_header(vhd_journal_t *j, vhd_header_t *header)
  24.156  {
  24.157 -	off64_t off;
  24.158 +	off_t off;
  24.159  	vhd_context_t *vhd;
  24.160  
  24.161  	vhd = &j->vhd;
  24.162 @@ -985,7 +985,7 @@ vhd_journal_restore_batmap(vhd_journal_t
  24.163  static int
  24.164  vhd_journal_restore_metadata(vhd_journal_t *j)
  24.165  {
  24.166 -	off64_t off;
  24.167 +	off_t off;
  24.168  	char **locators;
  24.169  	vhd_footer_t copy;
  24.170  	vhd_context_t *vhd;
  24.171 @@ -1046,7 +1046,7 @@ vhd_journal_restore_metadata(vhd_journal
  24.172  
  24.173  restore:
  24.174  	off  = vhd_journal_position(j);
  24.175 -	if (off == (off64_t)-1)
  24.176 +	if (off == (off_t)-1)
  24.177  		return -errno;
  24.178  
  24.179  	if (j->header.journal_data_offset != off)
  24.180 @@ -1259,7 +1259,7 @@ vhd_journal_create(vhd_journal_t *j, con
  24.181  	char *buf;
  24.182  	int i, err;
  24.183  	size_t size;
  24.184 -	off64_t off;
  24.185 +	off_t off;
  24.186  	struct stat stats;
  24.187  
  24.188  	memset(j, 0, sizeof(vhd_journal_t));
  24.189 @@ -1345,7 +1345,7 @@ vhd_journal_add_block(vhd_journal_t *j, 
  24.190  {
  24.191  	int err;
  24.192  	char *buf;
  24.193 -	off64_t off;
  24.194 +	off_t off;
  24.195  	size_t size;
  24.196  	uint64_t blk;
  24.197  	vhd_context_t *vhd;
    25.1 --- a/tools/blktap2/vhd/lib/libvhd.c	Tue Jun 23 11:27:54 2009 +0100
    25.2 +++ b/tools/blktap2/vhd/lib/libvhd.c	Tue Jun 23 17:24:14 2009 +0100
    25.3 @@ -250,8 +250,8 @@ vhd_validate_footer(vhd_footer_t *footer
    25.4  	if (memcmp(footer->cookie, HD_COOKIE, csize) != 0 &&
    25.5  	    memcmp(footer->cookie, VHD_POISON_COOKIE, csize) != 0) {
    25.6  		char buf[9];
    25.7 -		memcpy(buf, footer->cookie, 8);
    25.8 -		buf[8]= '\0';
    25.9 +		strncpy(buf, footer->cookie, sizeof(buf));
   25.10 +		buf[sizeof(buf)-1]= '\0';
   25.11  		VHDLOG("invalid footer cookie: %s\n", buf);
   25.12  		return -EINVAL;
   25.13  	}
   25.14 @@ -311,8 +311,8 @@ vhd_validate_header(vhd_header_t *header
   25.15  
   25.16  	if (memcmp(header->cookie, DD_COOKIE, 8) != 0) {
   25.17  		char buf[9];
   25.18 -		memcpy(buf, header->cookie, 8);
   25.19 -		buf[8] = '\0';
   25.20 +		strncpy(buf, header->cookie, sizeof(buf));
   25.21 +		buf[sizeof(buf)-1]= '\0';
   25.22  		VHDLOG("invalid header cookie: %s\n", buf);
   25.23  		return -EINVAL;
   25.24  	}
   25.25 @@ -403,9 +403,9 @@ vhd_validate_batmap(vhd_batmap_t *batmap
   25.26  }
   25.27  
   25.28  int
   25.29 -vhd_batmap_header_offset(vhd_context_t *ctx, off64_t *_off)
   25.30 +vhd_batmap_header_offset(vhd_context_t *ctx, off_t *_off)
   25.31  {
   25.32 -	off64_t off;
   25.33 +	off_t off;
   25.34  	size_t  bat;
   25.35  
   25.36  	*_off = 0;
   25.37 @@ -592,11 +592,11 @@ vhd_bitmap_clear(vhd_context_t *ctx, cha
   25.38   * byte of the file which is not vhd metadata
   25.39   */
   25.40  int
   25.41 -vhd_end_of_headers(vhd_context_t *ctx, off64_t *end)
   25.42 +vhd_end_of_headers(vhd_context_t *ctx, off_t *end)
   25.43  {
   25.44  	int err, i, n;
   25.45  	uint32_t bat_bytes;
   25.46 -	off64_t eom, bat_end;
   25.47 +	off_t eom, bat_end;
   25.48  	vhd_parent_locator_t *loc;
   25.49  
   25.50  	*end = 0;
   25.51 @@ -612,7 +612,7 @@ vhd_end_of_headers(vhd_context_t *ctx, o
   25.52  	eom       = MAX(eom, bat_end);
   25.53  
   25.54  	if (vhd_has_batmap(ctx)) {
   25.55 -		off64_t hdr_end, hdr_secs, map_end, map_secs;
   25.56 +		off_t hdr_end, hdr_secs, map_end, map_secs;
   25.57  
   25.58  		err = vhd_get_batmap(ctx);
   25.59  		if (err)
   25.60 @@ -636,7 +636,7 @@ vhd_end_of_headers(vhd_context_t *ctx, o
   25.61  	n = sizeof(ctx->header.loc) / sizeof(vhd_parent_locator_t);
   25.62  
   25.63  	for (i = 0; i < n; i++) {
   25.64 -		off64_t loc_end;
   25.65 +		off_t loc_end;
   25.66  
   25.67  		loc = &ctx->header.loc[i];
   25.68  		if (loc->code == PLAT_CODE_NONE)
   25.69 @@ -651,10 +651,10 @@ vhd_end_of_headers(vhd_context_t *ctx, o
   25.70  }
   25.71  
   25.72  int
   25.73 -vhd_end_of_data(vhd_context_t *ctx, off64_t *end)
   25.74 +vhd_end_of_data(vhd_context_t *ctx, off_t *end)
   25.75  {
   25.76  	int i, err;
   25.77 -	off64_t max;
   25.78 +	off_t max;
   25.79  	uint64_t blk;
   25.80  
   25.81  	if (!vhd_type_dynamic(ctx)) {
   25.82 @@ -663,7 +663,7 @@ vhd_end_of_data(vhd_context_t *ctx, off6
   25.83  			return err;
   25.84  
   25.85  		max = vhd_position(ctx);
   25.86 -		if (max == (off64_t)-1)
   25.87 +		if (max == (off_t)-1)
   25.88  			return -errno;
   25.89  
   25.90  		*end = max - sizeof(vhd_footer_t);
   25.91 @@ -871,7 +871,7 @@ vhd_read_short_footer(vhd_context_t *ctx
   25.92  {
   25.93  	int err;
   25.94  	char *buf;
   25.95 -	off64_t eof;
   25.96 +	off_t eof;
   25.97  
   25.98  	buf = NULL;
   25.99  
  25.100 @@ -880,7 +880,7 @@ vhd_read_short_footer(vhd_context_t *ctx
  25.101  		goto out;
  25.102  
  25.103  	eof = vhd_position(ctx);
  25.104 -	if (eof == (off64_t)-1) {
  25.105 +	if (eof == (off_t)-1) {
  25.106  		err = -errno;
  25.107  		goto out;
  25.108  	}
  25.109 @@ -918,7 +918,7 @@ out:
  25.110  }
  25.111  
  25.112  int
  25.113 -vhd_read_footer_at(vhd_context_t *ctx, vhd_footer_t *footer, off64_t off)
  25.114 +vhd_read_footer_at(vhd_context_t *ctx, vhd_footer_t *footer, off_t off)
  25.115  {
  25.116  	int err;
  25.117  	char *buf;
  25.118 @@ -958,14 +958,14 @@ int
  25.119  vhd_read_footer(vhd_context_t *ctx, vhd_footer_t *footer)
  25.120  {
  25.121  	int err;
  25.122 -	off64_t off;
  25.123 +	off_t off;
  25.124  
  25.125  	err = vhd_seek(ctx, 0, SEEK_END);
  25.126  	if (err)
  25.127  		return err;
  25.128  
  25.129  	off = vhd_position(ctx);
  25.130 -	if (off == (off64_t)-1)
  25.131 +	if (off == (off_t)-1)
  25.132  		return -errno;
  25.133  
  25.134  	err = vhd_read_footer_at(ctx, footer, off - 512);
  25.135 @@ -983,7 +983,7 @@ vhd_read_footer(vhd_context_t *ctx, vhd_
  25.136  }
  25.137  
  25.138  int
  25.139 -vhd_read_header_at(vhd_context_t *ctx, vhd_header_t *header, off64_t off)
  25.140 +vhd_read_header_at(vhd_context_t *ctx, vhd_header_t *header, off_t off)
  25.141  {
  25.142  	int err;
  25.143  	char *buf;
  25.144 @@ -1028,7 +1028,7 @@ int
  25.145  vhd_read_header(vhd_context_t *ctx, vhd_header_t *header)
  25.146  {
  25.147  	int err;
  25.148 -	off64_t off;
  25.149 +	off_t off;
  25.150  
  25.151  	if (!vhd_type_dynamic(ctx)) {
  25.152  		VHDLOG("%s is not dynamic!\n", ctx->file);
  25.153 @@ -1044,7 +1044,7 @@ vhd_read_bat(vhd_context_t *ctx, vhd_bat
  25.154  {
  25.155  	int err;
  25.156  	char *buf;
  25.157 -	off64_t off;
  25.158 +	off_t off;
  25.159  	size_t size;
  25.160  
  25.161  	buf  = NULL;
  25.162 @@ -1092,7 +1092,7 @@ vhd_read_batmap_header(vhd_context_t *ct
  25.163  {
  25.164  	int err;
  25.165  	char *buf;
  25.166 -	off64_t off;
  25.167 +	off_t off;
  25.168  	size_t size;
  25.169  
  25.170  	buf = NULL;
  25.171 @@ -1137,7 +1137,7 @@ vhd_read_batmap_map(vhd_context_t *ctx, 
  25.172  {
  25.173  	int err;
  25.174  	char *buf;
  25.175 -	off64_t off;
  25.176 +	off_t off;
  25.177  	size_t map_size;
  25.178  
  25.179  	map_size = vhd_sectors_to_bytes(batmap->header.batmap_size);
  25.180 @@ -1331,7 +1331,7 @@ vhd_macx_encode_location(char *name, cha
  25.181  		goto out;
  25.182  	}
  25.183  
  25.184 -	sprintf(uri, "file://%s", name);
  25.185 +	snprintf(uri, ibl+1, "file://%s", name);
  25.186  
  25.187  	if (iconv(cd, &urip, &ibl, &uri_utf8p, &obl) == (size_t)-1 ||
  25.188  	    ibl || obl) {
  25.189 @@ -1446,7 +1446,7 @@ vhd_w2u_encode_location(char *name, char
  25.190  }
  25.191  
  25.192  static char *
  25.193 -vhd_macx_decode_location(char *in, char *out, int len)
  25.194 +vhd_macx_decode_location(const char *in, char *out, int len)
  25.195  {
  25.196  	iconv_t cd;
  25.197  	char *name;
  25.198 @@ -1459,7 +1459,7 @@ vhd_macx_decode_location(char *in, char 
  25.199  	if (cd == (iconv_t)-1) 
  25.200  		return NULL;
  25.201  
  25.202 -	if (iconv(cd, &in, &ibl, &out, &obl) == (size_t)-1 || ibl)
  25.203 +	if (iconv(cd, (char **)&in, &ibl, &out, &obl) == (size_t)-1 || ibl)
  25.204  		return NULL;
  25.205  
  25.206  	iconv_close(cd);
  25.207 @@ -1474,7 +1474,7 @@ vhd_macx_decode_location(char *in, char 
  25.208  }
  25.209  
  25.210  static char *
  25.211 -vhd_w2u_decode_location(char *in, char *out, int len, char *utf_type)
  25.212 +vhd_w2u_decode_location(const char *in, char *out, int len, char *utf_type)
  25.213  {
  25.214  	iconv_t cd;
  25.215  	char *name, *tmp;
  25.216 @@ -1487,7 +1487,7 @@ vhd_w2u_decode_location(char *in, char *
  25.217  	if (cd == (iconv_t)-1) 
  25.218  		return NULL;
  25.219  
  25.220 -	if (iconv(cd, &in, &ibl, &out, &obl) == (size_t)-1 || ibl)
  25.221 +	if (iconv(cd, (char **)&in, &ibl, &out, &obl) == (size_t)-1 || ibl)
  25.222  		return NULL;
  25.223  
  25.224  	iconv_close(cd);
  25.225 @@ -1646,7 +1646,7 @@ vhd_parent_locator_get(vhd_context_t *ct
  25.226  
  25.227  int
  25.228  vhd_parent_locator_write_at(vhd_context_t *ctx,
  25.229 -			    const char *parent, off64_t off, uint32_t code,
  25.230 +			    const char *parent, off_t off, uint32_t code,
  25.231  			    size_t max_bytes, vhd_parent_locator_t *loc)
  25.232  {
  25.233  	struct stat stats;
  25.234 @@ -1762,7 +1762,7 @@ out:
  25.235  }
  25.236  
  25.237  static int
  25.238 -vhd_footer_offset_at_eof(vhd_context_t *ctx, off64_t *off)
  25.239 +vhd_footer_offset_at_eof(vhd_context_t *ctx, off_t *off)
  25.240  {
  25.241  	int err;
  25.242  	if ((err = vhd_seek(ctx, 0, SEEK_END)))
  25.243 @@ -1777,7 +1777,7 @@ vhd_read_bitmap(vhd_context_t *ctx, uint
  25.244  	int err;
  25.245  	char *buf;
  25.246  	size_t size;
  25.247 -	off64_t off;
  25.248 +	off_t off;
  25.249  	uint64_t blk;
  25.250  
  25.251  	buf   = NULL;
  25.252 @@ -1827,7 +1827,7 @@ vhd_read_block(vhd_context_t *ctx, uint3
  25.253  	char *buf;
  25.254  	size_t size;
  25.255  	uint64_t blk;
  25.256 -	off64_t end, off;
  25.257 +	off_t end, off;
  25.258  
  25.259  	buf   = NULL;
  25.260  	*bufp = NULL;
  25.261 @@ -1881,7 +1881,7 @@ fail:
  25.262  }
  25.263  
  25.264  int
  25.265 -vhd_write_footer_at(vhd_context_t *ctx, vhd_footer_t *footer, off64_t off)
  25.266 +vhd_write_footer_at(vhd_context_t *ctx, vhd_footer_t *footer, off_t off)
  25.267  {
  25.268  	int err;
  25.269  	vhd_footer_t *f;
  25.270 @@ -1923,7 +1923,7 @@ int
  25.271  vhd_write_footer(vhd_context_t *ctx, vhd_footer_t *footer)
  25.272  {
  25.273  	int err;
  25.274 -	off64_t off;
  25.275 +	off_t off;
  25.276  
  25.277  	if (ctx->is_block)
  25.278  		err = vhd_footer_offset_at_eof(ctx, &off);
  25.279 @@ -1943,7 +1943,7 @@ vhd_write_footer(vhd_context_t *ctx, vhd
  25.280  }
  25.281  
  25.282  int
  25.283 -vhd_write_header_at(vhd_context_t *ctx, vhd_header_t *header, off64_t off)
  25.284 +vhd_write_header_at(vhd_context_t *ctx, vhd_header_t *header, off_t off)
  25.285  {
  25.286  	int err;
  25.287  	vhd_header_t *h;
  25.288 @@ -1990,7 +1990,7 @@ int
  25.289  vhd_write_header(vhd_context_t *ctx, vhd_header_t *header)
  25.290  {
  25.291  	int err;
  25.292 -	off64_t off;
  25.293 +	off_t off;
  25.294  
  25.295  	if (!vhd_type_dynamic(ctx))
  25.296  		return -EINVAL;
  25.297 @@ -2003,7 +2003,7 @@ int
  25.298  vhd_write_bat(vhd_context_t *ctx, vhd_bat_t *bat)
  25.299  {
  25.300  	int err;
  25.301 -	off64_t off;
  25.302 +	off_t off;
  25.303  	vhd_bat_t b;
  25.304  	size_t size;
  25.305  
  25.306 @@ -2046,7 +2046,7 @@ int
  25.307  vhd_write_batmap(vhd_context_t *ctx, vhd_batmap_t *batmap)
  25.308  {
  25.309  	int err;
  25.310 -	off64_t off;
  25.311 +	off_t off;
  25.312  	vhd_batmap_t b;
  25.313  	char *buf, *map;
  25.314  	size_t size, map_size;
  25.315 @@ -2122,7 +2122,7 @@ int
  25.316  vhd_write_bitmap(vhd_context_t *ctx, uint32_t block, char *bitmap)
  25.317  {
  25.318  	int err;
  25.319 -	off64_t off;
  25.320 +	off_t off;
  25.321  	uint64_t blk;
  25.322  	size_t secs, size;
  25.323  
  25.324 @@ -2161,7 +2161,7 @@ int
  25.325  vhd_write_block(vhd_context_t *ctx, uint32_t block, char *data)
  25.326  {
  25.327  	int err;
  25.328 -	off64_t off;
  25.329 +	off_t off;
  25.330  	size_t size;
  25.331  	uint64_t blk;
  25.332  
  25.333 @@ -2212,12 +2212,12 @@ namedup(char **dup, const char *name)
  25.334  }
  25.335  
  25.336  int
  25.337 -vhd_seek(vhd_context_t *ctx, off64_t offset, int whence)
  25.338 +vhd_seek(vhd_context_t *ctx, off_t offset, int whence)
  25.339  {
  25.340 -	off64_t off;
  25.341 -
  25.342 -	off = lseek64(ctx->fd, offset, whence);
  25.343 -	if (off == (off64_t)-1) {
  25.344 +	off_t off;
  25.345 +
  25.346 +	off = lseek(ctx->fd, offset, whence);
  25.347 +	if (off == (off_t)-1) {
  25.348  		VHDLOG("%s: seek(0x%08"PRIx64", %d) failed: %d\n",
  25.349  		       ctx->file, offset, whence, -errno);
  25.350  		return -errno;
  25.351 @@ -2226,10 +2226,10 @@ vhd_seek(vhd_context_t *ctx, off64_t off
  25.352  	return 0;
  25.353  }
  25.354  
  25.355 -off64_t
  25.356 +off_t
  25.357  vhd_position(vhd_context_t *ctx)
  25.358  {
  25.359 -	return lseek64(ctx->fd, 0, SEEK_CUR);
  25.360 +	return lseek(ctx->fd, 0, SEEK_CUR);
  25.361  }
  25.362  
  25.363  int
  25.364 @@ -2444,7 +2444,8 @@ vhd_initialize_header_parent_name(vhd_co
  25.365  	int err;
  25.366  	iconv_t cd;
  25.367  	size_t ibl, obl;
  25.368 -	char *pname, *ppath, *dst;
  25.369 +	char *ppath, *dst;
  25.370 +	const char *pname;
  25.371  
  25.372  	err   = 0;
  25.373  	pname = NULL;
  25.374 @@ -2478,7 +2479,7 @@ vhd_initialize_header_parent_name(vhd_co
  25.375  
  25.376  	memset(dst, 0, obl);
  25.377  
  25.378 -	if (iconv(cd, &pname, &ibl, &dst, &obl) == (size_t)-1 || ibl)
  25.379 +	if (iconv(cd, (char **)&pname, &ibl, &dst, &obl) == (size_t)-1 || ibl)
  25.380  		err = (errno ? -errno : -EINVAL);
  25.381  
  25.382  out:
  25.383 @@ -2487,18 +2488,18 @@ out:
  25.384  	return err;
  25.385  }
  25.386  
  25.387 -static off64_t
  25.388 +static off_t
  25.389  get_file_size(const char *name)
  25.390  {
  25.391  	int fd;
  25.392 -	off64_t end;
  25.393 +	off_t end;
  25.394  
  25.395  	fd = open(name, O_LARGEFILE | O_RDONLY);
  25.396  	if (fd == -1) {
  25.397  		VHDLOG("unable to open '%s': %d\n", name, errno);
  25.398  		return -errno;
  25.399  	}
  25.400 -	end = lseek64(fd, 0, SEEK_END);
  25.401 +	end = lseek(fd, 0, SEEK_END);
  25.402  	close(fd); 
  25.403  	return end;
  25.404  }
  25.405 @@ -2563,7 +2564,7 @@ static int
  25.406  vhd_write_parent_locators(vhd_context_t *ctx, const char *parent)
  25.407  {
  25.408  	int i, err;
  25.409 -	off64_t off;
  25.410 +	off_t off;
  25.411  	uint32_t code;
  25.412  
  25.413  	code = PLAT_CODE_NONE;
  25.414 @@ -2683,7 +2684,7 @@ out:
  25.415  static int
  25.416  vhd_create_batmap(vhd_context_t *ctx)
  25.417  {
  25.418 -	off64_t off;
  25.419 +	off_t off;
  25.420  	int err, map_bytes;
  25.421  	vhd_batmap_header_t *header;
  25.422  
  25.423 @@ -2694,7 +2695,7 @@ vhd_create_batmap(vhd_context_t *ctx)
  25.424  	header    = &ctx->batmap.header;
  25.425  
  25.426  	memset(header, 0, sizeof(vhd_batmap_header_t));
  25.427 -	memcpy(header->cookie, VHD_BATMAP_COOKIE, sizeof(header->cookie));
  25.428 +	memcpy(header->cookie, VHD_BATMAP_COOKIE, sizeof(*header->cookie));
  25.429  
  25.430  	err = vhd_batmap_header_offset(ctx, &off);
  25.431  	if (err)
  25.432 @@ -2763,7 +2764,7 @@ vhd_initialize_fixed_disk(vhd_context_t 
  25.433  		return err;
  25.434  
  25.435  	buf = mmap(0, VHD_BLOCK_SIZE, PROT_READ,
  25.436 -		   MAP_SHARED | MAP_ANONYMOUS, -1, 0);
  25.437 +		   MAP_SHARED | MAP_ANON, -1, 0);
  25.438  	if (buf == MAP_FAILED)
  25.439  		return -errno;
  25.440  
  25.441 @@ -2781,7 +2782,7 @@ out:
  25.442  }
  25.443  
  25.444  int 
  25.445 -vhd_get_phys_size(vhd_context_t *ctx, off64_t *size)
  25.446 +vhd_get_phys_size(vhd_context_t *ctx, off_t *size)
  25.447  {
  25.448  	int err;
  25.449  
  25.450 @@ -2792,9 +2793,9 @@ vhd_get_phys_size(vhd_context_t *ctx, of
  25.451  }
  25.452  
  25.453  int 
  25.454 -vhd_set_phys_size(vhd_context_t *ctx, off64_t size)
  25.455 +vhd_set_phys_size(vhd_context_t *ctx, off_t size)
  25.456  {
  25.457 -	off64_t phys_size;
  25.458 +	off_t phys_size;
  25.459  	int err;
  25.460  
  25.461  	err = vhd_get_phys_size(ctx, &phys_size);
  25.462 @@ -2815,7 +2816,7 @@ static int
  25.463  		vhd_flag_creat_t flags)
  25.464  {
  25.465  	int err;
  25.466 -	off64_t off;
  25.467 +	off_t off;
  25.468  	vhd_context_t ctx;
  25.469  	vhd_footer_t *footer;
  25.470  	vhd_header_t *header;
  25.471 @@ -2901,7 +2902,7 @@ static int
  25.472  		goto out;
  25.473  
  25.474  	off = vhd_position(&ctx);
  25.475 -	if (off == (off64_t)-1) {
  25.476 +	if (off == (off_t)-1) {
  25.477  		err = -errno;
  25.478  		goto out;
  25.479  	}
  25.480 @@ -2976,7 +2977,7 @@ static int
  25.481  __vhd_io_dynamic_read_link(vhd_context_t *ctx, char *map,
  25.482  			   char *buf, uint64_t sector, uint32_t secs)
  25.483  {
  25.484 -	off64_t off;
  25.485 +	off_t off;
  25.486  	uint32_t blk, sec;
  25.487  	int err, cnt, map_off;
  25.488  	char *bitmap, *data, *src;
  25.489 @@ -3032,7 +3033,7 @@ static int
  25.490  		char *map, char *buf, uint64_t sec, uint32_t secs)
  25.491  {
  25.492  	int fd, err;
  25.493 -	off64_t off;
  25.494 +	off_t off;
  25.495  	uint64_t size;
  25.496  	char *data;
  25.497  
  25.498 @@ -3044,8 +3045,8 @@ static int
  25.499  		return -errno;
  25.500  	}
  25.501  
  25.502 -	off = lseek64(fd, vhd_sectors_to_bytes(sec), SEEK_SET);
  25.503 -	if (off == (off64_t)-1) {
  25.504 +	off = lseek(fd, vhd_sectors_to_bytes(sec), SEEK_SET);
  25.505 +	if (off == (off_t)-1) {
  25.506  		VHDLOG("%s: seek(0x%08"PRIx64") failed: %d\n",
  25.507  		       filename, vhd_sectors_to_bytes(sec), -errno);
  25.508  		err = -errno;
  25.509 @@ -3178,7 +3179,7 @@ static int
  25.510  {
  25.511  	char *buf;
  25.512  	size_t size;
  25.513 -	off64_t off, max;
  25.514 +	off_t off, max;
  25.515  	int i, err, gap, spp;
  25.516  
  25.517  	spp = getpagesize() >> VHD_SECTOR_SHIFT;
  25.518 @@ -3202,7 +3203,7 @@ static int
  25.519  		return err;
  25.520  
  25.521  	size = vhd_sectors_to_bytes(ctx->spb + ctx->bm_secs + gap);
  25.522 -	buf  = mmap(0, size, PROT_READ, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
  25.523 +	buf  = mmap(0, size, PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
  25.524  	if (buf == MAP_FAILED)
  25.525  		return -errno;
  25.526  
  25.527 @@ -3227,7 +3228,7 @@ static int
  25.528  		       char *buf, uint64_t sector, uint32_t secs)
  25.529  {
  25.530  	char *map;
  25.531 -	off64_t off;
  25.532 +	off_t off;
  25.533  	uint32_t blk, sec;
  25.534  	int i, err, cnt, ret;
  25.535  
    26.1 --- a/tools/blktap2/vhd/lib/vhd-util-check.c	Tue Jun 23 11:27:54 2009 +0100
    26.2 +++ b/tools/blktap2/vhd/lib/vhd-util-check.c	Tue Jun 23 17:24:14 2009 +0100
    26.3 @@ -146,7 +146,7 @@ ok:
    26.4  static char *
    26.5  vhd_util_check_validate_header(int fd, vhd_header_t *header)
    26.6  {
    26.7 -	off64_t eof;
    26.8 +	off_t eof;
    26.9  	int i, cnt, size;
   26.10  	uint32_t checksum;
   26.11  
   26.12 @@ -164,8 +164,8 @@ vhd_util_check_validate_header(int fd, v
   26.13  	if (header->data_offset != ~(0ULL))
   26.14  		return "invalid data offset";
   26.15  
   26.16 -	eof = lseek64(fd, 0, SEEK_END);
   26.17 -	if (eof == (off64_t)-1)
   26.18 +	eof = lseek(fd, 0, SEEK_END);
   26.19 +	if (eof == (off_t)-1)
   26.20  		return "error finding eof";
   26.21  
   26.22  	if (header->table_offset <= 0  ||
   26.23 @@ -232,7 +232,7 @@ static char *
   26.24  vhd_util_check_validate_batmap(vhd_context_t *vhd, vhd_batmap_t *batmap)
   26.25  {
   26.26  	int size;
   26.27 -	off64_t eof;
   26.28 +	off_t eof;
   26.29  	uint32_t checksum;
   26.30  
   26.31  	size = sizeof(batmap->header.cookie);
   26.32 @@ -249,8 +249,8 @@ vhd_util_check_validate_batmap(vhd_conte
   26.33  	if (!batmap->header.batmap_size)
   26.34  		return "invalid size zero";
   26.35  
   26.36 -	eof = lseek64(vhd->fd, 0, SEEK_END);
   26.37 -	if (eof == (off64_t)-1)
   26.38 +	eof = lseek(vhd->fd, 0, SEEK_END);
   26.39 +	if (eof == (off_t)-1)
   26.40  		return "error finding eof";
   26.41  
   26.42  	if (!batmap->header.batmap_offset ||
   26.43 @@ -269,7 +269,7 @@ static char *
   26.44  vhd_util_check_validate_parent_locator(vhd_context_t *vhd,
   26.45  				       vhd_parent_locator_t *loc)
   26.46  {
   26.47 -	off64_t eof;
   26.48 +	off_t eof;
   26.49  
   26.50  	if (vhd_validate_platform_code(loc->code))
   26.51  		return "invalid platform code";
   26.52 @@ -290,8 +290,8 @@ vhd_util_check_validate_parent_locator(v
   26.53  	if (!loc->data_len)
   26.54  		return "invalid data length";
   26.55  
   26.56 -	eof = lseek64(vhd->fd, 0, SEEK_END);
   26.57 -	if (eof == (off64_t)-1)
   26.58 +	eof = lseek(vhd->fd, 0, SEEK_END);
   26.59 +	if (eof == (off_t)-1)
   26.60  		return "error finding eof";
   26.61  
   26.62  	if (loc->data_offset + vhd_parent_locator_size(loc) >
   26.63 @@ -304,11 +304,12 @@ vhd_util_check_validate_parent_locator(v
   26.64  	return NULL;
   26.65  }
   26.66  
   26.67 -static char *
   26.68 +static const char *
   26.69  vhd_util_check_validate_parent(vhd_context_t *vhd, const char *ppath)
   26.70  {
   26.71 -	char *msg;
   26.72 +	const char *msg;
   26.73  	vhd_context_t parent;
   26.74 +	uint32_t status;
   26.75  
   26.76  	msg = NULL;
   26.77  
   26.78 @@ -335,7 +336,7 @@ vhd_util_check_footer(int fd, vhd_footer
   26.79  	size_t size;
   26.80  	int err, opened;
   26.81  	char *msg, *buf;
   26.82 -	off64_t eof, off;
   26.83 +	off_t eof, off;
   26.84  	vhd_footer_t primary, backup;
   26.85  
   26.86  	memset(&primary, 0, sizeof(primary));
   26.87 @@ -349,16 +350,16 @@ vhd_util_check_footer(int fd, vhd_footer
   26.88  
   26.89  	memset(buf, 0, sizeof(primary));
   26.90  
   26.91 -	eof = lseek64(fd, 0, SEEK_END);
   26.92 -	if (eof == (off64_t)-1) {
   26.93 +	eof = lseek(fd, 0, SEEK_END);
   26.94 +	if (eof == (off_t)-1) {
   26.95  		err = -errno;
   26.96  		printf("error calculating end of file: %d\n", err);
   26.97  		goto out;
   26.98  	}
   26.99  
  26.100  	size = ((eof % 512) ? 511 : 512);
  26.101 -	eof  = lseek64(fd, eof - size, SEEK_SET);
  26.102 -	if (eof == (off64_t)-1) {
  26.103 +	eof  = lseek(fd, eof - size, SEEK_SET);
  26.104 +	if (eof == (off_t)-1) {
  26.105  		err = -errno;
  26.106  		printf("error calculating end of file: %d\n", err);
  26.107  		goto out;
  26.108 @@ -391,8 +392,8 @@ vhd_util_check_footer(int fd, vhd_footer
  26.109  	}
  26.110  
  26.111  check_backup:
  26.112 -	off = lseek64(fd, 0, SEEK_SET);
  26.113 -	if (off == (off64_t)-1) {
  26.114 +	off = lseek(fd, 0, SEEK_SET);
  26.115 +	if (off == (off_t)-1) {
  26.116  		err = -errno;
  26.117  		printf("error seeking to backup footer: %d\n", err);
  26.118  		goto out;
  26.119 @@ -454,7 +455,7 @@ static int
  26.120  vhd_util_check_header(int fd, vhd_footer_t *footer)
  26.121  {
  26.122  	int err;
  26.123 -	off64_t off;
  26.124 +	off_t off;
  26.125  	char *msg, *buf;
  26.126  	vhd_header_t header;
  26.127  
  26.128 @@ -465,8 +466,8 @@ vhd_util_check_header(int fd, vhd_footer
  26.129  	}
  26.130  
  26.131  	off = footer->data_offset;
  26.132 -	off = lseek64(fd, off, SEEK_SET);
  26.133 -	if (off == (off64_t)-1) {
  26.134 +	off = lseek(fd, off, SEEK_SET);
  26.135 +	if (off == (off_t)-1) {
  26.136  		err = -errno;
  26.137  		printf("error seeking to header: %d\n", err);
  26.138  		goto out;
  26.139 @@ -513,7 +514,7 @@ vhd_util_check_differencing_header(vhd_c
  26.140  static int
  26.141  vhd_util_check_bat(vhd_context_t *vhd)
  26.142  {
  26.143 -	off64_t eof, eoh;
  26.144 +	off_t eof, eoh;
  26.145  	int i, j, err, block_size;
  26.146  
  26.147  	err = vhd_seek(vhd, 0, SEEK_END);
  26.148 @@ -523,7 +524,7 @@ vhd_util_check_bat(vhd_context_t *vhd)
  26.149  	}
  26.150  
  26.151  	eof = vhd_position(vhd);
  26.152 -	if (eof == (off64_t)-1) {
  26.153 +	if (eof == (off_t)-1) {
  26.154  		printf("error calculating eof: %d\n", -errno);
  26.155  		return -errno;
  26.156  	}
  26.157 @@ -645,7 +646,8 @@ vhd_util_check_parent_locators(vhd_conte
  26.158  {
  26.159  	int i, n, err;
  26.160  	vhd_parent_locator_t *loc;
  26.161 -	char *msg, *file, *ppath, *location, *pname;
  26.162 +	char *file, *ppath, *location, *pname;
  26.163 +	const char *msg;
  26.164  	int mac, macx, w2ku, w2ru, wi2r, wi2k, found;
  26.165  
  26.166  	mac      = 0;
    27.1 --- a/tools/blktap2/vhd/lib/vhd-util-coalesce.c	Tue Jun 23 11:27:54 2009 +0100
    27.2 +++ b/tools/blktap2/vhd/lib/vhd-util-coalesce.c	Tue Jun 23 17:24:14 2009 +0100
    27.3 @@ -35,12 +35,12 @@
    27.4  static int
    27.5  __raw_io_write(int fd, char* buf, uint64_t sec, uint32_t secs)
    27.6  {
    27.7 -	off64_t off;
    27.8 +	off_t off;
    27.9  	size_t ret;
   27.10  
   27.11  	errno = 0;
   27.12 -	off = lseek64(fd, vhd_sectors_to_bytes(sec), SEEK_SET);
   27.13 -	if (off == (off64_t)-1) {
   27.14 +	off = lseek(fd, vhd_sectors_to_bytes(sec), SEEK_SET);
   27.15 +	if (off == (off_t)-1) {
   27.16  		printf("raw parent: seek(0x%08"PRIx64") failed: %d\n",
   27.17  		       vhd_sectors_to_bytes(sec), -errno);
   27.18  		return -errno;
    28.1 --- a/tools/blktap2/vhd/lib/vhd-util-modify.c	Tue Jun 23 11:27:54 2009 +0100
    28.2 +++ b/tools/blktap2/vhd/lib/vhd-util-modify.c	Tue Jun 23 17:24:14 2009 +0100
    28.3 @@ -56,7 +56,7 @@ vhd_util_modify(int argc, char **argv)
    28.4  	char *name;
    28.5  	vhd_context_t vhd;
    28.6  	int err, c, size, parent, parent_raw;
    28.7 -	off64_t newsize = 0;
    28.8 +	off_t newsize = 0;
    28.9  	char *newparent = NULL;
   28.10  
   28.11  	name       = NULL;
    29.1 --- a/tools/blktap2/vhd/lib/vhd-util-query.c	Tue Jun 23 11:27:54 2009 +0100
    29.2 +++ b/tools/blktap2/vhd/lib/vhd-util-query.c	Tue Jun 23 17:24:14 2009 +0100
    29.3 @@ -37,7 +37,7 @@ vhd_util_query(int argc, char **argv)
    29.4  {
    29.5  	char *name;
    29.6  	vhd_context_t vhd;
    29.7 -	off64_t currsize;
    29.8 +	off_t currsize;
    29.9  	int ret, err, c, size, physize, parent, fields, depth;
   29.10  
   29.11  	name    = NULL;
    30.1 --- a/tools/blktap2/vhd/lib/vhd-util-read.c	Tue Jun 23 11:27:54 2009 +0100
    30.2 +++ b/tools/blktap2/vhd/lib/vhd-util-read.c	Tue Jun 23 17:24:14 2009 +0100
    30.3 @@ -59,11 +59,11 @@ vhd_print_header(vhd_context_t *vhd, vhd
    30.4  {
    30.5  	int err;
    30.6  	uint32_t  cksm;
    30.7 -	char      uuid[37], time_str[26], cookie[9], out[512], *name;
    30.8 +	char      uuid[39], time_str[26], cookie[9], out[512], *name;
    30.9  
   30.10  	printf("VHD Header Summary:\n-------------------\n");
   30.11  
   30.12 -	snprintf(cookie, 9, "%s", h->cookie);
   30.13 +	snprintf(cookie, sizeof(cookie), "%s", h->cookie);
   30.14  	printf("Cookie              : %s\n", cookie);
   30.15  
   30.16  	printf("Data offset (unusd) : %s\n", conv(hex, h->data_offset));
   30.17 @@ -95,11 +95,11 @@ vhd_print_footer(vhd_footer_t *f, int he
   30.18  {
   30.19  	uint64_t  c, h, s;
   30.20  	uint32_t  ff_maj, ff_min, cr_maj, cr_min, cksm, cksm_save;
   30.21 -	char      time_str[26], creator[5], uuid[37], cookie[9];
   30.22 +	char      time_str[26], creator[5], uuid[39], cookie[9];
   30.23  
   30.24  	printf("VHD Footer Summary:\n-------------------\n");
   30.25  
   30.26 -	snprintf(cookie, 9, "%s", f->cookie);
   30.27 +	snprintf(cookie, sizeof(cookie), "%s", f->cookie);
   30.28  	printf("Cookie              : %s\n", cookie);
   30.29  
   30.30  	printf("Features            : (0x%08x) %s%s\n", f->features,
    31.1 --- a/tools/blktap2/vhd/lib/vhd-util-repair.c	Tue Jun 23 11:27:54 2009 +0100
    31.2 +++ b/tools/blktap2/vhd/lib/vhd-util-repair.c	Tue Jun 23 17:24:14 2009 +0100
    31.3 @@ -37,7 +37,7 @@ vhd_util_repair(int argc, char **argv)
    31.4  {
    31.5  	char *name;
    31.6  	int err, c;
    31.7 -	off64_t eof;
    31.8 +	off_t eof;
    31.9  	vhd_context_t vhd;
   31.10  
   31.11  	name = NULL;
    32.1 --- a/tools/blktap2/vhd/lib/vhd-util-resize.c	Tue Jun 23 11:27:54 2009 +0100
    32.2 +++ b/tools/blktap2/vhd/lib/vhd-util-resize.c	Tue Jun 23 17:24:14 2009 +0100
    32.3 @@ -95,7 +95,7 @@ vhd_fixed_shrink(vhd_journal_t *journal,
    32.4  }
    32.5  
    32.6  static int
    32.7 -vhd_write_zeros(vhd_journal_t *journal, off64_t off, uint64_t size)
    32.8 +vhd_write_zeros(vhd_journal_t *journal, off_t off, uint64_t size)
    32.9  {
   32.10  	int err;
   32.11  	char *buf;
   32.12 @@ -109,7 +109,7 @@ vhd_write_zeros(vhd_journal_t *journal, 
   32.13  	if (err)
   32.14  		return err;
   32.15  
   32.16 -	buf = mmap(0, map, PROT_READ, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
   32.17 +	buf = mmap(0, map, PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
   32.18  	if (buf == MAP_FAILED)
   32.19  		return -errno;
   32.20  
   32.21 @@ -143,7 +143,7 @@ vhd_fixed_grow(vhd_journal_t *journal, u
   32.22  		goto out;
   32.23  
   32.24  	eof = vhd_position(vhd);
   32.25 -	if (eof == (off64_t)-1) {
   32.26 +	if (eof == (off_t)-1) {
   32.27  		err = -errno;
   32.28  		goto out;
   32.29  	}
   32.30 @@ -234,13 +234,13 @@ quicksort(vhd_block_t *list, int left, i
   32.31  }
   32.32  
   32.33  static int
   32.34 -vhd_move_block(vhd_journal_t *journal, uint32_t src, off64_t offset)
   32.35 +vhd_move_block(vhd_journal_t *journal, uint32_t src, off_t offset)
   32.36  {
   32.37  	int err;
   32.38  	char *buf;
   32.39  	size_t size;
   32.40  	vhd_context_t *vhd;
   32.41 -	off64_t off, src_off;
   32.42 +	off_t off, src_off;
   32.43  
   32.44  	buf     = NULL;
   32.45  	vhd     = &journal->vhd;
   32.46 @@ -300,7 +300,7 @@ static int
   32.47  vhd_clobber_block(vhd_journal_t *journal, uint32_t src, uint32_t dest)
   32.48  {
   32.49  	int err;
   32.50 -	off64_t off;
   32.51 +	off_t off;
   32.52  	vhd_context_t *vhd;
   32.53  
   32.54  	vhd = &journal->vhd;
   32.55 @@ -404,7 +404,7 @@ vhd_clear_bat_entries(vhd_journal_t *jou
   32.56  {
   32.57  	int i, err;
   32.58  	vhd_context_t *vhd;
   32.59 -	off64_t orig_map_off, new_map_off;
   32.60 +	off_t orig_map_off, new_map_off;
   32.61  	uint32_t orig_entries, new_entries;
   32.62  
   32.63  	vhd          = &journal->vhd;
   32.64 @@ -473,7 +473,7 @@ vhd_clear_bat_entries(vhd_journal_t *jou
   32.65  static int
   32.66  vhd_dynamic_shrink(vhd_journal_t *journal, uint64_t secs)
   32.67  {
   32.68 -	off64_t eof;
   32.69 +	off_t eof;
   32.70  	uint32_t blocks;
   32.71  	vhd_context_t *vhd;
   32.72  	int i, j, err, free_cnt;
   32.73 @@ -581,7 +581,7 @@ vhd_next_block_offset(vhd_context_t *vhd
   32.74  }
   32.75  
   32.76  static inline int
   32.77 -in_range(off64_t off, off64_t start, off64_t size)
   32.78 +in_range(off_t off, off_t start, off_t size)
   32.79  {
   32.80  	return (start < off && start + size > off);
   32.81  }
   32.82 @@ -599,7 +599,7 @@ skip_check(int mode, int type)
   32.83  }
   32.84  
   32.85  static int
   32.86 -vhd_check_for_clobber(vhd_context_t *vhd, off64_t off, int mode)
   32.87 +vhd_check_for_clobber(vhd_context_t *vhd, off_t off, int mode)
   32.88  {
   32.89  	int i, n;
   32.90  	char *msg;
   32.91 @@ -676,7 +676,7 @@ fail:
   32.92   * take any metadata after the bat (@eob) and shift it
   32.93   */
   32.94  static int
   32.95 -vhd_shift_metadata(vhd_journal_t *journal, off64_t eob,
   32.96 +vhd_shift_metadata(vhd_journal_t *journal, off_t eob,
   32.97  		   size_t bat_needed, size_t map_needed)
   32.98  {
   32.99  	int i, n, err;
  32.100 @@ -724,7 +724,7 @@ vhd_shift_metadata(vhd_journal_t *journa
  32.101  	}
  32.102  
  32.103  	for (i = 0; i < n; i++) {
  32.104 -		off64_t off;
  32.105 +		off_t off;
  32.106  		size_t size;
  32.107  
  32.108  		if (!locators[i])
  32.109 @@ -775,7 +775,7 @@ static int
  32.110  vhd_add_bat_entries(vhd_journal_t *journal, int entries)
  32.111  {
  32.112  	int i, err;
  32.113 -	off64_t off;
  32.114 +	off_t off;
  32.115  	vhd_bat_t new_bat;
  32.116  	vhd_context_t *vhd;
  32.117  	uint32_t new_entries;
  32.118 @@ -878,7 +878,7 @@ static int
  32.119  vhd_dynamic_grow(vhd_journal_t *journal, uint64_t secs)
  32.120  {
  32.121  	int i, err;
  32.122 -	off64_t eob, eom;
  32.123 +	off_t eob, eom;
  32.124  	vhd_context_t *vhd;
  32.125  	vhd_block_t first_block;
  32.126  	uint64_t blocks, size_needed;
  32.127 @@ -953,7 +953,7 @@ vhd_dynamic_grow(vhd_journal_t *journal,
  32.128  	 * move vhd data blocks to the end of the file to make room 
  32.129  	 */
  32.130  	do {
  32.131 -		off64_t new_off, bm_size, gap_size;
  32.132 +		off_t new_off, bm_size, gap_size;
  32.133  
  32.134  		new_off = vhd_sectors_to_bytes(vhd_next_block_offset(vhd));
  32.135  
    33.1 --- a/tools/blktap2/vhd/lib/vhd-util-scan.c	Tue Jun 23 11:27:54 2009 +0100
    33.2 +++ b/tools/blktap2/vhd/lib/vhd-util-scan.c	Tue Jun 23 17:24:14 2009 +0100
    33.3 @@ -33,6 +33,7 @@
    33.4  #include <stdlib.h>
    33.5  #include <unistd.h>
    33.6  #include <fnmatch.h>
    33.7 +#include <libgen.h>	/* for basename() */
    33.8  
    33.9  #include "list.h"
   33.10  #include "libvhd.h"
   33.11 @@ -82,7 +83,7 @@ struct vhd_image {
   33.12  	char                *name;
   33.13  	char                *parent;
   33.14  	uint64_t             capacity;
   33.15 -	off64_t              size;
   33.16 +	off_t                size;
   33.17  	uint8_t              hidden;
   33.18  	int                  error;
   33.19  	char                *message;
    34.1 --- a/tools/blktap2/vhd/lib/vhd-util-set-field.c	Tue Jun 23 11:27:54 2009 +0100
    34.2 +++ b/tools/blktap2/vhd/lib/vhd-util-set-field.c	Tue Jun 23 17:24:14 2009 +0100
    34.3 @@ -37,7 +37,7 @@ vhd_util_set_field(int argc, char **argv
    34.4  {
    34.5  	long value;
    34.6  	int err, c;
    34.7 -	off64_t eof;
    34.8 +	off_t eof;
    34.9  	vhd_context_t vhd;
   34.10  	char *name, *field;
   34.11  
    35.1 --- a/tools/blktap2/vhd/vhd-update.c	Tue Jun 23 11:27:54 2009 +0100
    35.2 +++ b/tools/blktap2/vhd/vhd-update.c	Tue Jun 23 17:24:14 2009 +0100
    35.3 @@ -36,8 +36,6 @@
    35.4  #include <fcntl.h>
    35.5  #include <stdlib.h>
    35.6  #include <unistd.h>
    35.7 -#include <endian.h>
    35.8 -#include <byteswap.h>
    35.9  
   35.10  #include "atomicio.h"
   35.11  #include "libvhd.h"
    36.1 --- a/tools/check/check_uuid_devel	Tue Jun 23 11:27:54 2009 +0100
    36.2 +++ b/tools/check/check_uuid_devel	Tue Jun 23 17:24:14 2009 +0100
    36.3 @@ -3,4 +3,5 @@
    36.4  
    36.5  . ./funcs.sh
    36.6  
    36.7 +has_header uuid.h || \
    36.8  has_header uuid/uuid.h || fail "missing uuid headers (package uuid-dev)"