- add fdisk_gpt_disable_relocation() to disable move backup header to standard location
- add fdisk_gpt_enable_minimize() to move backup header behind last partition
Note that fdisk_gpt_disable_relocation() has to be used before fdisk_assign_device(),
because automatic relocation is done when libfdisk reads the header from the device.
For example:
lb = fdisk_get_label(cxt, "gpt");
fdisk_gpt_disable_relocation(lb, 1);
fdisk_assign_device(cxt, devname, 0);
For fdisk_gpt_enable_minimize() it's not important as recalculation is
done before write, for example:
fdisk_assign_device(cxt, devname, 0);
fdisk_gpt_enable_minimize(fdisk_get_label(cxt, NULL), 1);
... add partition, etc ...
fdisk_write_disklabel(cxt);
Signed-off-by: Karel Zak <kzak@redhat.com>
We have fdisk_set_disklabel_id(), but it's old ask-API based function.
It's not comfortable if you want to avoid dialog or template.
Addresses: https://github.com/karelzak/util-linux/issues/916
Signed-off-by: Karel Zak <kzak@redhat.com>
It's possible that caller has the device already opened for some
other task, so let's reuse the file descriptor.
Requested-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
This small change improves possibility to modify by script described
PT and use script API in another tools as primary way to create
partitions.
All you need is to compose script by fdisk_script_set_header() and
fdisk_script_set_table() and than apply by fdisk_apply_script().
Requested-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's provide API for applications that don't want to use the default
1MiB grain. The new function allow to use "as minimal as possible" if
grain is set by fdisk_save_user_grain() to 512.
If the phy sector size (or minimal I/O size) is greater than specified
grain size than smallest possible setting is used.
Signed-off-by: Karel Zak <kzak@redhat.com>
The default (for historical reasons) is to use dialog driven partitioning.
It's possible to avoid dialogs by fdisk_partition template for
fdisk_add_partition().
Unfortunately in some case (mostly DOS driver) it's not enough, because
we need to distinguish between logical and primary partitions. If we know
that dialogs are unwanted then we can default to primary partition, etc.
This function simplify semantic of the library for non-interactive
programs.
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch introduces fdisk_reread_changes(). The function is
less invasive alternative to fdisk_reread_partition_table().
The new function uses BLKPG ioctls for modified partitions. The
another partitions are not affected. This solution allows to
successfully use fdisks on disk where some partitions are still use
(mounted). For example if you want to resize the last partition on the
device.
Signed-off-by: Karel Zak <kzak@redhat.com>
Now libfdisk provides functionality wipe disk device only ([s]fdisk
option --wipe).
This patch allows to probe for filesystems/RAIDs on newly created
partitions. It means we can remove signatures before the partition
node (device) is created. This reduces udev events and it's
unnecessary to call wipefs for all partitions. For example
sfdisk --wipe=always --wipe-partitions=always /dev/sda <<<
...
EOF
is a elegant way how to create new disk layout without any obsolete
filesystems/RAIDs.
Signed-off-by: Karel Zak <kzak@redhat.com>
Now libfdisk warns if another filesystem/RAID/PT signature is detected
on the device. It seems better and user-friendly to make it possible to
wipe the signatures when we write a new disk label to the device.
This patch adds to the library API
fdisk_enable_wipe()
fdisk_has_wipe()
fdisk_get_collision()
to control this new feature. The device modification is done by
libblkid (the same we use in some mkfs-like utils).
Signed-off-by: Karel Zak <kzak@redhat.com>
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 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>