Add swap handling to the msdos labels.

This commit is contained in:
Joel Andres Granados Moreno 2009-07-27 17:03:49 +00:00
parent 6ced1a092a
commit 10a6043a52
2 changed files with 124 additions and 22 deletions

View File

@ -1,26 +1,125 @@
From ae78428ae1bc521a11be60b6acdb511a6e7aee21 Mon Sep 17 00:00:00 2001
From 2df065840eda1ac1fc99a31627ea0f06ca7a4ca7 Mon Sep 17 00:00:00 2001
From: Joel Granados Moreno <jgranado@redhat.com>
Date: Wed, 10 Jun 2009 18:34:46 +0200
Subject: [PATCH] Use the swap flag.
Subject: [PATCH] Handle swap flag in msdos type labels.
* libparted/labels/dos.c (msdos_partition_set_flag): Set the partition
type if the user sets the swap flag.
* 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 | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
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 f219e7d..b4cd23a 100644
index 7ec15ee..f8307c5 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -1413,6 +1413,11 @@ msdos_partition_set_flag (PedPartition* part,
@@ -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) {
+ return ped_partition_set_system (part, ped_file_system_type_get("linux-swap"));
+ 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;

View File

@ -4,7 +4,7 @@
Summary: The GNU disk partition manipulation program
Name: parted
Version: 1.9.0
Release: 7%{?dist}
Release: 8%{?dist}
License: GPLv3+
Group: Applications/System
URL: http://www.gnu.org/software/parted
@ -15,12 +15,12 @@ Patch2: %{name}-1.9.0-extended-mbr.patch
Patch3: %{name}-1.9.0-noheaders.patch
Patch4: %{name}-1.9.0-pop-push-error.patch
Patch5: %{name}-1.9.0-no-cylinder-align.patch
Patch6: %{name}-1.9.0-swap-flag.patch
Patch7: %{name}-1.9.0-remove-struct-elem.patch
Patch8: %{name}-1.9.0-move-function-declarations.patch
Patch9: %{name}-1.9.0-dasd-duplicate.patch
Patch10: %{name}-1.9.0-new-duplicate.patch
Patch11: %{name}-1.9.0-handle-dup-error.patch
Patch6: %{name}-1.9.0-remove-struct-elem.patch
Patch7: %{name}-1.9.0-move-function-declarations.patch
Patch8: %{name}-1.9.0-dasd-duplicate.patch
Patch9: %{name}-1.9.0-new-duplicate.patch
Patch10: %{name}-1.9.0-handle-dup-error.patch
Patch11: %{name}-1.9.0-swap-flag.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: e2fsprogs-devel
@ -65,12 +65,12 @@ Parted library, you need to install this package.
%patch3 -p1 -b .noheaders
%patch4 -p1 -b .pop-push-error
%patch5 -p1 -b .no-cylinder-align
%patch6 -p1 -b .swap-flag
%patch7 -p1 -b .remove-struct-elem
%patch8 -p1 -b .move-function-declarations
%patch9 -p1 -b .dasd-duplicate
%patch10 -p1 -b .new-duplicate
%patch11 -p1 -b .handle-dup-error
%patch6 -p1 -b .remove-struct-elem
%patch7 -p1 -b .move-function-declarations
%patch8 -p1 -b .dasd-duplicate
%patch9 -p1 -b .new-duplicate
%patch10 -p1 -b .handle-dup-error
%patch11 -p1 -b .swap-flag
%build
@ -129,6 +129,9 @@ fi
%{_exec_prefix}/%{_lib}/pkgconfig/libparted.pc
%changelog
* Mon Jul 27 2009 Joel Granados <jgranado@redhat> - 1.9.0-8
- Add the swap flag to the dos type labels
* Sat Jul 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.9.0-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild