Date: Mon, 3 Mar 2003 16:27:13 -0800 (PST) From: Julian Elischer <julian@elischer.org> To: Brooks Davis <brooks@one-eyed-alien.net> Cc: hackers@freebsd.org Subject: Re: review request: making fdisk support hog slices Message-ID: <Pine.BSF.4.21.0303031626240.42494-100000@InterJet.elischer.org> In-Reply-To: <20030303162243.A2233@Odin.AC.HMC.Edu>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0303031626240.42494-100000>
