From owner-freebsd-hackers Mon Mar 3 16:27:21 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 E2BE737B401 for ; Mon, 3 Mar 2003 16:27:18 -0800 (PST) Received: from rwcrmhc52.attbi.com (rwcrmhc52.attbi.com [216.148.227.88]) by mx1.FreeBSD.org (Postfix) with ESMTP id 558AB43FAF for ; Mon, 3 Mar 2003 16:27:18 -0800 (PST) (envelope-from julian@elischer.org) Received: from interjet.elischer.org (12-232-168-4.client.attbi.com[12.232.168.4]) by rwcrmhc52.attbi.com (rwcrmhc52) with ESMTP id <2003030400271505200prqfae>; Tue, 4 Mar 2003 00:27:15 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id QAA45011; Mon, 3 Mar 2003 16:27:14 -0800 (PST) Date: Mon, 3 Mar 2003 16:27:13 -0800 (PST) From: Julian Elischer To: Brooks Davis Cc: hackers@freebsd.org Subject: Re: review request: making fdisk support hog slices In-Reply-To: <20030303162243.A2233@Odin.AC.HMC.Edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 How about using the same scheme that disklabel uses.. a "*" means 'rest of device'. On Mon, 3 Mar 2003, Brooks Davis wrote: > 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 > =================================================================== > 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 > =================================================================== > 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 = *cp++; > - if (!isdigit(*cp)) > + if (!isdigit(*cp) && *cp != '-') > break; /* assume end of line */ > end = NULL; > command->args[command->n_args].arg_val = strtol(cp, &end, 0); > @@ -1077,7 +1077,16 @@ process_partition(CMD *command) > bzero((char *)partp, sizeof (struct dos_partition)); > partp->dp_typ = command->args[1].arg_val; > partp->dp_start = command->args[2].arg_val; > - partp->dp_size = 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 == -1) { > + partp->dp_size = ((disksecs - partp->dp_start) / dos_cylsecs) * > + dos_cylsecs - dos_sectors; > + } else { > + partp->dp_size = command->args[3].arg_val; > + } > max_end = partp->dp_start + partp->dp_size; > > if (partp->dp_typ == 0) { > > -- > 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 > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message