Commit Graph

49 Commits

Author SHA1 Message Date
Karel Zak d58121a22a docs: update copyright years
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-31 18:12:07 +02:00
Karel Zak f11fe35f5e libfdisk: (docs) add missing references
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-07-22 10:33:53 +02:00
Karel Zak 967b8c2579 libfdisk: (docs) document new functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-09 10:50:42 +02:00
Karel Zak 387ac2771f libfdisk: (gpt) add functionality to move backup header
- 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>
2020-02-05 14:37:41 +01:00
Karel Zak e5f3144616 libfdisk: add fdisk_set_disklabel_id_from_string()
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>
2020-01-23 15:50:12 +01:00
Karel Zak 24cee7157a docs: update year in libs docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-06 12:59:45 +01:00
Karel Zak 7571ec08a1 libfdisk: add fdisk_assign_device_by_fd()
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>
2019-06-18 13:30:42 +02:00
Karel Zak bfdca6d728 libfdisk: add fdisk_script_set_table()
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>
2019-06-17 15:46:10 +02:00
Karel Zak cbfd67cfea libfdisk: (docs) add reference to v2.33
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-07 12:30:13 +02:00
Karel Zak ab295603e9 libfdisk: (docs) add missing function
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-19 12:00:59 +02:00
Karel Zak 745801e44a libfdisk: add fdisk_get_devmodel() and fdisk_get_devno()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-30 14:01:46 +02:00
Karel Zak cd42d02ff2 libfdisk: (docs) update year
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-03-20 18:55:49 +01:00
Karel Zak ed930a9b89 libfdisk: fix docs warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-21 13:23:08 +01:00
Karel Zak 9070c2e200 libfdisk: (docs) add missing docs blocks
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-21 13:12:12 +01:00
Ruediger Meier 73afd3f8e8 misc: fix typos using codespell
Some more funny typos, please review carefully.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-02-16 11:12:52 +01:00
Karel Zak adf09b5c38 libfdisk: add fdisk_save_user_grain()
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>
2017-08-22 14:55:51 +02:00
Karel Zak 992f7cbae4 libfdisk: add fdisk_disable_dialogs()
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>
2017-07-19 11:30:57 +02:00
Karel Zak 1dd63a3b05 libfdisk: use BLKPG ioctls to inform kernel about changes
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>
2017-07-14 11:34:55 +02:00
Karel Zak b9da153254 libfdisk: add fdisk_device_is_used()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-14 11:34:55 +02:00
Karel Zak 6a1889b03b libfdisk: move fdisk_reread_partition_table() to another file
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-14 11:33:30 +02:00
Karel Zak 2469ba3677 libfdisk: add fdisk_reassign_device()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-10 12:32:26 +02:00
Karel Zak f854eca369 libfdisk: update docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-23 14:22:04 +02:00
Karel Zak 8d3e3e6b4d libfdisk: (docs) add missing 'since' tags
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-23 14:02:14 +02:00
Karel Zak 29f2e825d8 libfdisk: add fdisk_partition_has_wipe()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-09 14:30:02 +02:00
Karel Zak 0cec78a3c4 libfdisk: classify collision type
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-14 14:23:45 +01:00
Karel Zak 7526c305b4 libfdisk: don't use blkdev ioctls for regular files
$ fdisk <diskimage>

open("sdc.img", O_RDONLY|O_CLOEXEC)     = 3
ioctl(3, BLKSSZGET, 0x7ffcf51357c4)     = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(3, BLKGETSIZE64, 0x7ffcf51357b0)  = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(3, BLKGETSIZE, 0x7ffcf51356c8)    = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(3, FDGETPRM, 0x7ffcf51356d0)      = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(3, HDIO_GETGEO, 0x7ffcf5135790)   = -1 ENOTTY (Inappropriate ioctl for device)

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-01-13 11:23:23 +01:00
Sébastien Helleu d673b74e9d docs: replace FTP by HTTPS in kernel.org URLs
The links to ftp://ftp.kernel.org/ are replaced by
https://www.kernel.org/.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 11:22:26 +01:00
Karel Zak 81b176c4da docs: some random fixes
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-27 12:52:47 +02:00
Karel Zak be163aa0da libfdisk: (docs) add missing version notes
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-27 11:58:32 +02:00
Karel Zak f88eeb25f2 libfdisk: cleanup fdisk_gpt_set_npartitions()
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-06-21 14:21:30 +02:00
Sebastian Rasmussen d35df4db5b docs: Fix various typos
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Karel Zak 40c9c3a6b7 libfdisk: add API for work with labelitems
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-12 14:37:29 +02:00
Karel Zak 131e38a28e libfdisk: add fdisk_wipe_partition()
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>
2016-05-04 12:32:52 +02:00
Karel Zak 6cbb7371b3 libfdisk: add API to control signatures wiping
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>
2016-02-18 12:58:12 +01:00
Karel Zak 3c7fde5f92 libfdisk: add JSON dump output
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-15 13:18:09 +02:00
Karel Zak d5dbd57b22 docs: fix gtk-docs related warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-28 12:28:23 +02:00
Karel Zak 31ea7fa6d4 libfdisk: add fdisk_label_get_fields_ids_all()
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>
2015-05-11 12:42:24 +02:00
Michael Marineau 4a4a0927c6 libfdisk: (gpt) add API for raw partition attributes
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>
2015-05-05 12:39:36 +02:00
Karel Zak b17c1f1447 libfdisk: add fdisk_table_get_partition_by_partno()
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-22 12:21:19 +02:00
Karel Zak 3457d90e30 libfdisk: support bootbits protection from (p)MBR
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-13 13:40:25 +02:00
Karel Zak 5cdbe36fbc libfdisk: add fgets() callback for scripts
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-25 16:05:14 +01:00
Karel Zak 4863ddaddf libfdisk: add some docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-10 13:17:29 +01:00
Karel Zak a473657eac libfdisk: (docs) fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-20 10:34:19 +01:00
Karel Zak 354f8cc8cf libfdiskL add API to print SIZE field in bytes
The patch also add --bytes to fdisk and fdisk.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-19 11:24:48 +01:00
Karel Zak 791da22d0e libfdisk: add version.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-13 13:46:31 +01:00
Karel Zak 2b6c532e17 docs: update API docs years
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-13 12:03:17 +01:00
Karel Zak 0c07055c39 libfdisk: cleanup gtk-docs warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-13 11:45:19 +01:00
Karel Zak bbfc24298f libfdisk: remove 'end' from struct fdisk_partition
This struct member duplicate "start+size".

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-04 12:24:31 +01:00
Karel Zak 705854f307 libfdisk: add API docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-26 19:13:57 +01:00