Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Jun 2014 04:32:43 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r267999 - user/marcel/mkimg
Message-ID:  <201406280432.s5S4Whbh017881@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Sat Jun 28 04:32:42 2014
New Revision: 267999
URL: http://svnweb.freebsd.org/changeset/base/267999

Log:
  Use image_copyout_region() to write 2MB of user data interleaved with
  the block's sector bitmap. This should complete the support, modulo
  bug fixing.

Modified:
  user/marcel/mkimg/vhd.c

Modified: user/marcel/mkimg/vhd.c
==============================================================================
--- user/marcel/mkimg/vhd.c	Sat Jun 28 04:30:40 2014	(r267998)
+++ user/marcel/mkimg/vhd.c	Sat Jun 28 04:32:42 2014	(r267999)
@@ -214,6 +214,7 @@ vhd_write(int fd)
 	struct vhd_dyn_header header;
 	uuid_t id;
 	uint64_t imgsz;
+	lba_t blk, nblks;
 	uint32_t *bat;
 	void *bitmap;
 	size_t batsz;
@@ -274,14 +275,21 @@ vhd_write(int fd)
 	if (bitmap == NULL)
 		return (errno);
 	memset(bitmap, 0xff, VHD_SECTOR_SIZE);
-	if (sparse_write(fd, bitmap, VHD_SECTOR_SIZE) < 0) {
-		free(bitmap);
-		return (errno);
+
+	blk = 0;
+	nblks = image_get_size();
+	while (blk < nblks) {
+		if (sparse_write(fd, bitmap, VHD_SECTOR_SIZE) < 0) {
+			error = errno;
+			break;
+		}
+		error = image_copyout_region(fd, blk, VHD_BLOCK_SIZE / secsz);
+		if (error)
+			break;
+		blk += VHD_BLOCK_SIZE / secsz;
 	}
 	free(bitmap);
-
-	error = image_copyout(fd);
-	if (error)
+	if (blk != nblks)
 		return (error);
 
 	if (sparse_write(fd, &footer, sizeof(footer)) < 0)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406280432.s5S4Whbh017881>