Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Mar 2003 16:22:43 -0800
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        hackers@freebsd.org
Subject:   review request: making fdisk support hog slices
Message-ID:  <20030303162243.A2233@Odin.AC.HMC.Edu>

next in thread | raw e-mail | index | archive | help

--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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030303162243.A2233>