From owner-svn-src-user@FreeBSD.ORG Sat Jun 28 04:32:43 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7093256D; Sat, 28 Jun 2014 04:32:43 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5E3A82133; Sat, 28 Jun 2014 04:32:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5S4WhiI017882; Sat, 28 Jun 2014 04:32:43 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5S4Whbh017881; Sat, 28 Jun 2014 04:32:43 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201406280432.s5S4Whbh017881@svn.freebsd.org> From: Marcel Moolenaar Date: Sat, 28 Jun 2014 04:32:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r267999 - user/marcel/mkimg X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Jun 2014 04:32:43 -0000 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)