On Wed, Feb 20, 2008 at 07:09:02PM -0300, Otavio Salvador wrote:
>
> For this patch to be accepted, would be nice to have a test case for
> it. You could take a look at tests directory and see some of them as
> example.
Done.
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
diff -Nur git/include/parted/disk.h git.new/include/parted/disk.h
--- git/include/parted/disk.h 2008-02-21 15:10:44.000000000 +0100
+++ git.new/include/parted/disk.h 2008-02-21 17:39:22.000000000 +0100
@@ -1,6 +1,6 @@
/*
libparted - a library for manipulating disk partitions
- Copyright (C) 1999, 2000, 2001, 2002, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -52,10 +52,11 @@
PED_PARTITION_HPSERVICE=8,
PED_PARTITION_PALO=9,
PED_PARTITION_PREP=10,
- PED_PARTITION_MSFT_RESERVED=11
+ PED_PARTITION_MSFT_RESERVED=11,
+ PED_PARTITION_BOOT_BIOS=12
};
#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT
-#define PED_PARTITION_LAST_FLAG PED_PARTITION_MSFT_RESERVED
+#define PED_PARTITION_LAST_FLAG PED_PARTITION_BOOT_BIOS
enum _PedDiskTypeFeature {
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
diff -Nur git/libparted/disk.c git.new/libparted/disk.c
--- git/libparted/disk.c 2008-02-21 15:10:44.000000000 +0100
+++ git.new/libparted/disk.c 2008-02-21 17:37:52.000000000 +0100
@@ -2227,6 +2227,8 @@
switch (flag) {
case PED_PARTITION_BOOT:
return N_("boot");
+ case PED_PARTITION_BOOT_BIOS:
+ return N_("boot_bios");
case PED_PARTITION_ROOT:
return N_("root");
case PED_PARTITION_SWAP:
diff -Nur git/libparted/labels/gpt.c git.new/libparted/labels/gpt.c
--- git/libparted/labels/gpt.c 2008-02-21 15:10:44.000000000 +0100
+++ git.new/libparted/labels/gpt.c 2008-02-21 17:39:02.000000000 +0100
@@ -4,7 +4,7 @@
original version by Matt Domsch <[EMAIL PROTECTED]>
Disclaimed into the Public Domain
- Portions Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007
+ Portions Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
EFI GUID Partition Table handling
@@ -86,6 +86,10 @@
((efi_guid_t) { PED_CPU_TO_LE32 (0xC12A7328), PED_CPU_TO_LE16 (0xF81F), \
PED_CPU_TO_LE16 (0x11d2), 0xBA, 0x4B, \
{ 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B }})
+#define PARTITION_BOOT_BIOS_GUID \
+ ((efi_guid_t) { PED_CPU_TO_LE32 (0x21686148), PED_CPU_TO_LE16 (0x6449), \
+ PED_CPU_TO_LE16 (0x6E6f), 0x74, 0x4E, \
+ { 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 }})
#define LEGACY_MBR_PARTITION_GUID \
((efi_guid_t) { PED_CPU_TO_LE32 (0x024DEE41), PED_CPU_TO_LE16 (0x33E7), \
PED_CPU_TO_LE16 (0x11d3, 0x9D, 0x69, \
@@ -245,6 +249,7 @@
int lvm;
int raid;
int boot;
+ int boot_bios;
int hp_service;
int hidden;
int msftres;
@@ -753,13 +758,16 @@
gpt_part_data->lvm = gpt_part_data->raid
= gpt_part_data->boot = gpt_part_data->hp_service
- = gpt_part_data->hidden = gpt_part_data->msftres = 0;
+ = gpt_part_data->hidden = gpt_part_data->msftres
+ = gpt_part_data->boot_bios = 0;
if (pte->Attributes.RequiredToFunction & 0x1)
gpt_part_data->hidden = 1;
if (!guid_cmp (gpt_part_data->type, PARTITION_SYSTEM_GUID))
gpt_part_data->boot = 1;
+ else if (!guid_cmp (gpt_part_data->type, PARTITION_BOOT_BIOS_GUID))
+ gpt_part_data->boot_bios = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_RAID_GUID))
gpt_part_data->raid = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_LVM_GUID))
@@ -1130,6 +1138,7 @@
gpt_part_data->lvm = 0;
gpt_part_data->raid = 0;
gpt_part_data->boot = 0;
+ gpt_part_data->boot_bios = 0;
gpt_part_data->hp_service = 0;
gpt_part_data->hidden = 0;
gpt_part_data->msftres = 0;
@@ -1208,6 +1217,10 @@
gpt_part_data->type = PARTITION_SYSTEM_GUID;
return 1;
}
+ if (gpt_part_data->boot_bios) {
+ gpt_part_data->type = PARTITION_BOOT_BIOS_GUID;
+ return 1;
+ }
if (gpt_part_data->hp_service) {
gpt_part_data->type = PARTITION_HPSERVICE_GUID;
return 1;
@@ -1306,6 +1319,16 @@
if (state)
gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->boot_bios
+ = gpt_part_data->hp_service
+ = gpt_part_data->msftres = 0;
+ return gpt_partition_set_system (part, part->fs_type);
+ case PED_PARTITION_BOOT_BIOS:
+ gpt_part_data->boot_bios = state;
+ if (state)
+ gpt_part_data->raid
+ = gpt_part_data->lvm
+ = gpt_part_data->boot
= gpt_part_data->hp_service
= gpt_part_data->msftres = 0;
return gpt_partition_set_system (part, part->fs_type);
@@ -1314,6 +1337,7 @@
if (state)
gpt_part_data->boot
= gpt_part_data->lvm
+ = gpt_part_data->boot_bios
= gpt_part_data->hp_service
= gpt_part_data->msftres = 0;
return gpt_partition_set_system (part, part->fs_type);
@@ -1322,6 +1346,7 @@
if (state)
gpt_part_data->boot
= gpt_part_data->raid
+ = gpt_part_data->boot_bios
= gpt_part_data->hp_service
= gpt_part_data->msftres = 0;
return gpt_partition_set_system (part, part->fs_type);
@@ -1331,6 +1356,7 @@
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->boot_bios
= gpt_part_data->msftres = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_MSFT_RESERVED:
@@ -1339,6 +1365,7 @@
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->boot_bios
= gpt_part_data->hp_service = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_HIDDEN:
@@ -1367,6 +1394,8 @@
return gpt_part_data->lvm;
case PED_PARTITION_BOOT:
return gpt_part_data->boot;
+ case PED_PARTITION_BOOT_BIOS:
+ return gpt_part_data->boot_bios;
case PED_PARTITION_HPSERVICE:
return gpt_part_data->hp_service;
case PED_PARTITION_MSFT_RESERVED:
@@ -1390,6 +1419,7 @@
case PED_PARTITION_RAID:
case PED_PARTITION_LVM:
case PED_PARTITION_BOOT:
+ case PED_PARTITION_BOOT_BIOS:
case PED_PARTITION_HPSERVICE:
case PED_PARTITION_MSFT_RESERVED:
case PED_PARTITION_HIDDEN:
diff -Nur git/tests/Makefile.am git.new/tests/Makefile.am
--- git/tests/Makefile.am 2008-02-21 15:10:44.000000000 +0100
+++ git.new/tests/Makefile.am 2008-02-21 17:38:05.000000000 +0100
@@ -9,7 +9,8 @@
t3000-constraints.sh \
t3100-resize-ext2-partion.sh \
t4100-msdos-partition-limits.sh \
- t4100-dvh-partition-limits.sh
+ t4100-dvh-partition-limits.sh \
+ t5000-tags.sh
EXTRA_DIST = \
$(TESTS) test-lib.sh mkdtemp
diff -Nur git/tests/t5000-tags.sh git.new/tests/t5000-tags.sh
--- git/tests/t5000-tags.sh 1970-01-01 01:00:00.000000000 +0100
+++ git.new/tests/t5000-tags.sh 2008-02-21 17:38:00.000000000 +0100
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+# Copyright (C) 2007,2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+test_description="test boot_bios flag in gpt labels"
+
+. ./init.sh
+
+dev=loop-file
+
+test_expect_success \
+ "setup: create zeroed device" \
+ '{ dd if=/dev/zero bs=1024 count=64; } > $dev'
+
+test_expect_success \
+ 'create gpt label' \
+ 'parted -s $dev mklabel gpt >out 2>&1'
+
+test_expect_success \
+ 'add a partition' \
+ 'parted -s $dev mkpart primary 0 1 >>out 2>&1'
+
+test_expect_success \
+ 'print the table (before manual modification)' \
+ 'parted -s $dev print >>out 2>&1'
+
+# Using bios_boot_magic='\x48\x61' looks nicer, but isn't portable.
+# dash's builtin printf doesn't recognize such \xHH hexadecimal escapes.
+bios_boot_magic='\110\141\150\41\111\144\157\156\164\116\145\145\144\105\106\111'
+
+printf "$bios_boot_magic" | dd of=$dev bs=1024 seek=1 conv=notrunc
+
+test_expect_success \
+ 'print the table (after manual modification)' \
+ 'parted -s $dev print >>out 2>&1'
+
+pwd=`pwd`
+
+fail=0
+{
+ cat <<EOF
+Model: (file)
+Disk .../$dev: 65.5kB
+Sector size (logical/physical): 512B/512B
+Partition Table: gpt
+
+Number Start End Size File system Name Flags
+ 1 17.4kB 48.6kB 31.2kB primary
+
+Model: (file)
+Disk .../$dev: 65.5kB
+Sector size (logical/physical): 512B/512B
+Partition Table: gpt
+
+Number Start End Size File system Name Flags
+ 1 17.4kB 48.6kB 31.2kB primary boot_bios
+
+EOF
+} > exp || fail=1
+
+test_expect_success \
+ 'prepare actual and expected output' \
+ 'test $fail = 0 &&
+ mv out o2 && sed "s,^Disk .*/$dev:,Disk .../$dev:," o2 > out'
+
+test_expect_success 'check for expected output' '$compare out exp'
+
+test_done
_______________________________________________
parted-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/parted-devel