From owner-svn-src-head@FreeBSD.ORG Tue Nov 18 04:57:26 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6F017106564A for ; Tue, 18 Nov 2008 04:57:26 +0000 (UTC) (envelope-from delphij@gmail.com) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.189]) by mx1.freebsd.org (Postfix) with ESMTP id EE9F88FC0A for ; Tue, 18 Nov 2008 04:57:25 +0000 (UTC) (envelope-from delphij@gmail.com) Received: by fk-out-0910.google.com with SMTP id k31so3324844fkk.11 for ; Mon, 17 Nov 2008 20:57:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to :to:subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=oCf9tKgEu5CuDHp4H7ln/Iy5kdeNunW7UsSHSbbjIj0=; b=HFS/HFWwZBvDEMgS3VXFzddnYpjn52gT9pIEGPnzOD3vS3uFSBpC9ga8jt2GxoRL0b ABAUxBAcL+Uj/9O6+vhV6GHOAX2Og1mDFNQpZ0cUWWjoLgbp4c+7bP4fqxy8VV1XK1zC nKXfiXdJApcnUM1EJgTU1J5hW7RyNMcipfzg4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:to:subject:cc:in-reply-to :mime-version:content-type:content-transfer-encoding :content-disposition:references; b=UCQ+RDweKujHlqo7S2e1liGVwKQVc9Vt3odLJVr+lLLK/oPJjBYG3w8x+0DKX2Jq5p 4LcxIoXupW1PX+L9YwaooKjJBKjH+WUk26c804VDGfnjxQSY+lnqPqccJEB3gcoxRRiK hedlYx0qY4dsFnFV/exGIBjoHmIMvkqyThJ5c= Received: by 10.181.135.12 with SMTP id m12mr1199818bkn.88.1226982588944; Mon, 17 Nov 2008 20:29:48 -0800 (PST) Received: by 10.180.242.16 with HTTP; Mon, 17 Nov 2008 20:29:48 -0800 (PST) Message-ID: Date: Mon, 17 Nov 2008 20:29:48 -0800 From: "Xin LI" To: "Marcel Moolenaar" In-Reply-To: <200811180003.mAI03UKc061998@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200811180003.mAI03UKc061998@svn.freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r185038 - head/sbin/geom/class/part X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: delphij@delphij.net List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Nov 2008 04:57:26 -0000 Thanks! On Mon, Nov 17, 2008 at 4:03 PM, Marcel Moolenaar wrote: > Author: marcel > Date: Tue Nov 18 00:03:30 2008 > New Revision: 185038 > URL: http://svn.freebsd.org/changeset/base/185038 > > Log: > Pad the bootcode we write to the partition to a multiple of the > sector size. > > Submitted by: Alexey Shuvaev > Prompted by: delphij > MFC after: 3 days > > Modified: > head/sbin/geom/class/part/geom_part.c > > Modified: head/sbin/geom/class/part/geom_part.c > ============================================================================== > --- head/sbin/geom/class/part/geom_part.c Tue Nov 18 00:01:16 2008 (r185037) > +++ head/sbin/geom/class/part/geom_part.c Tue Nov 18 00:03:30 2008 (r185038) > @@ -393,6 +393,8 @@ gpart_write_partcode(struct gctl_req *re > struct ggeom *gp; > struct gprovider *pp; > const char *s; > + char *buf; > + off_t bsize; > int error, fd; > > s = gctl_get_ascii(req, "class"); > @@ -428,8 +430,21 @@ gpart_write_partcode(struct gctl_req *re > errx(EXIT_FAILURE, "%s: not enough space", dsf); > if (lseek(fd, 0, SEEK_SET) != 0) > err(EXIT_FAILURE, "%s", dsf); > - if (write(fd, code, size) != size) > + > + /* > + * When writing to a disk device, the write must be > + * sector aligned and not write to any partial sectors, > + * so round up the buffer size to the next sector and zero it. > + */ > + bsize = (size + pp->lg_sectorsize - 1) / > + pp->lg_sectorsize * pp->lg_sectorsize; > + buf = calloc(1, bsize); > + if (buf == NULL) > + err(EXIT_FAILURE, "%s", dsf); > + bcopy(code, buf, size); > + if (write(fd, buf, bsize) != bsize) > err(EXIT_FAILURE, "%s", dsf); > + free(buf); > close(fd); > } else > errx(EXIT_FAILURE, "invalid partition index"); > -- Xin LI http://www.delphij.net