This patch introduces smart crc32 function that is able to exclude
specified. The advantage is that we does not have to modify GPT header
(set the current in-header crc field to zero) when we count crc32.
This allows to keep GPT header in read-only buffers and simplify code.
Signed-off-by: Karel Zak <kzak@redhat.com>
- verify that the new partition fits to the area if the size of the
has not been modified
- fix remaining space calculation (yes, brown-paper-bag bug..)
- offer also space before first partition as free space
Signed-off-by: Karel Zak <kzak@redhat.com>
For example:
# modprobe scsi_debug dev_size_mb=1000 opt_blks=65535 physblk_exp=3
creates a disk with:
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
where 33553920 % 4096 != 0, it means that use Optimal I/O size to
align partition results that partition is not aligned to physical
sector boundary.
Reported-by: Tom Yan <tom.ty89@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
* removes list() label operation from internal API
The list() has been based on fdisk_info() it was useless for
anything else than print on stdout...
* add a new get_item() label operation and fdisk_get_disklabel_item() public API
The new API provides abstract and pretty simple way how to get label
specific disk label information, for example
fdisk_get_disklabel_item(cxt, GPT_LABELITEM_ENTRIESLBA, &iterm);
return LBA of the array with GPT entries.
Note that this patch does not implement public functions to get
data from the @item object.
* removes get_id() label operation -- it's subset of the new get_item()
* the new internal API is also used to implement backwardly compatible
fdisk_list_disklabel() and fdisk_get_disklabel_id()
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's create a disk with 33553920 bytes optimal I/O size:
# modprobe scsi_debug dev_size_mb=1000 opt_blks=65535
and try to create partition:
echo -e 'n\n\n\n\n+512M\np\nq\n' | fdisk /dev/sdc
old version:
Device Boot Start End Sectors Size Id Type
/dev/sdc1 65535 1114110 1048576 512M 83 Linux
The next partition will be expected on sector 1114110 + 1, but it's
not aligned to optimal I/O:
((1114110 + 1) * 512) % 33553920 = 8192
fixed version:
Device Boot Start End Sectors Size Id Type
/dev/sdc1 65535 1114094 1048560 512M 83 Linux
((1114094 + 1) * 512) % 33553920 = 0
Note that the same problem with alignment calculation has been fixed
in Linux kernel by commit b8839b8c55f3fdd60dc36abcda7e0266aff7985c
(Oct 2014).
The patch also improves fdisk_align_lba_in_range() to not align sizes
smaller than grain (default 1MiB) to make it possible to create really
small partitions.
Reported-by: Tom Yan <tom.ty89@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
It is impossible to predict /dev/dm-N partition names. Use predictable
and better readable /dev/mapper names instead.
[kzak@redhat.com: - remove if-before-free]
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
The default configuration of multipath-tools appends "-partN" to
partition nodes. Follow this conventions and do the same.
It fixes for example fdisk -l /dev/mapper/name_of_the_device.
Note that the current implementation only partially fixes the problem. It
does not reflect any udev configuration changes, as udev does not provide
any function to return names of future (or current) partitions of a
particular device. It also does not fix fdisk -l /dev/dm-0.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
The current fdisk_label_get_fields_ids() is too smart as it
differentiate between details mode etc. It's useful for default
output, but in some cases it's better to provide all output fields.
Signed-off-by: Karel Zak <kzak@redhat.com>
The new libfdisk/gpt test (4a4a0927) discovered that we read and write
partition attributes wrongly on BE systems.
Our temporarily used char[8] bits are always LE and do not need to be
converted.
CC: Michael Marineau <michael.marineau@coreos.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
The existing APIs can only toggle individual bits or get and set bits in
a complex text representation, making it impractical to use libfdisk for
manipulating the GPT partition attribute field in more complex ways such
as updating a value that is multiple bits wide. For example priority
based partition selection originally designed for ChromeOS includes two
integer values that are 4-bits wide.
http://www.chromium.org/chromium-os/chromiumos-design-docs/disk-format#TOC-Trusting-the-GPT
[kzak@redhat.com: - add new symbols to .sym file and docs
- remove unused variables from test program]
Signed-off-by: Michael Marineau <michael.marineau@coreos.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Search for the protective partition before attempting to validate that
it covers the GPT header. Some hybrid MBRs list partitions out of order.
For example, CoreOS images ship with a hybrid MBR that lists the boot
partition first and the protective partition second in order to maintain
compatibility with old versions of Xen's PV-GRUB.
Signed-off-by: Michael Marineau <michael.marineau@coreos.com>