bin/143389: [2tb] fdisk(8) cannot handle above 1TB under i386
system.
Mark Johnston
mjohnston at sandvine.com
Tue Oct 26 19:00:22 UTC 2010
The following reply was made to PR bin/143389; it has been noted by GNATS.
From: Mark Johnston <mjohnston at sandvine.com>
To: "bug-followup at FreeBSD.org" <bug-followup at FreeBSD.org>,
"aoyama at peach.ne.jp" <aoyama at peach.ne.jp>
Cc:
Subject: Re: bin/143389: [2tb] fdisk(8) cannot handle above 1TB under i386
system.
Date: Tue, 26 Oct 2010 18:43:42 +0000
I was about to submit a PR about this before I found this one.
The problem is that fdisk is using a signed integer to store slice
sizes, so attempts to create a slice of size >1TB will result in
fdisk using LONG_MAX as the slice size...which ends up corresponding
to 1TB on platforms where sizeof(long) =3D=3D 4.
The solution is to use an unsigned long instead.
We have a patch in our tree for it.
Thanks,
-Mark
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c
index 0b2ce7d..89b35f9 100644
--- a/sbin/fdisk/fdisk.c
+++ b/sbin/fdisk/fdisk.c
@@ -105,9 +105,9 @@ typedef struct cmd {
char cmd;
int n_args;
struct arg {
- char argtype;
- int arg_val;
- char *arg_str;
+ char argtype;
+ unsigned long arg_val;
+ char *arg_str;
} args[MAX_ARGS];
} CMD;
=20
@@ -979,7 +979,7 @@ parse_config_line(char *line, CMD *command)
if (isalpha(*cp))
command->args[command->n_args].argtype =3D *cp++;
end =3D NULL;
- command->args[command->n_args].arg_val =3D strtol(cp, &end, 0);
+ command->args[command->n_args].arg_val =3D strtoul(cp, &end, 0)=
;
if (cp =3D=3D end || (!isspace(*end) && *end !=3D '\0')) {
char ch;
end =3D cp;
More information about the freebsd-bugs
mailing list