summaryrefslogtreecommitdiffstats
path: root/libfdisk
Commit message (Collapse)AuthorAgeFilesLines
* libfdisk: Add GPT type GUID for Itanium Linux rootAndrew Wilcox2016-01-121-0/+1
| | | | | | References: http://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/ Signed-off-by: Andrew Wilcox <awilfox@adelielinux.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: Detect out-of-space when adding new primary partitionIan Wienand2015-10-091-1/+4
| | | | | | | | | | | | | | | | | | | | | | I got a bit confused with the interaction below: Command (m for help): p Disk /dev/sda: 41 GiB, 43965677568 bytes, 85870464 sectors ... Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 1026047 1024000 500M 83 Linux /dev/sda2 1026048 85868543 84842496 40.5G 8e Linux LVM Command (m for help): n To create more partitions, first replace a primary with an extended partition. I knew I should have had two primary partitions available, but I did not notice that the disk was seen as full (I was trying to grow it) This change detects available primary partitions, and if so indicates we are out of space, rather than out of partitions. Signed-off-by: Ian Wienand <iwienand@redhat.com>
* lib/crc32: don't require to modify GPT headerKarel Zak2015-09-241-46/+35Star
| | | | | | | | | | 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>
* libfdisk: fix partition move/resize codeKarel Zak2015-09-172-9/+24
| | | | | | | | | - 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>
* libfdisk: add more debug message to resize codeKarel Zak2015-09-171-4/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) control ranges in set_partitionKarel Zak2015-09-172-3/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) reorder only when necessaryKarel Zak2015-09-023-5/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (bsd) add note about non-written parental MBRKarel Zak2015-08-311-1/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Fix trivial typosYuri Chornoivan2015-08-252-2/+2
|
* libfdisk: (gpt) fix label pointer usage [smatch scan]Karel Zak2015-08-051-1/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: remove impossible condition [smatch scan]Karel Zak2015-08-051-3/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: make context->label usage more robust [smatch scan]Karel Zak2015-08-052-3/+4
|
* build-sys: add --disable-assertKarel Zak2015-08-042-9/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: cleanup assert() usageKarel Zak2015-08-045-35/+10Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: allow to change partition type for extended partitionsKarel Zak2015-07-301-10/+51
| | | | | Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1248115 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: result of operation is garbage or undefined [clang analyze]Karel Zak2015-07-291-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: undefined or garbage value returned to caller [clang analyze]Karel Zak2015-07-291-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add comment to the header fileKarel Zak2015-07-241-31/+31
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix fdisk_label_parse_parttype() for unknown typesKarel Zak2015-07-151-5/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) add missing GUIDsKarel Zak2015-07-151-2/+34
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add GPT GUIDs for PRePScott Moser2015-07-151-0/+3
| | | | | | Power Firmware (OFW) scans chosen devices for PReP partition IDs. Signed-off-by: Scott Moser <smoser@ubuntu.com>
* libfdisk: (gpt) fix "MidnightBSD UFS" UUIDKarel Zak2015-07-151-1/+1
| | | | | Reported-by: Андрей Гаврилин <gaal.dev@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add GPT GUIDs for ARMsKarel Zak2015-06-221-0/+2
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/203 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: ignore misaligned optimal I/O sizeKarel Zak2015-06-181-3/+12
| | | | | | | | | | | | | | | | | | 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>
* libfdisk: add JSON dump outputKarel Zak2015-06-154-10/+182
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: rename script functions to improve readabilityKarel Zak2015-06-151-6/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add new API to read label specific dataKarel Zak2015-06-119-150/+427
| | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* libfdisk: (dos) fix cylinders calculationKarel Zak2015-06-101-10/+5Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: differentiate between +<sector> and +<size>{M,G,...}Karel Zak2015-06-102-10/+6Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: improve +0 partition sizeKarel Zak2015-06-082-32/+52
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) fix tiny partitions calculationKarel Zak2015-06-081-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) make it possible to create really small partitionsKarel Zak2015-06-081-2/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: support alignment to non power of 2Karel Zak2015-06-081-7/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* docs: fix gtk-docs related warningsKarel Zak2015-05-282-1/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: Use predictable /dev/mapper partition names for /dev/dm-NStanislav Brabec2015-05-281-3/+13
| | | | | | | | | | 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>
* Use correct partition names for /dev/mapperStanislav Brabec2015-05-261-2/+4
| | | | | | | | | | | | | | 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>
* libfdisk: keep FDISK_FIELD_CYLINDERS independent on context modeKarel Zak2015-05-111-2/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add fdisk_label_get_fields_ids_all()Karel Zak2015-05-114-5/+53
| | | | | | | | 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>
* libfdisk: (gpt) fix attributes endianessRuediger Meier2015-05-111-4/+4
| | | | | | | | | | | 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>
* libfdisk: (gpt) add API for raw partition attributesMichael Marineau2015-05-055-0/+138
| | | | | | | | | | | | | | | | | 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>
* libfdisk: (gpt) fix check for beginning of protective partitionMichael Marineau2015-05-051-7/+7
| | | | | | | | | | 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>
* libfdisk: (gpt) add extra check for First/Last LBAKarel Zak2015-04-231-0/+15
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) fix end sector calculation on resizeKarel Zak2015-04-231-2/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix scriptk parser to support alone signsKarel Zak2015-04-221-6/+8
| | | | | | for example echo "- - - *" | sfdisk /dev/sda1 -N1 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: allow to move start to first usable LBAKarel Zak2015-04-221-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add warning to resize functionKarel Zak2015-04-221-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: support resize operation in fdisk_set_partition()Karel Zak2015-04-221-14/+227
| | | | | | | Note that the resize is not exported by API yet, the only way to use it is sfdisk-like scripts. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add fdisk_table_get_partition_by_partno()Karel Zak2015-04-224-1/+40
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix script parser to support resize operationsKarel Zak2015-04-222-4/+41
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: don't resize in label driversKarel Zak2015-04-222-36/+0Star
| | | | | | The resize operation has to be implemented on upper layer. Signed-off-by: Karel Zak <kzak@redhat.com>