History log of /freebsd-9.3-release/sbin/geom/class/part/geom_part.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 267654 19-Jun-2014 gjb

Copy stable/9 to releng/9.3 as part of the 9.3-RELEASE cycle.

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

# 258186 15-Nov-2013 asomers

MFC 257006

sbin/geom/class/part/geom_part.c
Always validate the return of find_geomcfg(). It could be NULL, for
example when the geom is withering.

Approved by: ken(mentor)
Sponsored by: Spectra Logic Corporation


# 255017 29-Aug-2013 ae

MFC r251587 (by marcel):
Remove stub implementation.

MFC r251588 (by 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.


# 235258 11-May-2012 ae

MFC r235033:
Don't ignore start offset value when user specifies it together
with alignment.

PR: bin/167567
Tested by: Warren Block


# 230563 26-Jan-2012 ae

MFC r229916 (by eadler):
Fix warning when compiling with gcc46:
error: variable 'secsz' set but not used


# 225736 22-Sep-2011 kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by: re (implicit)


# 225445 08-Sep-2011 ae

Don't use the whole free space when resizing partition to a larger size
on a disk with non zero stripesize (e.g. disks with 4k sector size)[1].
Also do not use automatic alignment when size is exactly specified, but
an alignment is not. Use automatic alignment only for case when user
omits both "-s" and "-a" options.

Reported by: Mikael Fridh <frimik at gmail> [1]
Approved by: re (kib)
MFC after: 1 week


# 223364 21-Jun-2011 ae

When user specifies the bootcode with size smaller than VTOC_BOOTCODE,
gpart_write_partcode_vtoc8 does access out of range of allocated memory.
Check size of bootcode before writing it.

Pointed out by: ru
MFC after: 1 week


# 223356 21-Jun-2011 delphij

Mod the offset padding by alignment. Without this change we may
pad too much when underlying GEOM object have a zero stripesize.

MFC after: 1 month


# 223355 21-Jun-2011 ae

The "size" param needs no adjusting to stripeoffset.

Reported by: Kris Moore


# 223158 16-Jun-2011 ae

Add "alignment" param to the request before calling gpart_autofill().


# 222819 07-Jun-2011 ae

Do not use LCM from stripesize and user specified alignment value.
When user wants have specific alignment - do what user wants.
Use stripesize as alignment value in case, when some of gpart's
arguments are ommitted for automatic calculation.

Suggested by: mav


# 222631 02-Jun-2011 ae

Always use LCM when stripesize > 0.


# 222630 02-Jun-2011 ae

Use stripesize and stripeoffset in the automatic calculation of
partition offsets. If user requests specific alignment and
provider's stripesize is not zero, then use a least common multiple
from the stripesize and user specified value.
Also fix "gpart resize" implementation: do not try to align the partition
size, because the start offset may be not aligned. Instead align the
end offset and then calculate size. Also use stripesize and stripeoffset
for "gpart resize" command.


# 222357 27-May-2011 ae

Synchronize manpage's synopsis with program's usage. Since -l and -r
keys are mutually exclusive for the `gpart show` command, then mark
them so.

Requested by: ru


# 222264 24-May-2011 ae

Simplify ALIGNDOWN macro.


# 222263 24-May-2011 ae

Fix calculation of alignment for odd values. Also do not change value
when it is already aligned.


# 221967 15-May-2011 ae

Some partitioning schemes want to have partitions that are aligned
with geometry. And they do recalculation of user specified parameters.
MBR, PC98, VTOC8, EBR schemes are doing that. For these schemes an
auto alignment feature (ie. gpart add -a alignment) would not work.
But it can work for GPT and BSD schemes. BSD scheme usualy is created
inside MBR, so we can use knowledge about offset of MBR partition to
calculate aligned values for BSD partitions.

Use "offset" attribute of the parent provider for better alignment.

MFC after: 2 weeks


# 221952 15-May-2011 ae

Simplify the code a bit. For own providers GEOM_PART always provides
"start" and "end" config attributes.

MFC after: 1 week


# 221363 03-May-2011 ae

Add "-a alignment" option to gpart(8). When it specified gpart(8)
tries to align partition start offset and size to be multiple of
alignment value.

MFC after: 2 weeks


# 219416 08-Mar-2011 ae

It is better to sometimes have not aligned columns than
often have wrapped lines.

MFC after: 2 weeks


# 219415 08-Mar-2011 ae

Add -p option to `gpart show` command to show provider's names of
partitions instead of partition's indexes. This may be useful with
GPT partitioning scheme or EBR without GEOM_PART_EBR_COMPAT option.

MFC after: 2 weeks


# 216619 21-Dec-2010 ae

Check number of arguments before trying to read arg0. This prevents access
to arg0 and dumping core when `gpart bootcode` called without arguments.


# 215704 22-Nov-2010 brucec

Fix some more warnings found by clang.


# 215672 22-Nov-2010 ae

Add SIGINT handler to `gpart restore` action.

MFC after: 1 week


# 215671 22-Nov-2010 ae

Always dump partition labels with `gpart backup`, but `gpart restore`
does restore them only when -l option is specified [1]. Make number of
entries field in backup format optional. Document -l and -r options of
`gpart show` action.

Suggested by: pjd [1]
MFC after: 1 week


# 215570 20-Nov-2010 ae

Add to gpart(8) an ability to backup partition table and
restore it from given backup.

Discussed with: geom@
Approved by: kib (mentor)
MFC after: 1 week


# 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


# 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


# 213187 26-Sep-2010 ae

Remove superfluous word from "gpart bootcode" usage message.

Approved by: kib (mentor)


# 213097 24-Sep-2010 ae

Implement "force" (-F) option for gpart destroy verb.
This option doesn't passed to kernel and handled in user-space.
With -F option gpart creates new "delete" request for each
partition in table. Each request has flags="X" that disables
auto-commit feature. Last request is the original "destroy" request.
It has own flags and can have disabled or enabled auto-commit feature.
If error is occurred when deleting partitions, then new "undo" request
is created and all changes will be rolled back.

Approved by: kib (mentor)


# 212708 15-Sep-2010 pjd

GPART_PARAM_INDEX is now G_TYPE_NUMBER.


# 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.


# 212613 14-Sep-2010 pjd

Update two last places where "arg0" should be used instead of "geom".


# 212608 14-Sep-2010 pjd

All gpart(8) subcommands apart from the 'bootcode' subcommand handle
given geom/provider names with and without /dev/ prefix. Teach the
'bootcode' subcommand to handle /dev/<foo> names as well.


# 212606 14-Sep-2010 pjd

Introduce special G_VAL_OPTIONAL define, which when given in value field
tells geom(8) to ignore it when it is not given and don't try to obtain
default value.


# 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.


# 212547 13-Sep-2010 pjd

- Allow to specify value as const pointers.
- Make optional string values always an empty string.


# 209388 21-Jun-2010 ae

Remove G_TYPE_ASCLBA type and replace it with G_TYPE_STRING in gpart.
Move code that converts params from humanized numbers to sectors count
to subr.c and adjust comment.
Add post-processing for "size" and "start offset" params in gpart,
now they are properly converted to sectors count with known sector size
that can be greater that 512 bytes.
Also replace "unsigned long long" type to "off_t" for unify code since
it used for medium size in libgeom(3) and DIOCGMEDIASIZE ioctl.

PR: bin/146277
Reviewed by: marcel (previous version)
Approved by: kib (mentor)
MFC after: 1 month


# 208777 03-Jun-2010 marius

- In gpart_bootfile_read() fix an off-by-one error preventing the bootstrap
file to be of maximum size.
- Add special handling required for SMI/VTOC8 disklabel partcode, i.e. avoid
overwriting the label when writing the bootstrap code to the partition
starting at 0 and install it to all partitions when the -i option is omitted
just like geom_sunlabel(4) and sunlabel(8) do by default.
- Add missing prototypes.
- Add const where applicable.

Reviewed by: marcel
MFC after: 3 days


# 208173 16-May-2010 nwhitehorn

Teach gpart about bootcode on APM.


# 207095 23-Apr-2010 marcel

Implement the resize command for resizing partitions. Without new
size, the partition in question is resized to fill all available
space. Quality work by Andrey!

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


# 198478 26-Oct-2009 lulf

- Initialize variable in order to avoid GCC warning and enable WARNS=6.

PR: bin/139970
Submitted by: Ulrich Spörlein <uqs -at- spoerlein.net>


# 196278 16-Aug-2009 marcel

Emit a proper error message instead of dumping core when 1)
GEOM_PART does not exist in the kernel, and 2) the GEOM in
question does not exist.
Additionally abort in case of programming errors that result
in neither the class nor geom not being present in the gctl
request.

Submitted by: "Andrey V. Elsukov" <bu7cher@yandex.ru>
Approved by: re (kib)


# 193728 08-Jun-2009 jhb

Change the printf format string to match the variable type to quiet
warnings.


# 193673 08-Jun-2009 marcel

Make the size (-s) and start (-b) parameters of the add verb optional.
The missing parameter(s) are automatically filled-in.


# 193648 07-Jun-2009 marcel

Allow humanized numbers for LBAs, as well as partition indices for
gpart(8). LBAs in particular are ugly. The ganularity is a sector,
but users expect byte granularity when specifying the size or offset
with a SI unit. Handle LBAs specially to deal with this.


# 188330 08-Feb-2009 marcel

Prefer the start and end attributes over the offset and size
attributes. The start and end more accurately describe the
space taken by a partition. The offset and size are used to
describe the effective (usable) storage of that partition.


# 185496 30-Nov-2008 marcel

Print error messages as-is, when they don't conform to
<errno> [<parameter> 'value']
These are error messages from (lib)geom itself.


# 185495 30-Nov-2008 marcel

Call gctl_free() after we processed the error string.
It's being freed as part of the request.


# 185454 29-Nov-2008 marcel

Parse the error string returned by the kernel. The format is:
<errno> [<parameter> <value>]
So, rather than printing the error:
gpart: 22 scheme 'gpt'
gpart(8) now prints:
gpart: scheme 'gpt': invalid argument


# 185046 18-Nov-2008 marcel

Use humanize_number(), rather than a home-grown algorithm for
formatting a number in a human-friendly way.

Note that with this commit a megabyte changed from 1000000 to
1048576 and a 80G disk is now printed as being 75G in size.
This is deliberate. It's consistent with the core of geom(8).
However, the original choice for a megabyte being 1000000 was
on purpose and matches what disk vendors put on the box. The
consistency is considered more important.

Submitted by: delphij


# 185044 18-Nov-2008 marcel

Sort includes

Submitted by: delphij


# 185038 17-Nov-2008 marcel

Pad the bootcode we write to the partition to a multiple of the
sector size.

Submitted by: Alexey Shuvaev <shuvaev@physik.uni-wuerzburg.de>
Prompted by: delphij
MFC after: 3 days


# 184070 20-Oct-2008 marcel

Add support for multiple attributes. This is required for the
PC98 scheme.


# 179854 17-Jun-2008 marcel

Implement the set and unset verbs. While here, have the manpage
catch up with various changes.


# 179769 12-Jun-2008 marcel

Implement the -l and -r options for gpart show.
The -l option changes the output to show the partition label, if applicable
and when present. The -r option changes the output to show the raw (i.e.
scheme-specific) partition types.


# 179629 06-Jun-2008 marcel

Enhance the bootcode command to also allow bootcode to be written
to a partition. This avoids that users need to use dd(1) to install
boot code (as is needed for VTOC8 and booting GPT on PCs).


# 179550 04-Jun-2008 marcel

Replace checks for RESCUE in sources with checks for STATIC_GEOM_CLASSES
and define STATIC_GEOM_CLASSES when building the rescue binary. This way
geom can more easily be part of other crunched binaries, as it requires
only a Makefile change.


# 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.


# 173313 03-Nov-2007 marcel

Allow building of a special rescue version of geom that
has a subset of the classes compiled-in.


# 172856 21-Oct-2007 marcel

Fix a last-minute, but more importantly, an untested change that
made the previous commit non-functional: the usage string was put
in the wrong field...


# 172837 20-Oct-2007 marcel

Add the show command to print the partition information ala gpt(8).
Update the manpage accordingly. While here, mention the MBR scheme
and add a bugs section. With this commit gpt(8) can be obsoleted.


# 169586 15-May-2007 marcel

Add gpart(8).

In order to support gpart(8), geom(8) needs to support a named
argument. Also, optional string parameters are a requirement.
Both have been added to the infrastructure. The former required
all existing classes to be adjusted.