From owner-svn-src-head@freebsd.org Wed Aug 17 15:41:27 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AFFEEBBC7D2; Wed, 17 Aug 2016 15:41:27 +0000 (UTC) (envelope-from des@des.no) Received: from smtp.des.no (smtp.des.no [194.63.250.102]) by mx1.freebsd.org (Postfix) with ESMTP id 776611905; Wed, 17 Aug 2016 15:41:27 +0000 (UTC) (envelope-from des@des.no) Received: from desk.des.no (smtp.des.no [194.63.250.102]) by smtp.des.no (Postfix) with ESMTP id E4C702D4B; Wed, 17 Aug 2016 15:41:25 +0000 (UTC) Received: by desk.des.no (Postfix, from userid 1001) id 1AD428EB6; Wed, 17 Aug 2016 17:40:00 +0200 (CEST) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Hans Petter Selasky Cc: Slawa Olhovchenkov , Nathan Whitehorn , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r304142 - head/usr.sbin/bsdinstall/partedit References: <201608150930.u7F9UL1V069576@repo.freebsd.org> <861t1n6749.fsf@desk.des.no> <581c856c-826b-529e-c9c6-a397fb679708@freebsd.org> <20160817144944.GM22212@zxy.spb.ru> <4a28f419-5293-0753-068d-1e07ddb01c2d@selasky.org> <86shu34erp.fsf@desk.des.no> Date: Wed, 17 Aug 2016 17:39:59 +0200 In-Reply-To: (Hans Petter Selasky's message of "Wed, 17 Aug 2016 17:21:15 +0200") Message-ID: <86oa4r4d68.fsf@desk.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list 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: Wed, 17 Aug 2016 15:41:27 -0000 Hans Petter Selasky writes: > My intention is not to install FreeBSD on a 3K disk. My question is > pure mathematical, if the bsdinstall will segfault, division by zero > or anything like that, if one should try to install FreeBSD on a 3K > disk, because you round up the size of the disk to be bigger than it > actually is. The code in question computes the offset and size of the largest block of contiguous free space on a disk that already has a partition table. If you even got this far, it would round the offset up to 4096 and the size down by and equivalent amount and you'd get an error box saying "No free space left on device". Say you have a 3584-byte provider with 512-byte sectors formatted with MBR, leaving 3072 bytes (6 sectors) free at offset 512 (1); stripe size is unreported and is arbitrarily set to the smallest common multiple of 512 and 4096, which is 4096; misalignment is 512 % 4096 =3D=3D 512 bytes; adjustment is (4096 - 512) / 512 =3D=3D 7 sectors; adjusted offset is 8 sectors, adjusted size is -1 sectors which the caller rejects (and yes, the variables are unsigned and the check is for <=3D 0, not =3D=3D 0, so everything works as intended). DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no