From 86e0bd0dc01df04903b9f79b919246e3ba2688e2 Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Thu, 9 Sep 2004 07:46:53 +0000 Subject: The disk labels generated by bsdlabel can no address more than 0xffffffff sectors. Document this limit and avoid installing bogus labels on disks with more sectors. Allowing the installation of labels addressing as much of the disk as possiable may be a useful addition in some situations, but this was easy to implement and should reduce confusion. PR: bin/71408 --- sbin/bsdlabel/bsdlabel.8 | 26 +++++++++++++++++++------- sbin/bsdlabel/bsdlabel.c | 3 +++ 2 files changed, 22 insertions(+), 7 deletions(-) (limited to 'sbin/bsdlabel') diff --git a/sbin/bsdlabel/bsdlabel.8 b/sbin/bsdlabel/bsdlabel.8 index f2d55ebdfc20..cbb4e345493b 100644 --- a/sbin/bsdlabel/bsdlabel.8 +++ b/sbin/bsdlabel/bsdlabel.8 @@ -273,7 +273,7 @@ Lowercase versions of and .Cm G are allowed. -Size and type should be specifed without any spaces between them. +Size and type should be specified without any spaces between them. .Pp Example: 2097152, 1G, 1024M and 1048576K are all the same size (assuming 512-byte sectors). @@ -408,8 +408,8 @@ Display what the label would be for .Pa da0s1 using the partition layout in .Pa label_layout . -This is useful for determining how much space would be alloted for various -partitions with a labelling scheme using +This is useful for determining how much space would be allotted for various +partitions with a labeling scheme using .Cm % Ns -based or .Cm * @@ -468,6 +468,20 @@ which could be used as a source file for f: 5g * 4.2BSD g: * * 4.2BSD .Ed +.Sh DIAGNOSTICS +The kernel device drivers will not allow the size of a disk partition +to be decreased or the offset of a partition to be changed while it is open. +.Sh COMPATIBILITY +Due to the use of an +.Vt u_int32_t +to store the number of sectors, +bsdlabels are restricted to a maximum of 2^32-1 sectors. +This usually means 2TB of disk space. +Larger disks should be partitioned using another method such as +.Xr gpt 8 . +.Pp +The various BSDs all use slightly different versions of BSD labels and +are not generally compatible. .Sh SEE ALSO .Xr ccd 4 , .Xr geom 4 , @@ -475,7 +489,5 @@ which could be used as a source file for .\" Xr bsdlabel 5 , .Xr disktab 5 , .Xr boot0cfg 8 , -.Xr fdisk 8 -.Sh DIAGNOSTICS -The kernel device drivers will not allow the size of a disk partition -to be decreased or the offset of a partition to be changed while it is open. +.Xr fdisk 8 , +.Xr gpt 8 diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c index cef20506fd22..8d44e6878df0 100644 --- a/sbin/bsdlabel/bsdlabel.c +++ b/sbin/bsdlabel/bsdlabel.c @@ -477,6 +477,9 @@ readlabel(int flag) (ioctl(f, DIOCGSECTORSIZE, &secsize) != 0)) { err(4, "cannot get disk geometry"); } + if (mediasize > (off_t)0xffffffff * secsize) + errx(1, + "disks with more than 2^32-1 sectors are not supported"); (void)lseek(f, (off_t)0, SEEK_SET); if (read(f, bootarea, BBSIZE) != BBSIZE) err(4, "%s read", specname); -- cgit v1.2.3