From 2df065840eda1ac1fc99a31627ea0f06ca7a4ca7 Mon Sep 17 00:00:00 2001 From: Joel Granados Moreno Date: Wed, 10 Jun 2009 18:34:46 +0200 Subject: [PATCH] Handle swap flag in msdos type labels. * libparted/labels/dos.c (swap, raw_part_parse, msdos_partition_new) (msdos_partition_duplicate, msdos_partition_set_system) (msdos_partition_set_flag, msdos_partition_get_flag): Handle the swap flag. Set the partition type if the user sets the swap flag. --- libparted/labels/dos.c | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c index 7ec15ee..f8307c5 100644 --- a/libparted/labels/dos.c +++ b/libparted/labels/dos.c @@ -148,6 +148,7 @@ typedef struct { int lba; int palo; int prep; + int swap; OrigState* orig; /* used for CHS stuff */ } DosPartitionData; @@ -818,6 +819,7 @@ raw_part_parse (const PedDisk* disk, const DosRawPartition* raw_part, dos_data->lba = raw_part_is_lba (raw_part); dos_data->palo = raw_part->type == PARTITION_PALO; dos_data->prep = raw_part->type == PARTITION_PREP; + dos_data->swap = raw_part->type == PARTITION_LINUX_SWAP; dos_data->orig = ped_malloc (sizeof (OrigState)); if (!dos_data->orig) { ped_partition_destroy (part); @@ -1202,6 +1204,7 @@ msdos_partition_new (const PedDisk* disk, PedPartitionType part_type, dos_data->lba = 0; dos_data->palo = 0; dos_data->prep = 0; + dos_data->swap = 0; } else { part->disk_specific = NULL; } @@ -1237,6 +1240,7 @@ msdos_partition_duplicate (const PedPartition* part, PedDisk* disk) new_dos_data->lba = old_dos_data->lba; new_dos_data->palo = old_dos_data->palo; new_dos_data->prep = old_dos_data->prep; + new_dos_data->swap = old_dos_data->swap; if (old_dos_data->orig) { new_dos_data->orig = ped_malloc (sizeof (OrigState)); @@ -1284,6 +1288,7 @@ msdos_partition_set_system (PedPartition* part, dos_data->lvm = 0; dos_data->palo = 0; dos_data->prep = 0; + dos_data->swap = 0; if (dos_data->lba) dos_data->system = PARTITION_EXT_LBA; else @@ -1307,6 +1312,10 @@ msdos_partition_set_system (PedPartition* part, dos_data->system = PARTITION_PREP; return 1; } + if (dos_data->swap) { + dos_data->system = PARTITION_LINUX_SWAP; + return 1; + } if (!fs_type) dos_data->system = PARTITION_LINUX; @@ -1379,6 +1388,7 @@ msdos_partition_set_flag (PedPartition* part, dos_data->lvm = 0; dos_data->palo = 0; dos_data->prep = 0; + dos_data->swap = 0; } dos_data->raid = state; return ped_partition_set_system (part, part->fs_type); @@ -1389,6 +1399,7 @@ msdos_partition_set_flag (PedPartition* part, dos_data->raid = 0; dos_data->palo = 0; dos_data->prep = 0; + dos_data->swap = 0; } dos_data->lvm = state; return ped_partition_set_system (part, part->fs_type); @@ -1402,6 +1413,7 @@ msdos_partition_set_flag (PedPartition* part, dos_data->hidden = 0; dos_data->raid = 0; dos_data->lvm = 0; + dos_data->swap = 0; } dos_data->palo = state; return ped_partition_set_system (part, part->fs_type); @@ -1411,10 +1423,23 @@ msdos_partition_set_flag (PedPartition* part, dos_data->hidden = 0; dos_data->raid = 0; dos_data->lvm = 0; + dos_data->swap = 0; + dos_data->palo = 0; } dos_data->prep = state; return ped_partition_set_system (part, part->fs_type); + case PED_PARTITION_SWAP: + if (state) { + dos_data->hidden = 0; + dos_data->raid = 0; + dos_data->lvm = 0; + dos_data->palo = 0; + dos_data->prep = 0; + } + dos_data->swap = state; + return ped_partition_set_system (part, ped_file_system_type_get("linux-swap")); + default: return 0; } @@ -1451,6 +1476,9 @@ msdos_partition_get_flag (const PedPartition* part, PedPartitionFlag flag) case PED_PARTITION_PREP: return dos_data->prep; + case PED_PARTITION_SWAP: + return dos_data->swap; + default: return 0; } @@ -1496,6 +1496,7 @@ msdos_partition_is_flag_available (const case PED_PARTITION_LBA: case PED_PARTITION_PALO: case PED_PARTITION_PREP: + case PED_PARTITION_SWAP: return 1; default: -- 1.6.0.6