Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Oct 2010 19:00:21 GMT
From:      Mark Johnston <mjohnston@sandvine.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/143389: [2tb] fdisk(8) cannot handle above 1TB under i386 system.
Message-ID:  <201010261900.o9QJ0LXe010318@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/143389; it has been noted by GNATS.

From: Mark Johnston <mjohnston@sandvine.com>
To: "bug-followup@FreeBSD.org" <bug-followup@FreeBSD.org>,
	"aoyama@peach.ne.jp" <aoyama@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;



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