Commit Graph

68 Commits

Author SHA1 Message Date
Karel Zak fcd9a2a42d fdisk: cleanup header file
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:08 +02:00
Karel Zak a47fec81b2 fdisk: allow to exchange context pointer in menu callbacks
... to make it possible to switch to nested contexts (nested partition
tables).

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:06 +02:00
Karel Zak c10937dcaf fdisk: remove nowarn global variable
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:04 +02:00
Karel Zak bb58112e74 fdisk: (dos) remove unnecessary header file stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:04 +02:00
Karel Zak c37ebc12a5 fdisk: cleanup header file
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:04 +02:00
Karel Zak f02fecd19a fdisk: (dos) add dos menu callback
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:04 +02:00
Karel Zak f540fe15c3 fdisk: (dos) rename struct partition to dos_partition
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:02 +02:00
Karel Zak 6864f1681a fdisk: (dos) rename members in struct pte
... to make it more readable.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:01 +02:00
Karel Zak 76add3b235 fdisk: move dos specific code
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:01 +02:00
Karel Zak 9604138d17 fdisk: remove dead code
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:01 +02:00
Karel Zak 5497ba0442 fdisk: move get_nr_sects() fdisk.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:01 +02:00
Karel Zak afb7c83520 fdisk: remove old code to ask user
Old code has been broken by design:

 * use global variables
 * fixed buffer size
 * useless within libfdisk

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:01 +02:00
Karel Zak 950edd1a71 fdisk: use libfdisk to ask for partition type
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:01 +02:00
Karel Zak 918afd3f1a fdisk: remove ugly fatal() function
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:59 +02:00
Karel Zak a410f8df0f fdisk: use new menu infrastructure to verify keys
- use generic function to ask for key
 - verify the key against the current menu
 - call menu callback if defined

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:56 +02:00
Karel Zak 39f01b7b2b fdisk: use new menus
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:55 +02:00
Karel Zak b4bfbaddfa libfdisk: (sun) move driver from fdisk to library
... and also add fdisk_info_new_partition()

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:54 +02:00
Karel Zak 641a75ca99 fdisk: use fdisk_ask_partnum() everywhere
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 13:00:58 +01:00
Karel Zak ec10aa6782 fdisk: remove global unit variables
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 13:00:57 +01:00
Karel Zak 416c43a9a5 fdisk: add callback for ask-numbers API
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 13:00:54 +01:00
Karel Zak e3661531e6 fdisk: (dos) kill 'partitions' global variable
... and use size_t for partition numbers

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 12:47:31 +01:00
Karel Zak 62a7b31332 fdisk: (dos) move dos specific code
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 12:47:31 +01:00
Karel Zak cc0c4e56aa fdisk: (dos) move dos specific code
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 12:47:31 +01:00
Karel Zak 5dfca6343b fdisk: (dos) move dos_list_table_expert() to fdiskdoslabe.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 12:47:30 +01:00
Karel Zak dfc96cbf1f fdisk: (dos) move fix order code to fdiskdoslabe.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 12:47:30 +01:00
Karel Zak 6d864a495c fdisk: (dos) move list table code to fdiskdoslabe.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 12:47:30 +01:00
Karel Zak bddd84e7c5 fdisk: use libfdisk label->changed
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-11 12:47:30 +01:00
Karel Zak 171372d37c libfdisk: cleanup the rest of fdisks/utils.c stuff
- remove obsolete code
 - move fdisk_{set,get}_partition_type() to label.c (this is label
   driver operation)

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 12:47:28 +01:00
Karel Zak f4be9e2b99 libfdisk: add context functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 12:46:37 +01:00
Karel Zak 7ce1097533 libfdisk: add probing function
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 11:20:41 +01:00
Karel Zak c578f9af72 libfdisk: add fdisk_reset_alignment()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 11:20:41 +01:00
Karel Zak aa42788d5f libfdisk: add topology and geometry functions
- 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-11 11:20:41 +01:00
Karel Zak 3eb78aa745 libfdisk: add firstsector utils
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 11:20:41 +01:00
Karel Zak 8adbcf0ce9 libfdisk: add generic label code
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 11:20:40 +01:00
Karel Zak 9475cc78ff libfdisk: add alignment code
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 11:20:40 +01:00
Karel Zak a5fe1b3f1d libfdisk: add parttype code
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 11:20:40 +01:00
Karel Zak a8019843ab libfdisk: add basic structs
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 11:20:40 +01:00
Karel Zak f3744ac569 fdisk: use debug stuff from libfdisk
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 11:20:40 +01:00
Karel Zak 512a430fe7 fdisk: (gpt) align newly created partitions
- 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-04 17:54:15 +01:00
Karel Zak 3c88fb56b6 fdisk: move DOS units stuff to fdiskdoslabel.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-03 16:22:17 +01:00
Karel Zak cf3808e468 fdisk: remove global variable sector_offset
- 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-12-03 15:48:31 +01:00
Davidlohr Bueso 8254c3a594 fdisk: api: propagate add partitions to users
Similarly to commit 1f5eb51b79 we
do not propagate problems when adding partitions to user visible
api.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-11-30 13:48:27 +01:00
Davidlohr Bueso ff5775bd4f fdisk: api: move disklabel type to cxt
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-30 13:48:19 +01:00
Karel Zak 21770662c3 fdisk: don't fails silently if EBR is outside of disk
Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-30 11:54:10 +01:00
Davidlohr Bueso 1f5eb51b79 fdisk: api: propagate partition deletion to users
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-10-18 12:15:33 +02:00
Davidlohr Bueso 766d5156c4 fdisk: add GPT support
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-27 13:38:14 +02:00
Karel Zak ed470672bb fdisk: use fdisk_parttype in add_partition
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
Karel Zak 02460b8aae fdisk: add fdisk_set_partition_type()
- 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-27 13:38:13 +02:00
Karel Zak 010186f2a2 fdisk: add fdisk_get_partition_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
Karel Zak 559d921eda fdisk: add new functions for work with fdisk_parttype
- 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-27 13:38:13 +02:00