To fix 'make distcheck' compilation. The fdisks/Makemodule.am has one
new entry 'dos_part_types.h', the rest is about sorting the list.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
- default "First sector" has to be aligned
- "Last sector" has to be aligned if specified by +<size><suffix> convention
Signed-off-by: Karel Zak <kzak@redhat.com>
- always use pointers to make the code more generic
- always use "const" is possible
- always use le64_to_cpu() to access numbers
Signed-off-by: Karel Zak <kzak@redhat.com>
- add cxt->first_lba as replacement to sector_offset
- add label->reset_alignment() to overwrite the default alignment setting
- add fdisk_reset_alignment() to setup grain, first LBA offset, etc.
Signed-off-by: Karel Zak <kzak@redhat.com>
Get rid of it as a global variable as it belongs in the context.
To compare a disklabel on the device, the fdisk_dev_is_disklabel()
function is introduced. Also, to avoid naming issues, the fdisk_labeltype
members where renamed to FDISK_DISKLABEL_<type>.
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
UEFI states that the size of the GPT header must be between 92 and
the sector size. Add the check when verifying a valid header.
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
This patch enables creating a new, empty, GPT disklabel from either
an empty disk or one that already has a disklabel. For this
purpose, a 'g' option is added to the main menu and is visible to all
labels. Here's an example for a scsi_debug device (/dev/sdb):
...
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x20a614c8.
3696: fdisk: CONTEXT: zeroize in-memory first sector buffer
Command (m for help): g
3696: fdisk: LABEL: changing to gpt label
3696: fdisk: CONTEXT: zeroize in-memory first sector buffer
3696: fdisk: LABEL: created new empty GPT disklabel (GUID: D4EA0706-F011-46DC-B7DE-6A72C7090AF8)
Command (m for help): w
The partition table has been altered!
...
Acked-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
We were writing only 1 byte in LBA0, and GPT requires dealing with an entire
sector. This bug wasn't affecting when dealing with already existing devices
with GPT as we weren't writing an important part of the first sector, thus
leaving it unchanged. Also use write_all() wrapper from all-io.h
Acked-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
The generic fdisk_delete_partition() function returns 0 when a partition
is correctly deleted, otherwise it's corresponding error (negative values).
This, however, does not include problems that can occur in actual label
specific contexts, so we need to propagate the corresponding return code,
back to the user visible api.
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
This patch allows fdisk to handle GUID partition tables, based on the latest UEFI specifications
version 2.3.1, from June 27th, 2012. The following operations are supported:
- Probing (detects both protective and hybrid MBRs)
- Writing to disk
- Listing used partitions
- Adding partitions
- Deleting partitions
- Data integrity verifications (for both headers and partitions).
A few considerations:
- Currently we do not fix invalid primary headers -- we just abort!
- Header checksums are updated upon every change (ie: add/delete partitions), this allows us
to mathematically verify the changes on-the-fly, and not only when writing to disk, like
most other related tools do.
- We are extremly picky when writing to disk, any error aborts the opeartion.
- When creating a new partition, the following GUIDs are available:
http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs
For test cases, the gpt.img from libblkid tests, scsi_debug and my own hard drive (/dev/sda) were used.
For the image, all operations were tested successfully, and for /dev/sda all except write, which
was not tested - hey, I'm not suicidal!
[kzak@redhat.com: - add get/set partition type functions
- use unified on strings based table for partition types
- add partition type to table list function]
Tested-and-reviewed-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
- remove all label specific partition type stuff from fdisk.c to
label files
- add new fdisk_set_partition_type() to API
Signed-off-by: Karel Zak <kzak@redhat.com>
- add flags to fdisk_parttype to store more information about the types
- function for conversion from code to fdisk_parttype
- function for conversion from string to fdisk_parttype
- function for conversion from user input to fdisk_parttype
- support for unknown complex types (e.g. unknown UUIDs)
Signed-off-by: Karel Zak <kzak@redhat.com>
- move MBR partition types to dos_part_types.h
- make dos_part_types.h independent on datetypes to keep it useful in
all fdisks
- add struct fdisk_parrtype
- move label specific partition types to context->label
Signed-off-by: Karel Zak <kzak@redhat.com>
The proper specifier for size_t is %zu. %lu will work fine on 64-bit
architectures but not on 32-bit.
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
* fdisks/utils.c: s/firts/first/: found by misspellings.
s/Zero's/Zeros/: denoted by Pádraig Brady <P@draigBrady.com>.
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>