Re: disklabel: phantom partition extends past end of unit message on amd64, possible bug?

2014-04-24 Thread Shawn K. Quinn
On Wed, Apr 23, 2014, at 06:50 AM, Otto Moerbeek wrote: 
 A slightly different fix has been commited,
 
   -Otto

At first glance, the bug appears to be squashed. (I'll report back if I
find out otherwise later.) Thanks!

-- 
  Shawn K. Quinn
  skqu...@rushpost.com



Re: disklabel: phantom partition extends past end of unit message on amd64, possible bug?

2014-04-23 Thread Otto Moerbeek
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 163841 # /
   b: 70243488  2097216swap   # none
   c:   19535251680  unused
   d:  8911776 72340704  4.2BSD   2048 163841
   e:  8911776124776832  4.2BSD   2048 163841 # /usr
   f:171964064133688608  4.2BSD   2048 163841
   g:  8385920305652672  4.2BSD   2048 163841 #
   /var/squid
   h: 20964853314038592  4.2BSD   2048 163841 #
   /usr/local
   i:197091136335003456  4.2BSD   2048 163841 #
   /media/shawn-backups
   k:524291584532094592  4.2BSD   4096 327681 #
   /media/music
   l:120118048   1056386176  4.2BSD   2048 163841
   m: 25181216   1176504224  4.2BSD   2048 163841 #
   /var/www
   n:  2097152   1201685440  4.2BSD   2048 163841
   o: 83901568   1203782592  4.2BSD   2048 163841 # /var
   p:665840960   1287684160  4.2BSD   4096 327681 # /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
   skqu...@rushpost.com

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 -  1.193
+++ disklabel.c 23 Apr 2014 08:36:01 -
@@ -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) {



Re: disklabel: phantom partition extends past end of unit message on amd64, possible bug?

2014-04-23 Thread Otto Moerbeek
On Wed, Apr 23, 2014 at 10:37:55AM +0200, Otto Moerbeek wrote:

 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 163841 # /
b: 70243488  2097216swap   # none
c:   19535251680  unused
d:  8911776 72340704  4.2BSD   2048 163841
e:  8911776124776832  4.2BSD   2048 163841 # /usr
f:171964064133688608  4.2BSD   2048 163841
g:  8385920305652672  4.2BSD   2048 163841 #
/var/squid
h: 20964853314038592  4.2BSD   2048 163841 #
/usr/local
i:197091136335003456  4.2BSD   2048 163841 #
/media/shawn-backups
k:524291584532094592  4.2BSD   4096 327681 #
/media/music
l:120118048   1056386176  4.2BSD   2048 163841
m: 25181216   1176504224  4.2BSD   2048 163841 #
/var/www
n:  2097152   1201685440  4.2BSD   2048 163841
o: 83901568   1203782592  4.2BSD   2048 163841 # /var
p:665840960   1287684160  4.2BSD   4096 327681 # /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
skqu...@rushpost.com
 
 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.

A slightly different fix has been commited,

-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 -  1.193
 +++ disklabel.c   23 Apr 2014 08:36:01 -
 @@ -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) {



disklabel: phantom partition extends past end of unit message on amd64, possible bug?

2014-04-22 Thread Shawn K. Quinn
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 163841 # /
  b: 70243488  2097216swap   # none
  c:   19535251680  unused
  d:  8911776 72340704  4.2BSD   2048 163841
  e:  8911776124776832  4.2BSD   2048 163841 # /usr
  f:171964064133688608  4.2BSD   2048 163841
  g:  8385920305652672  4.2BSD   2048 163841 #
  /var/squid
  h: 20964853314038592  4.2BSD   2048 163841 #
  /usr/local
  i:197091136335003456  4.2BSD   2048 163841 #
  /media/shawn-backups
  k:524291584532094592  4.2BSD   4096 327681 #
  /media/music
  l:120118048   1056386176  4.2BSD   2048 163841
  m: 25181216   1176504224  4.2BSD   2048 163841 #
  /var/www
  n:  2097152   1201685440  4.2BSD   2048 163841
  o: 83901568   1203782592  4.2BSD   2048 163841 # /var
  p:665840960   1287684160  4.2BSD   4096 327681 # /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
  skqu...@rushpost.com