On Tue, Apr 22, 2014 at 09:51:47PM -0500, Shawn K. Quinn wrote:

> Either I'm missing something obvious, or something is amiss in disklabel
> as of the April 19 snapshot for amd64. I'm thinking it's the latter
> because, as you can see below, 'disklabel -E' has no issue with what
> 'disklabel -e' complains about:
> 
> Script started on Tue Apr 22 21:44:41 2014
> # disklabel sd0
> # /dev/rsd0c:
> type: SCSI
> disk: SCSI disk
> label: ST3750528AS
> duid: e6430fb1fad1094c
> flags:
> bytes/sector: 512
> sectors/track: 63
> tracks/cylinder: 255
> sectors/cylinder: 16065
> cylinders: 91201
> total sectors: 1953525168
> boundstart: 64
> boundend: 1953525168
> drivedata: 0
> 
> 16 partitions:
> #                size           offset  fstype [fsize bsize  cpg]
>   a:          2097152               64  4.2BSD   2048 16384    1 # /
>   b:         70243488          2097216    swap                   # none
>   c:       1953525168                0  unused
>   d:          8911776         72340704  4.2BSD   2048 16384    1
>   e:          8911776        124776832  4.2BSD   2048 16384    1 # /usr
>   f:        171964064        133688608  4.2BSD   2048 16384    1
>   g:          8385920        305652672  4.2BSD   2048 16384    1 #
>   /var/squid
>   h:         20964853        314038592  4.2BSD   2048 16384    1 #
>   /usr/local
>   i:        197091136        335003456  4.2BSD   2048 16384    1 #
>   /media/shawn-backups
>   k:        524291584        532094592  4.2BSD   4096 32768    1 #
>   /media/music
>   l:        120118048       1056386176  4.2BSD   2048 16384    1
>   m:         25181216       1176504224  4.2BSD   2048 16384    1 #
>   /var/www
>   n:          2097152       1201685440  4.2BSD   2048 16384    1
>   o:         83901568       1203782592  4.2BSD   2048 16384    1 # /var
>   p:        665840960       1287684160  4.2BSD   4096 32768    1 # /home
> # disklabel -E sd0
> Label editor (enter '?' for help at any prompt)
> > c
> partition to change size: [] p
> Partition p is currently 665840960 sectors in size, and can have a
> maximum
> size of 665841008 sectors.
> size: [665840960]
> > c
> partition to change size: [] c
> Partition must be between 'a' and 'p' (excluding 'c').
> > q
> No label changes.
> # disklabel -e sd0
> disklabel: partition c: partition extends past end of unit
> disklabel: partition p: partition extends past end of unit
> re-edit the label? [y]: n
> # ^D
> 
> Script done on Tue Apr 22 21:45:05 2014
> 
> (The editor session after 'disklabel -e' is simply ':q', so it's getting
> back the same disklabel that I got to edit with no changes.)
> 
> -- 
>   Shawn K. Quinn
>   [email protected]

What is happening:

The code to read back the ascii disklabel (after editing) now ignores
total sectors (disklabel rev 1.92). 

Next, checklabel finds a 0 size and assumes a size of 
sectors/cylinder * cylinders (disklabel.c:1294 in current)

In your case that's 16065*91201 = 1465144065, which is too small.

The diff below seems to correct this.

        -Otto


Index: disklabel.c
===================================================================
RCS file: /cvs/src/sbin/disklabel/disklabel.c,v
retrieving revision 1.193
diff -u -p -r1.193 disklabel.c
--- disklabel.c 18 Mar 2014 22:36:30 -0000      1.193
+++ disklabel.c 23 Apr 2014 08:36:01 -0000
@@ -839,10 +839,10 @@ edit(struct disklabel *lp, int f)
                starting_sector = DL_GETBSTART(&label);
                total_sectors = DL_GETDSIZE(&label);
                memset(&label, 0, sizeof(label));
-               error = getasciilabel(fp, &label);
                DL_SETBEND(&label, ending_sector);
                DL_SETBSTART(&label, starting_sector);
                DL_SETDSIZE(&label, total_sectors);
+               error = getasciilabel(fp, &label);
 
                if (error == 0) {
                        if (cmplabel(lp, &label) == 0) {

Reply via email to