fdisk: API: add label probing functionality

This patch sets the initial layout for label specific operations. A
new fdisk_label structure is created that will hold all these ops,
like new, delete, write and probe, among others. For now only probing
is implemented. Once this design is established, a copy of the probed
label will be copied to the main context structure, where calling the
specific functions will save 'disklabel' checks. Debugging support is
added as well.

This patch passes regression tests and manually passes bsd, sun, dos
and sgi labels probes.

Reviewed-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
This commit is contained in:
Davidlohr Bueso 2012-07-08 23:40:27 +02:00 committed by Karel Zak
parent 4e80697552
commit b8855c868f
15 changed files with 96 additions and 34 deletions

View file

@ -520,27 +520,6 @@ update_sector_offset(struct fdisk_context *cxt)
* 1: I/O error
*/
static int get_boot(struct fdisk_context *cxt, int try_only) {
disklabel = ANY_LABEL;
update_units(cxt);
if (!check_dos_label(cxt))
if (check_sun_label(cxt) || check_sgi_label(cxt) || check_aix_label(cxt)
|| check_mac_label(cxt))
return 0;
if (check_osf_label(cxt)) {
/* intialize partitions for BSD as well */
dos_init(cxt);
if (!valid_part_table_flag(cxt->mbr)) {
disklabel = OSF_LABEL;
return 0;
}
printf(_("This disk has both DOS and BSD magic.\n"
"Give the 'b' command to go to BSD mode.\n"));
return 0;
}
if (disklabel == ANY_LABEL) {
if (try_only)
return -1;