History log of /freebsd-current/sbin/bsdlabel/bsdlabel.c
Revision Date Author Comments
# 3661658c 24-Jan-2024 Ed Maste <emaste@FreeBSD.org>

bsdlabel: emit deprecation notice when run

Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Reision: https://reviews.freebsd.org/D43586


# 3f4f82c0 22-Jan-2024 Ed Maste <emaste@FreeBSD.org>

bsdlabel: limit to 8 partitions

bsdlabel is intended to support up to 20 partitions, but the disklabel
struct has a d_partitions array with only BSD_NPARTS_MIN (8) entries.
Previously, an attempt to operate on a bsdlabel with more than eight
partitions resulted in a buffer overflow.

As a stopgap limit bsdlabel to 8 partitions until this is fixed
properly.

PR: 276517


# 0b8224d1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

Remove copyright strings ifdef'd out

We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by: Netflix


# 51e16cb8 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

sbin: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# de59f46a 07-Feb-2023 Dmitry Chagin <dchagin@FreeBSD.org>

bsdlabel: Fix whitespace.

MFC after: 1 week


# 901b050b 07-Feb-2023 Dmitry Chagin <dchagin@FreeBSD.org>

bsdlabel: Remove a write-only variable.

Since r149061 (2005) the total_size variable is write-only.

Differential Revision: https://reviews.freebsd.org/D38368
MFC after: 2 weeks


# ac8e5d02 13-Aug-2019 Conrad Meyer <cem@FreeBSD.org>

Remove deprecated GEOM classes

Follow-up on r322318 and r322319 and remove the deprecated modules.

Shift some now-unused kernel files into userspace utilities that incorporate
them. Remove references to removed GEOM classes in userspace utilities.

Reviewed by: imp (earlier version)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D21249


# df57947f 18-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

spdx: initial adoption of licensing ID tags.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.

Initially, only tag files that use BSD 4-Clause "Original" license.

RelNotes: yes
Differential Revision: https://reviews.freebsd.org/D13133


# 2b375b4e 27-Jan-2017 Yoshihiro Takahashi <nyan@FreeBSD.org>

Remove pc98 support completely.
I thank all developers and contributors for pc98.

Relnotes: yes


# fb6a3593 18-Apr-2016 Marcelo Araujo <araujo@FreeBSD.org>

Use NULL instead of 0 for pointers.

strchr(3) will return NULL if the character does not appear in the
string.

MFC after: 2 weeks.


# e7d939bd 06-Jul-2014 Marcel Moolenaar <marcel@FreeBSD.org>

Remove ia64.

This includes:
o All directories named *ia64*
o All files named *ia64*
o All ia64-specific code guarded by __ia64__
o All ia64-specific makefile logic
o Mention of ia64 in comments and documentation

This excludes:
o Everything under contrib/
o Everything under crypto/
o sys/xen/interface
o sys/sys/elf_common.h

Discussed at: BSDcan


# b9f41b60 11-Apr-2012 Andrey V. Elsukov <ae@FreeBSD.org>

It seems that libdisk(3) incorrectly sets d_secperunit value.
Automatically fix it like GEOM_PART_BSD does.

MFC after: 1 week


# 4b85a12f 07-Jan-2012 Ulrich Spörlein <uqs@FreeBSD.org>

Spelling fixes for sbin/


# b3608ae1 03-Jan-2012 Ed Schouten <ed@FreeBSD.org>

Replace index() and rindex() calls with strchr() and strrchr().

The index() and rindex() functions were marked LEGACY in the 2001
revision of POSIX and were subsequently removed from the 2008 revision.
The strchr() and strrchr() functions are part of the C standard.

This makes the source code a lot more consistent, as most of these C
files also call into other str*() routines. In fact, about a dozen
already perform strchr() calls.


# 3fd209e4 30-Dec-2011 Maxim Sobolev <sobomax@FreeBSD.org>

Use in-label sectorsize to determine position of the label when
writing label into a file image. The most common use - putting disklabel
into ISO file. Before this change the label would always go to
the offset 512, while geom_part code expects it to be in the 1st
sector (i.e. 2048 incase of ISO). BSD disklabels provide good and
lightweight way to logically split livecds. It is non-intrusive as
far as ISO9660 goes (both boot-wise and metadata-wise) and
completely transparent to anything but BSD, so you can have
BSD-specific area appended after regular ISO.

And with a little bit of GEOM trickery you can do even more
interesting stuff with it.

For example we make "hybrid" bootable CDs using this method.
We create bootable ISO with kernel and such and append UFS
image compressed with UZIP and it works like a charm. We put
label based on the offsef of the BSD part into the ISO. The kernel
boots off normal ISO9660 part, tastes label attaches it,
tastes UZIP, attaches it and finally mounts UFS using GEOM_LABEL.
This provides much better way of eliminating waste than doing
"crunched" build.

MFC after: 1 month


# 1d23e44c 11-Dec-2011 Ed Schouten <ed@FreeBSD.org>

Add missing static keyword.

All global variables and functions are marked static. Simply because
this is an enum, doesn't mean we can't do so as well.


# b06ce685 07-Nov-2011 Andrey V. Elsukov <ae@FreeBSD.org>

Fix multi-line comment formatting.

MFC after: 2 weeks


# fd4bbf84 06-Nov-2011 Andrey V. Elsukov <ae@FreeBSD.org>

Add recommendation to use gpart(8) when user tries write disklabel
or bootcode to already opened provider.

MFC after: 1 week


# b11075cd 06-Nov-2011 Andrey V. Elsukov <ae@FreeBSD.org>

Remove unneeded checks.

MFC after: 1 week


# 982e6e69 06-Nov-2011 Andrey V. Elsukov <ae@FreeBSD.org>

bsdlabel(8) could automatically fill many of disklabel's deprecated
fields, but user could specify some of those fields when edits disklabel
with `bsdlabel -e`. But without -A flag these fields might be
overwritten with default values from the virgin disklabel.
So, don't overwrite such fields if they are not zero. Also add checks
to prevent creating disklabel with less than DEFPARTITIONS and more
than MAXPARTITIONS partitions.

PR: bin/162332
Tested by: Eugene Grosbein
MFC after: 1 week


# 1fd45acd 06-Nov-2011 Andrey V. Elsukov <ae@FreeBSD.org>

To be in sync with GEOM_PART_BSD limit the maximum number of supported
partitions to 20.

MFC after: 1 week


# a5871155 10-Mar-2011 Ulrich Spörlein <uqs@FreeBSD.org>

Widen fields that display partition offset/length.

This makes partitions between 50GiB and 2TiB (16TiB for 4k drives) print
correctly aligned.

While here, fix type of secsize. g_sectorsize() returns ssize_t, don't
store this in an unsigned var. Bump WARNS to 6.

MFC after: 4 weeks


# 4c8dfc4a 10-Mar-2011 Ulrich Spörlein <uqs@FreeBSD.org>

Remove dead code in bsdlabel depending on __alpha__


# a2299ad8 01-Dec-2010 Kevin Lo <kevlo@FreeBSD.org>

Closing file descriptors when it's done


# 1161d420 22-Nov-2010 Rebecca Cran <brucec@FreeBSD.org>

Fix some more warnings found by clang.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# e45d37b2 27-Aug-2010 Jaakko Heinonen <jh@FreeBSD.org>

Don't attempt to write label with GEOM_BSD based method if the class is
not available. This improves error reporting when bsdlabel(8) is unable
to open a device for writing. If GEOM_BSD was unavailable, only a rather
obscure error message "Class not found" was printed.

PR: bin/58390
Reviewed by: ae
Discussed with: marcel
MFC after: 1 month


# fb26ece7 15-Aug-2010 Jaakko Heinonen <jh@FreeBSD.org>

- Check that strtoul(3) succeeds to convert the entire string in a few
places.
- In getasciilabel(), set the disk type only when a valid type is given.

PR: bin/86765
MFC after: 2 weeks


# 049a9793 30-Jun-2010 Jaakko Heinonen <jh@FreeBSD.org>

- Don't assign the return value from read(2) to a variable of type
int.
- Use errx(3) instead of err(3) to print the error message on short
reads in readlabel(). errno won't be set on short reads which can
easily occur here due to the fixed size read request.

PR: 144307
Reviewed by: bde


# 73d6722d 16-May-2010 Kevin Lo <kevlo@FreeBSD.org>

Use setresuid/setresgid to drop privileges


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 9fdef774 19-Aug-2009 Marcel Moolenaar <marcel@FreeBSD.org>

MFC change 196383:
Remove the dependency on the kernel -- in particular the gctl request to
the GEOM_BSD class -- to translate the absolute offsets in the label to
relative ones. This makes bslabel(8) work correctly with GEOM_PART and
also when the BSD label is nested under arbitrary partitioning schemes.

Inspired by: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
Approved by: re (kib)


# eb0ea23e 19-Aug-2009 Marcel Moolenaar <marcel@FreeBSD.org>

Remove the dependency on the kernel -- in particular the gctl request to
the GEOM_BSD class -- to translate the absolute offsets in the label to
relative ones. This makes bslabel(8) work correctly with GEOM_PART and
also when the BSD label is nested under arbitrary partitioning schemes.

Inspired by: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
Approved by: re (kib)


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 9d8ce078 30-Sep-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- A call to close(2) might overwrite errno and thus give a wrong error message
on g_providername failure.

Suggested by: pjd
Approved by: pjd (mentor)


# bd5add58 30-Sep-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Improve error message given on g_providername call failure.
- While there, make error messages consistent with the rest.

Approved by: kib (mentor)


# 7a4b0bb2 18-Sep-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Make bsdlabel use libgeom to determine provider name, device path, the media
size and the sector size.
- Fix a bug where bsdlabel would try to read a regular file using the geom_bsd
class.

Quick review by: phk
Approved by: pjd (mentor)


# 67361fdf 22-Mar-2008 Craig Rodrigues <rodrigc@FreeBSD.org>

Remove comment about "-r" flag from readlabel. "-r" is a no-op.
The is comment is left over from the old disklabel command.

Reviewed by: phk


# d5718812 09-Dec-2007 Marcel Moolenaar <marcel@FreeBSD.org>

Allow bsdlabel to operate on labels that have at most 26 partitions
by virtue of there not being any (lower-case) letters avaliable for
more partitions.


# f72bbf97 20-Oct-2006 Maxim Konovalov <maxim@FreeBSD.org>

o '-s' flag was killed in rev. 1.75. Clean getopt(3).

PR: bin/104616
Submitted by: Oliver Fromme
MFC after: 1 week


# 3b89beb1 14-Aug-2005 Ian Dowse <iedowse@FreeBSD.org>

Attempt to improve the logic for automatically sizing partitions
to take into account the new default of starting the first partition
after the boot blocks instead of at sector 0. If you used automatic
sizing when the first partition did not start at 0, you would get
an error that the automatically sized partition extended beyond the
end of the disk.

Note that there are probably still many more complex cases where
automatic sizing and placement will not work (e.g. non-contiguous
or out of order partitions).


# ccdd2fce 06-Jan-2005 Ralf S. Engelschall <rse@FreeBSD.org>

Fix the derivation of the GEOM name from the specified device name by
complementing the existing special case of a not existing /dev prefix
with the recognition of an already existing /dev prefix.

This implicitly solves the following two issues related to working on
GEOM devices /dev/foo/bar (which have the GEOM provider name "foo/bar")
with the expected commands like "bsdlabel /dev/foo/bar":

1. the error "Geom not found" when trying to write or edit the BSD
label (because previously the incorrect GEOM name "bar" instead of
"foo/bar" was derived from "/dev/foo/bar").

2. the multiple times reported "magically introduced" partition offset
of 63 blocks and the resulting errors like "partition extends past
end of unit" and "partition c doesn't start at 0!".

This implicitly resulted because bsdlabel(8) determines the "MBR
offset" via GEOM and (intentionally) silently falls back to an offset
of 0 if it could not be queried (which is the case if the name was
incorrectly derived).

Usually (at least on PCs) the offset for the first slice is 63 blocks
and bsdlabel(8) automatically subtracts them from the absolute
offsets in the read on-disk BSD label, resulting in the display of an
effective offset of 0. If the GEOM query fails, the assumed offset of
0 is subtracted and an incorrect effective offset of 63 is displayed
and tried to be worked upon.

Reviewed by: pjd
MFC after: 1 week


# 86e0bd0d 09-Sep-2004 Brooks Davis <brooks@FreeBSD.org>

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


# 81807292 09-Aug-2004 Dag-Erling Smørgrav <des@FreeBSD.org>

The multiplier prefix is actually a multiplier suffix.


# 4c814dfc 08-Aug-2004 Dag-Erling Smørgrav <des@FreeBSD.org>

Use fallthrough to simplify the multiplier logic; optimistically add
support for the T multiplier; improve the error message for unrecognized
multipliers.


# 266e7997 08-Aug-2004 Dag-Erling Smørgrav <des@FreeBSD.org>

Fix some whitespace issues, and move a curly brace out of an #ifdef to
avoid confusing auto-indenting editors.


# 7747c959 30-Mar-2004 Luigi Rizzo <luigi@FreeBSD.org>

Implement a '-f' flag to teach bsdlabel to work on files instead of
disk partitions.


# c8785325 15-Mar-2004 John Baldwin <jhb@FreeBSD.org>

When installing boot blocks into an Alpha BSD label, setup the location,
length, and flags fields at the end of the SRM boot sector so that SRM can
find the bootstrap code. This fixes bsdlabel -m alpha to generate bootable
disklabels.

Reviewed by: phk


# 427823d5 18-Oct-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Only automatically create an 'a' partition when there is nothing
but a 'c' partition.


# 640c9cb2 05-Oct-2003 Ian Dowse <iedowse@FreeBSD.org>

Remove the hardcoded default block/frag/cpg values from bsdlabel
and the logic for setting them according to the partition size.
Instead, unspecified filesystem values are left at 0 so that newfs
will use its own defaults. It just caused confusion to have the
defaults duplicated in two different places.

Reviewed by: phk


# d4408879 27-Aug-2003 Poul-Henning Kamp <phk@FreeBSD.org>

When we initialize a disk with a virgin label, create also an 'a'
partition which starts after the bootstrap area and fills the entire
disk.


# 9ef521ec 07-Jun-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Augh! Fix the sparc64 build:

If we don't have a default label location for the compiled architecture,
insist that a -m <architecture> option is specified.


# 246300f2 07-Jun-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Sanitize setting of labeloffset and labelsector.


# 8c401bb9 03-Jun-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Give ia64 the exact same semantics as i386 with respect to non-512
byte sector devices.


# c9192519 03-Jun-2003 Marcel Moolenaar <marcel@FreeBSD.org>

Unbreak ia64. 'nuff said.


# b2bb9f9b 02-Jun-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Fix sectorsize != 512 on i386 and pc98. Add test cases for same.


# 83d771de 01-Jun-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Simplify the GEOM OAM api: Drop the request type, and let everything
hinge on the "verb" parameter which the class gets to interpret as
it sees fit.

Move the entire request into the kernel and move changed parameters
back when done.


# 7c4d80f2 31-May-2003 David E. O'Brien <obrien@FreeBSD.org>

Protext copyright[].


# 3ecb3802 13-May-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Add pc98 archtecture entry.

Approved by: re/rwatson


# 8970f1a4 09-May-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Before reading an ascii label, initialize with defaults so that
getasciipartspec() has a sectorisize in case it needs one.

Approved by: re/jhb


# 54f445fb 09-May-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Sigh, this shows just how much one can be conditioned my the environment:

Just because we for the last ten years have fought for every byte
in the boot code on i386, doesn't mean that other architectures could
not actually have space to spare there.

Remore debugging message.


# 5d853216 04-May-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Add transparent handling of mbroffset for backwards compatibility.


# 57dfbec5 03-May-2003 Poul-Henning Kamp <phk@FreeBSD.org>

More axe-work:

Hide all the historical fields of the label, unless people ask for them with -A,
set them to intelligently chosen defaults otherwise.

Distill the manual page to remove inaccuracies, misundertandings and obsolete
information. It can probably still be done better but now at least it is
not misinforming people.


# d2fe97c7 03-May-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Some minor remodelling with a large axe.


# 5daa806d 03-May-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Use new geom.ctl based OAM instead of ioctls.
Various cleanup.


# 204ae378 02-May-2003 Poul-Henning Kamp <phk@FreeBSD.org>

bsd_disklabel_le_dec() takes an extra argument now.


# dfbc3f0c 02-May-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Vastly simplify architecture handling: Use properties of label as
recorded in global variables, rather than checks on the architecture.

Drop horribly code to handle MBR/PC98's embedded in the BSD label area.
If you need to have an MBR or PC98 on your disk, you should not overlap
it with a BSDLABEL, if you don't need it, this code is nothing but trouble.


# 7838fd0e 02-May-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Default the location to the compiled for architecture if no -m arg specified.


# c80f9755 02-May-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Add three global variables which contain the location, size and a flag
for the alpha checksum, and set them depending on the specified architecture

Don't look for disklabels every 16 bytes, look the only place they should
be for the current architecture.

Always read the label from the raw disk and decode it into struct
disklabel rather than trust a cast from random addresses.

When writing to the raw disk, encode the label properly.


# 607f853a 02-May-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Remove the well-intentioned, but ill thought out check which prevents us
from dd(1)'ing the boot code off one drive and have bsdlabel write it
on another.


# 2c60b668 18-Apr-2003 Poul-Henning Kamp <phk@FreeBSD.org>

First scrub of s/disklabel/bsdlabel/

bsdlabel.5 deliberately exempted, its contents looks less than useful.


# 29f3f095 01-Apr-2003 Yaroslav Tykhiy <ytykhiy@gmail.com>

Don't die of SIGSEGV on a missing fstype field
in a saved disklabel file.

MFC after: 1 week


# bc33ea1a 15-Mar-2003 Ruslan Ermilov <ru@FreeBSD.org>

Teach disklabel(8) about different hardware architectures.
This is aimed at creating floppies during cross-releases.
For different endianness machines, a tool like bswapfs(8)
is necessary to make the generated floppies readable on
the target machine. While here, fixed unaligned access
on Alphas.

Tested on: i386, alpha


# ef9ab0b3 22-Feb-2003 Ruslan Ermilov <ru@FreeBSD.org>

Deal with vestiges of d_boot[01].


# 74c041ac 26-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

If we fail to open O_RDWR, try opening O_RDONLY, if we use ioctls
to fiddle the disk we can get away with it.

Try to use DIOCBSDBB to write boot code.


# 23e8074b 26-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

IA64 still needs to be able to run on MBR+BSD combination, so put disklabel
back.

Pointed out by: peter


# 8d48318b 26-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Drop the silly notion that i386 has two bootstrap files now that sys/boot
creates a single file named just "boot".

Apart from the fact that the option "-s" is now gone and that "-b" should
be pointed at /boot/boot instead of /boot/boot1, this patch should be
a no-op.


# a9595c82 26-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Remove #if checks for NUMBOOT==0, it's not relevant for any architecture
and if we get such an architecture, we can just avoid using the relevant
options.


# 7e3e26cd 25-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Offer better advice in #error.

Remove yet a usage message about -N/-W


# 6250c8c5 25-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Remove ia64 and powerpc #ifdefs: this is i386/pc98/alpha only code.


# 3874baaf 26-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Remove #ifdef __sparc64__ code. GEOM uses native SUN labels on this arch,
so no hacks are needed.


# 80baf8ce 26-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Fix typo in last commit.
Rearrange bits in writelabel() a bit for improved readability.


# 5a5469f2 26-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Remember to remove -N and -W from usage.


# 89fd458f 26-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Don't fiddle write-protect status of disklabel, it's a discontinued feature.


# f080d33b 26-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Retire the "-N" and "-W" options which implemented write-protection
for the disklabel: This facility is OBE.

First of all, we cannot sensibly implement this in a properly stacked
environment.

Second, if we did, it would confuse the heck out of users who
wouldn't be able to "start from scratch" by dd(8)'ing /dev/zero
onto /dev/da0.

Third, the offered protection is not comprehensive: no other software
would respect it.

Fourth and finally, the disklabel is already protected against
tampering if it controls open partitions.

Uselessness of these options discussed with: peter


# b0459c58 15-Jan-2003 Dag-Erling Smørgrav <des@FreeBSD.org>

Clear part_set, part_size_type and part_offset_type before parsing the
ascii label; otherwise checklabel() might report spurious errors because
of leftovers from a previous pass.

Reviewed by: bde
MFC after: 1 week


# 404a379e 04-Jan-2003 Yoshihiro Takahashi <nyan@FreeBSD.org>

Rename the dos_partition structure for pc98 to pc98_partition.


# f2f63257 02-Dec-2002 Greg Lehey <grog@FreeBSD.org>

Relax partition overlap check to allow Vinum partitions to overlap
other partitiosns. This is necessary when migrating conventional
partitions to Vinum and was broken by recent more stringent overlap
checks. This is arguably the wrong way to do it. A better method
would be to have the loader understand a subset of Vinum partitioning
and allow an install directly to Vinum, but until then, this is the
best we have.

Reviewed by: jhb
Approved by: re (rwatson)


# 484c7804 17-Nov-2002 Julian Elischer <julian@FreeBSD.org>

Everything in the disklabel is unsigned so make all the input routines
take unsigned values.
his allows one to label disk with the number of blocks > 31 bits
(though less then 32 bits)

e.g.
# size offset fstype [fsize bsize bps/cpg]
c: 3125755904 0 unused 0 0 # (Cyl. 0 - 194569*)
d: 3125755840 64 unused 0 0 # (Cyl. 0*- 194569*)
which is needd to test UFS2


# 6d8c8fab 07-Oct-2002 Yoshihiro Takahashi <nyan@FreeBSD.org>

Fix to support pc98.


# 0cdbe329 05-Oct-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Don't be noisy if DIOCWLABEL fails, it's probably because we're writing
the first label to the raw disk.

Sponsored by: DARPA & NAI Labs.


# 3bb24c35 01-Oct-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Split MBR and PC98 on-disk sliceformats out from disklabel.h, step 1:

Peter had repocopied sys/disklabel.h to sys/diskpc98.h and sys/diskmbr.h.

These two new copies are still intact copies of disklabel.h and
therefore protected by #ifndef _SYS_DISKLABEL_H_ so #including them
in programs which already include <sys.disklabel.h> is currently a
no-op.

This commit adds a number of such #includes.

Once I have verified that I have fixed all the places which need fixing,
I will commit the updated versions of the three #include files.

Sponsored by: DARPA & NAI Labs.


# b9d05a16 20-Sep-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Construct new disklabels based on the medias stated parameters in
userland, rather than expect all possible GEOMetries to know about
BSD disklabels.

Sponsored by: DARPA & NAI Labs


# ce66ddb7 21-Aug-2002 Tom Rhodes <trhodes@FreeBSD.org>

s/filesystem/file system/g as discussed on -developers


# b35e6950 16-Aug-2002 Bosko Milekic <bmilekic@FreeBSD.org>

Fix more breakage due to FSTYPENAMES/DKTYPENAMES split.

Also submitted by: David Wolfskill <david@catwhisker.org>


# c8223965 03-Jul-2002 Mark Murray <markm@FreeBSD.org>

Apply __FBSDID(); fix local variable(names) that stomp on global
definitions; fix some const strings; fix some signedness issues.


# 09dbd070 05-Jun-2002 Ian Dowse <iedowse@FreeBSD.org>

Oops, unbreak parsing of the `type' field in getasciilabel(). I had
changed a `goto' to a `continue' in revision 1.52, but it continued
the wrong loop.

Noticed by: bde


# 448f7629 30-May-2002 Alfred Perlstein <alfred@FreeBSD.org>

correct comment (replace i386 with __i386__)


# f1a7b7ee 29-May-2002 Ian Dowse <iedowse@FreeBSD.org>

Fix some serious brain damage in the default block/frag/cpg parameters
that are used if none at all are specified for a partition. Don't
keep replaying the last field if we run out of fields when processing
a line. Use a 8:1 frag:block ratio for both defaults.

More work here is required. I think disklabel should not attempt
to choose default filesystem parameters, and instead let newfs pick
any defaults if required.

PR: i386/38703
Reported by: Martin Kraemer <Martin.Kraemer@Fujitsu-Siemens.com>


# 67b46708 29-May-2002 Ian Dowse <iedowse@FreeBSD.org>

Split out the code for parsing the partition specification lines
into a separate function to avoid some over-long lines.


# 87efda01 20-May-2002 Benno Rice <benno@FreeBSD.org>

Spread the word of PowerPC.


# 77068a7f 12-May-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Retire the bogus uses of the disklabel field d_sbsize and begin to
initialize it to zero so we don't have to have everbody and their
aunt including FFS specific header files.

Sponsored by: DARPA & NAI Labs.


# 6b0ff5f5 07-Apr-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Get us to WARNS=2 with a bit of constification and some printf fiddling.

Pick up the c-partitions magicness from sys/disklabel.h instead
of defining our own magicness for it, remove trivial comment.

Sponsored by: DARPA and NAI Labs.


# 24ba60e3 07-Apr-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Nuke a totally pointless optional debug option

Sponsored by: DARPA and NAI Labs.


# 4805ff9a 04-Apr-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Remove remaining traces of d_boot[01]


# 95f6bf5d 03-Apr-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Kill only usage of the undocumnted and unuse d_boot[01] fields of
struct disklabel.

Sponsored by: DARPA & NAI Labs.


# c1fdb43f 19-Mar-2002 Warner Losh <imp@FreeBSD.org>

Remove stray register


# 326c7cda 17-Mar-2002 Warner Losh <imp@FreeBSD.org>

o remove __P
o Use ANSI function definitions
o const poison
o remove register


# fd43aa1c 10-Mar-2002 David E. O'Brien <obrien@FreeBSD.org>

Add complete Sparc64 support.
Submitted by: tmm

Dike out vax support.


# 90b8f6ba 10-Mar-2002 David E. O'Brien <obrien@FreeBSD.org>

* Support the Sparc64.
* Do not default to any particular platform. Require that we explicitly
support a particular platform.


# 5b445518 03-Mar-2002 Poul-Henning Kamp <phk@FreeBSD.org>

A bit of premptive GEOM POLA magic: If we don't get a virgin disklabel
from /dev/food0, then try from /dev/f00d0c, in strange cases this work.


# 5979df34 19-Aug-2001 Kris Kennaway <kris@FreeBSD.org>

Silence non-constant format string warnings by marking functions
as __printflike()/__printf0like(), adding const, or adding missing "%s"
format strings, as appropriate.

MFC after: 2 weeks


# 7bc6d015 09-Jul-2001 Brian Somers <brian@FreeBSD.org>

Fix the type of the NULL arg to execl()

Idea from: Theo de Raadt <deraadt@openbsd.org>


# 384d80b3 24-Jun-2001 Dima Dorfman <dd@FreeBSD.org>

Nuke unused variables.


# 0b3f0926 24-Apr-2001 Warner Losh <imp@FreeBSD.org>

Say "add -r" rather than 'use -r' since the former is more correct.
The latter implies to many people that they use only -r, which is
incorrect.


# 8d3105e8 04-Mar-2001 Warner Losh <imp@FreeBSD.org>

First attempt to not overflow in disk space calculations. Use off_t
for the size variable used to calculate the size of the partition.
Also use ULL suffix for constants to ensure that we use 64 bit math.


# 3233afae 25-Feb-2001 John W. De Boskey <jwd@FreeBSD.org>

Allow for easier configuration when using disklabel. A sample
being:

# size offset fstype [fsize bsize bps/cpg]
a: 400M 0 4.2BSD 4096 16384 75 # (Cyl. 0 - 812*)
b: 1G * swap
c: * * unused
e: 204800 * 4.2BSD
f: 5g * 4.2BSD
g: * * 4.2BSD

These patches are the original work of Randell Jesup, and
I believe Matt Dillon, with additional work by Warner Losh.
Please let me know if I've left someone out.

Incorporated into this is the fix for PR bin/22727.

This patchset still has style issues and a possible problem on
large disks. However, it was a agreed to get these committed before
performing major surgery on them.

PR: bin/22727
Submitted by: Randell Jesup <rjesup@wgate.com>


# ff7d5162 31-Oct-2000 Jordan K. Hubbard <jkh@FreeBSD.org>

Add support for virgin disklabels

Submitted by: dillon


# fc87418b 16-Sep-2000 Poul-Henning Kamp <phk@FreeBSD.org>

Turn dkcksum() into an __inline function.

Change its type to u_int_16_t.


# 42d6bd48 20-Apr-2000 David E. O'Brien <obrien@FreeBSD.org>

A local WIP snook in rev 1.31.

Noticed by: bde


# 43c6c959 20-Apr-2000 David E. O'Brien <obrien@FreeBSD.org>

Found more places where 'r' was being prepended to the device name.


# 37736675 14-Apr-2000 Warner Losh <imp@FreeBSD.org>

Add include of errno.h where needed, remove extern int errno where not.

These commits were inspired by a similar commit to netbsd.


# 09c4216d 09-Apr-2000 David E. O'Brien <obrien@FreeBSD.org>

Don't prepend "r" for the raw device anymore.


# aaae3130 10-Jan-2000 Kris Kennaway <kris@FreeBSD.org>

10 X's for mkstemp(), and don't redefine _PATH_TMP


# daf41e69 24-Sep-1999 Bill Fumerola <billf@FreeBSD.org>

Remove duplicate declarations for two internal functions.
Remove delcaration for getenv(), we already get it from stdlib.h


# 7f3dea24 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 3b3038a6 20-Jul-1999 Bill Fumerola <billf@FreeBSD.org>

Fix a gcc stupidity where it thought a variable was being used uninitialized

Add a case for UNSPEC which is in order by the enum definition, but out of
order alphabetically.


# efba76d7 17-Dec-1998 Jordan K. Hubbard <jkh@FreeBSD.org>

Look for boot blocks in new default location.


# cf6ceaf1 23-Oct-1998 Bruce Evans <bde@FreeBSD.org>

Oops, don't quite use RAW_PART instead of RAWPARTITION. Use 'a' + RAW_PART
in both places.


# 7de06420 17-Oct-1998 Bruce Evans <bde@FreeBSD.org>

Updated the error message for EXDEV to match recent kernel fixes.
Fixed nearby indentation.

Use RAW_PART instead of RAWPARTITION.


# 21c729c2 23-Aug-1998 Bruce Evans <bde@FreeBSD.org>

Attempt to fix my breakage of the alpha makebootarea() in rev.1.19.
The previous attempt just converted compile time breakage to runtime
breakage.


# 31ae054e 21-Aug-1998 Gary Palmer <gpalmer@FreeBSD.org>

Try to make this compile on both alpha and i386


# cc18e4cc 17-Aug-1998 Bruce Evans <bde@FreeBSD.org>

Fixed style bugs in previous commit.

Added some comments on #endifs.


# 130cd73a 17-Aug-1998 Doug Rabson <dfr@FreeBSD.org>

Teach disklabel how to install a bootstrap on an alpha with SRM console.


# 6cabb348 25-Jul-1998 Bruce Evans <bde@FreeBSD.org>

Fixed bugs in `disklabel -R...':
- nonstandard sector sizes didn't work because the sector size in the
ASCII label was not read before a (default, wrong) sector size was used.
- the exit status was 0 after exiting early due to an invalid ASCII label.

Abort `disklabel -B...' if the secondary bootstrap doesn't fit.


# e18fb238 20-Jul-1998 Bruce Evans <bde@FreeBSD.org>

Clear d_boot0 and d_boot1 in the virgin label. These are overlaid by
d_packname in in-core labels, so they are garbage if d_packname is
initialized in the dummy label for the whole disk. dsopen() will soon
initialize d_packname to "fictitious" if it is not already initialized.

Fixed nearby error handling. Rev.1.7 apparently confused Perror()
with perror().


# 2a1deaaa 28-Jun-1998 Bruce Evans <bde@FreeBSD.org>

Fixed printf format errors.


# 3121d4cb 08-Jun-1998 Philippe Charnier <charnier@FreeBSD.org>

Use warnx()+fprintf() to handle multi-line messages. Correct K&R support and
KNF continuation indent rule.
Requested by: Bruce.


# 6bd343a9 04-Jun-1998 Philippe Charnier <charnier@FreeBSD.org>

Add section number to .Xr. Use of .Nm. Typo. Add rcsid. Remove unused
#includes. Use err(3).


# bef2080a 10-Jun-1997 Philippe Charnier <charnier@FreeBSD.org>

Add Id. Use err(3). Costmetic in usage string.


# 8d64695c 28-Mar-1997 Warner Losh <imp@FreeBSD.org>

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 722ceb3f 23-Mar-1997 Warner Losh <imp@FreeBSD.org>

Use mkstemp rather than mktemp to prevent a small race.

Obtained from: OpenBSD


# 43be698c 17-Jun-1996 Bruce Evans <bde@FreeBSD.org>

Moved initialization of defaults for the label for the whole disk from
disklabel(8) to the kernel (dsopen()). Drivers should initialize the
hardware values (rpm, interleave, skews). Drivers currently don't do
this, but it usually doesn't matter since rotational position stuff is
normally disabled.


# d70e4e53 03-Feb-1996 Joerg Wunsch <joerg@FreeBSD.org>

Try to preserve the fdisk table in the primary bootstrap, should it
already exist.

Mention the cases where this doesn't work in the BUGS section of the
man page.


# 425bed3a 21-Jan-1996 Joerg Wunsch <joerg@FreeBSD.org>

Finally implement the "auto" disktype. It attempts to get all the
required information from the driver, and produce a virgin disklabel
for it. The latter might be further edited with `disklabel -e' to
satisfy the user's need.

The magic sequence is:

disklabel -r -w sdX auto
disklabel -e sdX


# 61de51ca 21-Jan-1996 Joerg Wunsch <joerg@FreeBSD.org>

Declare functions, resolve printf-format warnings.


# 5ebc7e62 30-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# f75dd518 22-Feb-1995 Bruce Evans <bde@FreeBSD.org>

Don't clobber d_secperunit in `disklabel -e'. `disklabel -e' replaces all
the values that it doesn't print by defaults. This seems wrong. I want
to be able to see the total number of sectors more than edit it. The
default d_secperunit of (sectors/track * tracks/cylinder * cylinders) is
bogus if sectors/track is only an approximation and more bogus if
sectors/track and tracks/cylinder are dummy values such as 4096 and 1
to defeat ufs's pessimizations.


# ca4693ed 04-Jan-1995 Justin T. Gibbs <gibbs@FreeBSD.org>

Allow for the specification of bsize, fsize, and bps (blocks per segment)
for LFS filesystems.


# 13e0abcb 25-Sep-1994 Paul Traina <pst@FreeBSD.org>

disklabel will dump core if you give it too few numbers to process
Obtained from: NetBSD misc/490 - John Kohl


# 8fae3551 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite sbin Sources

Note: XNSrouted and routed NOT imported here, they shall be imported with
usr.sbin.