From 0adf9412b786342346a9df9fd262765d6b97d38f Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Sat, 28 Mar 2015 02:42:02 +0100 Subject: try to detect recovery partitions on GPT --- perl-install/NEWS | 1 + perl-install/c/stuff.xs.pl | 25 +++++++++++++++++++++++++ perl-install/install/NEWS | 1 + perl-install/partition_table/gpt.pm | 2 ++ 4 files changed, 29 insertions(+) diff --git a/perl-install/NEWS b/perl-install/NEWS index cdc1b7c68..673bac170 100644 --- a/perl-install/NEWS +++ b/perl-install/NEWS @@ -1,5 +1,6 @@ - diskdrake: o better fix for fail to read too corrupted partition table + o try to detect recovery partitions on GPT - stage2: o revert changes made in 16.70 for a better fix to mga#13894 diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl index 9a983a493..9d8c11375 100755 --- a/perl-install/c/stuff.xs.pl +++ b/perl-install/c/stuff.xs.pl @@ -590,6 +590,31 @@ get_iso_volume_ids(int fd) print ' +int +is_recovery_partition(char * device_path, int part_number) + CODE: + PedDevice *dev = ped_device_get(device_path); + RETVAL = 0; + if(dev) { + PedDisk* disk = ped_disk_new(dev); + if(disk) { + PedPartition* part = ped_disk_get_partition(disk, part_number); + if (!part) { + printf("is_recovery_partition: failed to find partition\n"); + } else { + /* FIXME: not sure everything is covered ... */ + RETVAL=ped_partition_get_flag(part, PED_PARTITION_HPSERVICE) // HP-UX service partition + || ped_partition_get_flag(part, PED_PARTITION_MSFT_RESERVED) // Microsoft Reserved Partition -> LDM metadata, ... + || ped_partition_get_flag(part, PED_PARTITION_DIAG) // ==> PARTITION_MSFT_RECOVERY (Windows Recovery Environment) + || ped_partition_get_flag(part, PED_PARTITION_APPLE_TV_RECOVERY) + || ped_partition_get_flag(part, PED_PARTITION_HIDDEN); + } + ped_disk_destroy(disk); + } + } + OUTPUT: + RETVAL + int get_partition_flag(char * device_path, int part_number, char *type) CODE: diff --git a/perl-install/install/NEWS b/perl-install/install/NEWS index 5d64b6d57..c1a2f8029 100644 --- a/perl-install/install/NEWS +++ b/perl-install/install/NEWS @@ -1,5 +1,6 @@ - partitionning: o better fix for fail to read too corrupted partition table + o try to detect recovery partitions on GPT Version 16.74 - 27 March 2015 diff --git a/perl-install/partition_table/gpt.pm b/perl-install/partition_table/gpt.pm index 11cbe414d..3f0bc3f13 100644 --- a/perl-install/partition_table/gpt.pm +++ b/perl-install/partition_table/gpt.pm @@ -117,6 +117,8 @@ sub read_one { $_->{pt_type} = 0x8e; } elsif (c::get_partition_flag($hd->{file}, $_->{part_number}, 'RAID')) { $_->{pt_type} = 0xfd; + } elsif (c::get_partition_flag($hd->{file}, $_->{part_number}, 'recovery')) { + $_->{pt_type} = 0x12; } $_->{fs_type} = 'swap' if $_->{fs_type} eq 'linux-swap(v1)'; $_->{fs_type} = 'ntfs-3g' if $_->{fs_type} eq 'ntfs'; -- cgit v1.2.1