summaryrefslogtreecommitdiff
path: root/fdisks/fdisk.c
AgeCommit message (Collapse)AuthorFilesLines
2013-03-11fdisk: use libfdisk label->changedKarel Zak1-46/+27
The patch is huge because it's necessary to add a pointer context to all read_<foo> functions. Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11fdisk: (sun) remove nasty sunlabel macroKarel Zak1-2/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11libfdisk: (gpt) introduce driver independent partitions countersKarel Zak1-2/+15
label->nparts_{max,cur} to later replace global variable partitions Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11libfdisk: move label identifier to label structKarel Zak1-4/+11
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11libfdisk: kill dos_compatible_flag global variableKarel Zak1-15/+31
... move the variable to label private struct. Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11libfdisk: add fdisk_new_context(), reuse contextKarel Zak1-16/+16
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11libfdisk: add topology and geometry functionsKarel Zak1-11/+7
- rename __discovery_* to fdisk_discovery_* - rename fdisk_context_force_sector_size() to fdisk_override_sector_size() - rename fdisk_context_set_user_geometry() to fdisk_override_geometry() - remove non-default sector size warning Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11libfdisk: add alignment codeKarel Zak1-89/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-04fdisk: (gpt) align newly created partitionsKarel Zak1-0/+16
- 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>
2012-12-04fdisk: report PT type, inform about new GPTKarel Zak1-0/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-03fdisk: move DOS units stuff to fdiskdoslabel.cKarel Zak1-47/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-03fdisk: remove global variable sector_offsetKarel Zak1-61/+9
- 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>
2012-11-30fdisk: remove dead codeDavidlohr Bueso1-9/+0
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-11-30fdisk: api: move disklabel type to cxtDavidlohr Bueso1-94/+97
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>
2012-11-13fdisk: don't offer GPT stuff in BSD menuKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-02gpt: create empty disklabelsDavidlohr Bueso1-0/+4
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>
2012-10-18fdisk: fix segfault when printing gpt raw dataDavidlohr Bueso1-1/+2
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-10-18fdisk: api: propagate partition deletion to usersDavidlohr Bueso1-2/+4
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>
2012-09-27fdisk: add GPT supportDavidlohr Bueso1-19/+14
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>
2012-09-27fdisk: use fdisk_parttype in add_partitionKarel Zak1-5/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27fdisk: add fdisk_set_partition_type()Karel Zak1-69/+14
- 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>
2012-09-27fdisk: add fdisk_get_partition_type()Karel Zak1-19/+5
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27fdisk: add new functions for work with fdisk_parttypeKarel Zak1-59/+70
- 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>
2012-09-27fdisk: improve list partition typesKarel Zak1-28/+51
- add fdisk_parttype->typestr for types like GPT UUID or Mac - list typestr if specified Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27fdisk: move partition types to label specific partKarel Zak1-18/+14
- 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>
2012-07-31fdisk: cast before count sizeKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26fdisk: don't print CHS geometry unless DOS compatible mode is setPetr Uzel1-3/+3
References: http://marc.info/?l=util-linux-ng&m=134329693623430&w=2 Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-07-26fdisk: always print total number of sectorsPetr Uzel1-4/+3
Print it no regardless on units_per_sector. Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-07-26fdisk: fix typoPetr Uzel1-1/+1
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-07-26fdisk: make grain global variable part of fdisk_context()Petr Uzel1-9/+8
There is no reason for this to be global variable - it belongs to the context. Signed-off-by: Petr Uzel <petr.uzel@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26fdisk: add noreturn function attributeSami Kerola1-1/+2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-24Revert "fdisk: de-duplicate disk label strings"Karel Zak1-3/+3
... because it's not expected that fdisk_label will be exported by API and accessible for applications (like fdisk.c). It's private libfdisk stuff. This reverts commit e7818642600d6cd573a8e1ed5363fce52def5821.
2012-07-24fdisk: de-duplicate disk label stringsBernhard Voelker1-3/+3
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-07-24fdisk: fix compiler warning [-Werror=unused-variable]Petr Uzel1-1/+0
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-07-24fdisk: don't ignore 1MiB granularity on 512-byte sector devicesKarel Zak1-2/+15
Note that +10MB is 100000 (10^N) and relative values (+<size> convention) should be be aligned to the default grain (= 1 MiB). Old version: Last sector, +sectors or +size{K,M,G} (2048-2047999, default 2047999): +10MB Partition 1 of type Linux and of size 9.5 MiB is set ... /dev/loop0p1 2048 21578 9765+ 83 Linux /dev/loop0p2 21579 43062 10742 83 Linux New version: Last sector, +sectors or +size{K,M,G} (2048-2047999, default 2047999): +10MB Partition 1 of type Linux and of size 10 MiB is set ... /dev/loop0p1 2048 22527 10240 83 Linux /dev/loop0p2 22528 43007 10240 83 Linux Addresses: http://thread.gmane.org/gmane.linux.kernel.device-mapper.dm-crypt/5913/focus=5929 Reported-by: Milan Broz <mbroz@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-24fdisk: API: add fdisk_label_changeDavidlohr Bueso1-4/+4
[kzak@redhat.com: - rename function - remove fdisk_create_default_disklabel()] Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-07-24fdisk: API: add verify to label operationsDavidlohr Bueso1-76/+10
[kzak@redhat.com: - rename some functions] Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-24fdisk: API: add new partition to label operationsDavidlohr Bueso1-29/+9
Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-07-24fdisk: API: add write to label operationsDavidlohr Bueso1-17/+6
[kzak@redhat.com: - rename functions - use errno] Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-07-23fdisk: API: add delete partition to label operationsDavidlohr Bueso1-16/+5
Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-23fdisk: API: add to label operations to contextDavidlohr Bueso1-2/+2
The context structure is the fdisk API's main data type as it keeps all data together. Add the label structure to it, so that the pt-specific operations can be called from the context. [kzak@redhat.com: - merge with latest changes - don't allocate the label, use const pointer] Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-07-23fdisk: rename cxt->mbr buffer to cxt->firstsectorKarel Zak1-1/+1
MBR is regular name for DOS partition table, let use less confusing name for the buffer. Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-23fdisk: move label specific stuff to fdiskdoslabel.cKarel Zak1-5/+0
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-23fdisk: move DOS geometry code from generic part to label specificKarel Zak1-35/+5
get_partition_table_geometry() should be called from DOS code Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-23fdisk: get_boot() has to die (step II.)Karel Zak1-17/+7
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-23fdisk: get_boot() has to die (step I.)Karel Zak1-9/+6
- move generic stuff around "create disklabel" operation to API Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-23fdisk: move user geometry setting from fdisk.c to APIKarel Zak1-26/+12
- to avoid duplicate code - to remove fdisk_geom_set_cyls() from API Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-16Merge branch '2012wk28'Karel Zak1-21/+20
* 2012wk28: translation: unify file open error messages translation: unify stat error messages utmpdump: use help and version output macros su: align with howto-usage-function fdisk: make if clause easier to read look: remove extra semicolon utmpdump: remove unused variable swapon: remove unused variables lib/loopdev: minor bug fix: add missing semicolon lib/pager: minor compiler warning fixes libblkid: remove duplicate entries in symbols
2012-07-16translation: unify file open error messagesSami Kerola1-3/+3
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16fdisk: make if clause easier to readSami Kerola1-19/+18
Signed-off-by: Sami Kerola <kerolasa@iki.fi>