[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RAID support for Sun disktype [FIXEDPATCH]
From: |
Jim Meyering |
Subject: |
Re: RAID support for Sun disktype [FIXEDPATCH] |
Date: |
Mon, 22 Dec 2008 22:43:10 +0100 |
"Tom \"spot\" Callaway" <address@hidden> wrote:
> On Sun, 2008-12-21 at 23:39 +0100, Jim Meyering wrote:
>> If you feel like one more iteration,
>> it'd be nice if you would add a ChangeLog-style log entry
>> and create diffs against the latest upstream git repository.
>
> Sure, here's the updated patch.
>
> Thanks again,
>
> ~spot
>
>>From d3964a84ead6e897476e24de347e74e3b7e41e24 Mon Sep 17 00:00:00 2001
> From: Tom "spot" Callaway <address@hidden>
> Date: Mon, 22 Dec 2008 09:39:23 -0500
> Subject: [PATCH] Add support for RAID partition types for Sun disk layouts
>
> This patch enables RAID as a supported partition type on Sun disk
> layouts, commonly found/used on SPARC hardware. It has been tested
> on Aurora SPARC Linux (and Fedora SPARC). I have no idea if Solaris
> supports Software RAID or not...
>
> Along with the code change, I wrote a test case that checks if the
> RAID partition type is supported on sun disk labels.
Thanks.
However, that fails for me when the build directory name (as printed
by pwd) contains a symlink, e.g.,
--- out 2008-12-22 19:13:24.000000000 +0000
+++ exp 2008-12-22 19:13:24.000000000 +0000
@@ -1,3 +1,3 @@
BYT;
-/media/sda4/home/meyering/work/co/parted/parted/tests/parted-t4000.pFuBeiocit/sun-disk-file:20480s:file:512:512:sun:;
+/work/co/parted/parted/tests/parted-t4000.pFuBeiocit/sun-disk-file:20480s:file:512:512:sun:;
So I'm going to fold in this incremental fix that removes
the file name altogether:
diff --git a/tests/t4000-sun-raid-type.sh b/tests/t4000-sun-raid-type.sh
index ca38601..3cf874e 100755
--- a/tests/t4000-sun-raid-type.sh
+++ b/tests/t4000-sun-raid-type.sh
@@ -23,8 +23,7 @@ test_description="RAID support on sun disk type"
N=10M
dev=sun-disk-file
-pwd=`pwd`
-exp="BYT;\n$pwd/$dev:20480s:file:512:512:sun:;\n1:0s:50s:51s"
+exp="BYT;\n---:20480s:file:512:512:sun:;\n1:0s:50s:51s"
test_expect_success \
'create an empty file as a test disk' \
'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
@@ -41,7 +40,8 @@ test_expect_success 'check for empty output' '$compare out
/dev/null'
test_expect_success \
'print the partition data in machine readable format' \
- 'parted -m -s $dev unit s p > out 2>&1'
+ 'parted -m -s $dev unit s p > out 2>&1 &&
+ sed "s,^.*/$dev:,---:," out > k && mv k out'
test_expect_success \
'check for expected values for the partition' '
@@ -55,7 +55,8 @@ test_expect_success 'check for empty output' '$compare out
/dev/null'
test_expect_success \
'print the partition data in machine readable format again' \
- 'parted -m -s $dev unit s p > out 2>&1'
+ 'parted -m -s $dev unit s p > out 2>&1 &&
+ sed "s,^.*/$dev:,---:," out > k && mv k out'
test_expect_success \
'check for expected values (including raid flag) for the partition' '
Also, I noticed this:
# Copyright (C) 2008 Tom "spot" Callaway <address@hidden>
If you don't object, I'll change it to be like all the others:
(mainly to forestall complaints/queries about the difference)
# Copyright (C) 2008 Free Software Foundation, Inc.
and then, add authorship details after the copyright,
# Written by Tom "spot" Callaway <address@hidden>
# Derived from an example by Jim Meyering <address@hidden>
Complete patches below:
(notice how I adjusted the log entry to list every
affected file and function)
Unless you object, I'll merge the 2nd patch
into the first before pushing.
-------------------
>From f487dcd9dbd6fbe33df7ebddfdd66255ae2be7ad Mon Sep 17 00:00:00 2001
From: Tom "spot" Callaway <address@hidden>
Date: Mon, 22 Dec 2008 09:39:23 -0500
Subject: [PATCH 1/2] sun partition tables: add support for RAID partition types
This patch enables RAID as a supported partition type on Sun disk
layouts, commonly found/used on SPARC hardware. It has been tested
on Aurora SPARC Linux (and Fedora SPARC). I have no idea if Solaris
supports Software RAID or not...
Along with the code change, I wrote a test case that checks if the
RAID partition type is supported on sun disk labels.
* libparted/labels/sun.c [_SunPartitionData] (is_raid): New member.
(sun_read): Initialize the ->is_raid member.
(sun_partition_new): Clear is_raid, like all the other members.
(sun_partition_duplicate): Propagate the is_raid member.
(sun_partition_set_system): Make sun_data->type reflect is_raid.
(sun_partition_set_flag): Also initialize ->is_raid.
(sun_partition_get_flag): Handle PED_PARTITION_RAID.
(sun_partition_is_flag_available): Likewise.
* tests/t4000-sun-raid-type.sh: New file.
* tests/Makefile.am (TESTS): Add t4000-sun-raid-type.sh.
---
libparted/labels/sun.c | 41 ++++++++++++++++++++++----
tests/Makefile.am | 1 +
tests/t4000-sun-raid-type.sh | 65 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 101 insertions(+), 6 deletions(-)
create mode 100755 tests/t4000-sun-raid-type.sh
diff --git a/libparted/labels/sun.c b/libparted/labels/sun.c
index 6f1900b..76f2b78 100644
--- a/libparted/labels/sun.c
+++ b/libparted/labels/sun.c
@@ -87,6 +87,7 @@ struct _SunPartitionData {
int is_boot;
int is_root;
int is_lvm;
+ int is_raid;
};
struct _SunDiskData {
@@ -347,6 +348,7 @@ sun_read (PedDisk* disk)
sun_data->is_boot = sun_data->type == 0x1;
sun_data->is_root = sun_data->type == 0x2;
sun_data->is_lvm = sun_data->type == 0x8e;
+ sun_data->is_raid = sun_data->type == 0xfd;
part->num = i + 1;
part->fs_type = ped_file_system_probe (&part->geom);
@@ -482,6 +484,7 @@ sun_partition_new (const PedDisk* disk, PedPartitionType
part_type,
sun_data->is_boot = 0;
sun_data->is_root = 0;
sun_data->is_lvm = 0;
+ sun_data->is_raid = 0;
} else {
part->disk_specific = NULL;
}
@@ -515,6 +518,7 @@ sun_partition_duplicate (const PedPartition* part)
new_sun_data->is_boot = old_sun_data->is_boot;
new_sun_data->is_root = old_sun_data->is_root;
new_sun_data->is_lvm = old_sun_data->is_lvm;
+ new_sun_data->is_raid = old_sun_data->is_raid;
return new_part;
}
@@ -547,6 +551,10 @@ sun_partition_set_system (PedPartition* part, const
PedFileSystemType* fs_type)
sun_data->type = 0x8e;
return 1;
}
+ if (sun_data->is_raid) {
+ sun_data->type = 0xfd;
+ return 1;
+ }
sun_data->type = 0x83;
if (fs_type) {
@@ -573,20 +581,38 @@ sun_partition_set_flag (PedPartition* part,
PedPartitionFlag flag, int state)
switch (flag) {
case PED_PARTITION_BOOT:
sun_data->is_boot = state;
- if (state)
- sun_data->is_root = sun_data->is_lvm = 0;
+ if (state) {
+ sun_data->is_lvm = 0;
+ sun_data->is_raid = 0;
+ sun_data->is_root = 0;
+ }
return ped_partition_set_system (part, part->fs_type);
case PED_PARTITION_ROOT:
sun_data->is_root = state;
- if (state)
- sun_data->is_boot = sun_data->is_lvm = 0;
+ if (state) {
+ sun_data->is_boot = 0;
+ sun_data->is_lvm = 0;
+ sun_data->is_raid = 0;
+ }
return ped_partition_set_system (part, part->fs_type);
case PED_PARTITION_LVM:
sun_data->is_lvm = state;
- if (state)
- sun_data->is_root = sun_data->is_boot = 0;
+ if (state) {
+ sun_data->is_boot = 0;
+ sun_data->is_raid = 0;
+ sun_data->is_root = 0;
+ }
+ return ped_partition_set_system (part, part->fs_type);
+
+ case PED_PARTITION_RAID:
+ sun_data->is_raid = state;
+ if (state) {
+ sun_data->is_boot = 0;
+ sun_data->is_lvm = 0;
+ sun_data->is_root = 0;
+ }
return ped_partition_set_system (part, part->fs_type);
default:
@@ -612,6 +638,8 @@ sun_partition_get_flag (const PedPartition* part,
PedPartitionFlag flag)
return sun_data->is_root;
case PED_PARTITION_LVM:
return sun_data->is_lvm;
+ case PED_PARTITION_RAID:
+ return sun_data->is_raid;
default:
return 0;
@@ -627,6 +655,7 @@ sun_partition_is_flag_available (const PedPartition* part,
case PED_PARTITION_BOOT:
case PED_PARTITION_ROOT:
case PED_PARTITION_LVM:
+ case PED_PARTITION_RAID:
return 1;
default:
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1c8c753..ab3b7cb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -9,6 +9,7 @@ TESTS = \
t2200-dos-label-recog.sh \
t3000-constraints.sh \
t3100-resize-ext2-partion.sh \
+ t4000-sun-raid-type.sh \
t4100-msdos-partition-limits.sh \
t4100-dvh-partition-limits.sh \
t4200-partprobe.sh \
diff --git a/tests/t4000-sun-raid-type.sh b/tests/t4000-sun-raid-type.sh
new file mode 100755
index 0000000..ca38601
--- /dev/null
+++ b/tests/t4000-sun-raid-type.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+# Copyright (C) 2008 Tom "spot" Callaway <address@hidden>
+# Derived from an example by Jim Meyering <address@hidden>
+
+# 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="RAID support on sun disk type"
+
+: ${srcdir=.}
+. $srcdir/test-lib.sh
+
+N=10M
+dev=sun-disk-file
+pwd=`pwd`
+exp="BYT;\n$pwd/$dev:20480s:file:512:512:sun:;\n1:0s:50s:51s"
+test_expect_success \
+ 'create an empty file as a test disk' \
+ 'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
+
+test_expect_success \
+ 'label the test disk as a sun disk' \
+ 'parted -s $dev mklabel sun > out 2>&1'
+test_expect_success 'check for empty output' '$compare out /dev/null'
+
+test_expect_success \
+ 'create a single partition' \
+ 'parted -s $dev unit s mkpart ext2 0s 50s > out 2>&1'
+test_expect_success 'check for empty output' '$compare out /dev/null'
+
+test_expect_success \
+ 'print the partition data in machine readable format' \
+ 'parted -m -s $dev unit s p > out 2>&1'
+
+test_expect_success \
+ 'check for expected values for the partition' '
+ printf "$exp:::;\n" > exp &&
+ $compare out exp'
+
+test_expect_success \
+ 'set the raid flag' \
+ 'parted -s $dev set 1 raid >out 2>&1'
+test_expect_success 'check for empty output' '$compare out /dev/null'
+
+test_expect_success \
+ 'print the partition data in machine readable format again' \
+ 'parted -m -s $dev unit s p > out 2>&1'
+
+test_expect_success \
+ 'check for expected values (including raid flag) for the partition' '
+ printf "$exp:::raid;\n" > exp &&
+ $compare out exp'
+
+test_done
--
1.6.1.rc3.359.g43db1
>From 14eb7c199eb11961de7551d507964c3ba51b0dd4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 22 Dec 2008 22:16:32 +0100
Subject: [PATCH 2/2] make test more portable; tweak copyright
---
tests/t4000-sun-raid-type.sh | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/tests/t4000-sun-raid-type.sh b/tests/t4000-sun-raid-type.sh
index ca38601..34c56ee 100755
--- a/tests/t4000-sun-raid-type.sh
+++ b/tests/t4000-sun-raid-type.sh
@@ -1,7 +1,6 @@
#!/bin/sh
-# Copyright (C) 2008 Tom "spot" Callaway <address@hidden>
-# Derived from an example by Jim Meyering <address@hidden>
+# Copyright (C) 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
@@ -16,6 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# Written by Tom "spot" Callaway <address@hidden>
+# Derived from an example by Jim Meyering <address@hidden>
+
test_description="RAID support on sun disk type"
: ${srcdir=.}
@@ -23,8 +25,7 @@ test_description="RAID support on sun disk type"
N=10M
dev=sun-disk-file
-pwd=`pwd`
-exp="BYT;\n$pwd/$dev:20480s:file:512:512:sun:;\n1:0s:50s:51s"
+exp="BYT;\n---:20480s:file:512:512:sun:;\n1:0s:50s:51s"
test_expect_success \
'create an empty file as a test disk' \
'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
@@ -41,7 +42,8 @@ test_expect_success 'check for empty output' '$compare out
/dev/null'
test_expect_success \
'print the partition data in machine readable format' \
- 'parted -m -s $dev unit s p > out 2>&1'
+ 'parted -m -s $dev unit s p > out 2>&1 &&
+ sed "s,^.*/$dev:,---:," out > k && mv k out'
test_expect_success \
'check for expected values for the partition' '
@@ -55,7 +57,8 @@ test_expect_success 'check for empty output' '$compare out
/dev/null'
test_expect_success \
'print the partition data in machine readable format again' \
- 'parted -m -s $dev unit s p > out 2>&1'
+ 'parted -m -s $dev unit s p > out 2>&1 &&
+ sed "s,^.*/$dev:,---:," out > k && mv k out'
test_expect_success \
'check for expected values (including raid flag) for the partition' '
--
1.6.1.rc3.359.g43db1
- RAID support for Sun disktype [FIXEDPATCH], Tom \"spot\" Callaway, 2008/12/13
- Re: RAID support for Sun disktype [FIXEDPATCH], Jim Meyering, 2008/12/21
- Re: RAID support for Sun disktype [FIXEDPATCH], Tom \"spot\" Callaway, 2008/12/21
- Re: RAID support for Sun disktype [FIXEDPATCH], Jim Meyering, 2008/12/21
- Re: RAID support for Sun disktype [FIXEDPATCH], Tom \"spot\" Callaway, 2008/12/21
- Re: RAID support for Sun disktype [FIXEDPATCH], Jim Meyering, 2008/12/21
- Re: RAID support for Sun disktype [FIXEDPATCH], Tom \"spot\" Callaway, 2008/12/22
- Re: RAID support for Sun disktype [FIXEDPATCH],
Jim Meyering <=
- Re: RAID support for Sun disktype [FIXEDPATCH], Tom \"spot\" Callaway, 2008/12/22
- Re: RAID support for Sun disktype [FIXEDPATCH], Jim Meyering, 2008/12/23