[Parted-commits] GNU Parted Official Repository: Changes to 'next'
Jim Meyering
meyering at alioth.debian.org
Mon Mar 16 16:48:13 UTC 2009
libparted/arch/linux.c | 3 +-
libparted/labels/gpt.c | 23 ++++++-------------
libparted/labels/pt-tools.c | 24 +++++++++++++++++++
libparted/labels/pt-tools.h | 5 ++--
tests/Makefile.am | 2 +
tests/t0300-dos-on-gpt.sh | 41 ++++++++++++++++++++++++++++++++++
tests/t1700-ext-probe.sh | 2 -
tests/t4100-dvh-partition-limits.sh | 3 +-
tests/t4100-msdos-partition-limits.sh | 3 +-
tests/t7000-scripting.sh | 8 ++++++
tests/t8000-loop.sh | 7 ++++-
tests/test-lib.sh | 11 +++++++++
12 files changed, 109 insertions(+), 23 deletions(-)
New commits:
commit 4316c268051a5854611b7af0938d3c9fb0828e04
Author: Jim Meyering <meyering at redhat.com>
Date: Mon Mar 16 17:47:04 2009 +0100
tests: make t8000-loop.sh stop immediately upon failiure
* tests/t8000-loop.sh (immediate): ... to avoid cascading.
diff --git a/tests/t8000-loop.sh b/tests/t8000-loop.sh
index b7d39b8..f599b11 100755
--- a/tests/t8000-loop.sh
+++ b/tests/t8000-loop.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-# Copyright (C) 2008 Free Software Foundation, Inc.
+# Copyright (C) 2008-2009 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
@@ -23,6 +23,11 @@ device_mapper_required_=1
: ${srcdir=.}
. $srcdir/test-lib.sh
+# Stop immediately, upon failure.
+# Otherwise, subsequent tests would fail,
+# too and just obscure the earlier failure.
+immediate=1
+
cleanup_() {
test -n "$d1" && losetup -d "$d1"
rm -f "$f1";
commit 511b09c6179b22cfedf5cfd14d72e39ace169ce5
Author: Jim Meyering <meyering at redhat.com>
Date: Thu Mar 12 19:58:34 2009 +0100
tests: fix the final test failure on RHEL 5.3
* tests/t1700-ext-probe.sh (dev): Use mkfs.$type, not mkfs -t $type.
The latter doesn't work on RHEL5: a file system created with
"mkfs -F -t ext3" appears to be created as ext2.
diff --git a/tests/t1700-ext-probe.sh b/tests/t1700-ext-probe.sh
index 5a0744d..3ea0e4e 100755
--- a/tests/t1700-ext-probe.sh
+++ b/tests/t1700-ext-probe.sh
@@ -30,7 +30,7 @@ for type in ext2 ext3 ext4; do
test_expect_success \
"create an $type file system" '
dd if=/dev/zero of=$dev bs=1024 count=4096 >/dev/null &&
- mkfs -F -t $type $dev >/dev/null'
+ mkfs.$type -F $dev >/dev/null'
test_expect_success \
"probe the $type file system" '
commit 674fe029e429b1414a6155c22ff54f802fe55646
Author: Jim Meyering <meyering at redhat.com>
Date: Wed Mar 11 20:40:20 2009 +0100
tests: skip xfs-requiring tests when mkfs.xfs is not installed
* tests/test-lib.sh (require_xfs_): New function.
* tests/t4100-dvh-partition-limits.sh: Use it.
* tests/t4100-msdos-partition-limits.sh: Likewise.
diff --git a/tests/t4100-dvh-partition-limits.sh b/tests/t4100-dvh-partition-limits.sh
index 95ec02b..0606a7e 100755
--- a/tests/t4100-dvh-partition-limits.sh
+++ b/tests/t4100-dvh-partition-limits.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-# Copyright (C) 2008 Free Software Foundation, Inc.
+# Copyright (C) 2008-2009 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
@@ -22,6 +22,7 @@ privileges_required_=1
: ${srcdir=.}
. $srcdir/test-lib.sh
+require_xfs_
####################################################
# Create and mount a file system capable of dealing with >=2TB files.
diff --git a/tests/t4100-msdos-partition-limits.sh b/tests/t4100-msdos-partition-limits.sh
index 47000a8..d58c387 100755
--- a/tests/t4100-msdos-partition-limits.sh
+++ b/tests/t4100-msdos-partition-limits.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-# Copyright (C) 2008 Free Software Foundation, Inc.
+# Copyright (C) 2008-2009 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
@@ -22,6 +22,7 @@ privileges_required_=1
: ${srcdir=.}
. $srcdir/test-lib.sh
+require_xfs_
####################################################
# Create and mount a file system capable of dealing with >=2TB files.
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
index edfabfc..63d3f95 100644
--- a/tests/test-lib.sh
+++ b/tests/test-lib.sh
@@ -336,4 +336,14 @@ normalize_part_diag_()
return 1
}
+require_xfs_()
+{
+ ( mkfs.xfs -V ) >/dev/null 2>&1 ||
+ {
+ say "skipping $0: this test requires XFS support"
+ test_done
+ exit
+ }
+}
+
sector_size_=${PARTED_SECTOR_SIZE:-512}
commit e66f66f67b42a6d47773c599da1946eadf9c5259
Author: Jim Meyering <meyering at redhat.com>
Date: Wed Mar 11 19:38:35 2009 +0100
tests: skip t7000-scripting.sh if configure without readline
Otherwise, that test would fail due to slight differences in output.
* tests/Makefile.am (TESTS_ENVIRONMENT): Define CONFIG_HEADER.
* tests/t7000-scripting.sh: Skip if configured without readline.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 73b33eb..10a9b99 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -43,4 +43,5 @@ init.sh: Makefile.in
TESTS_ENVIRONMENT = \
srcdir='$(srcdir)' \
+ CONFIG_HEADER='$(abs_top_builddir)/lib/config.h' \
ENABLE_DEVICE_MAPPER=$(ENABLE_DEVICE_MAPPER)
diff --git a/tests/t7000-scripting.sh b/tests/t7000-scripting.sh
index 771fdcd..71251bc 100755
--- a/tests/t7000-scripting.sh
+++ b/tests/t7000-scripting.sh
@@ -20,6 +20,14 @@ test_description='Make sure the scripting option works (-s) properly.'
: ${srcdir=.}
. $srcdir/test-lib.sh
+config_h=$abs_top_srcdir
+grep '^#define HAVE_LIBREADLINE 1' $CONFIG_HEADER > /dev/null ||
+ {
+ say "skipping $0: configured without readline support"
+ test_done
+ exit
+ }
+
# The failure messages.
cat << EOF > errS || fail=1
Error: You requested a partition from 512B to 50.7kB.
commit d53d7a7961a38b051cee20b5b53a204dcbafdfb5
Author: Jim Meyering <meyering at redhat.com>
Date: Wed Mar 11 18:36:04 2009 +0100
tests: don't infloop for manual test invocation with unrecognized option
* tests/test-lib.sh: Diagnose an invalid option.
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
index 0c3af8e..edfabfc 100644
--- a/tests/test-lib.sh
+++ b/tests/test-lib.sh
@@ -51,6 +51,7 @@ do
exit 0 ;;
-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
verbose=t; shift ;;
+ *) echo "invalid option: $1"; exit 1;;
esac
done
commit aa49d372c442d43e70bb2b91db2e03aae4b60284
Author: Jim Meyering <meyering at redhat.com>
Date: Wed Mar 11 17:45:27 2009 +0100
tests: add one to exercise the dos/gpt seg-faulting bug
* tests/t0300-dos-on-gpt.sh: Test for this bug.
* tests/Makefile.am (TESTS): Add it to the list.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4bf3abb..73b33eb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -4,6 +4,7 @@ TESTS = \
t0200-gpt.sh \
t0201-gpt.sh \
t0250-gpt.sh \
+ t0300-dos-on-gpt.sh \
t1000-mkpartfs.sh \
t1100-busy-label.sh \
t1500-small-ext2.sh \
diff --git a/tests/t0300-dos-on-gpt.sh b/tests/t0300-dos-on-gpt.sh
new file mode 100755
index 0000000..4042512
--- /dev/null
+++ b/tests/t0300-dos-on-gpt.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# Copyright (C) 2009 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='avoid segfault creating a dos PT on top of a gpt one'
+
+PARTED_SECTOR_SIZE=4096
+export PARTED_SECTOR_SIZE
+
+: ${srcdir=.}
+. $srcdir/test-lib.sh
+
+dev=loop-file
+test_expect_success \
+ 'create a backing file large enough for a GPT partition table' \
+ 'dd if=/dev/null of=$dev seek=4001 2> /dev/null'
+
+test_expect_success \
+ 'create a GPT partition table' \
+ 'parted -s $dev mklabel gpt > out 2>&1'
+test_expect_success 'expect no output' 'compare out /dev/null'
+
+test_expect_success \
+ 'create a DOS partition table on top of it' \
+ 'parted -s $dev mklabel msdos > out 2>&1'
+test_expect_success 'expect no output' 'compare out /dev/null'
+
+test_done
commit 26358d3214b3b6a8f83a3d52b8ebe54347eec9e0
Author: Jim Meyering <meyering at redhat.com>
Date: Wed Mar 11 16:06:53 2009 +0100
gpt_clobber: avoid segfault when 512 < sector_size
* libparted/labels/gpt.c (gpt_clobber): Rewrite not to use a
fixed-size buffer assuming a 512-byte sector.
Eliminate entirely a buffer that is allocated (not long enough)
and zeroed-out solely so to help zero out a few sectors.
Instead, use the new ptt_clear_sectors function.
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 950c365..1ce7333 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -483,35 +483,31 @@ gpt_probe (const PedDevice * dev)
static int
gpt_clobber(PedDevice * dev)
{
- LegacyMBR_t pmbr;
- uint8_t* zeroed_pth_raw = ped_malloc (pth_get_size (dev));
uint8_t* pth_raw = ped_malloc (pth_get_size (dev));
GuidPartitionTableHeader_t* gpt;
PED_ASSERT (dev != NULL, return 0);
- memset(&pmbr, 0, sizeof(pmbr));
- memset(zeroed_pth_raw, 0, pth_get_size (dev));
-
/*
* TO DISCUSS: check whether checksum is correct?
* If not, we might get a wrong AlternateLBA field and destroy
* one sector of random data.
*/
if (!ped_device_read(dev, pth_raw,
- GPT_PRIMARY_HEADER_LBA, GPT_HEADER_SECTORS))
- goto error_free;
+ GPT_PRIMARY_HEADER_LBA, GPT_HEADER_SECTORS)) {
+ free (pth_raw);
+ return 0;
+ }
gpt = pth_new_from_raw (dev, pth_raw);
free (pth_raw);
- if (!ped_device_write(dev, &pmbr, GPT_PMBR_LBA, GPT_PMBR_SECTORS))
+ if (!ptt_clear_sectors(dev, GPT_PMBR_LBA, GPT_PMBR_SECTORS))
goto error_free_with_gpt;
- if (!ped_device_write(dev, &zeroed_pth_raw,
- GPT_PRIMARY_HEADER_LBA, GPT_HEADER_SECTORS))
+ if (!ptt_clear_sectors(dev, GPT_PRIMARY_HEADER_LBA, GPT_HEADER_SECTORS))
goto error_free_with_gpt;
- if (!ped_device_write(dev, &zeroed_pth_raw, dev->length - GPT_HEADER_SECTORS,
- GPT_HEADER_SECTORS))
+ if (!ptt_clear_sectors(dev, dev->length - GPT_HEADER_SECTORS,
+ GPT_HEADER_SECTORS))
goto error_free_with_gpt;
if ((PedSector) PED_LE64_TO_CPU (gpt->AlternateLBA) < dev->length - 1) {
@@ -527,9 +523,6 @@ gpt_clobber(PedDevice * dev)
error_free_with_gpt:
pth_free (gpt);
-error_free:
- free (pth_raw);
- free (zeroed_pth_raw);
return 0;
}
#endif /* !DISCOVER_ONLY */
commit ad49e90098801e1e9a61e77ec4cf00f4ebf27d76
Author: Jim Meyering <meyering at redhat.com>
Date: Tue Mar 10 22:58:20 2009 +0100
ptt_clear_sectors: new function
* libparted/labels/pt-tools.c (ptt_clear_sectors): New function.
* libparted/labels/pt-tools.h: Declare.
diff --git a/libparted/labels/pt-tools.c b/libparted/labels/pt-tools.c
index 50fa55d..564f611 100644
--- a/libparted/labels/pt-tools.c
+++ b/libparted/labels/pt-tools.c
@@ -1,5 +1,5 @@
/* partition table tools
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008-2009 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
@@ -24,6 +24,8 @@
#include "pt-tools.h"
+static char zero[16 * 1024];
+
/* Write a single sector to DISK, filling the first BUFLEN
bytes of that sector with data from BUF, and NUL-filling
any remaining bytes. Return nonzero to indicate success,
@@ -62,3 +64,23 @@ ptt_read_sector (PedDevice const *dev, PedSector sector_num, void **buf)
*buf = b;
return 1;
}
+
+/* Zero N sectors of DEV, starting with START.
+ Return nonzero to indicate success, zero otherwise. */
+int
+ptt_clear_sectors (PedDevice *dev, PedSector start, PedSector n)
+{
+ PED_ASSERT (dev->sector_size <= sizeof zero, return 0);
+ PedSector n_z_sectors = sizeof zero / dev->sector_size;
+ PedSector n_full = n / n_z_sectors;
+ PedSector i;
+ for (i = 0; i < n_full; i++)
+ {
+ if (!ped_device_write (dev, zero, start + n_z_sectors * i, n_z_sectors))
+ return 0;
+ }
+
+ PedSector rem = n - n_z_sectors * i;
+ return (rem == 0
+ ? 1 : ped_device_write (dev, zero, start + n_z_sectors * i, rem));
+}
diff --git a/libparted/labels/pt-tools.h b/libparted/labels/pt-tools.h
index 0af8e73..d36929e 100644
--- a/libparted/labels/pt-tools.h
+++ b/libparted/labels/pt-tools.h
@@ -1,5 +1,5 @@
/* libparted - a library for manipulating disk partitions
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008-2009 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
@@ -18,4 +18,5 @@
#include <parted/disk.h>
int ptt_write_sector (PedDisk const *disk, void const *buf, size_t buflen);
-int ptt_read_sector (const PedDevice *dev, PedSector sector_num, void **buf);
+int ptt_read_sector (PedDevice const *dev, PedSector sector_num, void **buf);
+int ptt_clear_sectors (PedDevice *dev, PedSector start, PedSector count);
commit 4f3f3454211b9af730450986cf3b270db557d187
Author: Jim Meyering <meyering at redhat.com>
Date: Wed Mar 11 12:46:55 2009 +0100
linux_write: use sector_size, not hard-coded 512
* libparted/arch/linux.c (linux_write): Use sector_size,
not a hard-coded 512, to find start of last sector.
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index b8a8bf0..32b932b 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1720,7 +1720,8 @@ linux_write (PedDevice* dev, const void* buffer, PedSector start,
&& start + count - 1 == dev->length - 1)
return ped_device_write (dev, buffer, start, count - 1)
&& _write_lastoddsector (
- dev, (char*) buffer + (count-1) * 512);
+ dev, ((char*) buffer
+ + (count-1) * dev->sector_size));
}
while (1) {
if (_device_seek (dev, start))
More information about the Parted-commits
mailing list