Let's print number of detected errors or "No errors detected." for
MBR. We already use the same for GPT.
The patch also modifies fdisk_verify_disklabel() return code to inform
caller about number of issues.
Addresses: https://github.com/karelzak/util-linux/issues/1051
Signed-off-by: Karel Zak <kzak@redhat.com>
The current code implements the default start as first free space, but
it does not check if the space is large enough.
Addresses: https://github.com/karelzak/util-linux/issues/1044
Signed-off-by: Karel Zak <kzak@redhat.com>
It seems the previous MAXIMUM_PARTS bug fix has not been generic
enough. Let's use the check for all dos_add_partition().
This patch also remove libfdisk attempt to be smart and search for
unused primary partition. If you need more than 60 partition in MBR
than you have a different problem that cannot be solved by libfdisk
...
References: b80fb30a5b
Addresses: https://github.com/karelzak/util-linux/issues/1022
Signed-off-by: Karel Zak <kzak@redhat.com>
The include/partx.h interface we use in util-linux uses 512-byte
sectors, but libfdisk uses real sector sizes.
Signed-off-by: Karel Zak <kzak@redhat.com>
Now, the type shortcuts are supported for sfdisk scripts only.
Unfortunately, the current implementation is not generic enough
and it's also fragile as 'E' shortcut is in collision with 0x0E
type for MBR. The another issue is 'L' which makes shortcuts useless
for fdisk where 'L' is used for another purpose in dialogs.
This patch introduces partition type aliases as extension to
shortcuts. The definition of the shortcut is part of the label
definition and it's not more hardcoded in sfdisk script code.
This patch also introduces 'Ex' shortcut as replacement for (now
deprecated) 'E'.
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/gpt.c:1713:6: warning: assuming pointer wraparound does not
occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
- 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>
- add sector-size between supported headers (already in --dump output)
- report unknown headers by -ENOTSUP
- ignore ENOTSUP in sfdisk (but print warning) and in fdisk_script_read_file()
Addresses: https://github.com/karelzak/util-linux/issues/949
Signed-off-by: Karel Zak <kzak@redhat.com>
- move all calculations to inline functions
- remove duplicate code
- keep the same names for the same stuff
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>
libfdisk chooses a grain of 1MB fairly arbitrarily, and this granule
may not be honored by other utilities. GPT disks formatted elsewhere
may have space before the first partition, AND a partition that exists
solely below 1MB. If this occurs, cfdisk ends up adding a free space
region where end < start, resulting in a 16 Exabyte free region.
That's too many exabytes.
This happens because the start gets rounded up to the granule size in
new_freespace() but the end is left alone. The logs show it best:
23274: libfdisk: CXT: [0x572d878]: initialized: last=34, grain=2048
23274: libfdisk: CXT: [0x572d878]: partno=10, start=64
23274: libfdisk: CXT: [0x572d878]: freespace analyze: partno=10, start=64, end=64
23274: libfdisk: CXT: [0x572d878]: LBA 34 aligned-up 2048 [grain=2048s]
23274: libfdisk: CXT: [0x572d878]: LBA 63 aligned-down 0 [grain=2048s]
23274: libfdisk: CXT: [0x572d878]: LBA 34 aligned-near 0 [grain=2048s]
23274: libfdisk: CXT: [0x572d878]: 0 in range <2048..0> aligned to 2048
23274: libfdisk: PART: [0x574bb98]: alloc
23274: libfdisk: TAB: [0x5749d58]: adding freespace
23274: libfdisk: TAB: [0x5749d58]: insert entry 0x574bb98 pre=0x574a820 [start=2048, end=63, size=18446744073709549632, freespace ]
Avoid this by aligning the last value like new_freespace() does.
Signed-off-by: Evan Green <evangreen86@gmail.com>
Sorry detail-oriented people tend to wipe these out if they notice them.
Add in automated tools and lots of excess end-of-line spaces get wiped
out.
Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
* current code overwrites hybrid MBR because EE partition
is expected from fist sector, this is not true for hybrid MBR
* print "The partition table has been altered." message also for
nested contexts
* remove "You have to sync the MBR manually" message
Addresses: https://github.com/karelzak/util-linux/issues/851
Signed-off-by: Karel Zak <kzak@redhat.com>
The traditional MBR has pretty well NO limitations on slices. They can
be a single misaligned sector if desired. While this is undesireable
for most real world uses, for the few places they're still used extra
limitations cause breakage not safety.
Signed-off-by: Karel Zak <kzak@redhat.com>
We do not use sector-size from dumps to create partition tables,
because it's always necessary to use real device specific settings.
The new sector-size value is usable when you use the dump as
a description of the device or disk image.
Addresses: https://github.com/karelzak/util-linux/issues/869
Signed-off-by: Karel Zak <kzak@redhat.com>
The current implementation does not allow to move partition for
example in +/-1 sector range, because free space analyze is by default
based on regular grain used for partitioning (=1MiB).
Signed-off-by: Karel Zak <kzak@redhat.com>
The code uses last_sector -= 1 for tiny partitions. This does not make
sense. This stupidity has been introduced by (my) badly commented commit
09a4ca5e45 ... sorry.
Fortunately, this issue is visible only for tiny partitions on large
devices (partitions where size < grain; usual grain is 1MiB) if the last
sector is specified by relative notation (+size{siffix}).
Note that "last -= 1" makes sense when the "last" is align to the
optimal I/O boundary; in this case we need to set the end of the
partition one sector before the boundary. For tiny devices it does not
makes sense as we do not align these partitions.
Addresses: https://github.com/karelzak/util-linux/issues/843
Signed-off-by: Karel Zak <kzak@redhat.com>
The unnamed-field format supports partition type shortcuts:
",1MiB,L'
but for named-field format it requires full type:
(mbr) "size=1MiB,type=83"
(gpt) "size=1MiB,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4"
This patch implements type shortcuts also for named-field format:
"size=1MiB,type=L"
to make it more user-friendly and unified.
Addresses: https://github.com/karelzak/util-linux/issues/837
Signed-off-by: Karel Zak <kzak@redhat.com>