From owner-freebsd-hackers Mon Mar 3 16:22:51 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D480F37B405 for ; Mon, 3 Mar 2003 16:22:47 -0800 (PST) Received: from odin.ac.hmc.edu (Odin.AC.HMC.Edu [134.173.32.75]) by mx1.FreeBSD.org (Postfix) with ESMTP id D579243F93 for ; Mon, 3 Mar 2003 16:22:46 -0800 (PST) (envelope-from brdavis@odin.ac.hmc.edu) Received: from odin.ac.hmc.edu (IDENT:brdavis@localhost.localdomain [127.0.0.1]) by odin.ac.hmc.edu (8.12.3/8.12.3) with ESMTP id h240MhJu006477 for ; Mon, 3 Mar 2003 16:22:44 -0800 Received: (from brdavis@localhost) by odin.ac.hmc.edu (8.12.3/8.12.3/Submit) id h240Mhhk006475 for hackers@freebsd.org; Mon, 3 Mar 2003 16:22:43 -0800 Date: Mon, 3 Mar 2003 16:22:43 -0800 From: Brooks Davis To: hackers@freebsd.org Subject: review request: making fdisk support hog slices Message-ID: <20030303162243.A2233@Odin.AC.HMC.Edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="9jxsPFA5p3P2qPhR" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-Virus-Scanned: by amavisd-milter (http://amavis.org/) on odin.ac.hmc.edu Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I've made some trivial changes to fdisk's config file parsing code to allow the user to specify -1 as the length of a slice to force it to run to the end of the disk. This allows you to create a set of fixed sized slices and then one that fills the disk without having to worry about the actual size of the disk. The actual code is almost exactly the same as the code for -I. As noted in the addition to the manpage, no check is performed to insure that the hog slice is actually the last slice on the disk. This is done because 1) fdisk isn't really set up to allow for that kind of checking and 2) my partition tables already have overlaping partitions due to using fake partitions for disk versioning. I'd like to commit this soon with the intent to MFC it after 4.8. Comments, objections, etc? Thanks, Brooks Index: fdisk.8 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /usr/cvs/src/sbin/fdisk/fdisk.8,v retrieving revision 1.34 diff -u -p -r1.34 fdisk.8 --- fdisk.8 21 Aug 2002 18:10:07 -0000 1.34 +++ fdisk.8 27 Feb 2003 23:54:36 -0000 @@ -364,6 +364,11 @@ starting at sector for .Ar length sectors. +If +.Ar length +is -1, the slice will extend to the end of the disk. +No checks are performed to insure the slice is actually the last slice +on the disk. .Pp Only those slices explicitly mentioned by these lines are modified; any slice not referenced by a Index: fdisk.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /usr/cvs/src/sbin/fdisk/fdisk.c,v retrieving revision 1.68 diff -u -p -r1.68 fdisk.c --- fdisk.c 30 Dec 2002 21:18:04 -0000 1.68 +++ fdisk.c 28 Feb 2003 01:37:58 -0000 @@ -947,7 +947,7 @@ parse_config_line(char *line, CMD *comma break; /* found comment */ if (isalpha(*cp)) command->args[command->n_args].argtype =3D *cp++; - if (!isdigit(*cp)) + if (!isdigit(*cp) && *cp !=3D '-') break; /* assume end of line */ end =3D NULL; command->args[command->n_args].arg_val =3D strtol(cp, &end, 0); @@ -1077,7 +1077,16 @@ process_partition(CMD *command) bzero((char *)partp, sizeof (struct dos_partition)); partp->dp_typ =3D command->args[1].arg_val; partp->dp_start =3D command->args[2].arg_val; - partp->dp_size =3D command->args[3].arg_val; + /* + * If the user passed -1 as the length, assume they wanted to + * fill the disk to the end with this partition. + */ + if (command->args[3].arg_val =3D=3D -1) { + partp->dp_size =3D ((disksecs - partp->dp_start) / dos_cylsecs) *=20 + dos_cylsecs - dos_sectors; + } else { + partp->dp_size =3D command->args[3].arg_val; + } max_end =3D partp->dp_start + partp->dp_size; =20 if (partp->dp_typ =3D=3D 0) { --=20 Any statement of the form "X is the one, true Y" is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4 --9jxsPFA5p3P2qPhR Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE+Y/HSXY6L6fI4GtQRArKxAJkBMu/kGjHN8UHNpP4zx1jgAhGsfwCgwUQN U3X/aiexvKAxYJq1iwmRh+4= =S6mU -----END PGP SIGNATURE----- --9jxsPFA5p3P2qPhR-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message