From owner-svn-src-user@FreeBSD.ORG Fri Mar 21 04:14:26 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 A7200E11; Fri, 21 Mar 2014 04:14:26 +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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 94A97172; Fri, 21 Mar 2014 04:14:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2L4EQNe098732; Fri, 21 Mar 2014 04:14:26 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2L4EQQF098731; Fri, 21 Mar 2014 04:14:26 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201403210414.s2L4EQQF098731@svn.freebsd.org> From: Marcel Moolenaar Date: Fri, 21 Mar 2014 04:14:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r263462 - 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.17 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: Fri, 21 Mar 2014 04:14:26 -0000 Author: marcel Date: Fri Mar 21 04:14:26 2014 New Revision: 263462 URL: http://svnweb.freebsd.org/changeset/base/263462 Log: Fix writing GPT: 1. Fix copy-paste bug that resulted in not sizing the image correctly for the secondary header and table. 2. The hdr_lba_end field in the header is the LBA of the last usable sector, not the one after it. While here, fix a white-space nit. Modified: user/marcel/mkimg/gpt.c Modified: user/marcel/mkimg/gpt.c ============================================================================== --- user/marcel/mkimg/gpt.c Fri Mar 21 03:27:42 2014 (r263461) +++ user/marcel/mkimg/gpt.c Fri Mar 21 04:14:26 2014 (r263462) @@ -121,7 +121,7 @@ gpt_metadata(u_int where, u_int parts, u { u_int secs; - if (where != SCHEME_META_IMG_START && where != SCHEME_META_IMG_START) + if (where != SCHEME_META_IMG_START && where != SCHEME_META_IMG_END) return (0); secs = gpt_tblsz(parts, secsz); @@ -243,7 +243,7 @@ gpt_write(int fd, off_t imgsz, u_int par hdr->hdr_revision = GPT_HDR_REVISION; hdr->hdr_size = offsetof(struct gpt_hdr, padding); hdr->hdr_lba_start = 2 + tblsz; - hdr->hdr_lba_end = nblocks - tblsz - 1; + hdr->hdr_lba_end = nblocks - tblsz - 2; uuidgen(&hdr->hdr_uuid, 1); hdr->hdr_entries = parts; hdr->hdr_entsz = sizeof(struct gpt_ent); @@ -251,7 +251,7 @@ gpt_write(int fd, off_t imgsz, u_int par error = gpt_write_hdr(fd, hdr, 1, nblocks - 1, 2, secsz); if (!error) error = gpt_write_hdr(fd, hdr, nblocks - 1, 1, - nblocks - tblsz -1, secsz); + nblocks - tblsz - 1, secsz); free(hdr); out: