History log of /freebsd-10.3-release/sys/geom/part/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
296373 04-Mar-2016 marius

- Copy stable/10@296371 to releng/10.3 in preparation for 10.3-RC1
builds.
- Update newvers.sh to reflect RC1.
- Update __FreeBSD_version to reflect 10.3.
- Update default pkg(8) configuration to use the quarterly branch.

Approved by: re (implicit)

293634 10-Jan-2016 ae

MFC r292057:
Make detection of GPT a bit more reliable.

When we are detecting a partition table and didn't find PMBR, try to
read backup GPT header from the last sector and if it is correct,
assume that we have GPT.

Differential Revision: https://reviews.freebsd.org/D4282

MFC r292058:
Remove a note about damaged PMBR. Now GPT will be detected automatically
with such corruption.

Relnotes: yes


286207 02-Aug-2015 ae

MFC r285889:
Report the scheme and provider names in warning message about unaligned
partition.

PR: 201873


285756 21-Jul-2015 allanjude

MFC: r285594
New partition flag for gpart, writes the 0xee partition in the pmbr in the second slot, rather than the first.
Works around Lenovo legacy GPT boot issue

PR: 184910
Approved by: re (gjb), marcel
Relnotes: yes
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D3140


284565 18-Jun-2015 ae

MFC r284151:
Teach G_PART_GPT class handle g_resize_provider event.


282861 13-May-2015 ae

MFC r282465:
Add apple-boot, apple-hfs and apple-ufs aliases to MBR scheme.
Sort DOSPTYP_* entries in diskmbr.h by value.
Document these scheme-specific types in gpart(8).


281303 09-Apr-2015 mav

MFC r280687: Make GEOM_PART work in presence of previous withered self.


280261 19-Mar-2015 ae

MFC r269854:
Remove duplicate entry.

MFC r279935:
Add GUID and alias for Apple Core Storage partition.

PR: 196241


271636 15-Sep-2014 emaste

MFC EFI support for the installer

r264978 (nwhitehorn):

Add EFI support to the installer. This requires that the kernel
provide a sysctl to determine what firmware is in use. This sysctl
does not exist yet, so the following blocks are in front of the
wheels:
- I've provisionally called this "hw.platform" after the equivalent
thing on PPC
- The logic to check the sysctl is short-circuited to always choose
BIOS. There's a comment in the top of the file about how to turn
this off.

If IA64 acquired a boot1.efifat-like thing (probably with very few
modifications), the same code could be adapted there.

r265016 (nwhitehorn):

Finish connecting up installer UEFI support. If the kernel was
booted using EFI, set up the disks for an EFI system. If booted from
BIOS/CSM, set up for BIOS.

r268256 (nwhitehorn):

After EFI support was added to the installer, it needed to allow
boot partitions of types other than "freebsd-boot" (in particular,
"efi"). This allows the removal of some nasty hacks for supporting
PowerPC systems, in particular aliasing freebsd-boot to apple-boot
on APM and an IBM-specific code on MBR.

This changes the installer to use the correct names, which also
breaks a degeneracy in the meaning of "freebsd-boot" that allows the
addition of support for some newer IBM systems that can boot from
GPT in addition to MBR. Since I have no idea how to detect which
those systems are, leave the default on IBM PPC systems as MBR for
now.

Approved by: re
PR: 193658
Relnotes: Yes


270552 25-Aug-2014 ae

MFC r268407 (by gjb):
Fix non-version text after .Fx macro usage.

MFC r269487 (by issyl0):
Add generic list, status, load and unload docs to gpart(8)

- In the style of gmirror(8).
PR: docs/191534

MFC r269852:
Add sysctl and loader tunable kern.geom.part.mbr.enforce_chs that is set
by default. It can be used to disable automatic alignment to CHS geometry,
that GEOM_PART_MBR does.


268091 01-Jul-2014 ae

MFC r267355:
Add UUIDs for DragonFlyBSD's partition types.

MFC r267356:
Add DragonFlyBSD's Hammer FS types and type names.

MFC r267357:
Add aliases for DragonFlyBSD's partition types.

MFC r267358:
Allow dumping to DragonFlyBSD's swap partition.

MFC r267359:
Add disklabel64 support to GEOM_PART class.

This partitioning scheme is used in DragonFlyBSD. It is similar to
BSD disklabel, but has the following improvements:
* metadata has own dedicated place and isn't accessible through partitions;
* all offsets are 64-bit;
* supports 16 partitions by default (has reserved place for more);
* has reserved place for backup label (but not yet implemented);
* has UUIDs for partitions and partition types;

MFC r267360:
Add disklabel64 support

Relnotes: yes


267156 06-Jun-2014 ae

MFC r266880:
Use g_conf_printf_escaped() to escape symbols, which can break
an XML tree.


265912 12-May-2014 ae

MFC r256690:
Add an automatic resize support to the GEOM_PART class.

When parent provider has been resized, the scheme specific G_PART_RESIZE
method does an update of scheme's metadata. But all changes are not saved
to disk, until `gpart commit` will be called.

MFC r265336:
Add an advice what to do when partition was automatically resized.


265910 12-May-2014 ae

MFC r265318:
For schemes that do an automatic partition aligning move this code to
separate function.

MFC r265331:
Prevent an unexpected shrinking on resizing due to alignment for MBR,
PC98 and VTOC8 schemes.

MFC r265333:
Add better error description for case when we are doing resize and
scheme-specific method returns EBUSY.

MFC r265539:
It is safe to allow shrinking, when aligned size is bigger than current.


261993 16-Feb-2014 marcel

MFC r258448:
Have the GPT probe return a lower priority when the MBR is not a PMBR.


260980 21-Jan-2014 marck

MFC r259925-259926:

Add GPT UUID for VMware vSAN meta-data partition.

Approved by: ae


260385 07-Jan-2014 scottl

MFC Alexander Motin's GEOM direct dispatch work:

r256603:
Introduce new function devstat_end_transaction_bio_bt(), adding new argument
to specify present time. Use this function to move binuptime() out of lock,
substantially reducing lock congestion when slow timecounter is used.

r256606:
Move g_io_deliver() out of the lock, as required for direct dispatch.
Move g_destroy_bio() out too to reduce lock scope even more.

r256607:
Fix passing uninitialized bio_resid argument to g_trace().

r256610:
Add unmapped I/O support to GEOM RAID.

r256830:
Restore BIO_UNMAPPED and BIO_TRANSIENT_MAPPING in biodonne() when unmapping
temporary mapped buffer. That fixes double unmap if biodone() called twice
for the same BIO (but with different done methods).

r256880:
Merge GEOM direct dispatch changes from the projects/camlock branch.

When safety requirements are met, it allows to avoid passing I/O requests
to GEOM g_up/g_down thread, executing them directly in the caller context.
That allows to avoid CPU bottlenecks in g_up/g_down threads, plus avoid
several context switches per I/O.

r259247:
Fix bug introduced at r256607. We have to recalculate bp_resid here since
sizes of original and completed requests may differ due to end of media.

Testing of the stable/10 merge was done by Netflix, but all of the credit
goes to Alexander and iX Systems.

Submitted by: mav
Sponsored by: iX Systems


256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


255237 05-Sep-2013 ae

Remove stub implementation.

MFC after: 1 week


254095 08-Aug-2013 ae

gpt_entries is used as limit for the number of partition entries in
the GEOM_PART. Instead of just using number of entries from the GPT
header, calculate this limit based on the reserved space between
GPT header and first available LBA.

MFC after: 2 weeks


254015 07-Aug-2013 marcel

Change <sys/diskpc98.h> to not redefine the same symbols that are
being defined in <sys/diskmbr.h>. Instead give the symbols here a
"PC98_" prefix. This way, both <sys/diskmbr.h> and <sys/diskpc98.h>
can be included in the same C source file.

The renaming is trivial. The only gotcha is that DOSBBSECTOR is
also redefined from 0 to 1. This because DOSBBSECTOR was always
used in conjunction with an addition of 1. The PC98_BBSECTOR symbol
is defined as 1 and the expression is simplified.

Note: it is not believed that ports are seriously impacted; or at
all for that matter.

Approved by: nyan@


253938 04-Aug-2013 marcel

Remove inclusion of <sys/diskmbr.h>. We have no business knowing
anything related to MBR in this file.


251588 09-Jun-2013 marcel

Change the set and unset ctlreqs by making the index argument optional.
This allows setting attributes on tables. One simply does not provide
an index in that case. Otherwise the entry corresponding the index has
the attribute set or unset.

Use this change to fix a relatively longstanding bug in our GPT scheme
that's the result of rev 198097 (relatively harmless) followed by rev
237057 (damaging). The damaging part being that our GPT scheme always
has the active flag set on the PMBR slice. This is in violation with
EFI. Existing EFI implementions for both x86 and ia64 reject the GPT.
As such, GPT disks created by us aren't usable under EFI because of
that.

After this change, GPT disks never have the active flag set on the PMBR
slice. In order to make the GPT disk bootable under some x86 BIOSes,
the reason of rev 198097, one must now set the active attribute on the
gpt table. The kernel will apply this to the PMBR slice For (S)ATA:
gpart set -a active ada0

To fix an existing GPT disk that has the active flag set in the PMBR,
and that does not need the flag, use (again for (S)ATA):
gpart unset -a active ada0

The EBR, MBR & PC98 schemes, which also impement at least 1 attribute,
now check to make sure the entry passed is valid. They do not have
attributes that apply to the table.


251587 09-Jun-2013 marcel

Remove stub implementation.


248517 19-Mar-2013 kib

The geom_part provider supports unmapped bio iff the underlying
provider does so, since geom_part never inspects the bio_data.

Sponsored by: The FreeBSD Foundation
Tested by: pho


247961 07-Mar-2013 gavin

Support the FAT16 partition type in gpart(8)

PR: kern/174714
Submitted by: 4721 at hushmail dot com
MFC after: 1 week


241296 06-Oct-2012 avg

g_part_taste: directly destroy consumer and geom here, no need for withering

Besides withered but still alive consumers may interfere with
re-tatsing.

MFC after: 16 days


239790 28-Aug-2012 ed

Remove unneeded G_PF_CANDELETE flag.

This flag is only used by GEOM so it can be propagated to the character
device's SI_CANDELETE. Unfortunately, SI_CANDELETE seems to do nothing.


238886 29-Jul-2012 mav

Implement media change notification for DA and CD removable media devices.
It includes three parts:
1) Modifications to CAM to detect media media changes and report them to
disk(9) layer. For modern SATA (and potentially UAS) devices it utilizes
Asynchronous Notification mechanism to receive events from hardware.
Active polling with TEST UNIT READY commands with 3 seconds period is used
for incapable hardware. After that both CD and DA drivers work the same way,
detecting two conditions: "NOT READY: Medium not present" after medium was
detected previously, and "UNIT ATTENTION: Not ready to ready change, medium
may have changed". First one reported to disk(9) as media removal, second
as media insert/change. To reliably receive second event new
AC_UNIT_ATTENTION async added to make UAs broadcasted to all periphs by
generic error handling code in cam_periph_error().
2) Modifications to GEOM core to handle media remove and change events.
Media removal handled by spoiling all consumers attached to the provider.
Media change event also schedules provider retaste after spoiling to probe
new media. New flag G_CF_ORPHAN was added to consumers to reflect that
consumer is in process of destruction. It allows retaste to create new
geom instance of the same class, while previous one is still dying.
3) Modifications to some GEOM classes: DEV -- to report media change
events to devd; VFS -- to handle spoiling same as orphan to prevent
accessing replaced media. PART class already handles spoiling alike to
orphan.

Reviewed by: silence on geom@ and scsi@
Tested by: avg
Sponsored by: iXsystems, Inc. / PC-BSD
MFC after: 2 months


238657 20-Jul-2012 trasz

Make it possible to resize opened partitions.

Sponsored by: FreeBSD Foundation


237057 14-Jun-2012 ae

Always reconstruct partition entries in the PMBR when Boot Camp is
disabled. This helps to easily recover from situations when PMBR is
damaged and contains no entries.

MFC after: 1 week


236023 25-May-2012 marcel

Add a partition type for nandfs to the apm, bsd, gpt and vtoc8 schemes.
The gpart alias for these partition types is "freebsd-nandfs".


234417 18-Apr-2012 marck

VMware environments are not unusual now. Add VMware partitions recognition
(both MBR for ESXi <= 4.1 and GPT for ESXi 5) to g_part.

Reviewed by: ae
Approved by: ae
MFC after: 2 weeks


233652 29-Mar-2012 ae

VMDB offset should be greater than logical volume size only for MBR.


233651 29-Mar-2012 ae

Do proper cleanup for the GPT case when an error occurs.


233342 23-Mar-2012 ae

Check that scheme is not already registered. This may happens when a
KLD is preloaded with loader(8) and leads to infinity loops.

Also do not return EEXIST error code from MOD_LOAD handler, because
we have undocumented(?) ability replace kernel's module with preloaded one.
And if we have so, then preloaded module will be initialized first.
Thus error in MOD_LOAD handler will be triggered for the kernel.

PR: kern/165573
MFC after: 3 weeks


233181 19-Mar-2012 ae

Add CTLFLAG_TUN to sysctls.

MFC after: 1 month


233176 19-Mar-2012 ae

Add new GEOM_PART_LDM module that implements the Logical Disk Manager
scheme. The LDM is a logical volume manager for MS Windows NT and it
is also known as dynamic volumes. It supports about 2000 partitions
and also provides the capability for software RAID implementations.

This version implements only partitioning scheme capability and based
on the linux-ntfs project documentation and several publications across
the Web. NOTE: JBOD, RAID0 and RAID5 volumes aren't supported.

An access to the LDM metadata is read-only. When LDM is on the disk
partitioned with MBR we can also destroy metadata. For the GPT
partitioned disks destroy action is not supported.

Reviewed by: ivoras (previous version)
MFC after: 1 month


233175 19-Mar-2012 ae

Make kern.geom.part node not static. Also add CTLFLAG_TUN to the
check_integrity sysctl.

MFC after: 1 month


233000 15-Mar-2012 ae

Add MODULE_DEPEND() to geom_part modules.

MFC after: 2 weeks


232680 08-Mar-2012 emaste

Remove unactionable message about label geometry

It's not clear to a user what they should do after seeing the "geometry
does not match label" kernel message, and it does not appear to present
a problem in practice. Thus, just remove the messages.

Approved by: marcel


231929 20-Feb-2012 ae

If nested scheme allows dump kernel to its partition, we may allow
dump for the parent partition too.

MFC after: 2 weeks


231928 20-Feb-2012 ae

Add alias for the partition type 0x0f. Now "ebr" name is used for both
types 0x05 and 0x0f, but 0x05 is preferred and used when partition is
created with "gpart add -t ebr ...".
This should keep EBR partitions accessible after r231754 for those,
who have EBR on the partition with type 0x0f.


231754 15-Feb-2012 ae

Add additional check to EBR probe and create methods:
don't try probe and create EBR scheme when parent partition type
is not "ebr". This fixes error messages about corrupted EBR for
some partitions where is actually another partition scheme.

NOTE: if you have EBR on the partition with different than "ebr"
(0x05) type, then you will lost access to partitions until it will be
changed.

MFC after: 2 weeks


231751 15-Feb-2012 ae

Add PART::type attribute handler. It returns partition type as string.

MFC after: 2 weeks


231367 10-Feb-2012 ae

Add alias for the partition with type 0x42 to the MBR scheme.

MFC after: 1 week


231349 10-Feb-2012 ae

Let's be more realistic and limit maximum number of partition to 4k.

MFC after: 1 week


230990 04-Feb-2012 emaste

Correct typo in comment (numbver)


230861 01-Feb-2012 ae

The scheme code may not know about some inconsistency in the metadata.
So, add an integrity check after recovery attempt.

MFC after: 1 week


230522 25-Jan-2012 nwhitehorn

Experimental support for booting CHRP-type PowerPC systems from hard disks.


230064 13-Jan-2012 truckman

Allow an MBR primary or extended Linux swap partition to be specified
as the system dump device. This was already allowed for GPT. The Linux
swap metadata at the beginning of the partition should not be disturbed
because the crash dump is written at the end.

Reviewed by: alfred, pjd, marcel
MFC after: 2 weeks


228076 28-Nov-2011 ae

Add an ability to increase number of allocated APM entries when we
have reserved free space in the APM area.
Also instead of one write request per each APM entry, use MAXPHY
sized writes when we are updating APM.

MFC after: 1 month


228061 28-Nov-2011 ae

The size of APM could be bigger than number of already allocated entries.
And the first usable sector should not start from the inside of APM area.

MFC after: 1 month


227309 07-Nov-2011 ed

Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.

The SYSCTL_NODE macro defines a list that stores all child-elements of
that node. If there's no SYSCTL_DECL macro anywhere else, there's no
reason why it shouldn't be static.


226880 28-Oct-2011 ae

Our geom withering function could take some time before geom with its
providers and consumers will be destroyed. Before take some actions
with a geom, check that it is not destroyed at the moment.

Tested by: nwhitehorn
MFC after: 1 week


226647 23-Oct-2011 marcel

Add support for Boot Camp. The support is defined as follows:
o Detect when Boot Camp is enabled (i.e. the MBR mirrors the GPT).
o When Boot Camp is enabled, update the MBR whenever we write the GPT.
o Creation of a Boot Camp enabled GPT is not supported.
o Automatically disable Boot Camp when the GPT has been changed so that
there's either no EFI partition or no HFS+ partition.
o The first 4 partitions (by index) get mirrored in the MBR.

Requested by, discussed with and tested by: kris@pcbsd.org
MFC after: 1 week


226522 18-Oct-2011 marius

Allow to dump on Solaris swap partitions.

PR: 161764
Submitted by: Peter Jeremy


223660 29-Jun-2011 ae

Initialize elements of state array when creating the GPT table.
This fixes the problem, when the secondary GPT header is not erased when
partition table destroyed. Move equal operations from g_part_gpt_create
and g_part_gpt_recover to the separate function g_gpt_set_defaults.

Reported by: dwhite
MFC after: 1 week


223594 27-Jun-2011 ae

EBR could contain an early stage of boot code. But we do not support it.
Remove message about non empty bootcode, we can not break something
while GEOM_PART_EBR_COMPAT is defined.

But without GEOM_PART_EBR_COMPAT any changes in EBR are allowed and we
can accidentally wipe the boot code. To do not break anything save
the first EBR chunk and keep it untouched each time when we are
changing EBR. Note that we are still not support boot code for EBR.

PR: kern/141235
MFC after: 1 month


223587 27-Jun-2011 ae

MS Windows NT+ uses 4 bytes at offset 0x1b8 in the MBR to identify
disk drive. The boot0cfg(8) utility preserves these 4 bytes when is
writing bootcode to keep a multiboot ability.
Change gpart's bootcode method to keep DSN if it is not zero. Also
do not allow writing bootcode with size not equal to MBRSIZE.

PR: kern/157819
Tested by: Eir Nym
MFC after: 1 month


223332 20-Jun-2011 ae

Change the way how we update bootcode for BSD scheme.
Since the only parameter that we check is size of bootcode, then
allow only two sizes: size of boot1 and size of /boot/boot.
This partially protects users from losing ability to boot if incorrect
bootcode is specified.

Requested by: ru


222642 03-Jun-2011 ae

Add diagnostic message about not aligned partitions.

Idea from: ivoras


222341 27-May-2011 ae

Some partitioning tools may have a different opinion about disk
geometry and partitions may start from withing the first track.
If we found such partitions, then do not reserve space of the
first track, only first sector.


222281 25-May-2011 ae

Do not truncate available disk space to the closest track boundary.


222280 25-May-2011 ae

Do not truncate available disk space to the closest track boundary.


222279 25-May-2011 ae

Do not truncate available disk space to the closest track boundary.


222244 24-May-2011 ae

Remove unused variable.

MFC after: 1 week


222243 24-May-2011 ae

Remove unused variable.

MFC after: 1 week


221992 16-May-2011 ae

Make diagnostic messages more specific. With bootverbose print out
all inconsistencies of integrity in the partition table, not first
found only.

Requested by: kib


221984 16-May-2011 ae

Add diagnostic messages for integrity checks.


221972 15-May-2011 ae

Add a sysctl kern.geom.part.check_integrity for those who has corrupt
partition tables and lost an ability to boot after r221788.
Also unhide an error message from bootverbose, this would help to
easier determine the problem.


221788 11-May-2011 ae

Add basic metadata integrity check. In case when partition table was
probed and read successfull, but it contains invalid values (e.g.
overlapped partitions, offset or size is out of bounds), then table
will be rejected.

MFC after: 1 month


221658 08-May-2011 ae

Limit number of sectors that can be addressed.

MFC after: 1 week


221656 08-May-2011 ae

Limit number of sectors that can be addressed.

MFC after: 1 week


221654 08-May-2011 ae

Limit number of sectors that can be addressed.
Reject table if blkcount from metadata is greater than provider.


221652 08-May-2011 ae

Limit number of sectors that can be addressed.

MFC after: 1 week


221647 08-May-2011 ae

Replace UINT_MAX to UINT32_MAX.

Pointed out by: kib
MFC after: 1 week


221645 08-May-2011 ae

Limit number of sectors that can be addressed.

MFC after: 1 week


221644 08-May-2011 ae

Limit number of sectors that can be addressed.

MFC after: 1 week


220652 15-Apr-2011 gavin

Remove an incorrect be16toh() that prevented geom_part_apm from working on
little-endian machines.

Reviewed by: marcel
MFC after: 2 weeks


219029 25-Feb-2011 netchild

Add some FEATURE macros for various GEOM classes.

No FreeBSD version bump, the userland application to query the features will
be committed last and can serve as an indication of the availablility if
needed.

Sponsored by: Google Summer of Code 2010
Submitted by: kibab
Reviewed by: silence on geom@ during 2 weeks
X-MFC after: to be determined in last commit with code from this project


218909 21-Feb-2011 brucec

Fix typos - remove duplicate "the".

PR: bin/154928
Submitted by: Eitan Adler <lists at eitanadler.com>
MFC after: 3 days


218845 19-Feb-2011 nyan

Add support to set a slice name.


218558 11-Feb-2011 nyan

Add support to write boot menu.


218014 28-Jan-2011 ae

Add new user-friendly aliases for partition types for the MBR and
EBR schemes: fat32, ebr, linux-data, linux-raid, linux-swap and
linux-lvm. Add bios-boot GUID and alias for the GPT scheme. It used by
GRUB 2 loader. Also do sorting definitions of types in diskmbr.h
and in g_part.c.

PR: bin/120990, kern/147664
MFC after: 2 weeks


217924 27-Jan-2011 ae

While inspecting the disklabel check that start offset of partition is
within provider's bounds. If not then reject this disklabel.
Mark bbarea as NULL to do not free it again in destroy method.

MFC after: 1 week


217531 18-Jan-2011 ae

Limit maximum number of GPT entries to 4k. It is most realistic value
and can prevent kernel memory exhausting when big value is specified
from command line.

Split reading and writing operation to several iteration to do not
trigger KASSERT when data length is greater than MAXPHYS.

PR: kern/144962, kern/147851
MFC after: 2 weeks


217109 07-Jan-2011 mdf

Fix a memory overflow where the input length to g_gpt_utf8_to_utf16()
was specified incorrectly, causing the bzero to run past the end of a
malloc(9)'d object.

Submitted by: Eric Youngblut < eyoungblut AT isilon DOT com >
MFC after: 3 days


217040 06-Jan-2011 nwhitehorn

Add an entry to the gpart XML to determine if the geom has pending changes
that need to be committed (or undone).

MFC after: 2 weeks


216755 28-Dec-2010 ae

Allow destroying EBR in COMPAT (default) mode.

MFC after: 2 week


216754 28-Dec-2010 ae

Make EBR probe method less strictly to be able detect EBRs with
small non fatal inconsistency. EBR may contain boot loader and sometimes
it just has some garbage data. Now this does not prevent FreeBSD to use
extended partitions. But since we do not support bootcode for EBR we mark
tables which have non empty boot area as corrupt. This does make them
readonly and we can not damage this data.

PR: kern/141235
MFC after: 1 month


216269 07-Dec-2010 brucec

Don't warn if a partition appears not to be aligned on a track boundary.
Modern disks use LBA and create a fake CHS geometry that doesn't have any
relation to the on-disk layout of data.


216132 02-Dec-2010 ivoras

Add a note about the magic number 20. Actually, 22.75 entries fit in
a 512 byte sector but when choosing magic numbers, 20 looks nicer.

Discussed with: marcel


215118 11-Nov-2010 ae

Fix regression introduced in r215088: gpart(8) reports
"arg0 'provider': Invalid argument" after creating new partition
table.
Move code for search of existing geom into g_part_find_geom
function and use this function instead of g_part_parm_geom
in g_part_ctl_create.

Approved by: kib (mentor)


215088 10-Nov-2010 ae

In r212554 name of G_PART_PARM_GEOM and G_PART_PARM_PROVIDER
ctlreq parameters was changed to "arg0". Fix the last place where
it is used.

Approved by: kib (mentor)


214352 25-Oct-2010 ae

Reimplemented "gpart destroy -F". Now it does all work in kernel.
This was needed for recover implementation.

Implement the recover command for GPT. Now GPT will marked as
corrupt when any of three types of corruption will be detected:
1. Damaged primary GPT header or table
2. Damaged secondary GPT header or table
3. Secondary header is not located in the last LBA
Marked GPT becomes read-only. Any changes with corrupt table
are prohibited. Only "destroy" and "recover" commands are allowed.

Discussed with: geom@ (mostly silence)
Tested by: Ilya A. Arhipov
Approved by: mav (mentor)
MFC after: 2 weeks


213769 13-Oct-2010 rpaulo

The canonical way to print __func__ when using KASSERT() is to write
("%s", __func__). This avoids clang's -Wformat-string warnings.


213662 09-Oct-2010 ae

Replace strlen(_PATH_DEV) with sizeof(_PATH_DEV) - 1.

Suggested by: kib
Approved by: kib (mentor)
MFC after: 5 days


213174 25-Sep-2010 ae

Some schemes can allocate memory for internal purposes but when
GEOM does withering this memory doesn't freed. Add G_PART_DESTROY
call to g_part_wither. Also add missed g_free() call to G_PART_READ
method for MBR and PC98 schemes.

Submitted by: jh (previous version)
Reviewed by: pjd
Approved by: kib (mentor)


213135 24-Sep-2010 pjd

Allow to configure GPT attributes. It shouldn't be allowed to set bootfailed
attribute (it should be allowed only to unset it), but for test purposes it
might be useful, so the current code allows it.

Reviewed by: arch@ (Message-ID: <20100917234542.GE1902@garage.freebsd.pl>)
MFC after: 2 weeks


212706 15-Sep-2010 pjd

Change message when setting or unsetting attribute less confusing.
Before:

ada0 has <attrib> set

After:

<attrib> set on ada0

MFC after: 2 weeks


212703 15-Sep-2010 pjd

Make the message that informs about bootcode being written to disk less
confusing.

Note there is still no information about 'partcode' being written to disk
(gpart bootcode -p <partcode> <disk>).

Maybe in the future all the messages printed by gpart(8) on success could be
hidden under -v?

PR: bin/150239
Reported by: Roddi <roddi@me.com>
Submitted by: arundel
MFC after: 2 weeks


212614 14-Sep-2010 pjd

- Change all places where G_TYPE_ASCNUM is used to G_TYPE_NUMBER.
It turns out the new type wasn't really needed.
- Reorganize code a little bit.


212609 14-Sep-2010 pjd

Simplify the code a bit.


212554 13-Sep-2010 pjd

- Remove gc_argname field. It was introduced for gpart(8), but if I
understand everything correctly, we don't really need it.
- Provide default numeric value as strings. This allows to simplify
a lot of code.
- Bump version number.


210792 03-Aug-2010 ae

Check that table is not NULL before access, it can be NULL
for some cases.

Approved by: mav (mentor)
MFC after: 2 weeks


210746 02-Aug-2010 ae

Release access for consumers that are opened, but will be destroyed
indirectly by orphan method.

PR: 148688
Silence from: marcel
Approved by: mav (mentor)
MFC after: 2 weeks


210401 23-Jul-2010 ae

Prevent access after free to table entry in case when
user deletes partition that not yet created (changes doesn't
committed to disk).

PR: 148687
Approved by: mav (mentor)
MFC after: 7 days


209536 26-Jun-2010 rpaulo

Add NTFS partition type to GEOM_MBR.


208746 02-Jun-2010 marius

Don't leak memory on destruction.

Reviewed by: marcel
MFC after: 3 days


208515 24-May-2010 marius

Fix some whitespace nits.


208173 16-May-2010 nwhitehorn

Teach gpart about bootcode on APM.


207181 25-Apr-2010 marcel

Re-calculate a geometry when reprobing as well.

PR: kern/145452
Reported by: "Andrey V. Elsukov" <bu7cher@yandex.ru>


207178 25-Apr-2010 marcel

Fix undo for schemes that have internal partitions. Internal partitions
do not constitute user-visible or active partitions and as such should
not prevent undoing pending operations.

While here, initialize the last usable sector for the placeholder geom
based on the null scheme, created to allow undoing the destruction of
a scheme. This gives consistent output with "gpart show".

Based on a patch from: "Andrey V. Elsukov" <bu7cher@yandex.ru>


207094 23-Apr-2010 marcel

Implement the resize verb and add support for resizing partitions
for all schemes but EBR. Quality work by Andrey!

Submitted by: "Andrey V. Elsukov" <bu7cher@yandex.ru>


203261 30-Jan-2010 marcel

Export the UUID of the partition in the XML. The partition UUID is used
by EFI's device path to identify a partition. In order for FreeBSD to
add EFI boot options, proper device paths need to be constructed.


202977 25-Jan-2010 trasz

Remove unneeded variables.

Found with: clang


201645 06-Jan-2010 mav

Change the way in which zero stripesize is handled. Instead of reporting
zero stripeoffset in such case (as if device has no stripes), report offset
from the beginning of the media (as if device has single infinite stripe).

This gives partitioning tools information, required to guess better
partition alignment, in case if hardware doesn't report it's stripe size.
For example, it should give disklabel info about odd offset made by fdisk.


201374 02-Jan-2010 marcel

Properly return the UUID represented by the alias.

PR: 142174
Submitted by: Przemyslaw Laczynski <torindel@gmail.com>
Pointy hat to: rpaulo


200539 14-Dec-2009 rpaulo

Add Microsoft and NetBSD partition types handling.


200534 14-Dec-2009 rpaulo

Simplify partition type parsing by using a data-oriented model.
While there add more Apple and Linux partition types.


199232 12-Nov-2009 rpaulo

Add a missing check for Apple HFS partitions.

MFC after: 1 week


199228 12-Nov-2009 rnoland

We need to allocate space for the header in the create path also.

This fixes a null pointer dereference with "gpart create -s GPT" after
the previous commit.

Reported by: Yuri Pankov
Pointyhat to: me
MFC after: 1 week


199017 07-Nov-2009 rnoland

Fix handling of GPT headers when size is > 92 bytes.

It is valid for an on-disk GPT header to report a header size which is
greater than 92 bytes. Previously, we would read in the sector and copy
only the 92 bytes that we know how to deal with before calculating the
checksum for comparison. This meant that when we did the checksum, we
overshot the buffer and took in random memory, so the checksum would fail.

We now determine the size of the header and allocate enough space to
preserve the entire on-disk contents. This allows us to be correctly
calculate the checksum and be able to modify and write the header back
to the disk, while preserving data that we might not understand.

Reported by: Kris Weston
Approved by: marcel@
MFC after: 2 weeks


198097 14-Oct-2009 rnoland

Set the active flag in the PMBR when we install bootcode on a GPT
partitioned disk. Some BIOS require this to be set before they will
boot the device.

Approved by: marcel
MFC after: 2 weeks


197898 09-Oct-2009 pjd

If provider is open for writing when we taste it, skip it for classes that
depend on on-disk metadata. This was we won't attach to providers that are used
by other classes. For example we don't want to configure partitions on da0 if
it is part of gmirror, what we really want is partitions on mirror/foo.

During regular work it works like this: if provider is open for writing a class
receives the spoiled event from GEOM and detaches, once provider is closed the
taste event is send again and class can rediscover its metadata if it is still
there. This doesn't work that way when new class arrives, because GEOM gives
all existing providers for it to taste, also those open for writing. Classes
have to decided on their own if they want to deal with such providers (eg.
geom_dev) or not (classes modified by this commit).

Reported by: des, Oliver Lehmann <lehmann@ans-netz.de>
Tested by: des, Oliver Lehmann <lehmann@ans-netz.de>
Discussed with: phk, marcel
Reviewed by: marcel
MFC after: 3 days


197608 28-Sep-2009 marcel

The first 96 bytes may not be zeroes. It can contain trivial boot
code that merely emits an error and waits for a key press before
rebooting. The error being that extended partitions are not
bootable. The origin is presumed to be Windows 2000; Windows XP
does not do this...

For now, ignore the first 96 bytes when checking that the EBR is
(for the most part) all zeroes.

Tested by: Mario Lobo <mlobo@digiart.art.br>
MFC after: 1 week


197449 24-Sep-2009 marcel

Don't create more partitions than can fit in the table by checking
that the index is within bounds.


196333 17-Aug-2009 marcel

The start of the EFI GPT partition in the PMBR can always be represented
by CHS addressing. Don't define these fields as 0xff, but rather define
them correctly. This prevents boot problems on PCs where GPT is being
used.

PR: 115406
Submitted by: Kent Hauser <kent@khauser.net>
Approved by: re (kib)


195436 08-Jul-2009 marcel

Revert revisions 188839 and 188868. Use of the ioctl in geom_dev.c
is invalid because the ioctl happens without prior open. The ioctl
got introduced to provide backward compatibility for extended
partitions, but it ended up not being used because it didn't work
as expected. Since there are no consumers of the ioctl and the
implementation is broken, the best fix is to remove the code
entirely.

Spotted by: phk
Approved by: re (kensmith)


191134 16-Apr-2009 marcel

Precision '*' expects an int and strlen() returns a size_t.
Compensate.


191130 15-Apr-2009 marcel

Add a compat option to the EBR scheme that controls the
naming of the partitions (GEOM_PART_EBR_COMPAT). When
compatibility is enabled, changes to the partitioning are
disallowed.

Remove the device name aliasing added previously to provide
backward compatibility, but which in practice doesn't give
us anything.

Enable compatibility on amd64 and i386.


190878 10-Apr-2009 thompsa

Revert r190676,190677

The geom and CAM changes for root_hold are the wrong solution for USB design
quirks.

Requested by: scottl


190849 08-Apr-2009 marcel

Don't use hexadecimal in the EBR partition names, because 'a'..'f'
are more commonly known as BSD partition names.

Discussed with: ivoras@


190676 03-Apr-2009 thompsa

Add a how argument to root_mount_hold() so it can be passed NOWAIT and be called
in situations where sleeping isnt allowed.


190667 03-Apr-2009 marcel

The 9 bytes immediately prior to the partition table can contain
signatures or disk serial numbers. Don't assume those to be zero
in all cases. This fixes a false negative.

Tested by: avatar@mmlab.cse.yzu.edu.tw


190537 30-Mar-2009 marcel

Sharpen the saw:
o PC98 uses 32-bit block numbers. Limit the scheme to 2^32-1
blocks when the media is larger. The 32-bit block numbers
are implicit (16-bit cylinder * 8-bit head * 8-bit sector).


190536 30-Mar-2009 marcel

Sharpen the saw:
o MBR uses 32-bit block numbers. Limit the scheme to 2^32-1
blocks when the media is larger.


190535 30-Mar-2009 marcel

Sharpen the saw:
o EBR uses 32-bit block numbers. Limit the scheme to 2^32-1
blocks when the media is larger.
o Calculate the number of entries based on the rounded media
size, rather than the raw media size.


190534 30-Mar-2009 marcel

Sharpen the saw:
o Don't create a GPT scheme underneath another scheme when
the probe doesn't allow it.


190463 27-Mar-2009 marcel

Sharpen the saw:
o BSD uses 32-bit block numbers. Limit the scheme to 2^32-1
blocks when the media is larger.


190461 27-Mar-2009 marcel

Sharpen the saw:
o Don't create an APM scheme underneath another scheme when
the probe doesn't allow it.
o APM uses 32-bit block numbers. Limit the scheme to 2^32-1
blocks when the media is larger.


190443 26-Mar-2009 marcel

Change the priority from high to normal. This makes sure that
the BSD or GPT schemes can take precedence as appropriate.


190232 22-Mar-2009 ivoras

Be more explicit and complain if kernel dumps are perfomed on unsupported
partition types. This is to help users used to the old behaviour.

Reviewed by: marcel
Approved by: gnn (mentor)


190058 19-Mar-2009 ivoras

Make GEOM provider names starting with "/dev/" acceptable as well as their
"raw" names. While there, change the formatting of extended MSDOS partitions
so that the dot (".") is not used to separate two numbers (which kind of
looks like the whole is a decimal number). Use "+" instead, which also
hints that the second part of the name is the offset from the start of
the partition in the first part of the name. Also change the offset from
decimal to hexadecimal notation, simply for aesthetic reasons and future
compatibility.

GEOM_PART is the default in 8-CURRENT but not yet in 7-STABLE so this
changeset can be MFC-ed without causing major problems from the second
part.

Reviewed by: marcel
Approved by: gnn (mentor)
MFC after: 2 weeks


189695 11-Mar-2009 nyan

Move the PC98_[MS]ID_* defines from g_part_pc98.c to diskpc98.h.

Reviewed by: marcel


189616 10-Mar-2009 nyan

Restore the return statement. It was accidentally removed by rev 188429.


188899 21-Feb-2009 marcel

o When creating the EBR scheme, set the number of entries
properly. Otherwise the minimum of 1 is used and you can
only insert a single partition/slice and only at sector
0 (index 1).
o When adding a partition/slice, recalculate the index after
the start and size of the partition/slice are adjusted to
make them a multiple of the track size. Since the precheck
method sets the index based on the start of the partition
as provided by the user, we know that we're off by at most
1 and adjusting the index is safe.


188893 21-Feb-2009 marcel

Add bootcode handling.


188839 20-Feb-2009 marcel

Provide compatibility symlink for logical partitions:
1. Extend geom_dev by having it create the symlink (i.e. call
make_dev_alias) based on the DIOCGPROVIDERALIAS ioctl.
In this way the functionaility is generic and thus usable
by any geom/provider.
2. Have g_part handle said ioctl through the devalias method,
so that it's under control of the scheme itself. By design
the alias will not be created for newly added partitions.


188838 20-Feb-2009 marcel

Fix an infinite loop created when the last logical partition is
removed.


188723 17-Feb-2009 marcel

Add a default implementation for pre-check. It should
always succeed if not implemented.

Pointy hat: marcel


188705 17-Feb-2009 marcel

Remove gpt_offset and related code. It was introduced for use
by the BSD scheme, ended up not to be needed. Remove to avoid
abuse and to keep the bloat to a minimum.


188667 16-Feb-2009 marcel

Add support to add, delete and modify logical partitions, as well
as to create and destroy the extended partitioning scheme. In
other words: full support.


188659 15-Feb-2009 marcel

Add method precheck to the g_part interface. The precheck
method allows schemes to reject the ctl request, pre-check
the parameters and/or modify/set parameters. There are 2
use cases that triggered the addition:
1. When implementing a R/O scheme, deletes will still
happen to the in-memory representation. The scheme is
not involved in that operation. The pre-check method
can be used to fail the delete up-front. Without this
the write to disk will typically fail, but at that
time the delete already happened.
2. The EBR scheme uses a linked list to record slices.
There's no index. The EBR scheme defines the index
as a function of the start LBA of the partition. The
add verb picks an index for the range and then invokes
the add method of the scheme to fill in the blanks. It
is too late for the add method to change the index.
The pre-check is used to set the index up-front. This
also (silently) overrides/nullifies any (pointless)
user-specified index value.


188429 10-Feb-2009 imp

Fix g_part_dumpconf and g_part_name prototpyes.

Submitted by: marcel@


188354 09-Feb-2009 marcel

Add the EBR scheme. The EBR scheme supports the Extended Boot Records
found inside extended partitions and used to create logical partitions.
At this time write/modify support is not (yet) present.
The EBR and MBR schemes both check the parent scheme. The MBR will
back-off when nested under another MBR, whereas the EBR only nests
under a MBR.


188352 08-Feb-2009 marcel

Allow gpe_offset to be set by the scheme. When gpe_offset is zero,
or invalid, initialize it to the start of the partition. Adjust
the mediasize when the offset lies somewhere inside the partition.


188329 08-Feb-2009 marcel

o Add the "PART::scheme" attribute that returns the name of the
underlying partitioning scheme.
o Put the start and end of the partition in the XML configuration.
The start and end are the LBAs of the first and last sector
(resp.) of the partition. They are currently identical to the
offset and size attributes, which describe the partition as an
offset and size in bytes, but may not in the future. The start
and end will be used for the logical partition boundaries and
may include metadata. The offset and size will always represent
the useful storage space within the partition. Typically these
two notions are the same, but for logical partitions in an
extended partition, the EBR is more naturally treated as being
part of the partition.


188303 08-Feb-2009 imp

Fix g_part_*dumpconf to return void to match kobj definition.
Fix g_part_*name to return a const char * rather than a char *.


186823 06-Jan-2009 marius

- Don't enforce an upper-bound to the number of sectors or heads,
allowing the full 16-bit width of the corresponding fields in the
VTOC8 label to be used. The removed limits basically only held
true for providers labeled using the synthetic geometry provided
by cam_calc_geometry(9) but neither SCSI disks labeled with Solaris
nor sufficiently large ATA disks.
- Given that providers (originally) labeled with Solaris typically
use the native geometry as reported by the target while FreeBSD
typically uses a synthetic one put the message complaining about
mismatching geometries between what the label indicates and what
GEOM thinks the provider has, which we generally can't help,
under bootverbose in order to not unnecessarily scare users.
- For informational purposes add the non-matching values to the
message complaining about them, similar to what r186501 did for
g_part_bsd_read() except also indicating the origin of the
values.
- Make it clear that the messages emitted by this code refer to
the VTOC8 support rather than to another existing scheme or to
VTOC32.


186807 06-Jan-2009 marcel

Don't enforce an upper-bound to the number of sectors or heads
that that the provider has. The limits we imposed were PC BIOS
specific and not always applicable.


186733 04-Jan-2009 marcel

Improve probing.
o Don't check the dummy fields.
o The entry is unused if either dp_mid is 0 or dp_sid is 0.
o The start or end cylinder cannot be 0.
o The start CHS cannot be equal to the end CHS.

Submitted by: nyan


186501 26-Dec-2008 obrien

When the geometry does not match the label, print out the values.


185497 01-Dec-2008 marcel

Allow boot code to be smaller than what the scheme expects.
This effectively changes the boot code size to be an upper
bound and makes the interface more flexible.


185327 26-Nov-2008 marcel

Allow dumpon to a partition of type FS_UNUSED as well.


185048 18-Nov-2008 marcel

Partition type FS_UNUSED does not mean the partition entry
is unused. Unused partition entries have a partition size
of zero. Therefore, partitions can have type FS_UNUSED.

MFC after: 3 days


184734 06-Nov-2008 marcel

Fix a panic caused by a corrupted table when the header is
still valid. We were checking the state of the header and
not the table.

PR: 119868
Based on a patch from: Jaakko Heinonen <jh@saunalahti.fi>
MFC after: 1 week


184552 02-Nov-2008 imp

Add support for reading Tivo Series 1 partitioning. This likely needs
a little refinement, but is good enough to commit as is.

# Should look to see if I should move swab(3) into the kernel or just
# provide the unoptimized routine here.

Reviewed by: marcel@


184264 25-Oct-2008 marcel

Invalid BSD disklabels have been created by sysinstall and
are possibly still being created. The d_secperunit field
contains the number of sectors of the disk and not of the
slice/partition to which the disklabel applies.
Rather than reject the disklabel, we now silently adjust
the field. Existing code, like bslabel(8), does not seem
to check the label that extensively and seems to adjust
fields as a side-effect as well.
In other words, it's not that important apparently, so
gpart should not be too strict about it.

Reported by: nyan@
Reported by: Andriy Gapon <avg@icyb.net.ua>


184151 22-Oct-2008 marcel

Allow dumps to partitions with a tag of 0. The legacy
sunlabel implementation in FreeBSD does not use VTOC
information and as such as no partition types.


184069 20-Oct-2008 marcel

The active and bootable flags are not part of the type.
Export the active and bootable flags as attributes in
the configuration XML and allow them to be manipulated
with the set/unset commands.

Since libdisk treats the flags as part of the partition
type, preserve behavior by keeping them included in the
configuration text.


183455 29-Sep-2008 marcel

Return G_PART_PROBE_PRI_HIGH instead of G_PART_PROBE_PRI_NORM
if the probe succeeds. This guarantees that the BSD scheme
wins over the MBR scheme when MBR gets to probe first. Build-
or link-time conditions can cause schemes to end up in the
linker set in a different order. Normally BSD is before MBR
in the linker set and as such get to probe first. But typically
when the kernel gets rebuild or relinked, this can change.


183454 29-Sep-2008 marcel

Insert the null scheme at the head. This does not change any
functionality, but creates an invariant: the first element
on the list is always the null scheme.


183420 27-Sep-2008 marcel

Export the partition name in the conftxt and confxml output.
The conftxt output is used by libdisk, and the confxml
output is used by gpart itself (gpart show -l).

Submitted by: nyan@


183419 27-Sep-2008 marcel

Hold the root mount while we're tasting. It is possible
that a nested partition (typically the BSD disklabel)
is not done tasting while the root file system is being
mounted. While this is rare, it's still possible.


183410 27-Sep-2008 marcel

Allow 255 sectors/track for the BSD disklabel. The previous limit
of 63 sectors/track is too PC BIOS specific. On pc98, where the
BSD disklabel is used as well, 255 sectors/track is not uncommon.

Submitted by: nyan@


182798 05-Sep-2008 rpaulo

Fix build.


182797 05-Sep-2008 rpaulo

Keep entries sorted.


182793 05-Sep-2008 rpaulo

Include the vendor in the partition name.


182784 05-Sep-2008 rpaulo

Detect Apple HFS GPT slices.


181463 09-Aug-2008 des

Add sbuf_new_auto as a shortcut for the very common case of creating a
completely dynamic sbuf.

Obtained from: Varnish
MFC after: 2 weeks


180717 22-Jul-2008 peter

Trivial commit to attempt to diagnose a svn problem. Add
comment that Tivo disks are APM, but do not have a DDR record.


179853 18-Jun-2008 marcel

Add the set and unset verbs used to set and clear attributes for
partition entries. Implement the setunset method for the MBR
scheme to control the active flag.


179763 12-Jun-2008 marcel

Finish the support for partition labels and add it to the XML.


179756 12-Jun-2008 marcel

Add the raw partition type to the XML.


179755 12-Jun-2008 marcel

Add the raw partition type to the XML.


179752 12-Jun-2008 marcel

Add the raw partition type to the XML.


179751 12-Jun-2008 marcel

Add the raw partiton type to the XML.


179750 12-Jun-2008 marcel

Add the raw partition type to the XML.


179748 12-Jun-2008 marcel

Add the partition label and the raw partition type to the XML.


178444 23-Apr-2008 marcel

Implement the G_PART_DUMPCONF method for all 6 schemes. Also call
the method for the (indent == NULL) case (i.e. the kern.geom.conftxt
sysctl). The purpose is to extend the conftxt output with scheme-
specific fields which can be used by libdisk. In particular, have
the schemes dump the xs and xt fields, which contain the backward
compatible values for class type and partition type. This allows
libdisk to work with the legacy slicers as well as with gpart and
helps/promotes migration.


178180 13-Apr-2008 marcel

Add the bootcode verb for installing boot code. Boot code
is supported for the MBR, GPT and PC98 schemes, where GPT
installs boot code into the PMBR.


177713 29-Mar-2008 marcel

Change the order from SI_ORDER_FIRST to SI_ORDER_ANY (within
SI_SUB_DRIVERS) to avoid loading schemes before all the GEOM
classes have been loaded and initialized. Otherwise we may
end up using mutexes that haven't been initialized (due to
g_retaste() posting an event).


177692 28-Mar-2008 marcel

Add support for PC-9800 partition tables.


177510 23-Mar-2008 marcel

Redefine G_PART_SCHEME_DECLARE() from populating a private linker set
to declaring a proper module. The module event handler is part of the
gpart core and will add the scheme to an internal list on module load
and will remove the scheme from the internal list on module unload.
This makes it possible to dynamically load and unload partitioning
schemes.


176718 02-Mar-2008 marcel

Add support for VTOC8 labels (aka sun disk labels). When a label does
not have VTOC information about the partitions, it will be created.
This is because the VTOC information is used for the partition type
and FreeBSD's sunlabel(8) does not create nor use VTOC information.
For this purpose, new tags have been added to support FreeBSD's
partition types.


176672 29-Feb-2008 marcel

Follow-up improvements to the handling of false positives: If the
partition table is empty, check to see if we have something that
looks sufficiently like a BPB. On non-i386 machines, the boot
sector typically doesn't contain boot code; the end of the boot
sector is all zeroes. This is also where the partition table is
for MBRs.
We only check the sector size and cluster size, as that seems to
be the most reliable across implementations, BPB versions and
platforms.


176650 28-Feb-2008 marcel

Better handle false positives. The MBR differs from the boot sector
only because there's a partition table where the boot sector has
boot code. Boot sectors without boot code look like a MBR for all
practical purposes. This change adds a check for the partition table
and fails the probe when it's obvously invalid. The assumption being
that the sector contains a boot sector and not a MBR.
More checks are needed to distinguish a boot secto without boot code
from a (empty) MBR.


174882 24-Dec-2007 marcel

Various fixes:
o BSD disklabels have relative offsets. Even for the BSD in MBR slice
setup, except when the mbroffset ioctl is supported. Since we don't
support that ioctl, bsdlabel(8) expects relative offsets. So, when
reading an existing disklabel, correct for disklabels that mistakenly
have the mbroffset offsets.
o Don't take the geometry seriously, because it's untrustworthy. We do
expect the numbers to be within range. This means that the secperunit
field will not be computed from secpercyl and ncyls, but simply is
the mediasize in sectors.
o Don't enforce partitions to be aligned to track boundaries. The
default label, constructed by bsdlabel(8), puts partition a at offset
BBSIZE bytes, which commonly means sector 16.


174499 09-Dec-2007 marcel

Fix a bug in the add verb, where we failed to keep the list
of partitions in index-order. This is assumed by the APM, MBR
and BSD partitioning schemes.


174465 08-Dec-2007 marcel

Internal partitions can not be deleted or modified.


174456 08-Dec-2007 marcel

Skip internal partitions in the check for (user) partitions for
the destroy command. Previously a freshly created BSD disklabel
could not be destroyed because of the internal partition.


174437 08-Dec-2007 marcel

Add support for FS_ZFS.


174326 06-Dec-2007 marcel

Add a BSD disklabel backend to g_part:
o Disklabels can have between 8 and 20 partitions (inclusive).
o No device special file is created for the raw partition.
o Switch ia64 to use this backend.
o No support for boot code yet.


172940 24-Oct-2007 jhb

First cut at support for booting a GPT labeled disk via the BIOS bootstrap
on i386 and amd64 machines. The overall process is that /boot/pmbr lives
in the PMBR (similar to /boot/mbr for MBR disks) and is responsible for
locating and loading /boot/gptboot. /boot/gptboot is similar to /boot/boot
except that it groks GPT rather than MBR + bsdlabel. Unlike /boot/boot,
/boot/gptboot lives in its own dedicated GPT partition with a new
"FreeBSD boot" type. This partition does not have a fixed size in that
/boot/pmbr will load the entire partition into the lower 640k. However,
it is limited in that it can only be 545k. That's still a lot better than
the current 7.5k limit for boot2 on MBR. gptboot mostly acts just like
boot2 in that it reads /boot.config and loads up /boot/loader. Some more
details:
- Include uuid_equal() and uuid_is_nil() in libstand.
- Add a new 'boot' command to gpt(8) which makes a GPT disk bootable using
/boot/pmbr and /boot/gptboot. Note that the disk must have some free
space for the boot partition.
- This required exposing the backend of the 'add' function as a
gpt_add_part() function to the rest of gpt(8). 'boot' uses this to
create a boot partition if needed.
- Don't cripple cgbase() in the UFS boot code for /boot/gptboot so that
it can handle a filesystem > 1.5 TB.
- /boot/gptboot has a simple loader (gptldr) that doesn't do any I/O
unlike boot1 since /boot/pmbr loads all of gptboot up front. The
C portion of gptboot (gptboot.c) has been repocopied from boot2.c.
The primary changes are to parse the GPT to find a root filesystem
and to use 64-bit disk addresses. Currently gptboot assumes that the
first UFS partition on the disk is the / filesystem, but this algorithm
will likely be improved in the future.
- Teach the biosdisk driver in /boot/loader to understand GPT tables.
GPT partitions are identified as 'disk0pX:' (e.g. disk0p2:) which is
similar to the /dev names the kernel uses (e.g. /dev/ad0p2).
- Add a new "freebsd-boot" alias to g_part() for the new boot UUID.

MFC after: 1 month
Discussed with: marcel (some things might still change, but am committing
what I have so far)


172857 21-Oct-2007 marcel

Add the freebsd-zfs alias. Both APM and GPT have ZFS partition
types.


170897 17-Jun-2007 marcel

Have gpart synthesize a disk geometry if the underlying provider
don't have it. Some partitioning schemes, as well as file systems,
operate on the geometry and without it such schemes (e.g. MBR)
and file systems (e.g. FAT) can't be created. This is useful for
memory disks.


170651 13-Jun-2007 marcel

Add the MBR partitioning scheme to g_part. This does not yet
support the ability to install boot code.


170362 06-Jun-2007 marcel

Prefix unknown (i.e. un-aliased) partition types with '!'. This is
how they had to be given with ctlreq.


170361 06-Jun-2007 marcel

Call sbuf_finish() before sbuf_data() and sbuf_len().


169588 15-May-2007 marcel

Fix a dereference in KASSERT.


169585 15-May-2007 marcel

o Implement automatic commit. It's enabled when the flags parameter
exists and contains the 'C' flag.
o The partition label can be the empty string. It's how labels are
cleared.
o When an action fails, lower permissions when they were raised
in order to allow the action. A failed action will not result
in any uncommitted changes.
o Allow the flags paremeter to be present but empty. It's the
equivalent of not being present.


169404 09-May-2007 marcel

Write the output parameter (if present) for the add, create, delete
destroy and modify verbs.


169398 09-May-2007 marcel

When reverting the creation of a partitioning scheme on a provider,
the failure to probe an existing partitioning scheme means that no
previous partitioning scheme existed. Don't error. Just destroy the
geom.


169389 08-May-2007 marcel

MFp4:
119373: o Remove the query verb, along with the request and response
parameters.
o Add the version and output parameters.
119390: [APM,GPT] Properly clear deleted entries.
119394: o Make the alias the standard and use the '!' to prefix
literal partition types.
o Treat schemes and partition types as case insensitive.
119462: [GPT] Fix a page fault caused when modifying a partition entry
without a new partition type.


169065 27-Apr-2007 marcel

Put the scheme (APM, GPT, etc) in the XML.


166561 08-Feb-2007 rodrigc

#include <sys/systm.h> before <sys/geom.h> to get KASSERT(), and fix LINT build.


166551 07-Feb-2007 marcel

Evolve the ctlreq interface added to geom_gpt into a generic
partitioning class that supports multiple schemes. Current
schemes supported are APM (Apple Partition Map) and GPT.
Change all GEOM_APPLE anf GEOM_GPT options into GEOM_PART_APM
and GEOM_PART_GPT (resp).

The ctlreq interface supports verbs to create and destroy
partitioning schemes on a disk; to add, delete and modify
partitions; and to commit or undo changes made.