- Rebase on upstream Alpha source release

- drop included patches (all but one)
- add Phillip Susi's GPG key
- make sure gcc warnings as errors remains disabled since we use git for patches
This commit is contained in:
Brian C. Lane 2014-07-28 12:50:21 -07:00
parent 13386670d0
commit 3dcf9083a3
137 changed files with 171 additions and 22291 deletions

2
.gitignore vendored
View File

@ -7,3 +7,5 @@ clog
/parted-3.0.tar.xz.sig /parted-3.0.tar.xz.sig
/parted-3.1.tar.xz /parted-3.1.tar.xz
/parted-3.1.tar.xz.sig /parted-3.1.tar.xz.sig
/parted-3.1.90.tar.xz
/parted-3.1.90.tar.xz.sig

View File

@ -1,50 +0,0 @@
From f6835518a7a8722b247079799a9145c3101f9a8a Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Fri, 2 Mar 2012 17:59:32 +0100
Subject: [PATCH 001/131] maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
---
.prev-version | 2 +-
NEWS | 3 +++
cfg.mk | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/.prev-version b/.prev-version
index 9f55b2c..8c50098 100644
--- a/.prev-version
+++ b/.prev-version
@@ -1 +1 @@
-3.0
+3.1
diff --git a/NEWS b/NEWS
index fe0fcdd..3bef20e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
GNU parted NEWS -*- outline -*-
+* Noteworthy changes in release ?.? (????-??-??) [?]
+
+
* Noteworthy changes in release 3.1 (2012-03-02) [stable]
** New features
diff --git a/cfg.mk b/cfg.mk
index ba8ba77..c6a00c8 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -42,7 +42,7 @@ local-checks-to-skip = \
# Now that we have better (check.mk) tests, make this the default.
export VERBOSE = yes
-old_NEWS_hash = 04810d10a532cf2e75d602ddda0d64b1
+old_NEWS_hash = bd453bcf049e292a9677c094d24a29dd
include $(srcdir)/dist-check.mk
--
1.9.3

View File

@ -1,100 +0,0 @@
From b55724f291fa405f652fbbc5cae6e36cc8a2d200 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 20 Mar 2012 17:25:22 -0700
Subject: [PATCH 002/131] libparted: check PMBR before GPT partition table
The UEFI spec requires that a valid GPT disk label have a PMBR
partition. This moves the PMBR check to before the GPT check,
exiting gpt_probe with a 0 if the PMBR is not valid.
The previous behavior would cause problems in the following situation:
1. format a disk as GPT
2. re-format it as MSDOS using tools that don't understand GPT
Subsequent operations with parted would then complain about the invalid
PMBR, but would not allow the disk to be used as an msdos disk. This
change causes parted to recognize the msdos partition table.
* libparted/labels/gpt.c (gpt_probe): Move _pmbr_is_valid test.
Reported by Chris Murphy in http://bugzilla.redhat.com/805272
---
libparted/labels/gpt.c | 47 ++++++++++++++---------------------------------
1 file changed, 14 insertions(+), 33 deletions(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 84bdc12..91ad71a 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -457,7 +457,6 @@ _pmbr_is_valid (const LegacyMBR_t *mbr)
static int
gpt_probe (const PedDevice *dev)
{
- GuidPartitionTableHeader_t *gpt = NULL;
int gpt_sig_found = 0;
PED_ASSERT (dev != NULL);
@@ -465,47 +464,29 @@ gpt_probe (const PedDevice *dev)
if (dev->length <= 1)
return 0;
+ void *label;
+ if (!ptt_read_sector (dev, 0, &label))
+ return 0;
+
+ if (!_pmbr_is_valid (label))
+ {
+ free (label);
+ return 0;
+ }
+ free (label);
+
void *pth_raw = ped_malloc (pth_get_size (dev));
if (ped_device_read (dev, pth_raw, 1, GPT_HEADER_SECTORS)
|| ped_device_read (dev, pth_raw, dev->length - 1, GPT_HEADER_SECTORS))
{
- gpt = pth_new_from_raw (dev, pth_raw);
+ GuidPartitionTableHeader_t *gpt = pth_new_from_raw (dev, pth_raw);
if (gpt->Signature == PED_CPU_TO_LE64 (GPT_HEADER_SIGNATURE))
gpt_sig_found = 1;
+ pth_free (gpt);
}
-
free (pth_raw);
- pth_free (gpt);
-
- if (!gpt_sig_found)
- return 0;
-
- void *label;
- if (!ptt_read_sector (dev, 0, &label))
- return 0;
-
- int ok = 1;
- if (!_pmbr_is_valid ((const LegacyMBR_t *) label))
- {
- int ex_status = ped_exception_throw
- (PED_EXCEPTION_WARNING,
- PED_EXCEPTION_YES_NO,
- _("%s contains GPT signatures, indicating that it has "
- "a GPT table. However, it does not have a valid "
- "fake msdos partition table, as it should. Perhaps "
- "it was corrupted -- possibly by a program that "
- "doesn't understand GPT partition tables. Or "
- "perhaps you deleted the GPT table, and are now "
- "using an msdos partition table. Is this a GPT "
- "partition table?"),
- dev->path);
- if (ex_status == PED_EXCEPTION_NO)
- ok = 0;
- }
-
- free (label);
- return ok;
+ return gpt_sig_found;
}
static PedDisk *
--
1.9.3

View File

@ -1,98 +0,0 @@
From 5021bbdc6ee892890c2c6fede806b9ad6a6a9378 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 20 Mar 2012 17:25:23 -0700
Subject: [PATCH 003/131] tests: add t0301-overwrite-gpt-pmbr.sh
Make sure parted checks the PMBR before the GPT partition table.
* NEWS: Update with new GPT behavior.
* tests/overwrite-gpt-pmbr.sh: New test.
* tests/Makefile.am (TESTS): Add it.
---
NEWS | 5 +++++
tests/Makefile.am | 1 +
tests/t0301-overwrite-gpt-pmbr.sh | 44 +++++++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+)
create mode 100755 tests/t0301-overwrite-gpt-pmbr.sh
diff --git a/NEWS b/NEWS
index 3bef20e..3969c44 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ GNU parted NEWS -*- outline -*-
* Noteworthy changes in release ?.? (????-??-??) [?]
+** Bug Fixes
+
+ libparted: treat a disk with no pMBR as an msdos-labeled disk
+ even when it has valid GPT headers.
+
* Noteworthy changes in release 3.1 (2012-03-02) [stable]
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1b37fd9..1264812 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -28,6 +28,7 @@ TESTS = \
t0250-gpt.sh \
t0280-gpt-corrupt.sh \
t0300-dos-on-gpt.sh \
+ t0301-overwrite-gpt-pmbr.sh \
t0400-loop-clobber-infloop.sh \
t0500-dup-clobber.sh \
t0501-duplicate.sh \
diff --git a/tests/t0301-overwrite-gpt-pmbr.sh b/tests/t0301-overwrite-gpt-pmbr.sh
new file mode 100755
index 0000000..e7edb66
--- /dev/null
+++ b/tests/t0301-overwrite-gpt-pmbr.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+# Test creating a msdos partition over a GPT partition with
+# fdisk which doesn't remove the GPT partitions, only the PMBR
+
+# Copyright (C) 2009-2012 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/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+
+ss=$sector_size_
+dev=loop-file
+
+# Create a GPT partition table.
+dd if=/dev/null of=$dev bs=$ss seek=80 2> /dev/null || framework_failure
+parted -s $dev mklabel gpt > out 2>&1 || framework_failure_
+compare /dev/null out || framework_failure_
+
+# Create an MSDOS partition table in another file.
+dd if=/dev/null of=m bs=$ss seek=80 2> /dev/null || framework_failure
+parted -s m mklabel msdos > out 2>&1 || framework_failure_
+compare /dev/null out || framework_failure_
+
+# Transplant the MSDOS MBR into the GPT-formatted image.
+dd if=m of=$dev bs=$ss count=1 conv=notrunc || framework_failure_
+
+# Now, try to create a GPT partition table in $dev.
+# Before, parted would prompt, asking about the apparent inconsistency.
+parted -s $dev mklabel gpt > out 2>&1 || fail=1
+# expect no output
+compare /dev/null out || fail=1
+
+Exit $fail
--
1.9.3

View File

@ -1,37 +0,0 @@
From 7fd33a6d24da6a82b830552999b2332140f556d4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Mon, 26 Mar 2012 21:52:08 +0200
Subject: [PATCH 004/131] tests: remove bogus envvar setting from
t0300-dos-on-gpt.sh
* tests/t0300-dos-on-gpt.sh: Remove envvar setting that effectively
disabled testing(only in this test) of simulated sector sizes smaller
than 4KiB.
Also, use a much smaller backing file.
---
tests/t0300-dos-on-gpt.sh | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/tests/t0300-dos-on-gpt.sh b/tests/t0300-dos-on-gpt.sh
index 41bc391..fbe8d7c 100755
--- a/tests/t0300-dos-on-gpt.sh
+++ b/tests/t0300-dos-on-gpt.sh
@@ -17,13 +17,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
-
-PARTED_SECTOR_SIZE=4096
-export PARTED_SECTOR_SIZE
+ss=$sector_size_
dev=loop-file
# create a backing file large enough for a GPT partition table
-dd if=/dev/null of=$dev seek=4001 2> /dev/null || framework_failure
+dd if=/dev/null of=$dev bs=$ss seek=80 2> /dev/null || framework_failure
# create a GPT partition table
parted -s $dev mklabel gpt > out 2>&1 || fail=1
--
1.9.3

View File

@ -1,51 +0,0 @@
From 4ac1c02b590668c93afdb48900e0858de58cda3a Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 8 Jun 2012 13:19:25 +0100
Subject: [PATCH 005/131] gpt: fix endianness bug in
gpt_get_max_supported_partition_count
* libparted/labels/gpt.c (gpt_get_max_supported_partition_count):
Take endianness of pth->FirstUsableLBA into account (64-bit,
little endian) when calculating the maximum number of partitions.
* NEWS (Bug fixes): Mention it.
---
NEWS | 3 +++
libparted/labels/gpt.c | 4 ++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 3969c44..f929b99 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ libparted: gpt: fix gpt_get_max_supported_partition_count to work
+ also on little-endian systems.
+
libparted: treat a disk with no pMBR as an msdos-labeled disk
even when it has valid GPT headers.
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 91ad71a..6032e3f 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1785,12 +1785,12 @@ gpt_get_max_supported_partition_count (const PedDisk *disk, int *max_n)
if (!_header_is_valid (disk, pth, 1))
{
- pth->FirstUsableLBA = 34;
+ pth->FirstUsableLBA = PED_CPU_TO_LE64 (34);
pth->SizeOfPartitionEntry
= PED_CPU_TO_LE32 (sizeof (GuidPartitionEntry_t));
}
- *max_n = (disk->dev->sector_size * (pth->FirstUsableLBA - 2)
+ *max_n = (disk->dev->sector_size * (PED_LE64_TO_CPU (pth->FirstUsableLBA) - 2)
/ PED_LE32_TO_CPU (pth->SizeOfPartitionEntry));
pth_free (pth);
return true;
--
1.9.3

View File

@ -1,110 +0,0 @@
From e38df2d81f0a4647711ffeb92a32c99e7ce9a92d Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Sat, 9 Jun 2012 17:26:21 +0200
Subject: [PATCH 006/131] tests: add a test to exercise just-fixed code
* tests/print-max.c: Extend to provide coverage of
ped_disk_get_max_supported_partition_count, too.
* tests/t9021-maxima.sh (max_n_partitions): New function, with
naively hard-coded max-number-of-partitions-per-partition-table-type
values.
Use it to ensure that each expected value matches the actual one.
* cfg.mk: Exempt this test's use of error from the syntax-check
for unmarked diagnostics.
---
cfg.mk | 2 ++
tests/print-max.c | 10 ++++++++++
tests/t9021-maxima.sh | 26 +++++++++++++++++++++++++-
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/cfg.mk b/cfg.mk
index c6a00c8..45d2ac2 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -69,3 +69,5 @@ exclude_file_name_regexp--sc_prohibit_always-defined_macros = \
exclude_file_name_regexp--sc_prohibit_path_max_allocation = \
^libparted/arch/beos\.c$$
+
+exclude_file_name_regexp--sc_unmarked_diagnostics = ^tests/print-max\.c$$
diff --git a/tests/print-max.c b/tests/print-max.c
index 7560d49..41aa8c6 100644
--- a/tests/print-max.c
+++ b/tests/print-max.c
@@ -2,9 +2,11 @@
#include <parted/parted.h>
#include <stdio.h>
#include <stdlib.h>
+#include <errno.h>
#include "closeout.h"
#include "progname.h"
+#include "error.h"
int
main (int argc, char **argv)
@@ -26,8 +28,16 @@ main (int argc, char **argv)
PedSector max_length = ped_disk_max_partition_length (disk);
PedSector max_start_sector = ped_disk_max_partition_start_sector (disk);
+ if (!ped_device_open(dev))
+ error (EXIT_FAILURE, errno, "failed to open %s\n", dev_name);
+ int max_n_partitions;
+ bool ok = ped_disk_get_max_supported_partition_count (disk,
+ &max_n_partitions);
+
printf ("max len: %llu\n", (unsigned long long) max_length);
printf ("max start sector: %llu\n", (unsigned long long) max_start_sector);
+ printf ("max number of partitions: %d\n",
+ ok ? max_n_partitions : -1);
ped_disk_destroy (disk);
ped_device_destroy (dev);
diff --git a/tests/t9021-maxima.sh b/tests/t9021-maxima.sh
index 0570585..ca10d17 100755
--- a/tests/t9021-maxima.sh
+++ b/tests/t9021-maxima.sh
@@ -23,6 +23,27 @@ dev=dev-file
PATH="..:$PATH"
export PATH
+max_n_partitions()
+{
+ case $1 in
+
+ # Technically, msdos partition tables have no limit on the maximum number
+ # of partitions, but we pretend it is 64 due to implementation details.
+ msdos) m=64;;
+
+ gpt) m=128;;
+ dvh) m=16;;
+ sun) m=8;;
+ mac) m=65536;;
+ bsd) m=8;;
+ amiga) m=128;;
+ loop) m=1;;
+ pc98) case $ss in 512) m=16;; *) m=64;; esac;;
+ *) warn_ invalid partition table type: $1 1>&2; exit 1;;
+ esac
+ echo $m
+}
+
# FIXME: add aix when/if it's supported again
for t in msdos gpt dvh sun mac bsd amiga loop pc98; do
echo $t
@@ -40,8 +61,11 @@ for t in msdos gpt dvh sun mac bsd amiga loop pc98; do
esac
print-max $dev > out 2>&1 || fail=1
+ m=$(max_n_partitions $t) || fail=1
printf '%s\n' "max len: $max_len" \
- "max start sector: $max_start" > exp || fail=1
+ "max start sector: $max_start" \
+ "max number of partitions: $m" \
+ > exp || fail=1
compare exp out || fail=1
done
--
1.9.3

View File

@ -1,51 +0,0 @@
From 89377f99947391c081df6dad27edf6ac3daec5c0 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Tue, 28 Aug 2012 19:47:54 +0200
Subject: [PATCH 007/131] maint: avoid new syntax-check failure re @xref
* doc/parted.texi: Adjust @xref usage: it must be used only
at start of sentence.
* doc/parted-pt_BR.texi: Likewise.
---
doc/parted-pt_BR.texi | 4 ++--
doc/parted.texi | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/doc/parted-pt_BR.texi b/doc/parted-pt_BR.texi
index 8eb5cec..8878f83 100644
--- a/doc/parted-pt_BR.texi
+++ b/doc/parted-pt_BR.texi
@@ -1094,7 +1094,7 @@ de sistemas operacionais Microsoft.
@item raid
(MSDOS) - este sinalizador pode ser habilitado para dizer ao Linux que
-essa partição é uma partição de software RAID @xref{LVM e RAID}.
+essa partição é uma partição de software RAID. @xref{LVM e RAID}.
@item LVM
(MSDOS) - este sinalizador pode ser habilitado para dizer à partição
@@ -1994,7 +1994,7 @@ mudan
com o kernel 2.4, e quando nós adicionarmos suporte a ele.)
Se você quer redimensionar sua partição root ou de boot, use um disco
-de boot @xref{Discos de boot do Parted}, ou use o redimensionador
+de boot @pxref{Discos de boot do Parted}, ou use o redimensionador
online do Andreas Dilger, incluído no pacote ext2resize @ref{Ext2}.
@menu
diff --git a/doc/parted.texi b/doc/parted.texi
index 6561d0e..1601151 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -348,7 +348,7 @@ specify the location in ``G''). Use the sector unit ``s'' to specify exact
locations. With parted-2.4 and newer,
IEC binary units like ``MiB'', ``GiB'', ``TiB'', etc., specify
exact locations as well.
-See @xref{IEC binary units}.
+@xref{IEC binary units}.
If you don't give a parameter to a command, Parted will prompt you for it.
For example:
--
1.9.3

View File

@ -1,28 +0,0 @@
From 00a5736ff2220229d75d4259c582ae0a62539915 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Tue, 28 Aug 2012 19:49:25 +0200
Subject: [PATCH 008/131] maint: don't prohibit strncpy just yet
* cfg.mk (local-checks-to-skip): Add sc_prohibit_strncpy,
so that we do not yet enable the strncpy prohibition.
There are many uses, and it will be a lot of work to remove
all of them.
---
cfg.mk | 1 +
1 file changed, 1 insertion(+)
diff --git a/cfg.mk b/cfg.mk
index 45d2ac2..3d3014c 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -34,6 +34,7 @@ local-checks-to-skip = \
sc_error_message_period \
sc_file_system \
sc_prohibit_strcmp \
+ sc_prohibit_strncpy \
sc_prohibit_atoi_atof \
sc_require_test_exit_idiom \
sc_space_tab \
--
1.9.3

View File

@ -1,576 +0,0 @@
From 92154e8dfb35c70f6792c4efed9cd97b4c84cbcb Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Tue, 28 Aug 2012 19:50:48 +0200
Subject: [PATCH 009/131] build: update gnulib, bootstrap and init.sh
---
bootstrap | 267 ++++++++++++++++++++++++++++++++++++++--------------------
gnulib | 2 +-
tests/init.sh | 13 ++-
3 files changed, 185 insertions(+), 97 deletions(-)
diff --git a/bootstrap b/bootstrap
index 31eb651..e3e270b 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,6 +1,6 @@
#! /bin/sh
# Print a version string.
-scriptversion=2012-02-11.09; # UTC
+scriptversion=2012-07-19.14; # UTC
# Bootstrap this package from checked-out sources.
@@ -36,6 +36,10 @@ nl='
LC_ALL=C
export LC_ALL
+# Ensure that CDPATH is not set. Otherwise, the output from cd
+# would cause trouble in at least one use below.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
local_gl_dir=gl
me=$0
@@ -73,6 +77,33 @@ Running without arguments will suffice in most cases.
EOF
}
+# warnf_ FORMAT-STRING ARG1...
+warnf_ ()
+{
+ warnf_format_=$1
+ shift
+ nl='
+'
+ case $* in
+ *$nl*) me_=$(printf "$me"|tr "$nl|" '??')
+ printf "$warnf_format_" "$@" | sed "s|^|$me_: |" ;;
+ *) printf "$me: $warnf_format_" "$@" ;;
+ esac >&2
+}
+
+# warn_ WORD1...
+warn_ ()
+{
+ # If IFS does not start with ' ', set it and emit the warning in a subshell.
+ case $IFS in
+ ' '*) warnf_ '%s\n' "$*";;
+ *) (IFS=' '; warn_ "$@");;
+ esac
+}
+
+# die WORD1...
+die() { warn_ "$@"; exit 1; }
+
# Configuration.
# Name of the Makefile.am
@@ -126,7 +157,8 @@ extract_package_name='
p
}
'
-package=`sed -n "$extract_package_name" configure.ac` || exit
+package=$(sed -n "$extract_package_name" configure.ac) \
+ || die 'cannot find package name in configure.ac'
gnulib_name=lib$package
build_aux=build-aux
@@ -182,6 +214,8 @@ use_git=true
# otherwise find the first of the NAMES that can be run (i.e.,
# supports --version). If found, set ENVVAR to the program name,
# die otherwise.
+#
+# FIXME: code duplication, see also gnu-web-doc-update.
find_tool ()
{
find_tool_envvar=$1
@@ -199,19 +233,15 @@ find_tool ()
else
find_tool_error_prefix="\$$find_tool_envvar: "
fi
- if test x"$find_tool_res" = x; then
- echo >&2 "$me: one of these is required: $find_tool_names"
- exit 1
- fi
- ($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
- echo >&2 "$me: ${find_tool_error_prefix}cannot run $find_tool_res --version"
- exit 1
- }
+ test x"$find_tool_res" != x \
+ || die "one of these is required: $find_tool_names"
+ ($find_tool_res --version </dev/null) >/dev/null 2>&1 \
+ || die "${find_tool_error_prefix}cannot run $find_tool_res --version"
eval "$find_tool_envvar=\$find_tool_res"
eval "export $find_tool_envvar"
}
-# Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6.
+# Find sha1sum, named gsha1sum on MacPorts, and shasum on Mac OS X 10.6.
find_tool SHA1SUM sha1sum gsha1sum shasum
# Override the default configuration, if necessary.
@@ -226,7 +256,6 @@ esac
test -z "${gnulib_extra_files}" && \
gnulib_extra_files="
$build_aux/install-sh
- $build_aux/missing
$build_aux/mdate-sh
$build_aux/texinfo.tex
$build_aux/depcomp
@@ -252,7 +281,7 @@ do
usage
exit;;
--gnulib-srcdir=*)
- GNULIB_SRCDIR=`expr "X$option" : 'X--gnulib-srcdir=\(.*\)'`;;
+ GNULIB_SRCDIR=${option#--gnulib-srcdir=};;
--skip-po)
SKIP_PO=t;;
--force)
@@ -266,21 +295,15 @@ do
--no-git)
use_git=false;;
*)
- echo >&2 "$0: $option: unknown option"
- exit 1;;
+ die "$option: unknown option";;
esac
done
-if $use_git || test -d "$GNULIB_SRCDIR"; then
- :
-else
- echo "$0: Error: --no-git requires --gnulib-srcdir" >&2
- exit 1
-fi
+$use_git || test -d "$GNULIB_SRCDIR" \
+ || die "Error: --no-git requires --gnulib-srcdir"
if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
- echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
- exit 1
+ die "Bootstrapping from a non-checked-out distribution is risky."
fi
# Ensure that lines starting with ! sort last, per gitignore conventions
@@ -303,10 +326,10 @@ insert_sorted_if_absent() {
file=$1
str=$2
test -f $file || touch $file
- echo "$str" | sort_patterns - $file | cmp - $file > /dev/null \
+ echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \
|| { echo "$str" | sort_patterns - $file > $file.bak \
&& mv $file.bak $file; } \
- || exit 1
+ || die "insert_sorted_if_absent $file $str: failed"
}
# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
@@ -319,7 +342,7 @@ insert_vc_ignore() {
# A .gitignore entry that does not start with '/' applies
# recursively to subdirectories, so prepend '/' to every
# .gitignore entry.
- pattern=`echo "$pattern" | sed s,^,/,`;;
+ pattern=$(echo "$pattern" | sed s,^,/,);;
esac
insert_sorted_if_absent "$vc_ignore_file" "$pattern"
}
@@ -330,11 +353,8 @@ grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
>/dev/null && found_aux_dir=yes
grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
>/dev/null && found_aux_dir=yes
-if test $found_aux_dir = no; then
- echo "$0: expected line not found in configure.ac. Add the following:" >&2
- echo " AC_CONFIG_AUX_DIR([$build_aux])" >&2
- exit 1
-fi
+test $found_aux_dir = yes \
+ || die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it"
# If $build_aux doesn't exist, create it now, otherwise some bits
# below will malfunction. If creating it, also mark it as ignored.
@@ -423,31 +443,48 @@ check_versions() {
$use_git || continue
fi
# Honor $APP variables ($TAR, $AUTOCONF, etc.)
- appvar=`echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
+ appvar=$(echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_')
test "$appvar" = TAR && appvar=AMTAR
case $appvar in
GZIP) ;; # Do not use $GZIP: it contains gzip options.
*) eval "app=\${$appvar-$app}" ;;
esac
+
+ # Handle the still-experimental Automake-NG programs specially.
+ # They remain named as the mainstream Automake programs ("automake",
+ # and "aclocal") to avoid gratuitous incompatibilities with
+ # pre-existing usages (by, say, autoreconf, or custom autogen.sh
+ # scripts), but correctly identify themselves (as being part of
+ # "GNU automake-ng") when asked their version.
+ case $app in
+ automake-ng|aclocal-ng)
+ app=${app%-ng}
+ ($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
+ warn_ "Error: '$app' not found or not from Automake-NG"
+ ret=1
+ continue
+ } ;;
+ esac
if [ "$req_ver" = "-" ]; then
# Merely require app to exist; not all prereq apps are well-behaved
# so we have to rely on $? rather than get_version.
$app --version >/dev/null 2>&1
if [ 126 -le $? ]; then
- echo "$me: Error: '$app' not found" >&2
+ warn_ "Error: '$app' not found"
ret=1
fi
else
# Require app to produce a new enough version string.
inst_ver=$(get_version $app)
if [ ! "$inst_ver" ]; then
- echo "$me: Error: '$app' not found" >&2
+ warn_ "Error: '$app' not found"
ret=1
else
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
if [ ! "$latest_ver" = "$inst_ver" ]; then
- echo "$me: Error: '$app' version == $inst_ver is too old" >&2
- echo " '$app' version >= $req_ver is required" >&2
+ warnf_ '%s\n' \
+ "Error: '$app' version == $inst_ver is too old" \
+ " '$app' version >= $req_ver is required"
ret=1
fi
fi
@@ -492,10 +529,8 @@ esac
# When we can deduce that gnulib-tool will require patch,
# and when patch is not already listed as a prerequisite, add it, too.
-if test ! -d "$local_gl_dir" \
- || find "$local_gl_dir" -name '*.diff' -exec false {} +; then
- :
-else
+if test -d "$local_gl_dir" \
+ && ! find "$local_gl_dir" -name '*.diff' -exec false {} +; then
case $buildreq in
*patch*) ;;
*) buildreq="patch -
@@ -506,11 +541,10 @@ fi
if ! printf "$buildreq" | check_versions; then
echo >&2
if test -f README-prereq; then
- echo "$0: See README-prereq for how to get the prerequisite programs" >&2
+ die "See README-prereq for how to get the prerequisite programs"
else
- echo "$0: Please install the prerequisite programs" >&2
+ die "Please install the prerequisite programs"
fi
- exit 1
fi
echo "$0: Bootstrapping from checked-out $package sources..."
@@ -539,7 +573,7 @@ git_modules_config () {
test -f .gitmodules && git config --file .gitmodules "$@"
}
-gnulib_path=`git_modules_config submodule.gnulib.path`
+gnulib_path=$(git_modules_config submodule.gnulib.path)
test -z "$gnulib_path" && gnulib_path=gnulib
# Get gnulib files.
@@ -612,10 +646,10 @@ download_po_files() {
subdir=$1
domain=$2
echo "$me: getting translations into $subdir for $domain..."
- cmd=`printf "$po_download_command_format" "$domain" "$subdir"`
+ cmd=$(printf "$po_download_command_format" "$domain" "$subdir")
eval "$cmd" && return
# Fallback to HTTP.
- cmd=`printf "$po_download_command_format2" "$subdir" "$domain"`
+ cmd=$(printf "$po_download_command_format2" "$subdir" "$domain")
eval "$cmd"
}
@@ -638,7 +672,7 @@ update_po_files() {
&& ls "$ref_po_dir"/*.po 2>/dev/null |
sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
- langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'`
+ langs=$(cd $ref_po_dir && echo *.po | sed 's/\.po//g')
test "$langs" = '*' && langs=x
for po in $langs; do
case $po in x) continue;; esac
@@ -675,18 +709,18 @@ symlink_to_dir()
# If the destination directory doesn't exist, create it.
# This is required at least for "lib/uniwidth/cjk.h".
- dst_dir=`dirname "$dst"`
+ dst_dir=$(dirname "$dst")
if ! test -d "$dst_dir"; then
mkdir -p "$dst_dir"
# If we've just created a directory like lib/uniwidth,
# tell version control system(s) it's ignorable.
# FIXME: for now, this does only one level
- parent=`dirname "$dst_dir"`
+ parent=$(dirname "$dst_dir")
for dot_ig in x $vc_ignore; do
test $dot_ig = x && continue
ig=$parent/$dot_ig
- insert_vc_ignore $ig `echo "$dst_dir"|sed 's,.*/,,'`
+ insert_vc_ignore $ig "${dst_dir##*/}"
done
fi
@@ -710,10 +744,10 @@ symlink_to_dir()
# so that broken tools aren't confused into skipping needed builds. See
# <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00326.html>.
test -h "$dst" &&
- src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
- dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
+ src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 &&
+ dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 &&
test "$src_i" = "$dst_i" &&
- both_ls=`ls -dt "$src" "$dst"` &&
+ both_ls=$(ls -dt "$src" "$dst") &&
test "X$both_ls" = "X$dst$nl$src" || {
dot_dots=
case $src in
@@ -721,11 +755,10 @@ symlink_to_dir()
*)
case /$dst/ in
*//* | */../* | */./* | /*/*/*/*/*/)
- echo >&2 "$me: invalid symlink calculation: $src -> $dst"
- exit 1;;
- /*/*/*/*/) dot_dots=../../../;;
- /*/*/*/) dot_dots=../../;;
- /*/*/) dot_dots=../;;
+ die "invalid symlink calculation: $src -> $dst";;
+ /*/*/*/*/) dot_dots=../../../;;
+ /*/*/*/) dot_dots=../../;;
+ /*/*/) dot_dots=../;;
esac;;
esac
@@ -736,6 +769,22 @@ symlink_to_dir()
}
}
+version_controlled_file() {
+ parent=$1
+ file=$2
+ if test -d .git; then
+ git rm -n "$file" > /dev/null 2>&1
+ elif test -d .svn; then
+ svn log -r HEAD "$file" > /dev/null 2>&1
+ elif test -d CVS; then
+ grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
+ grep '^/[^/]*/[0-9]' > /dev/null
+ else
+ warn_ "no version control for $file?"
+ false
+ fi
+}
+
# NOTE: we have to be careful to run both autopoint and libtoolize
# before gnulib-tool, since gnulib-tool is likely to provide newer
# versions of files "installed" by these two programs.
@@ -748,37 +797,54 @@ with_gettext=yes
grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
with_gettext=no
-if test $with_gettext = yes; then
- # Released autopoint has the tendency to install macros that have been
- # obsoleted in current gnulib, so run this before gnulib-tool.
- echo "$0: $AUTOPOINT --force"
- $AUTOPOINT --force || exit
-fi
+if test $with_gettext = yes || test $use_libtool = 1; then
-# Autoreconf runs aclocal before libtoolize, which causes spurious
-# warnings if the initial aclocal is confused by the libtoolized
-# (or worse out-of-date) macro directory.
-if test $use_libtool = 1; then
- echo "running: $LIBTOOLIZE --copy --install"
- $LIBTOOLIZE --copy --install
-fi
+ tempbase=.bootstrap$$
+ trap "rm -f $tempbase.0 $tempbase.1" 1 2 13 15
-version_controlled_file() {
- dir=$1
- file=$2
- found=no
- if test -d CVS; then
- grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
- grep '^/[^/]*/[0-9]' > /dev/null && found=yes
- elif test -d .git; then
- git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
- elif test -d .svn; then
- svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes
- else
- echo "$me: no version control for $dir/$file?" >&2
+ > $tempbase.0 > $tempbase.1 &&
+ find . ! -type d -print | sort > $tempbase.0 || exit
+
+ if test $with_gettext = yes; then
+ # Released autopoint has the tendency to install macros that have been
+ # obsoleted in current gnulib, so run this before gnulib-tool.
+ echo "$0: $AUTOPOINT --force"
+ $AUTOPOINT --force || exit
fi
- test $found = yes
-}
+
+ # Autoreconf runs aclocal before libtoolize, which causes spurious
+ # warnings if the initial aclocal is confused by the libtoolized
+ # (or worse out-of-date) macro directory.
+ # libtoolize 1.9b added the --install option; but we support back
+ # to libtoolize 1.5.22, where the install action was default.
+ if test $use_libtool = 1; then
+ install=
+ case $($LIBTOOLIZE --help) in
+ *--install*) install=--install ;;
+ esac
+ echo "running: $LIBTOOLIZE $install --copy"
+ $LIBTOOLIZE $install --copy
+ fi
+
+ find . ! -type d -print | sort >$tempbase.1
+ old_IFS=$IFS
+ IFS=$nl
+ for file in $(comm -13 $tempbase.0 $tempbase.1); do
+ IFS=$old_IFS
+ parent=${file%/*}
+ version_controlled_file "$parent" "$file" || {
+ for dot_ig in x $vc_ignore; do
+ test $dot_ig = x && continue
+ ig=$parent/$dot_ig
+ insert_vc_ignore "$ig" "${file##*/}"
+ done
+ }
+ done
+ IFS=$old_IFS
+
+ rm -f $tempbase.0 $tempbase.1
+ trap - 1 2 13 15
+fi
# Import from gnulib.
@@ -804,11 +870,12 @@ echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
for file in $gnulib_files; do
- symlink_to_dir "$GNULIB_SRCDIR" $file || exit
+ symlink_to_dir "$GNULIB_SRCDIR" $file \
+ || die "failed to symlink $file"
done
bootstrap_post_import_hook \
- || { echo >&2 "$me: bootstrap_post_import_hook failed"; exit 1; }
+ || die "bootstrap_post_import_hook failed"
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
# gnulib-populated directories. Such .m4 files would cause aclocal to fail.
@@ -836,16 +903,17 @@ echo "running: AUTOPOINT=true LIBTOOLIZE=true " \
"$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS"
AUTOPOINT=true LIBTOOLIZE=true \
$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS \
- || exit 1
+ || die "autoreconf failed"
# Get some extra files from gnulib, overriding existing files.
for file in $gnulib_extra_files; do
case $file in
*/INSTALL) dst=INSTALL;;
- build-aux/*) dst=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;;
+ build-aux/*) dst=$build_aux/${file#build-aux/};;
*) dst=$file;;
esac
- symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit
+ symlink_to_dir "$GNULIB_SRCDIR" $file $dst \
+ || die "failed to symlink $file"
done
if test $with_gettext = yes; then
@@ -861,7 +929,19 @@ if test $with_gettext = yes; then
a\
'"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
}
- ' po/Makevars.template >po/Makevars || exit 1
+ ' po/Makevars.template >po/Makevars \
+ || die 'cannot generate po/Makevars'
+
+ # If the 'gettext' module is in use, grab the latest Makefile.in.in.
+ # If only the 'gettext-h' module is in use, assume autopoint already
+ # put the correct version of this file into place.
+ case $gnulib_modules in
+ *gettext-h*) ;;
+ *gettext*)
+ cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in \
+ || die "cannot create po/Makefile.in.in"
+ ;;
+ esac
if test -d runtime-po; then
# Similarly for runtime-po/Makevars, but not quite the same.
@@ -875,7 +955,8 @@ if test $with_gettext = yes; then
a\
'"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
}
- ' po/Makevars.template >runtime-po/Makevars || exit 1
+ ' po/Makevars.template >runtime-po/Makevars \
+ || die 'cannot generate runtime-po/Makevars'
# Copy identical files from po to runtime-po.
(cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
diff --git a/gnulib b/gnulib
index 50bb21e..e1abd50 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 50bb21eab7dfc87bbfcbc75f0232407110cdd296
+Subproject commit e1abd50b01d6bd61bd0c996ca17378cd569c0aa1
diff --git a/tests/init.sh b/tests/init.sh
index ae86714..5f6e638 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -207,6 +207,14 @@ else
fi
fi
+# If this is bash, turn off all aliases.
+test -n "$BASH_VERSION" && unalias -a
+
+# Note that when supporting $EXEEXT (transparently mapping from PROG_NAME to
+# PROG_NAME.exe), we want to support hyphen-containing names like test-acos.
+# That is part of the shell-selection test above. Why use aliases rather
+# than functions? Because support for hyphen-containing aliases is more
+# widespread than that for hyphen-containing function names.
test -n "$EXEEXT" && shopt -s expand_aliases
# Enable glibc's malloc-perturbing option.
@@ -403,8 +411,7 @@ path_prepend_ ()
case $path_dir_ in
'') fail_ "invalid path dir: '$1'";;
/*) abs_path_dir_=$path_dir_;;
- *) abs_path_dir_=`cd "$initial_cwd_/$path_dir_" && echo "$PWD"` \
- || fail_ "invalid path dir: $path_dir_";;
+ *) abs_path_dir_=$initial_cwd_/$path_dir_;;
esac
case $abs_path_dir_ in
*:*) fail_ "invalid path dir: '$abs_path_dir_'";;
@@ -440,7 +447,7 @@ setup_ ()
pfx_=`testdir_prefix_`
test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \
|| fail_ "failed to create temporary directory in $initial_cwd_"
- cd "$test_dir_"
+ cd "$test_dir_" || fail_ "failed to cd to temporary directory"
# As autoconf-generated configure scripts do, ensure that IFS
# is defined initially, so that saving and restoring $IFS works.
--
1.9.3

View File

@ -1,86 +0,0 @@
From a185e958b5614ea7e606e85d3de879c5ffc127c0 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <stefano.lattarini@gmail.com>
Date: Thu, 30 Aug 2012 18:53:13 +0200
Subject: [PATCH 010/131] build: prefer $(AM_CPPFLAGS) over $(INCLUDES)
The latter is obsolete, and might be removed in future Automake versions.
Moreover, it's already been removed in Automake-NG, so its use would make
a port to Automake-NG more difficult.
* parted/Makefile.am (INCLUDES): Rename ...
(AM_CPPFLAGS): ... like this.
* partprobe/Makefile.am: Likewise.
* libparted/fs/Makefile.am: Likewise.
* libparted/Makefile.am: Likewise.
* libparted/labels/Makefile.am: Likewise.
Copyright-paperwork-exempt: yes
---
libparted/Makefile.am | 2 +-
libparted/fs/Makefile.am | 2 +-
libparted/labels/Makefile.am | 2 +-
parted/Makefile.am | 2 +-
partprobe/Makefile.am | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/libparted/Makefile.am b/libparted/Makefile.am
index 7cf35b2..bdc7976 100644
--- a/libparted/Makefile.am
+++ b/libparted/Makefile.am
@@ -62,4 +62,4 @@ libparted_la_LIBADD = \
EXTRA_DIST = mbr.s
-INCLUDES = $(partedincludedir) $(INTLINCS)
+AM_CPPFLAGS = $(partedincludedir) $(INTLINCS)
diff --git a/libparted/fs/Makefile.am b/libparted/fs/Makefile.am
index 8d48ea1..7fe364a 100644
--- a/libparted/fs/Makefile.am
+++ b/libparted/fs/Makefile.am
@@ -114,7 +114,7 @@ libparted_fs_resize_la_SOURCES = \
r/hfs/reloc_plus.c \
r/hfs/reloc_plus.h
-INCLUDES = \
+AM_CPPFLAGS = \
-I$(top_srcdir)/libparted/labels \
$(partedincludedir) \
$(INTLINCS)
diff --git a/libparted/labels/Makefile.am b/libparted/labels/Makefile.am
index 7fe347b..ec8abeb 100644
--- a/libparted/labels/Makefile.am
+++ b/libparted/labels/Makefile.am
@@ -37,7 +37,7 @@ liblabels_la_SOURCES = \
liblabels_la_LIBADD = $(OS_LIBS) $(INTLLIBS)
-INCLUDES = $(partedincludedir) $(INTLINCS)
+AM_CPPFLAGS = $(partedincludedir) $(INTLINCS)
BUILT_SOURCES = pt-limit.c
MAINTAINERCLEANFILES = $(BUILT_SOURCES)
diff --git a/parted/Makefile.am b/parted/Makefile.am
index 0b23693..e7bba2e 100644
--- a/parted/Makefile.am
+++ b/parted/Makefile.am
@@ -48,6 +48,6 @@ parted_LDFLAGS = $(PARTEDLDFLAGS)
# Tell the linker to omit references to unused shared libraries.
parted_LDFLAGS += $(IGNORE_UNUSED_LIBRARIES_CFLAGS)
-INCLUDES = $(partedincludedir) $(INTLINCS)
+AM_CPPFLAGS = $(partedincludedir) $(INTLINCS)
MAINTAINERCLEANFILES += Makefile.in
diff --git a/partprobe/Makefile.am b/partprobe/Makefile.am
index dbe2c9f..c0304a0 100644
--- a/partprobe/Makefile.am
+++ b/partprobe/Makefile.am
@@ -13,4 +13,4 @@ partprobe_LDADD = \
partprobe_LDFLAGS = $(PARTEDLDFLAGS)
-INCLUDES = $(partedincludedir) $(INTLINCS)
+AM_CPPFLAGS = $(partedincludedir) $(INTLINCS)
--
1.9.3

View File

@ -1,48 +0,0 @@
From 605c53ad0f209b9f62a15c3f89a9930860153489 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <stefano.lattarini@gmail.com>
Date: Thu, 30 Aug 2012 18:53:14 +0200
Subject: [PATCH 011/131] build: don't list files with unknown suffix in
_SOURCES
While this works with mainline Automake (which blindly treats source
files with an unknown extension as if they were header files), it is
undocumented (albeit admittedly unlikely to change). Moreover, it no
longer works with Automake-NG (and that's by design), so the use of
such feature would make a port to Automake-NG more difficult.
* libparted/labels/Makefile.am (liblabels_la_SOURCES): ... don't
list 'pt-limit.gperf' here; rather ...
(EXTRA_DIST): ... list 'pt-limit.c' and 'pt-limit.gperf' here.
(EXTRA_DIST, BUILT_SOURCES): Enhance few comments.
Copyright-paperwork-exempt: yes
---
libparted/labels/Makefile.am | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libparted/labels/Makefile.am b/libparted/labels/Makefile.am
index ec8abeb..f4e4d27 100644
--- a/libparted/labels/Makefile.am
+++ b/libparted/labels/Makefile.am
@@ -39,10 +39,11 @@ liblabels_la_LIBADD = $(OS_LIBS) $(INTLLIBS)
AM_CPPFLAGS = $(partedincludedir) $(INTLINCS)
+# Included by 'pt-tools.c', so needs to be built early.
BUILT_SOURCES = pt-limit.c
MAINTAINERCLEANFILES = $(BUILT_SOURCES)
-liblabels_la_SOURCES += pt-limit.gperf
-EXTRA_DIST = $(BUILT_SOURCES)
+# DOn't add this to '_SOURCES', because it's not to be compiled!
+EXTRA_DIST= pt-limit.c
GPERF = gperf
GPERF_OPTIONS = \
@@ -55,3 +56,4 @@ pt-limit.c: pt-limit.gperf
> $@-tmp
chmod a-w $@-tmp
mv $@-tmp $@
+EXTRA_DIST += pt-limit.gperf
--
1.9.3

View File

@ -1,36 +0,0 @@
From 904a8d31d2906e8e653d670e508c4c6bd4b264c1 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <stefano.lattarini@gmail.com>
Date: Thu, 30 Aug 2012 18:53:15 +0200
Subject: [PATCH 012/131] build: prefer pattern rules over suffix rules
That is acceptable, because the GNU parted build system already
requires GNU make anyway: the $(subst ...) built-in is used in the
common recipe for the 'ss-1024', 'ss-2048' and 'ss-4096' targets
in Makefile.am.
* include/parted/Makefile.am (.in.h.h): Rename ...
(%.h: %.in.h): ... as this pattern rule.
(SUFFIXES): Delete, no more needed.
Copyright-paperwork-exempt: yes
---
include/parted/Makefile.am | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/include/parted/Makefile.am b/include/parted/Makefile.am
index 19236f0..6f808c6 100644
--- a/include/parted/Makefile.am
+++ b/include/parted/Makefile.am
@@ -44,8 +44,7 @@ subst_pure_attr = \
$(BUILT_SOURCES): Makefile.am
-SUFFIXES = .in.h .h
-.in.h.h:
+%.h: %.in.h
$(AM_V_GEN)rm -f $@ $@-t
$(AM_V_at)perl -p \
-e '$(subst_const_attr);' \
--
1.9.3

View File

@ -1,53 +0,0 @@
From 803b2f58760ed82e5eb182df75ba18c00c9f43bf Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <stefano.lattarini@gmail.com>
Date: Thu, 30 Aug 2012 18:53:16 +0200
Subject: [PATCH 013/131] build: enable subdir-objects Automake option globally
That option is enabled unconditionally in Automake-NG, and enabling
it also for mainline Automake will help to ensure no unexpected
incompatibilities is introduced in a potential port to Automake-NG.
Moreover, if we have a source file 'sub/foo.c', having it compiled
in 'sub/foo.o' rather than in 'foo.o' is undeniably cleaner and more
natural.
* configure.ac (AM_INIT_AUTOMAKE): Add 'subdir-objects'.
* libparted/fs/Makefile.am (AUTOMAKE_OPTIONS): No need to declare
'subdir-objects' explicitly now.
Copyright-paperwork-exempt: yes
---
configure.ac | 3 ++-
libparted/fs/Makefile.am | 2 --
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index 1444279..49ef75c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,7 +52,8 @@ AC_SUBST([LT_CURRENT])
AC_SUBST([LT_REVISION])
AC_SUBST([LT_AGE])
-AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz color-tests parallel-tests])
+AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz color-tests parallel-tests
+ subdir-objects])
AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
AC_CANONICAL_HOST
diff --git a/libparted/fs/Makefile.am b/libparted/fs/Makefile.am
index 7fe364a..064f11a 100644
--- a/libparted/fs/Makefile.am
+++ b/libparted/fs/Makefile.am
@@ -3,8 +3,6 @@
#
# This file may be modified and/or distributed without restriction.
-AUTOMAKE_OPTIONS = subdir-objects
-
partedincludedir = -I$(top_builddir)/include -I$(top_srcdir)/include
AM_CFLAGS = $(WARN_CFLAGS)
--
1.9.3

View File

@ -1,32 +0,0 @@
From 2bd66d7d3e5a1924c65c051d4b639c5ab48bbb99 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <stefano.lattarini@gmail.com>
Date: Thu, 30 Aug 2012 18:53:17 +0200
Subject: [PATCH 014/131] tests: prefer AM_TESTS_ENVIRONMENT over
TESTS_ENVIRONMENT
The latter should be reserved for user overrides.
* tests/Makefile.am (TESTS_ENVIRONMENT): Rename ...
(AM_TESTS_ENVIRONMENT): ... like this.
Copyright-paperwork-exempt: yes
---
tests/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1264812..33e8f8e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -96,7 +96,7 @@ sep = $(PATH_SEPARATOR)
# variables that can perturb tests are unset or set to expected values.
# The rest are envvar settings that propagate build-related Makefile
# variables to test scripts.
-TESTS_ENVIRONMENT = \
+AM_TESTS_ENVIRONMENT = \
tmp__=$$TMPDIR; test -d "$$tmp__" || tmp__=.; \
TMPDIR=$$tmp__; export TMPDIR; \
export \
--
1.9.3

View File

@ -1,41 +0,0 @@
From af4d0f5706740848c3fef67a7ea0b78cf31ddb90 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <stefano.lattarini@gmail.com>
Date: Thu, 30 Aug 2012 18:53:18 +0200
Subject: [PATCH 015/131] tests: remove unused AM_TESTS_ENVIRONMENT entries
Probably a copy&paste errors, likely from the TESTS_ENVIRONMENT
definition in the 'tests/Makefile.am' in GNU coreutils.
* tests/Makefile.am (AM_TESTS_ENVIRONMENT): Don't define nor export
any of the variables PREFERABLY_POSIX_SHELL, REPLACE_GETCWD, CC,
MAKE, PERL.
Copyright-paperwork-exempt: yes
---
tests/Makefile.am | 5 -----
1 file changed, 5 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 33e8f8e..c97400b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -107,16 +107,11 @@ AM_TESTS_ENVIRONMENT = \
srcdir='$(srcdir)' \
top_srcdir='$(top_srcdir)' \
AWK='$(AWK)' \
- CC='$(CC)' \
- MAKE=$(MAKE) \
PACKAGE_BUGREPORT='$(PACKAGE_BUGREPORT)' \
PACKAGE_VERSION=$(PACKAGE_VERSION) \
CONFIG_HEADER='$(abs_top_builddir)/lib/config.h' \
ENABLE_DEVICE_MAPPER=$(ENABLE_DEVICE_MAPPER) \
PARTED_TEST_NAME=`basename '$(abs_srcdir)'`,`echo $$tst|sed 's,^\./,,;s,/,-,g'`\
- PERL='$(PERL)' \
- PREFERABLY_POSIX_SHELL='$(PREFERABLY_POSIX_SHELL)' \
- REPLACE_GETCWD=$(REPLACE_GETCWD) \
PATH='$(abs_top_builddir)/parted$(PATH_SEPARATOR)'"$$PATH" \
VERSION=$(VERSION) \
; 9>&2
--
1.9.3

View File

@ -1,51 +0,0 @@
From b2338d71549462c1dfbb434111b5c46701f54261 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <stefano.lattarini@gmail.com>
Date: Thu, 30 Aug 2012 18:53:19 +0200
Subject: [PATCH 016/131] build: require Automake >= 1.11.6
Now that we use AM_TESTS_ENVIRONMENT, we should require at least
Automake >= 1.11.2; but since all the Automake version until 1.11.5
are vulnerable to CVE-2012-3386:
<https://lists.gnu.org/archive/html/automake/2012-07/msg00023.html>
it's even better to require 1.11.6.
* configure.ac (AM_INIT_AUTOMAKE): Bump version requirement to 1.11.6.
* bootstrap.conf ($buildreq): Likewise.
Copyright-paperwork-exempt: yes
---
bootstrap.conf | 2 +-
configure.ac | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index b4456b2..39a5506 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -130,7 +130,7 @@ mkdir -p gnulib-tests
# Build prerequisites
buildreq="\
autoconf 2.61
-automake 1.11
+automake 1.11.6
autopoint -
bc -
gettext -
diff --git a/configure.ac b/configure.ac
index 49ef75c..832fc20 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,7 +52,7 @@ AC_SUBST([LT_CURRENT])
AC_SUBST([LT_REVISION])
AC_SUBST([LT_AGE])
-AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz color-tests parallel-tests
+AM_INIT_AUTOMAKE([1.11.6 no-dist-gzip dist-xz color-tests parallel-tests
subdir-objects])
AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
--
1.9.3

View File

@ -1,29 +0,0 @@
From c7c9978f0bbf05517437ccc76ea8eff5d811aaef Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <stefano.lattarini@gmail.com>
Date: Thu, 30 Aug 2012 18:53:20 +0200
Subject: [PATCH 017/131] maint: make Autoconf version requirement consistent
* bootstrap.conf ($buildreq): Require Autoconf >= 2.63, not >= 2.61,
for consistency with what is done in AC_INIT in configure.ac
Copyright-paperwork-exempt: yes
---
bootstrap.conf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 39a5506..a5d5910 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -129,7 +129,7 @@ mkdir -p gnulib-tests
# Build prerequisites
buildreq="\
-autoconf 2.61
+autoconf 2.63
automake 1.11.6
autopoint -
bc -
--
1.9.3

View File

@ -1,30 +0,0 @@
From 0406b2ce14fb86ede506c51d6b603b1f4a1ff42d Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <stefano.lattarini@gmail.com>
Date: Thu, 30 Aug 2012 18:53:21 +0200
Subject: [PATCH 018/131] maint: tighten per version requirement
* bootstrap.conf ($buildreq): Require Perl >= 5.6 (not merely >= 5.5),
because that's the minimal version required by modern Automake and
Autoconf.
Copyright-paperwork-exempt: yes
---
bootstrap.conf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index a5d5910..7f4ee53 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -138,7 +138,7 @@ git 1.4.4
gperf 3.0.3
gzip -
makeinfo -
-perl 5.5
+perl 5.6
rsync -
tar -
"
--
1.9.3

View File

@ -1,31 +0,0 @@
From 464c0f9ae4af8346cd494c6434f4addabdd76e9d Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Tue, 11 Sep 2012 17:22:52 +0200
Subject: [PATCH 019/131] maint: remove unnecessary wcslen use
* parted/strlist.c (gettext_to_wchar): Tighten up test for
mbsrtowcs failure and remove unnecessary wcslen use.
---
parted/strlist.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/parted/strlist.c b/parted/strlist.c
index d34fb56..1f90c0e 100644
--- a/parted/strlist.c
+++ b/parted/strlist.c
@@ -112,10 +112,10 @@ gettext_to_wchar (const char* str)
memset(&ps, 0, sizeof (ps));
status = mbsrtowcs(result, &str, count, &ps);
- if (status == (size_t) -1)
+ if (str != NULL)
goto error;
- result = xrealloc (result, (wcslen (result) + 1) * sizeof (wchar_t));
+ result = xrealloc (result, (status + 1) * sizeof (wchar_t));
return result;
error:
--
1.9.3

View File

@ -1,27 +0,0 @@
From 1d67e37ef257d3d3847126f3b899b8b0e11aa186 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Wed, 12 Sep 2012 10:02:46 +0200
Subject: [PATCH 020/131] tests: clarify a comment: _reading_ gpt tables on
tiny devices
* tests/t0203-gpt-tiny-device-abort.sh: Clarify.
---
tests/t0203-gpt-tiny-device-abort.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/t0203-gpt-tiny-device-abort.sh b/tests/t0203-gpt-tiny-device-abort.sh
index 7283c55..bf281ff 100644
--- a/tests/t0203-gpt-tiny-device-abort.sh
+++ b/tests/t0203-gpt-tiny-device-abort.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-# parted before 3.1 could abort for a pathologically small device with
-# a valid primary GPT header but no room for the backup header.
+# parted before 3.1 could abort while reading a pathologically small device
+# with a valid primary GPT header but no room for the backup header.
# Copyright (C) 2009-2012 Free Software Foundation, Inc.
--
1.9.3

View File

@ -1,31 +0,0 @@
From 46d9108009ccb9ac567cc285a15efb05864932d5 Mon Sep 17 00:00:00 2001
From: Davidlohr Bueso <dave@gnu.org>
Date: Tue, 11 Sep 2012 19:22:32 +0200
Subject: [PATCH 021/131] gpt: require first_usable_LBA <= last_usable_LBA
When verifying GPT header integrity, ensure that the
first usable LBA is no larger than the last usable LBA.
* libparted/labels/gpt.c (_header_is_valid): Reject a header
with last_usable < first_usable.
---
libparted/labels/gpt.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 6032e3f..83e518f 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -653,6 +653,10 @@ _header_is_valid (PedDisk const *disk, GuidPartitionTableHeader_t *gpt,
if (first_usable < 3)
return 0;
+ PedSector last_usable = PED_LE64_TO_CPU (gpt->LastUsableLBA);
+ if (last_usable < first_usable)
+ return 0;
+
origcrc = gpt->HeaderCRC32;
gpt->HeaderCRC32 = 0;
if (pth_crc32 (dev, gpt, &crc) != 0)
--
1.9.3

View File

@ -1,38 +0,0 @@
From 81faa9b3b957781871ec3ef0df6e357388f857a1 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Wed, 12 Sep 2012 20:34:48 +0200
Subject: [PATCH 022/131] tests: update t7000-scripting.sh to avoid new FP
* tests/t7000-scripting.sh: Use -34s as the endpoint, not -1s,
to avoid a spurious difference. Also, remove quoting artifacts.
---
tests/t7000-scripting.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/t7000-scripting.sh b/tests/t7000-scripting.sh
index e64814b..859acda 100755
--- a/tests/t7000-scripting.sh
+++ b/tests/t7000-scripting.sh
@@ -47,7 +47,7 @@ for mkpart in mkpart; do
dd if=/dev/zero of=testfile bs=${ss}c count=$N 2> /dev/null || fail=1
# Test the scripting mode of $mkpart.
- parted -s testfile -- mklabel gpt "$mkpart" p-name ext3 1s -1s > out 2>&1
+ parted -s testfile -- mklabel gpt "$mkpart" p-name ext3 1s -34s > out 2>&1
test $? = 1 || fail=1
# Compare the real error and the expected one
@@ -60,8 +60,8 @@ for mkpart in mkpart; do
dd if=/dev/zero of=testfile bs=${ss}c count=$N 2> /dev/null || fail=1
# Test the interactive mode of $mkpart
echo n | \
- parted ---pretend-input-tty testfile \
- "mklabel gpt '$mkpart' p-name ext3 1s -1s" > out 2>&1 && fail=1
+ parted ---pretend-input-tty -- testfile \
+ mklabel gpt $mkpart p-name ext3 1s -34s > out 2>&1 && fail=1
# We have to format the output before comparing.
# normalize the actual output
--
1.9.3

View File

@ -1,37 +0,0 @@
From 48f236f9cf1bbcd4c9cc29ebaecee7ed189580e3 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Wed, 12 Sep 2012 10:01:53 +0200
Subject: [PATCH 023/131] gpt: permit "mklabel gpt" on a 67-sector device
* libparted/labels/gpt.c (gpt_alloc): Correct checks in order to
allow creation of a GPT partition table on a 67-sector device.
The computation of the "data_end" sector number was one too low.
Whereas there are two sectors at the beginning of the disk (pMBR
and the GPT header sector), there is only one at the end: the
backup GPT header. That (67) is the size of the smallest GPT
partition table, allowing for *no* partition table sectors.
---
libparted/labels/gpt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 83e518f..564a889 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -501,11 +501,11 @@ gpt_alloc (const PedDevice *dev)
goto error;
data_start = 2 + GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / dev->sector_size;
- data_end = dev->length - 2
+ data_end = dev->length - 1
- GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / dev->sector_size;
/* If the device is too small to have room for data, reject it. */
- if (data_end <= data_start)
+ if (data_end < data_start)
goto error_free_disk;
disk->disk_specific = gpt_disk_data = ped_malloc (sizeof (GPTDiskData));
--
1.9.3

View File

@ -1,38 +0,0 @@
From 7ca7f595e4cef589db852394687a6ca0c2925fa7 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Wed, 12 Sep 2012 10:48:33 +0200
Subject: [PATCH 024/131] gpt: when "mklabel gpt" fails, always provide a
diagnostic
* libparted/labels/gpt.c (gpt_alloc): When rejecting a device because
it is too small, give a diagnostic, as is done in every other failure
path through this function.
---
libparted/labels/gpt.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 564a889..63b30b9 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -504,9 +504,15 @@ gpt_alloc (const PedDevice *dev)
data_end = dev->length - 1
- GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / dev->sector_size;
- /* If the device is too small to have room for data, reject it. */
+ /* If the device is too small to accommodate GPT headers, reject it. */
if (data_end < data_start)
- goto error_free_disk;
+ {
+ ped_exception_throw (PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_OK,
+ _("device is so small it cannot even"
+ " accommodate GPT headers"));
+ goto error_free_disk;
+ }
disk->disk_specific = gpt_disk_data = ped_malloc (sizeof (GPTDiskData));
if (!disk->disk_specific)
--
1.9.3

View File

@ -1,82 +0,0 @@
From 42c1964bdc2311ec142453cf43a8737da81b2f0d Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Wed, 12 Sep 2012 10:43:17 +0200
Subject: [PATCH 025/131] tests: show that small dev now evokes "mklabel gpt"
diagnostic
* tests/t0203-gpt-create-on-min-sized-device.sh: New test.
* tests/Makefile.am (TESTS): Add it.
---
tests/Makefile.am | 1 +
tests/t0203-gpt-create-on-min-sized-device.sh | 47 +++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
create mode 100644 tests/t0203-gpt-create-on-min-sized-device.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c97400b..66b9361 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -16,6 +16,7 @@ TESTS = \
t0202-gpt-pmbr.sh \
t0203-gpt-tiny-device-abort.sh \
t0203-gpt-shortened-device-primary-valid.sh \
+ t0203-gpt-create-on-min-sized-device.sh \
t0205-gpt-list-clobbers-pmbr.sh \
t0206-gpt-print-with-corrupt-primary-clobbers-pmbr.sh \
t0207-IEC-binary-notation.sh \
diff --git a/tests/t0203-gpt-create-on-min-sized-device.sh b/tests/t0203-gpt-create-on-min-sized-device.sh
new file mode 100644
index 0000000..113e191
--- /dev/null
+++ b/tests/t0203-gpt-create-on-min-sized-device.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+# parted 3.1 and prior would exit with no diagnostic when failing
+# to create a GPT partition table on a device that was too small.
+
+# Copyright (C) 2012 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/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+require_512_byte_sector_size_
+
+dev=loop-file
+ss=$sector_size_
+
+# Create the smallest file that can accommodate a GPT partition table.
+dd if=/dev/null of=$dev bs=$ss seek=67 || framework_failure
+
+# create a GPT partition table
+parted -s $dev mklabel gpt > out 2>&1 || fail=1
+# expect no output
+compare /dev/null out || fail=1
+
+# Create a file that is 1 sector smaller, and require failure,
+# *with* a diagnostic.
+rm -f $dev
+dd if=/dev/null of=$dev bs=$ss seek=66 || framework_failure
+
+echo Error: device is so small it cannot even accommodate GPT headers \
+ > exp || framework_failure
+
+# Try to create a GPT partition table in too little space. This must fail.
+parted -s $dev mklabel gpt > out 2>&1 && fail=1
+# There must be a diagnostic.
+compare out exp || fail=1
+
+Exit $fail
--
1.9.3

View File

@ -1,27 +0,0 @@
From bcc6517853c09f979951ab483bd6560d45bf8e3f Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Thu, 20 Sep 2012 20:22:13 +0200
Subject: [PATCH 026/131] tests: avoid syntax-check failure for reversed
compare args
* tests/t0203-gpt-create-on-min-sized-device.sh: Reverse args,
so that any diff output (upon failed test) looks sensible.
---
tests/t0203-gpt-create-on-min-sized-device.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/t0203-gpt-create-on-min-sized-device.sh b/tests/t0203-gpt-create-on-min-sized-device.sh
index 113e191..4cec64c 100644
--- a/tests/t0203-gpt-create-on-min-sized-device.sh
+++ b/tests/t0203-gpt-create-on-min-sized-device.sh
@@ -42,6 +42,6 @@ echo Error: device is so small it cannot even accommodate GPT headers \
# Try to create a GPT partition table in too little space. This must fail.
parted -s $dev mklabel gpt > out 2>&1 && fail=1
# There must be a diagnostic.
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
--
1.9.3

View File

@ -1,78 +0,0 @@
From 6c7932b90a9d078ffaf8ec9482b272c67d75a01d Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 4 Sep 2012 16:42:34 -0700
Subject: [PATCH 027/131] mac: don't let larger partition-table-specified block
size evoke UB
For example, in reading a MAC partition table on a 512-byte sector-size
disk, _disk_analyse_block_size could find reason to ask if it's ok to
increase that to e.g., 2048. Upon a positive reply, we would read 2048
bytes into a 512-byte buffer.
* libparted/labels/mac.c (mac_read): If needed, reallocate "buf"
to accommodate a new, larger sector size.
* NEWS (Bug fixes): Mention it.
---
NEWS | 7 +++++++
libparted/labels/mac.c | 14 +++++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index f929b99..bab3afb 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,13 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ libparted: mac: a MAC partition table could have a block_size larger
+ than the one the kernel told us about. Upon reading that partition
+ table, libparted would ask if it's ok to use the larger block size.
+ If you were to respond in the affirmative, libparted would read the
+ larger number of bytes into a buffer of the shorter length,
+ overrunning it.
+
libparted: gpt: fix gpt_get_max_supported_partition_count to work
also on little-endian systems.
diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c
index 1f59a1a..2485187 100644
--- a/libparted/labels/mac.c
+++ b/libparted/labels/mac.c
@@ -738,13 +738,16 @@ mac_read (PedDisk* disk)
if (!ptt_read_sector (disk->dev, 0, &buf))
return 0;
- MacRawDisk *raw_disk = (MacRawDisk *) buf;
+ MacRawDisk *raw_disk = buf;
if (!_check_signature (raw_disk))
goto error;
+ /* Record the original sector size; this function may change it. */
+ PedSector ss0 = disk->dev->sector_size;
if (!_disk_analyse_block_size (disk, raw_disk))
goto error;
+
if (!_disk_analyse_ghost_size (disk))
goto error;
ghost_size = mac_disk_data->ghost_size;
@@ -759,6 +762,15 @@ mac_read (PedDisk* disk)
mac_disk_data->block_size = raw_disk->block_size;
}
+ /* If _disk_analyse_block_size has increased the sector_size,
+ reallocate this buffer, so we can still read a sector into it. */
+ if (ss0 < disk->dev->sector_size) {
+ free (buf);
+ buf = ped_malloc (disk->dev->sector_size);
+ if (buf == NULL)
+ goto error;
+ }
+
for (num=1; num==1 || num <= last_part_entry_num; num++) {
void *raw_part = buf;
if (!ped_device_read (disk->dev, raw_part,
--
1.9.3

View File

@ -1,83 +0,0 @@
From 6499402a18baf22f08084acb289431b731d3afda Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Thu, 20 Sep 2012 20:18:50 +0200
Subject: [PATCH 028/131] tests: mac: exercise the just-fixed bug
* tests/t0350-mac-PT-increases-sector-size.sh: New test.
* tests/Makefile.am (TESTS): Add it.
---
tests/Makefile.am | 1 +
tests/t0350-mac-PT-increases-sector-size.sh | 49 +++++++++++++++++++++++++++++
2 files changed, 50 insertions(+)
create mode 100644 tests/t0350-mac-PT-increases-sector-size.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 66b9361..96abecb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -30,6 +30,7 @@ TESTS = \
t0280-gpt-corrupt.sh \
t0300-dos-on-gpt.sh \
t0301-overwrite-gpt-pmbr.sh \
+ t0350-mac-PT-increases-sector-size.sh \
t0400-loop-clobber-infloop.sh \
t0500-dup-clobber.sh \
t0501-duplicate.sh \
diff --git a/tests/t0350-mac-PT-increases-sector-size.sh b/tests/t0350-mac-PT-increases-sector-size.sh
new file mode 100644
index 0000000..2dbd8cd
--- /dev/null
+++ b/tests/t0350-mac-PT-increases-sector-size.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+# With parted-3.1, a MAC partition table that specified a sector size (B)
+# larger than what the kernel told us (SS) would cause parted to read B
+# bytes into a smaller, SS-byte buffer, clobbering heap storage.
+
+# Copyright (C) 2012 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/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+require_512_byte_sector_size_
+
+dev=loop-file
+ss=$sector_size_
+
+dd if=/dev/null of=$dev bs=$ss seek=2000 || framework_failure
+parted -s $dev mklabel mac > out 2>&1 || fail=1
+# expect no output
+compare /dev/null out || fail=1
+
+# Poke a big-endian 1024 into the 2-byte block_size slot.
+perl -e 'print pack("S>", 1024)'|dd of=$dev bs=1 seek=2 count=2 conv=notrunc \
+ || fail=1
+
+printf 'ignore\ncancel\n' > in || framework_failure
+
+cat <<EOF > exp
+BYT;
+FILE:2000s:file:1024:512:unknown::;
+EOF
+
+parted -m ---pretend-input-tty $dev u s p < in > err 2>&1 || fail=1
+sed 's, * ,,g;s!^/[^:]*:!FILE:!' err \
+ | grep -Evi '^(ignore|fix|error|warning)' \
+ > k && mv k err || fail=1
+compare exp err || fail=1
+
+Exit $fail
--
1.9.3

View File

@ -1,333 +0,0 @@
From e6536360bd4496cee1f1bf2dfb0b11f6bdbbfd4b Mon Sep 17 00:00:00 2001
From: "Roderick W. Smith" <rodsmith@rodsbooks.com>
Date: Sun, 23 Sep 2012 21:29:10 +0200
Subject: [PATCH 029/131] add support for a new Linux-specific GPT partition
type code
* NEWS: Describe the new Linux-specific partition type code
and the new msftres flag that can be used to override this type
code, should it be necessary.
* doc/parted.texi: Describe of the new msftres flag.
* include/parted/disk.in.h [_PedPartitionFlag]: Add
PED_PARTITION_MSFT_DATA.
* libparted/disk.c: Add check for PED_PARTITION_MSFT_DATA, with
return of "msftdata", to ped_partition_flag_get_name()
* libparted/labels/gpt.c (PARTITION_LINUX_DATA_GUID): Define.
[_GPTPartitionData]: New member, "int msftdata".
(_parse_part_entry): Set the msftdata flag if and only if the
PARTITION_BASIC_DATA_GUID type code is in use;
(gpt_partition_new): Use the PARTITION_LINUX_DATA_GUID
type as the default type code
(gpt_partition_set_system): Set the PARTITION_BASIC_DATA_GUID type
code on partitions on which the msftdata flag is set and set
PARTITION_LINUX_DATA_GUID as the type by default.
Clear the msftdata flag in most tests in gpt_partition_set_flag()
(gpt_partition_set_flag): Add test for PED_PARTITION_MSFT_DATA, which
sets msftdata and other flags appropriately
(gpt_partition_get_flag): Add test for the PED_PARTITION_MSFT_DATA
item that returns the status of the msftdata flag
(gpt_partition_is_flag_available): Add test for
PED_PARTITION_MSFT_DATA item to
* tests/t0220-gpt-msftres.sh: Accommodate the fact that now,
partition table listings include "msftdata" for file systems
of type NTFS and FAT*.
For more discussion and justification, see
http://thread.gmane.org/gmane.comp.gnu.parted.bugs/10456
---
NEWS | 19 +++++++++++++++++++
doc/parted.texi | 16 +++++++++++++++-
include/parted/disk.in.h | 5 +++--
libparted/disk.c | 2 ++
libparted/labels/gpt.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
tests/t0220-gpt-msftres.sh | 3 ++-
6 files changed, 84 insertions(+), 6 deletions(-)
diff --git a/NEWS b/NEWS
index bab3afb..4c4716d 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,25 @@ GNU parted NEWS -*- outline -*-
libparted: treat a disk with no pMBR as an msdos-labeled disk
even when it has valid GPT headers.
+** Changes in behavior
+
+ Added new Linux-specific partition GUID type code
+ (0FC63DAF-8483-4772-8E79-3D69D8477DE4) for Linux filesystem data on GPT
+ disks. This type code is now assigned as the default partition type code
+ for new partitions holding Linux filesystems.
+
+ Added new "msftdata" flag to identify partitions holding NTFS or FAT
+ filesystems on GPT disks. This flag corresponds to a GPT type code of
+ EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 ("Microsoft Basic Data"). Since
+ Linux filesystem partitions formerly used this type code, this flag may
+ optionally be set on Linux partitions to make the partition table type
+ codes match former configurations in case the new Linux filesystem type
+ code causes problems with some utility. Note that this flag cannot be
+ removed from NTFS or FAT partitions within parted except by setting a
+ competing flag, such as "boot" (which sets the type code used by EFI
+ System partitions) or "msftres" (which sets the "Microsoft Reserved" type
+ code).
+
* Noteworthy changes in release 3.1 (2012-03-02) [stable]
diff --git a/doc/parted.texi b/doc/parted.texi
index 1601151..b8db19d 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -793,6 +793,20 @@ on a partition that partition must be bootable.
For PC98 disk labels, all ext2 partitions must be bootable (this is
enforced by Parted).
+@item msftdata
+(GPT) - This flag identifies partitions that contain Microsoft filesystems
+(NTFS or FAT). It may optionally be set on Linux filesystems to mimic the
+type of configuration created by parted 3.0 and earlier, in which a
+separate Linux filesystem type code was not available on GPT disks. This
+flag can only be removed within parted by replacing it with a competing
+flag, such as boot or msftres.
+
+@item msftres
+(GPT) - This flag identifies a "Microsoft Reserved" partition, which is
+used by Windows on GPT disks. Note that this flag should not normally be
+set on Windows filesystem partitions (those that contain NTFS or FAT
+filesystems).
+
@item lba
(MS-DOS) - this flag can be enabled to tell MS DOS, MS Windows 9x and
MS Windows ME based operating systems to use Linear (LBA) mode.
@@ -907,7 +921,7 @@ which case this unit apply instead of the default unit for this
particular number, but CHS and cylinder units are not supported as
a suffix. If no suffix is given, then the default unit is assumed.
Parted will compute sensible ranges for the locations you specify
-(e.g. a range of +/- 500 MB when you specify the location in ``G'',
+(e.g., a range of +/- 500 MB when you specify the location in ``G'',
and a range of +/- 500 KB when you specify the location in ``M'')
and will select the nearest location in this range from the one you
wrote that satisfies constraints from both the operation, the
diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h
index 9734edd..a34e11e 100644
--- a/include/parted/disk.in.h
+++ b/include/parted/disk.in.h
@@ -72,10 +72,11 @@ enum _PedPartitionFlag {
PED_PARTITION_BIOS_GRUB=12,
PED_PARTITION_APPLE_TV_RECOVERY=13,
PED_PARTITION_DIAG=14,
- PED_PARTITION_LEGACY_BOOT=15
+ PED_PARTITION_LEGACY_BOOT=15,
+ PED_PARTITION_MSFT_DATA=16
};
#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT
-#define PED_PARTITION_LAST_FLAG PED_PARTITION_LEGACY_BOOT
+#define PED_PARTITION_LAST_FLAG PED_PARTITION_MSFT_DATA
enum _PedDiskTypeFeature {
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
diff --git a/libparted/disk.c b/libparted/disk.c
index f9b5fd2..c4b1a01 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -2433,6 +2433,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
return N_("prep");
case PED_PARTITION_MSFT_RESERVED:
return N_("msftres");
+ case PED_PARTITION_MSFT_DATA:
+ return N_("msftdata");
case PED_PARTITION_APPLE_TV_RECOVERY:
return N_("atvrecv");
case PED_PARTITION_DIAG:
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 63b30b9..490de70 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -122,6 +122,10 @@ typedef struct
((efi_guid_t) { PED_CPU_TO_LE32 (0x0657fd6d), PED_CPU_TO_LE16 (0xa4ab), \
PED_CPU_TO_LE16 (0x43c4), 0x84, 0xe5, \
{ 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f }})
+#define PARTITION_LINUX_DATA_GUID \
+ ((efi_guid_t) { PED_CPU_TO_LE32 (0x0FC63DAF), PED_CPU_TO_LE16 (0x8483), \
+ PED_CPU_TO_LE16 (0x4772), 0x8E, 0x79, \
+ { 0x3D, 0x69, 0xD8, 0x47, 0x7D, 0xE4 }})
#define PARTITION_LVM_GUID \
((efi_guid_t) { PED_CPU_TO_LE32 (0xe6d6d379), PED_CPU_TO_LE16 (0xf507), \
PED_CPU_TO_LE16 (0x44c2), 0xa2, 0x3c, \
@@ -280,6 +284,7 @@ typedef struct _GPTPartitionData
int hp_service;
int hidden;
int msftres;
+ int msftdata;
int atvrecv;
int msftrecv;
int legacy_boot;
@@ -788,6 +793,7 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
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
+ = gpt_part_data->msftdata
= gpt_part_data->msftrecv
= gpt_part_data->legacy_boot
= gpt_part_data->bios_grub = gpt_part_data->atvrecv = 0;
@@ -809,6 +815,8 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
gpt_part_data->hp_service = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RESERVED_GUID))
gpt_part_data->msftres = 1;
+ else if (!guid_cmp (gpt_part_data->type, PARTITION_BASIC_DATA_GUID))
+ gpt_part_data->msftdata = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RECOVERY))
gpt_part_data->msftrecv = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_APPLE_TV_RECOVERY_GUID))
@@ -1318,7 +1326,7 @@ gpt_partition_new (const PedDisk *disk,
if (!gpt_part_data)
goto error_free_part;
- gpt_part_data->type = PARTITION_BASIC_DATA_GUID;
+ gpt_part_data->type = PARTITION_LINUX_DATA_GUID;
gpt_part_data->lvm = 0;
gpt_part_data->raid = 0;
gpt_part_data->boot = 0;
@@ -1326,6 +1334,7 @@ gpt_partition_new (const PedDisk *disk,
gpt_part_data->hp_service = 0;
gpt_part_data->hidden = 0;
gpt_part_data->msftres = 0;
+ gpt_part_data->msftdata = 0;
gpt_part_data->msftrecv = 0;
gpt_part_data->atvrecv = 0;
gpt_part_data->legacy_boot = 0;
@@ -1422,6 +1431,11 @@ gpt_partition_set_system (PedPartition *part,
gpt_part_data->type = PARTITION_MSFT_RESERVED_GUID;
return 1;
}
+ if (gpt_part_data->msftdata)
+ {
+ gpt_part_data->type = PARTITION_BASIC_DATA_GUID;
+ return 1;
+ }
if (gpt_part_data->msftrecv)
{
gpt_part_data->type = PARTITION_MSFT_RECOVERY;
@@ -1453,7 +1467,7 @@ gpt_partition_set_system (PedPartition *part,
}
}
- gpt_part_data->type = PARTITION_BASIC_DATA_GUID;
+ gpt_part_data->type = PARTITION_LINUX_DATA_GUID;
return 1;
}
@@ -1571,6 +1585,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
+ = gpt_part_data->msftdata
= gpt_part_data->msftrecv
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
@@ -1582,6 +1597,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->boot
= gpt_part_data->hp_service
= gpt_part_data->msftres
+ = gpt_part_data->msftdata
= gpt_part_data->msftrecv
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
@@ -1593,6 +1609,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
+ = gpt_part_data->msftdata
= gpt_part_data->msftrecv
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
@@ -1604,6 +1621,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
+ = gpt_part_data->msftdata
= gpt_part_data->msftrecv
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
@@ -1615,6 +1633,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->lvm
= gpt_part_data->bios_grub
= gpt_part_data->msftres
+ = gpt_part_data->msftdata
= gpt_part_data->msftrecv
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
@@ -1626,8 +1645,25 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->lvm
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
+ = gpt_part_data->msftdata
+ = gpt_part_data->msftrecv
+ = gpt_part_data->atvrecv = 0;
+ return gpt_partition_set_system (part, part->fs_type);
+ case PED_PARTITION_MSFT_DATA:
+ gpt_part_data->msftres = state;
+ if (state) {
+ gpt_part_data->boot
+ = gpt_part_data->raid
+ = gpt_part_data->lvm
+ = gpt_part_data->bios_grub
+ = gpt_part_data->hp_service
+ = gpt_part_data->msftres
= gpt_part_data->msftrecv
= gpt_part_data->atvrecv = 0;
+ gpt_part_data->msftdata = 1;
+ } else {
+ gpt_part_data->msftdata = 0;
+ }
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_DIAG:
gpt_part_data->msftrecv = state;
@@ -1637,6 +1673,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->lvm
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
+ = gpt_part_data->msftdata
= gpt_part_data->msftres
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
@@ -1649,6 +1686,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
+ = gpt_part_data->msftdata
= gpt_part_data->msftrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_HIDDEN:
@@ -1687,6 +1725,8 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag)
return gpt_part_data->hp_service;
case PED_PARTITION_MSFT_RESERVED:
return gpt_part_data->msftres;
+ case PED_PARTITION_MSFT_DATA:
+ return gpt_part_data->msftdata;
case PED_PARTITION_DIAG:
return gpt_part_data->msftrecv;
case PED_PARTITION_APPLE_TV_RECOVERY:
@@ -1716,6 +1756,7 @@ gpt_partition_is_flag_available (const PedPartition *part,
case PED_PARTITION_BIOS_GRUB:
case PED_PARTITION_HPSERVICE:
case PED_PARTITION_MSFT_RESERVED:
+ case PED_PARTITION_MSFT_DATA:
case PED_PARTITION_DIAG:
case PED_PARTITION_APPLE_TV_RECOVERY:
case PED_PARTITION_HIDDEN:
diff --git a/tests/t0220-gpt-msftres.sh b/tests/t0220-gpt-msftres.sh
index d522aec..bd14c84 100755
--- a/tests/t0220-gpt-msftres.sh
+++ b/tests/t0220-gpt-msftres.sh
@@ -56,7 +56,8 @@ printf "BYT;\n$dev:${n_sectors}s:file:$ss:$ss:gpt::;\n" > exp
i=1
for type in $fs_types; do
end=$(expr $start + $part_size - 1)
- echo "$i:${start}s:${end}s:${part_size}s::$type:;" >> exp || fail=1
+ case $type in fat*|NTFS) flag=msftdata;; *) flag=;; esac
+ echo "$i:${start}s:${end}s:${part_size}s::$type:$flag;" >> exp || fail=1
parted -s $dev mkpart p-name $type ${start}s ${end}s > err 2>&1 || fail=1
compare /dev/null err || fail=1
parted -s $dev name $i $type > err 2>&1 || fail=1
--
1.9.3

View File

@ -1,341 +0,0 @@
From c987c73cbe773dfa3b14b911ffc243137195bbb3 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Sat, 29 Sep 2012 12:10:35 +0200
Subject: [PATCH 030/131] tests: clean up tests
Use warn_ and $ME_ in place of warn and $ME; remove definitions of
the latter two. Remove unused code.
* tests/lvm-utils.sh: Remove file. All functions were either unused
or duplicated/better in t-lvm.sh.
* tests/Makefile.am (EXTRA_DIST): Remove it.
* tests/t-local.sh (scsi_debug_setup_): Use echo 1>&2, not warn_, to
emit to log file only, not console. The diagnostic it emitted (in
verbose mode) was more "informational" than a warning.
* tests/t9030-align-check.sh: Use warn_, not warn.
* tests/t-lvm.sh: Likewise, and use fail_, not error (undefined!).
* tests/t-lib-helpers.sh (device_mapper_required_): Use t-lvm.sh
and an explicit lvm_init_root_dir_ in place of lvm-utils.sh.
---
tests/Makefile.am | 2 +-
tests/lvm-utils.sh | 208 ---------------------------------------------
tests/t-lib-helpers.sh | 4 +-
tests/t-local.sh | 2 +-
tests/t-lvm.sh | 11 +--
tests/t9030-align-check.sh | 3 +-
6 files changed, 10 insertions(+), 220 deletions(-)
delete mode 100644 tests/lvm-utils.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 96abecb..80d5525 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -74,7 +74,7 @@ TESTS = \
t9050-partition-table-types.sh
EXTRA_DIST = \
- $(TESTS) lvm-utils.sh t-local.sh t-lvm.sh \
+ $(TESTS) t-local.sh t-lvm.sh \
init.cfg init.sh t-lib-helpers.sh gpt-header-munge
check_PROGRAMS = print-align print-max dup-clobber duplicate fs-resize
diff --git a/tests/lvm-utils.sh b/tests/lvm-utils.sh
deleted file mode 100644
index 456d265..0000000
--- a/tests/lvm-utils.sh
+++ /dev/null
@@ -1,208 +0,0 @@
-# Put lvm-related utilities here.
-# This file is sourced from test infrastructure.
-
-# Copyright (C) 2007-2010 Red Hat, Inc. All rights reserved.
-#
-# This copyrighted material is made available to anyone wishing to use,
-# modify, copy, or redistribute it subject to the terms and conditions
-# of the GNU General Public License v.2.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-export LVM_SUPPRESS_FD_WARNINGS=1
-
-ME=$(basename "$0")
-warn() { echo >&2 "$ME: $@"; }
-
-unsafe_losetup_()
-{
- f=$1
-
- test -n "$G_dev_" \
- || fail_ "Internal error: unsafe_losetup_ called before init_root_dir_"
-
- # Iterate through $G_dev_/loop{,/}{0,1,2,3,4,5,6,7,8,9}
- for slash in '' /; do
- for i in 0 1 2 3 4 5 6 7 8 9; do
- dev=$G_dev_/loop$slash$i
- losetup $dev > /dev/null 2>&1 && continue;
- losetup "$dev" "$f" > /dev/null && { echo "$dev"; return 0; }
- break
- done
- done
-
- return 1
-}
-
-loop_setup_()
-{
- file=$1
- dd if=/dev/zero of="$file" bs=1M count=1 seek=1000 > /dev/null 2>&1 \
- || { warn "loop_setup_ failed: Unable to create tmp file $file"; return 1; }
-
- # NOTE: this requires a new enough version of losetup
- dev=$(unsafe_losetup_ "$file") \
- || { warn "loop_setup_ failed: Unable to create loopback device"; return 1; }
-
- echo "$dev"
- return 0;
-}
-
-compare_two_fields_()
-{
- local cmd1=$1;
- local obj1=$2;
- local field1=$3;
- local cmd2=$4;
- local obj2=$5;
- local field2=$6;
- local val1;
- local val2;
-
- val1=$($cmd1 --noheadings -o $field1 $obj1)
- val2=$($cmd2 --noheadings -o $field2 $obj2)
-if test "$verbose" = "t"
-then
- echo "compare_two_fields_ $obj1($field1): $val1 $obj2($field2): $val2"
-fi
- test $val1 = $val2
-}
-
-compare_vg_field_()
-{
- local vg1=$1;
- local vg2=$2;
- local field=$3;
- local val1;
- local val2;
-
- val1=$(vgs --noheadings -o $field $vg1)
- val2=$(vgs --noheadings -o $field $vg2)
-if test "$verbose" = "t"
-then
- echo "compare_vg_field_ VG1: $val1 VG2: $val2"
-fi
- test $val1 = $val2
-}
-
-check_vg_field_()
-{
- local vg=$1;
- local field=$2;
- local expected=$3;
- local actual;
-
- actual=$(vgs --noheadings -o $field $vg)
-if test "$verbose" = "t"
-then
- echo "check_vg_field_ VG=$vg, field=$field, actual=$actual, expected=$expected"
-fi
- test $actual = $expected
-}
-
-check_pv_field_()
-{
- local pv=$1;
- local field=$2;
- local expected=$3;
- local actual;
-
- actual=$(pvs --noheadings -o $field $pv)
-if test "$verbose" = "t"
-then
- echo "check_pv_field_ PV=$pv, field=$field, actual=$actual, expected=$expected"
-fi
- test $actual = $expected
-}
-
-check_lv_field_()
-{
- local lv=$1;
- local field=$2;
- local expected=$3;
- local actual;
-
- actual=$(lvs --noheadings -o $field $lv)
-if test "$verbose" = "t"
-then
- echo "check_lv_field_ LV=$lv, field=$field, actual=$actual, expected=$expected"
-fi
- test $actual = $expected
-}
-
-vg_validate_pvlv_counts_()
-{
- local local_vg=$1
- local num_pvs=$2
- local num_lvs=$3
- local num_snaps=$4
-
- check_vg_field_ $local_vg pv_count $num_pvs &&
- check_vg_field_ $local_vg lv_count $num_lvs &&
- check_vg_field_ $local_vg snap_count $num_snaps
-}
-
-dmsetup_has_dm_devdir_support_()
-{
- # Detect support for the envvar. If it's supported, the
- # following command will fail with the expected diagnostic.
- out=$(DM_DEV_DIR=j dmsetup version 2>&1)
- test "$?:$out" = "1:Invalid DM_DEV_DIR envvar value." ||
- test "$?:$out" = "1:Invalid DM_DEV_DIR environment variable value."
-}
-
-# set up private /dev and /etc
-init_root_dir_()
-{
- test -n "$test_dir_" \
- || fail_ "Internal error: called init_root_dir_ before" \
- "defining \$test_dir_"
-
- # Define these two globals.
- G_root_=$test_dir_/root
- G_dev_=$G_root_/dev
-
- export LVM_SYSTEM_DIR=$G_root_/etc
- export DM_DEV_DIR=$G_dev_
-
- # Only the first caller does anything.
- mkdir -p $G_root_/etc $G_dev_ $G_dev_/mapper $G_root_/lib
- for i in 0 1 2 3 4 5 6 7; do
- mknod $G_root_/dev/loop$i b 7 $i
- done
- for i in $abs_top_builddir/dmeventd/mirror/*.so $abs_top_builddir/dmeventd/snapshot/*.so
- do
- # NOTE: This check is necessary because the loop above will give us the value
- # "$abs_top_builddir/dmeventd/mirror/*.so" if no files ending in 'so' exist.
- # This is the best way I could quickly determine to skip over this bogus value.
- if [ -f $i ]; then
- echo Setting up symlink from $i to $G_root_/lib
- ln -s $i $G_root_/lib
- fi
- done
- cat > $G_root_/etc/lvm.conf <<-EOF
- devices {
- dir = "$G_dev_"
- scan = "$G_dev_"
- filter = [ "a/loop/", "a/mirror/", "a/mapper/", "r/.*/" ]
- cache_dir = "$G_root_/etc"
- sysfs_scan = 0
- }
- log {
- verbose = $verboselevel
- syslog = 0
- indent = 1
- }
- backup {
- backup = 0
- archive = 0
- }
- global {
- library_dir = "$G_root_/lib"
- }
-EOF
-}
-
-init_root_dir_
diff --git a/tests/t-lib-helpers.sh b/tests/t-lib-helpers.sh
index 4b3c122..6721003 100644
--- a/tests/t-lib-helpers.sh
+++ b/tests/t-lib-helpers.sh
@@ -395,6 +395,6 @@ wait_for_dev_to_disappear_()
device_mapper_required_()
{
- . "$abs_top_srcdir/tests/lvm-utils.sh" \
- || fail_ "device mapper setup failed"
+ . "$abs_top_srcdir/tests/t-lvm.sh"
+ lvm_init_root_dir_ || fail_ "device mapper setup failed"
}
diff --git a/tests/t-local.sh b/tests/t-local.sh
index dde1b8d..b40a5a0 100644
--- a/tests/t-local.sh
+++ b/tests/t-local.sh
@@ -100,7 +100,7 @@ scsi_debug_setup_()
modprobe scsi_debug "$@" || { rm -f stamp; return 1; }
scsi_debug_modprobe_succeeded_=1
test "$VERBOSE" = yes \
- && warn_ $ME_ modprobe scsi_debug succeeded
+ && echo $ME_ modprobe scsi_debug succeeded 1>&2
# Wait up to 2s (via .1s increments) for the list of devices to change.
# Sleeping for a fraction of a second requires GNU sleep, so fall
diff --git a/tests/t-lvm.sh b/tests/t-lvm.sh
index b08f934..9cee155 100644
--- a/tests/t-lvm.sh
+++ b/tests/t-lvm.sh
@@ -1,7 +1,7 @@
# Put lvm-related utilities here.
# This file is sourced from test infrastructure.
-# Copyright (C) 2007, 2008, 2010 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2007-2012 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
@@ -13,15 +13,12 @@
export LVM_SUPPRESS_FD_WARNINGS=1
-ME=$(basename "$0")
-warn() { echo >&2 "$ME: $@"; }
-
unsafe_losetup_()
{
f=$1
test -n "$G_dev_" \
- || error "Internal error: unsafe_losetup_ called before init_root_dir_"
+ || fail_ "Internal error: unsafe_losetup_ called before init_root_dir_"
# Iterate through $G_dev_/loop{,/}{0,1,2,3,4,5,6,7,8,9}
for slash in '' /; do
@@ -40,11 +37,11 @@ loop_setup_()
{
file=$1
dd if=/dev/zero of="$file" bs=1M count=1 seek=1000 > /dev/null 2>&1 \
- || { warn "loop_setup_ failed: Unable to create tmp file $file"; return 1; }
+ || { warn_ "loop_setup_ failed: Unable to create tmp file $file"; return 1; }
# NOTE: this requires a new enough version of losetup
dev=$(unsafe_losetup_ "$file" 2>/dev/null) \
- || { warn "loop_setup_ failed: Unable to create loopback device"; return 1; }
+ || { warn_ "loop_setup_ failed: Unable to create loopback device"; return 1; }
echo "$dev"
return 0;
diff --git a/tests/t9030-align-check.sh b/tests/t9030-align-check.sh
index b3618a7..f0830f0 100644
--- a/tests/t9030-align-check.sh
+++ b/tests/t9030-align-check.sh
@@ -49,7 +49,8 @@ while :; do
test $i = 70 && break
# Wait up to 10s for the partition file to disappear.
- wait_for_dev_to_disappear_ $p1 10 || { fail=1; warn $p1 failed to disappear; }
+ wait_for_dev_to_disappear_ $p1 10 \
+ || { fail=1; warn_ $ME_ $p1 failed to disappear; }
done
Exit $fail
--
1.9.3

View File

@ -1,27 +0,0 @@
From fb1faafaae67c328a34117573a71d1f02ef9f6fe Mon Sep 17 00:00:00 2001
From: Bob Beers <bob.beers.gmail.com>
Date: Thu, 4 Oct 2012 06:00:25 +0200
Subject: [PATCH 031/131] doc: libparted/disk.c: correct doxygen comment typo
* libparted/disk.c: s/PedPartition/PedDisk/
Copyright-paperwork-exempt: yes
---
libparted/disk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libparted/disk.c b/libparted/disk.c
index c4b1a01..d283674 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -1968,7 +1968,7 @@ _check_partition (PedDisk* disk, PedPartition* part)
}
/**
- * Adds PedPartition \p part to PedPartition \p disk.
+ * Adds PedPartition \p part to PedDisk \p disk.
*
* \warning The partition's geometry may be changed, subject to \p constraint.
* You could set \p constraint to <tt>ped_constraint_exact(&part->geom)</tt>,
--
1.9.3

View File

@ -1,47 +0,0 @@
From 478e472bf9f1c76b66a35ea75b45110152e5207d Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Sat, 6 Oct 2012 11:11:32 +0200
Subject: [PATCH 032/131] tests: stop using private "dev" directory for losetup
Something about Fedora 17's losetup changed so that using a private
dev directory no longer worked. Now, simply use /dev/ directly.
* tests/t-lvm.sh: Don't use $G_dev_. Not needed, and actually
caused the t6000-dm root-only test to fail on Fedora 17.
Also, redirect less to stderr: that helps diagnose failure.
---
tests/t-lvm.sh | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/tests/t-lvm.sh b/tests/t-lvm.sh
index 9cee155..cf1b8b8 100644
--- a/tests/t-lvm.sh
+++ b/tests/t-lvm.sh
@@ -17,14 +17,13 @@ unsafe_losetup_()
{
f=$1
- test -n "$G_dev_" \
- || fail_ "Internal error: unsafe_losetup_ called before init_root_dir_"
+ G_dev_=/dev
# Iterate through $G_dev_/loop{,/}{0,1,2,3,4,5,6,7,8,9}
for slash in '' /; do
for i in 0 1 2 3 4 5 6 7 8 9; do
dev=$G_dev_/loop$slash$i
- losetup $dev > /dev/null 2>&1 && continue;
+ losetup $dev 1>&2 && continue;
losetup "$dev" "$f" > /dev/null && { echo "$dev"; return 0; }
break
done
@@ -40,7 +39,7 @@ loop_setup_()
|| { warn_ "loop_setup_ failed: Unable to create tmp file $file"; return 1; }
# NOTE: this requires a new enough version of losetup
- dev=$(unsafe_losetup_ "$file" 2>/dev/null) \
+ dev=$(unsafe_losetup_ "$file") \
|| { warn_ "loop_setup_ failed: Unable to create loopback device"; return 1; }
echo "$dev"
--
1.9.3

View File

@ -1,59 +0,0 @@
From 718ac7342412aa7f32aaf3e9f379beb84883406e Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Sat, 6 Oct 2012 15:09:56 +0200
Subject: [PATCH 033/131] maint: fix an error in the preceding commit log
Stefano Lattarini noticed an error in the log for
commit v3.1-32-g478e472. Arrange for that error
to be fixed in the generated ChangeLog file.
* build-aux/git-log-fix: New file.
* Makefile.am (gen-ChangeLog): Adjust rule to use it.
---
.gitignore | 3 ++-
Makefile.am | 1 +
build-aux/git-log-fix | 7 +++++++
3 files changed, 10 insertions(+), 1 deletion(-)
create mode 100644 build-aux/git-log-fix
diff --git a/.gitignore b/.gitignore
index 054d9ea..5bb95d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,7 +32,8 @@ Makefile.in
TAGS
aclocal.m4
autom4te.cache
-build-aux
+/build-aux/*
+!/build-aux/git-log-fix
config.cache
config.h
config.hin
diff --git a/Makefile.am b/Makefile.am
index 5e52a42..686b61c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -107,6 +107,7 @@ gen_start_date = 2000-01-01
gen-ChangeLog:
if test -d .git; then \
$(top_srcdir)/build-aux/gitlog-to-changelog \
+ --amend=$(srcdir)/build-aux/git-log-fix \
--since=$(gen_start_date) > $(distdir)/cl-t; \
rm -f $(distdir)/ChangeLog; \
mv $(distdir)/cl-t $(distdir)/ChangeLog; \
diff --git a/build-aux/git-log-fix b/build-aux/git-log-fix
new file mode 100644
index 0000000..e2a68ee
--- /dev/null
+++ b/build-aux/git-log-fix
@@ -0,0 +1,7 @@
+# This file is expected to be used via gitlog-to-changelog's --amend=FILE
+# option. It specifies what changes to make to each given SHA1's commit
+# log and metadata, using Perl-eval'able expressions.
+
+478e472bf9f1c76b66a35ea75b45110152e5207d
+# Fix the log message:
+s,stderr,/dev/null,
--
1.9.3

View File

@ -1,30 +0,0 @@
From 5fc054beb415344a0ce44c19e554937c9158d08e Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Tue, 9 Oct 2012 14:02:15 +0200
Subject: [PATCH 034/131] tests: improve test for partitionable loop devices
* tests/init.cfg (require_partitionable_loop_device_): Skip
when cat fails.
---
tests/init.cfg | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tests/init.cfg b/tests/init.cfg
index 24b10bc..dc8b2bc 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -120,8 +120,9 @@ require_erasable_()
# At least Fedora 16 (kernel 3.1.6-1.fc16.x86_64) fails this test.
require_partitionable_loop_device_()
{
- case $(cat /sys/devices/virtual/block/$(basename $1)/ext_range) in
- 0|1) skip_ your system does not support loop partitioning;;
+ local f=/sys/devices/virtual/block/$(basename $1)/ext_range
+ case $(cat "$f") in
+ ''|0|1) skip_ your system is not configured to partition loop devices;;
esac
}
--
1.9.3

View File

@ -1,58 +0,0 @@
From 569e59d08fe2ec5e836536371e0a974a58e83166 Mon Sep 17 00:00:00 2001
From: Gilles Espinasse <g.esp@free.fr>
Date: Sun, 7 Oct 2012 15:40:23 +0200
Subject: [PATCH 035/131] tests: t8001: do not rely on "modprobe loop"
Remove 'rmmod loop' and 'modprobe loop max_part=7' commands.
The latter command may fail after the first command has run,
leaving the machine with no loop support.
This happens on my chroot, because:
- rmmod does not depend on the availability of the loop module,
- modprobe fails, since the kernel compiled inside the chroot
is different from the running kernel.
Instead, rely on t-lvm loop_setup_ to load the loop module, if required.
---
tests/t8001-loop-blkpg.sh | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/tests/t8001-loop-blkpg.sh b/tests/t8001-loop-blkpg.sh
index deef18b..9afde4a 100755
--- a/tests/t8001-loop-blkpg.sh
+++ b/tests/t8001-loop-blkpg.sh
@@ -20,6 +20,7 @@
require_root_
require_udevadm_settle_
+lvm_init_root_dir_
cleanup_fn_()
{
@@ -27,21 +28,14 @@ cleanup_fn_()
&& { udevadm settle --timeout=3; losetup -d "$loopdev"; }
}
-# If the loop module is loaded, unload it first
-if lsmod | grep '^loop[[:space:]]'; then
- rmmod loop || fail=1
-fi
-
-# Insert loop module with max_part > 1
-modprobe loop max_part=7 || fail=1
-
# Create backing file
dd if=/dev/zero of=backing_file bs=1M count=4 >/dev/null 2>&1 || fail=1
# Set up loop device on top of backing file
-loopdev=$(losetup -f --show backing_file)
+loopdev=$(loop_setup_ backing_file)
test -z "$loopdev" && fail=1
+# Skip this test if loop devices are not partitionable.
require_partitionable_loop_device_ $loopdev
# Expect this to succeed
--
1.9.3

View File

@ -1,30 +0,0 @@
From 319e7cd590ae16460cfecb70715bf41ceec81d1e Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Tue, 9 Oct 2012 15:40:33 +0200
Subject: [PATCH 036/131] build: do not rely on automake's AM_TESTS_ENVIRONMENT
* tests/Makefile.am (TESTS_ENVIRONMENT): Rename from
AM_TESTS_ENVIRONMENT, since it is not honored in automake-1.11.3
after all. This reverts commit v3.1-14-g2bd66d7. For now, I'll
leave the following commit that made bootstrap.conf require 1.11.2.
Prompted by a report of test failure from Phillip Susi.
---
tests/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 80d5525..cdc1c4b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -98,7 +98,7 @@ sep = $(PATH_SEPARATOR)
# variables that can perturb tests are unset or set to expected values.
# The rest are envvar settings that propagate build-related Makefile
# variables to test scripts.
-AM_TESTS_ENVIRONMENT = \
+TESTS_ENVIRONMENT = \
tmp__=$$TMPDIR; test -d "$$tmp__" || tmp__=.; \
TMPDIR=$$tmp__; export TMPDIR; \
export \
--
1.9.3

View File

@ -1,24 +0,0 @@
From 6a535214131b25b0f90dfff618ef6cf8083bb390 Mon Sep 17 00:00:00 2001
From: Petr Uzel <petr.uzel@suse.cz>
Date: Mon, 15 Oct 2012 10:31:50 +0200
Subject: [PATCH 037/131] build: .gitignore: ignore tests/fs-resize
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 5bb95d4..c2ccd4b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -76,6 +76,7 @@ stamp-h1
tags
tests/dup-clobber
tests/duplicate
+tests/fs-resize
tests/help-version.log
tests/old-init.sh
tests/print-align
--
1.9.3

View File

@ -1,28 +0,0 @@
From baa2ebd111d4f8df66254bc94ee79aeaae2a3f3e Mon Sep 17 00:00:00 2001
From: Petr Uzel <petr.uzel@suse.cz>
Date: Mon, 15 Oct 2012 10:31:54 +0200
Subject: [PATCH 038/131] partprobe: remove --no-update long option
It was deprecated and scheduled for removal in 2009.
* partprobe/partprobe.c (long_options): Remove "no-update" entry.
---
partprobe/partprobe.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/partprobe/partprobe.c b/partprobe/partprobe.c
index 8bccc4f..b8dca5e 100644
--- a/partprobe/partprobe.c
+++ b/partprobe/partprobe.c
@@ -57,9 +57,6 @@
static struct option const long_options[] =
{
- /* Note: the --no-update option is deprecated, and deliberately
- * not documented. FIXME: remove --no-update in 2009. */
- {"no-update", no_argument, NULL, 'd'},
{"dry-run", no_argument, NULL, 'd'},
{"summary", no_argument, NULL, 's'},
{"help", no_argument, NULL, 'h'},
--
1.9.3

View File

@ -1,48 +0,0 @@
From aec4b5228d1536452b1816731c41d9b37de2a25c Mon Sep 17 00:00:00 2001
From: Petr Uzel <petr.uzel@suse.cz>
Date: Mon, 15 Oct 2012 10:31:53 +0200
Subject: [PATCH 039/131] doc: update partprobe manpage
* doc/C/partprobe.8: Add long options, REPORTING BUGS section
and adjust DESCRIPTION section because it wasn't quite correct.
---
doc/C/partprobe.8 | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/doc/C/partprobe.8 b/doc/C/partprobe.8
index 6abf97d..48ae5dc 100644
--- a/doc/C/partprobe.8
+++ b/doc/C/partprobe.8
@@ -31,22 +31,23 @@ command.
.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
.\" respectively.
\fBpartprobe\fP is a program that informs the operating system kernel of
-partition table changes, by requesting that the operating system re-read
-the partition table.
+partition table changes.
.SH OPTIONS
This program uses short UNIX style options.
.TP
-.B \-d
+.B -d, --dry-run
Don't update the kernel.
.TP
-.B \-s
+.B -s, --summary
Show a summary of devices and their partitions.
.TP
-.B \-h
+.B -h, --help
Show summary of options.
.TP
-.B \-v
+.B -v, --version
Show version of program.
+.SH REPORTING BUGS
+Report bugs to <bug-parted@gnu.org>
.SH SEE ALSO
.BR parted (8).
.SH AUTHOR
--
1.9.3

View File

@ -1,67 +0,0 @@
From 05917368a7867a17d6b2e0df16bf54239aa52107 Mon Sep 17 00:00:00 2001
From: Petr Uzel <petr.uzel@suse.cz>
Date: Mon, 15 Oct 2012 10:31:52 +0200
Subject: [PATCH 040/131] partprobe: remove partitions when there is no
partition table
When partprobe detects no partition table on a device, it should
tell the kernel to drop partitions on that device, but it did not.
* parted/partprobe.c (process_dev): When ped_disk_probe fails,
create a dummy (empty) partition table and use that.
* NEWS (Bug fixes): Mention it.
Addresses: https://bugzilla.novell.com/783419
---
NEWS | 3 +++
partprobe/partprobe.c | 21 ++++++++++++++++-----
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/NEWS b/NEWS
index 4c4716d..293f5e4 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,9 @@ GNU parted NEWS -*- outline -*-
libparted: treat a disk with no pMBR as an msdos-labeled disk
even when it has valid GPT headers.
+ partprobe now tells the kernel to forget about any partitions
+ on a device that has no recognizable partition table.
+
** Changes in behavior
Added new Linux-specific partition GUID type code
diff --git a/partprobe/partprobe.c b/partprobe/partprobe.c
index b8dca5e..0919d3f 100644
--- a/partprobe/partprobe.c
+++ b/partprobe/partprobe.c
@@ -106,12 +106,23 @@ process_dev (PedDevice* dev)
PedDisk* disk;
disk_type = ped_disk_probe (dev);
- if (!disk_type || !strcmp (disk_type->name, "loop"))
+ if (disk_type && !strcmp (disk_type->name, "loop"))
return 1;
-
- disk = ped_disk_new (dev);
- if (!disk)
- goto error;
+ else if (!disk_type) {
+ /* Partition table not found, so create dummy,
+ empty one */
+ disk_type = ped_disk_type_get("msdos");
+ if (!disk_type)
+ goto error;
+
+ disk = ped_disk_new_fresh (dev, disk_type);
+ if (!disk)
+ goto error_destroy_disk;
+ } else {
+ disk = ped_disk_new (dev);
+ if (!disk)
+ goto error;
+ }
if (!opt_no_inform) {
if (!ped_disk_commit_to_os (disk))
goto error_destroy_disk;
--
1.9.3

View File

@ -1,65 +0,0 @@
From c897203a7f65a05e57c67e6cddee3f70110d0824 Mon Sep 17 00:00:00 2001
From: Jim Meyering <jim@meyering.net>
Date: Wed, 17 Oct 2012 16:55:02 +0200
Subject: [PATCH 041/131] maint: use $(AM_V_GEN) to cut down on build noise
* doc/Makefile.am: Prefix each rule with $(AM_V_GEN).
* doc/po4a.mk (dist_man_MANS): Likewise.
---
doc/Makefile.am | 2 +-
doc/po4a.mk | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 08046d1..e773efa 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -12,6 +12,6 @@ EXTRA_DIST = FAT \
.PHONY: updatepo
updatepo:
- list='$(SUBDIRS)'; for dir in $$list; do \
+ $(AM_V_GEN)list='$(SUBDIRS)'; for dir in $$list; do \
$(MAKE) -C "$$dir" updatepo; \
done
diff --git a/doc/po4a.mk b/doc/po4a.mk
index b378121..aaf4024 100644
--- a/doc/po4a.mk
+++ b/doc/po4a.mk
@@ -41,13 +41,13 @@ install-man: install-man1 install-man5 install-man8
# For each .po, try to generate the man page
all-local:
- for po in `ls -1 $(srcdir)/*.$(lang).po 2>/dev/null`; do \
+ $(AM_V_GEN)for po in `ls -1 $(srcdir)/*.$(lang).po 2>/dev/null`; do \
$(MAKE) $$(basename $${po%.$(lang).po}); \
done
# Remove the man pages that were generated from a .po
clean-local:
- for po in `ls -1 $(srcdir)/*.$(lang).po 2>/dev/null`; do \
+ $(AM_V_GEN)for po in `ls -1 $(srcdir)/*.$(lang).po 2>/dev/null`; do \
rm -f $$(basename $${po%.$(lang).po}); \
done
@@ -55,7 +55,7 @@ clean-local:
# Update the PO in srcdir, according to the POT in C.
# Based on the gettext po/Makefile.in.in
updatepo:
- tmpdir=`pwd`; \
+ $(AM_V_GEN)tmpdir=`pwd`; \
cd $(srcdir); \
for po in *.$(lang).po; do \
case "$$po" in '*'*) continue;; esac; \
@@ -83,7 +83,7 @@ dist-hook: updatepo
# Build the pages
partprobe.8:
- for locale in pt_BR ; do \
+ $(AM_V_GEN)for locale in pt_BR ; do \
po4a-translate -f man -m $(srcdir)/../C/$@ -p $@.$$locale.po -l $@ $(po4a_translate_options) ; \
if [ -f $(srcdir)/$@.$$locale.po.addendum ]; then \
po4a-translate -f man -m $(srcdir)/../C/$@ -p $@.$$locale.po -l $@ -a $(srcdir)/$@.$$locale.po.addendum $(po4a_translate_options) ; \
--
1.9.3

View File

@ -1,337 +0,0 @@
From d9f34625df17b30013e141516c2722b77b4b6eea Mon Sep 17 00:00:00 2001
From: Jim Meyering <jim@meyering.net>
Date: Wed, 17 Oct 2012 23:07:55 +0200
Subject: [PATCH 042/131] maint: regenerate .po, .pot files
---
doc/C/po/partprobe.8.pot | 59 ++++++++++++++++--------------
doc/pt_BR/partprobe.8.pt_BR.po | 83 +++++++++++++++++++++++++++---------------
2 files changed, 85 insertions(+), 57 deletions(-)
diff --git a/doc/C/po/partprobe.8.pot b/doc/C/po/partprobe.8.pot
index 19bd79f..d061382 100644
--- a/doc/C/po/partprobe.8.pot
+++ b/doc/C/po/partprobe.8.pot
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2011-02-26 06:06+0100\n"
+"POT-Creation-Date: 2012-10-17 21:43+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -93,106 +93,111 @@ msgstr ""
msgid "This manual page documents briefly the B<partprobe> command."
msgstr ""
-# type: Plain text
#. TeX users may be more comfortable with the \fB<whatever>\fP and
#. \fI<whatever>\fP escape sequences to invode bold face and italics,
#. respectively.
#. type: Plain text
-#: partprobe.8:36
+#: partprobe.8:35
msgid ""
"B<partprobe> is a program that informs the operating system kernel of "
-"partition table changes, by requesting that the operating system re-read the "
-"partition table."
+"partition table changes."
msgstr ""
# type: SH
#. type: SH
-#: partprobe.8:36
+#: partprobe.8:35
#, no-wrap
msgid "OPTIONS"
msgstr ""
# type: Plain text
#. type: Plain text
-#: partprobe.8:38
+#: partprobe.8:37
msgid "This program uses short UNIX style options."
msgstr ""
-# type: TP
#. type: TP
-#: partprobe.8:38
+#: partprobe.8:37
#, no-wrap
-msgid "B<-d>"
+msgid "B<-d, --dry-run>"
msgstr ""
# type: Plain text
#. type: Plain text
-#: partprobe.8:41
+#: partprobe.8:40
msgid "Don't update the kernel."
msgstr ""
-# type: TP
#. type: TP
-#: partprobe.8:41
+#: partprobe.8:40
#, no-wrap
-msgid "B<-s>"
+msgid "B<-s, --summary>"
msgstr ""
# type: Plain text
#. type: Plain text
-#: partprobe.8:44
+#: partprobe.8:43
msgid "Show a summary of devices and their partitions."
msgstr ""
-# type: TP
#. type: TP
-#: partprobe.8:44
+#: partprobe.8:43
#, no-wrap
-msgid "B<-h>"
+msgid "B<-h, --help>"
msgstr ""
# type: Plain text
#. type: Plain text
-#: partprobe.8:47
+#: partprobe.8:46
msgid "Show summary of options."
msgstr ""
-# type: TP
#. type: TP
-#: partprobe.8:47
+#: partprobe.8:46
#, no-wrap
-msgid "B<-v>"
+msgid "B<-v, --version>"
msgstr ""
# type: Plain text
#. type: Plain text
-#: partprobe.8:50
+#: partprobe.8:49
msgid "Show version of program."
msgstr ""
+#. type: SH
+#: partprobe.8:49
+#, no-wrap
+msgid "REPORTING BUGS"
+msgstr ""
+
+#. type: Plain text
+#: partprobe.8:51
+msgid "Report bugs to E<lt>bug-parted@gnu.orgE<gt>"
+msgstr ""
+
# type: SH
#. type: SH
-#: partprobe.8:50
+#: partprobe.8:51
#, no-wrap
msgid "SEE ALSO"
msgstr ""
# type: Plain text
#. type: Plain text
-#: partprobe.8:52
+#: partprobe.8:53
msgid "B<parted>(8)."
msgstr ""
# type: SH
#. type: SH
-#: partprobe.8:52
+#: partprobe.8:53
#, no-wrap
msgid "AUTHOR"
msgstr ""
# type: Plain text
#. type: Plain text
-#: partprobe.8:54
+#: partprobe.8:55
msgid ""
"This manual page was written by Timshel Knoll E<lt>timshel@debian.orgE<gt>, "
"for the Debian GNU/Linux system (but may be used by others)."
diff --git a/doc/pt_BR/partprobe.8.pt_BR.po b/doc/pt_BR/partprobe.8.pt_BR.po
index ffa47d7..4870d09 100644
--- a/doc/pt_BR/partprobe.8.pt_BR.po
+++ b/doc/pt_BR/partprobe.8.pt_BR.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2011-02-26 06:06+0100\n"
+"POT-Creation-Date: 2012-10-17 21:43+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Tassia Camoes Araujo <tassia@debian-ba.org>\n"
"Language-Team: l10n portuguese <debian-l10n-portuguese@lists.debian.org>\n"
@@ -100,11 +100,11 @@ msgstr "Esta página de manual documenta brevemente o comando B<partprobe>"
#. \fI<whatever>\fP escape sequences to invode bold face and italics,
#. respectively.
#. type: Plain text
-#: partprobe.8:36
+#: partprobe.8:35
+#, fuzzy
msgid ""
"B<partprobe> is a program that informs the operating system kernel of "
-"partition table changes, by requesting that the operating system re-read the "
-"partition table."
+"partition table changes."
msgstr ""
"B<partprobe> é uma programa que informa ao kernel do sistema operacional "
"sobre mudanças na tabela de partição, requisitando que o sistema operacional "
@@ -112,95 +112,118 @@ msgstr ""
# type: SH
#. type: SH
-#: partprobe.8:36
+#: partprobe.8:35
#, no-wrap
msgid "OPTIONS"
msgstr "OPÇÕES"
# type: Plain text
#. type: Plain text
-#: partprobe.8:38
+#: partprobe.8:37
msgid "This program uses short UNIX style options."
msgstr "Este programa usa opções de estilo curtas do UNIX."
-# type: TP
#. type: TP
-#: partprobe.8:38
+#: partprobe.8:37
#, no-wrap
-msgid "B<-d>"
-msgstr "B<-d>"
+msgid "B<-d, --dry-run>"
+msgstr ""
# type: Plain text
#. type: Plain text
-#: partprobe.8:41
+#: partprobe.8:40
msgid "Don't update the kernel."
msgstr "Não atualiza o kernel."
-# type: TP
#. type: TP
-#: partprobe.8:41
+#: partprobe.8:40
#, no-wrap
-msgid "B<-s>"
-msgstr "B<-s>"
+msgid "B<-s, --summary>"
+msgstr ""
# type: Plain text
#. type: Plain text
-#: partprobe.8:44
+#: partprobe.8:43
msgid "Show a summary of devices and their partitions."
msgstr "Mostra um sumário dos dispositivos e suas partições."
-# type: TP
#. type: TP
-#: partprobe.8:44
+#: partprobe.8:43
#, no-wrap
-msgid "B<-h>"
-msgstr "B<-h>"
+msgid "B<-h, --help>"
+msgstr ""
# type: Plain text
#. type: Plain text
-#: partprobe.8:47
+#: partprobe.8:46
msgid "Show summary of options."
msgstr "Mostra sumário de opções."
-# type: TP
#. type: TP
-#: partprobe.8:47
+#: partprobe.8:46
#, no-wrap
-msgid "B<-v>"
-msgstr "B<-v>"
+msgid "B<-v, --version>"
+msgstr ""
# type: Plain text
#. type: Plain text
-#: partprobe.8:50
+#: partprobe.8:49
msgid "Show version of program."
msgstr "Mostra versão do programa."
+#. type: SH
+#: partprobe.8:49
+#, no-wrap
+msgid "REPORTING BUGS"
+msgstr ""
+
+#. type: Plain text
+#: partprobe.8:51
+msgid "Report bugs to E<lt>bug-parted@gnu.orgE<gt>"
+msgstr ""
+
# type: SH
#. type: SH
-#: partprobe.8:50
+#: partprobe.8:51
#, no-wrap
msgid "SEE ALSO"
msgstr "VEJA TAMBÉM"
# type: Plain text
#. type: Plain text
-#: partprobe.8:52
+#: partprobe.8:53
msgid "B<parted>(8)."
msgstr "B<parted>(8)."
# type: SH
#. type: SH
-#: partprobe.8:52
+#: partprobe.8:53
#, no-wrap
msgid "AUTHOR"
msgstr "AUTOR"
# type: Plain text
#. type: Plain text
-#: partprobe.8:54
+#: partprobe.8:55
msgid ""
"This manual page was written by Timshel Knoll E<lt>timshel@debian.orgE<gt>, "
"for the Debian GNU/Linux system (but may be used by others)."
msgstr ""
"Esta página de manual foi escrita por Timshel Knoll E<lt>timshel@debian."
"orgE<gt>, para o sistema Debian GNU/Linux (mas pode ser usado por outros)."
+
+# type: TP
+#~ msgid "B<-d>"
+#~ msgstr "B<-d>"
+
+# type: TP
+#~ msgid "B<-s>"
+#~ msgstr "B<-s>"
+
+# type: TP
+#~ msgid "B<-h>"
+#~ msgstr "B<-h>"
+
+# type: TP
+#~ msgid "B<-v>"
+#~ msgstr "B<-v>"
--
1.9.3

View File

@ -1,83 +0,0 @@
From 2ab9f04692e74c8b1daae68f1c22c5723f6c39ef Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 17 Oct 2012 21:42:12 +0200
Subject: [PATCH 043/131] tests: cleanup losetup usage
The unsafe_losetup_ function was failing because losetup didn't
recognize that the 'private' /dev/loopX devices were the same as
/dev/loopX, it would fail even if one was in use. Switch to using
losetup --show which is a cleaner solution.
Also use sparse file for loop_setup to save space.
* tests/t-lvm.sh (unsafe_losetup_): Remove function.
(loop_setup_): Use losetup's --show option instead.
Use dd with /dev/null, not /dev/zero.
* tests/t6001-psep.sh: Use loop_setup_ rather than losetup --show.
---
tests/t-lvm.sh | 23 ++---------------------
tests/t6001-psep.sh | 8 ++------
2 files changed, 4 insertions(+), 27 deletions(-)
diff --git a/tests/t-lvm.sh b/tests/t-lvm.sh
index cf1b8b8..001523b 100644
--- a/tests/t-lvm.sh
+++ b/tests/t-lvm.sh
@@ -13,33 +13,14 @@
export LVM_SUPPRESS_FD_WARNINGS=1
-unsafe_losetup_()
-{
- f=$1
-
- G_dev_=/dev
-
- # Iterate through $G_dev_/loop{,/}{0,1,2,3,4,5,6,7,8,9}
- for slash in '' /; do
- for i in 0 1 2 3 4 5 6 7 8 9; do
- dev=$G_dev_/loop$slash$i
- losetup $dev 1>&2 && continue;
- losetup "$dev" "$f" > /dev/null && { echo "$dev"; return 0; }
- break
- done
- done
-
- return 1
-}
-
loop_setup_()
{
file=$1
- dd if=/dev/zero of="$file" bs=1M count=1 seek=1000 > /dev/null 2>&1 \
+ dd if=/dev/null of="$file" bs=1M count=1 seek=1000 > /dev/null 2>&1 \
|| { warn_ "loop_setup_ failed: Unable to create tmp file $file"; return 1; }
# NOTE: this requires a new enough version of losetup
- dev=$(unsafe_losetup_ "$file") \
+ dev=$(losetup --show -f "$file") \
|| { warn_ "loop_setup_ failed: Unable to create loopback device"; return 1; }
echo "$dev"
diff --git a/tests/t6001-psep.sh b/tests/t6001-psep.sh
index 490c6d2..1859ac9 100644
--- a/tests/t6001-psep.sh
+++ b/tests/t6001-psep.sh
@@ -44,14 +44,10 @@ cleanup_fn_() {
# create a file of size N bytes
N=10M
-# create the test file
-f1=$(pwd)/1; dd if=/dev/null of=$f1 bs=1 seek=$N 2> /dev/null || fail=1
-f2=$(pwd)/2; dd if=/dev/null of=$f2 bs=1 seek=$N 2> /dev/null || fail=1
-
-d1=$(loop_setup_ "$f1") \
+f1=$(pwd)/1; d1=$(loop_setup_ "$f1") \
|| skip_ "is this partition mounted with 'nodev'?"
-d2=$(loop_setup_ "$f2") \
+f2=$(pwd)/2 ;d2=$(loop_setup_ "$f2") \
|| skip_ "is this partition mounted with 'nodev'?"
dmsetup_cmd="0 `blockdev --getsz $d1` linear $d1 0"
--
1.9.3

View File

@ -1,34 +0,0 @@
From d3a81337ff149294b7cf63c45a61ffa24fa542c5 Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake@redhat.com>
Date: Tue, 23 Oct 2012 11:07:29 +0200
Subject: [PATCH 044/131] build: default to --enable-gcc-warnings in a git tree
Anyone building from cloned sources can be assumed to have a new
enough environment, such that enabling gcc warnings by default will
be useful. Tarballs still default to no warnings, and the default
can still be overridden with --disable-gcc-warnings.
* configure.ac (gl_gcc_warnings): Set default based on environment.
---
configure.ac | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 832fc20..417f325 100644
--- a/configure.ac
+++ b/configure.ac
@@ -187,7 +187,11 @@ AC_ARG_ENABLE([gcc-warnings],
*) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
esac
gl_gcc_warnings=$enableval],
- [gl_gcc_warnings=no]
+ [if test -d "$srcdir"/.git; then
+ gl_gcc_warnings=yes
+ else
+ gl_gcc_warnings=no
+ fi]
)
if test "$gl_gcc_warnings" = yes; then
--
1.9.3

View File

@ -1,638 +0,0 @@
From f0c0d53f998964e187f59de32ac92a2c0e2d5da9 Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Sun, 14 Oct 2012 23:59:58 -0400
Subject: [PATCH 045/131] libparted: refactor device-mapper partition sync code
The device-mapper partition sync code was still using the remove all
partitions, then add new partitions method. Refactor to use the same
algorithm as regular disks: try to remove all, and ignore any that could
not be removed but have not changed.
---
NEWS | 3 +
libparted/arch/linux.c | 405 ++++++++++++++++++++++---------------------------
tests/Makefile.am | 1 +
tests/t6002-dm-busy.sh | 92 +++++++++++
4 files changed, 274 insertions(+), 227 deletions(-)
create mode 100644 tests/t6002-dm-busy.sh
diff --git a/NEWS b/NEWS
index 293f5e4..a40d69b 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ libparted: Don't fail to manipulate partitions on dmraid disks that
+ have other partitions in use.
+
libparted: mac: a MAC partition table could have a block_size larger
than the one the kernel told us about. Upon reading that partition
table, libparted would ask if it's ok to use the larger block size.
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index e2c4139..70b26a9 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -285,7 +285,7 @@ struct blkdev_ioctl_param {
/* Maximum number of partitions supported by linux. */
#define MAX_NUM_PARTS 64
-static char* _device_get_part_path (PedDevice* dev, int num);
+static char* _device_get_part_path (PedDevice const *dev, int num);
static int _partition_is_mounted_by_path (const char* path);
static int
@@ -2225,28 +2225,53 @@ zasprintf (const char *format, ...)
return r < 0 ? NULL : resultp;
}
-static char*
-_device_get_part_path (PedDevice *dev, int num)
+static char *
+dm_canonical_path (PedDevice const *dev)
{
- size_t path_len = strlen (dev->path);
+ LinuxSpecific const *arch_specific = LINUX_SPECIFIC (dev);
+ /* Get map name from devicemapper */
+ struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
+ if (!task)
+ goto err;
+ if (!dm_task_set_major_minor (task, arch_specific->major,
+ arch_specific->minor, 0))
+ goto err;
+ if (!dm_task_run(task))
+ goto err;
+ char *dev_name = zasprintf ("/dev/mapper/%s", dm_task_get_name (task));
+ if (dev_name == NULL)
+ goto err;
+ dm_task_destroy (task);
+ return dev_name;
+err:
+ return NULL;
+}
+
+static char*
+_device_get_part_path (PedDevice const *dev, int num)
+{
+ char *devpath = (dev->type == PED_DEVICE_DM
+ ? dm_canonical_path (dev) : dev->path);
+ size_t path_len = strlen (devpath);
char *result;
/* Check for devfs-style /disc => /partN transformation
unconditionally; the system might be using udev with devfs rules,
and if not the test is harmless. */
- if (5 < path_len && !strcmp (dev->path + path_len - 5, "/disc")) {
+ if (5 < path_len && !strcmp (devpath + path_len - 5, "/disc")) {
/* replace /disc with /part%d */
result = zasprintf ("%.*s/part%d",
- (int) (path_len - 5), dev->path, num);
+ (int) (path_len - 5), devpath, num);
} else {
char const *p = (dev->type == PED_DEVICE_DAC960
|| dev->type == PED_DEVICE_CPQARRAY
|| dev->type == PED_DEVICE_ATARAID
- || isdigit (dev->path[path_len - 1])
+ || isdigit (devpath[path_len - 1])
? "p" : "");
- result = zasprintf ("%s%s%d", dev->path, p, num);
+ result = zasprintf ("%s%s%d", devpath, p, num);
}
-
+ if (dev->type == PED_DEVICE_DM)
+ free (devpath);
return result;
}
@@ -2530,6 +2555,8 @@ static unsigned int
_device_get_partition_range(PedDevice const* dev)
{
int range;
+ if (dev->type == PED_DEVICE_DM)
+ return MAX_NUM_PARTS;
bool ok = _sysfs_int_entry_from_dev(dev, "ext_range", &range);
if (!ok)
@@ -2538,6 +2565,128 @@ _device_get_partition_range(PedDevice const* dev)
return range > 1 ? range : 0;
}
+#ifdef ENABLE_DEVICE_MAPPER
+static int
+_dm_remove_partition(PedDisk* disk, int partno)
+{
+ int rc;
+ char *part_name = _device_get_part_path (disk->dev, partno);
+
+ int fd = open (part_name, O_RDONLY | O_EXCL);
+ if (fd == -1) {
+ if (errno == ENOENT)
+ errno = ENXIO; /* nothing to remove, device already doesn't exist */
+ free (part_name);
+ return 0;
+ }
+ close (fd);
+ struct dm_task *task = dm_task_create(DM_DEVICE_REMOVE);
+ if (!task) {
+ free (part_name);
+ return 0;
+ }
+ dm_task_set_name (task, part_name);
+ rc = dm_task_run(task);
+ dm_task_update_nodes();
+ dm_task_destroy(task);
+ free (part_name);
+ if (!rc)
+ return 0;
+
+ return 1;
+}
+
+static bool
+_dm_get_partition_start_and_length(PedPartition const *part,
+ unsigned long long *start,
+ unsigned long long *length)
+{
+ struct dm_task* task = NULL;
+ int rc = 0;
+
+ if (!(task = dm_task_create(DM_DEVICE_TABLE)))
+ return 0;
+ char *path = _device_get_part_path (part->disk->dev, part->num);
+ PED_ASSERT(path);
+ dm_task_set_name(task, path);
+ if (!dm_task_run(task))
+ goto err;
+
+ int major, minor;
+ char *params;
+ char *target_type;
+ dm_get_next_target(task, NULL, (uint64_t *)start, (uint64_t *)length, &target_type, &params);
+ if (sscanf (params, "%d:%d %Ld", &major, &minor, start) != 3)
+ goto err;
+ rc = 1;
+err:
+ free (path);
+ dm_task_destroy(task);
+ return rc;
+}
+
+
+static int
+_dm_add_partition (PedDisk* disk, const PedPartition* part)
+{
+ LinuxSpecific* arch_specific = LINUX_SPECIFIC (disk->dev);
+ char *params = NULL;
+ char *vol_name = NULL;
+
+ /* Get map name from devicemapper */
+ struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
+ if (!task)
+ goto err;
+
+ if (!dm_task_set_major_minor (task, arch_specific->major,
+ arch_specific->minor, 0))
+ goto err;
+
+ if (!dm_task_run(task))
+ goto err;
+
+ const char *dev_name = dm_task_get_name (task);
+ size_t name_len = strlen (dev_name);
+ vol_name = zasprintf ("%s%s%d",
+ dev_name,
+ isdigit (dev_name[name_len - 1]) ? "p" : "",
+ part->num);
+ if (vol_name == NULL)
+ goto err;
+
+ /* Caution: dm_task_destroy frees dev_name. */
+ dm_task_destroy (task);
+ task = NULL;
+ if ( ! (params = zasprintf ("%d:%d %lld", arch_specific->major,
+ arch_specific->minor, part->geom.start)))
+ goto err;
+
+ task = dm_task_create (DM_DEVICE_CREATE);
+ if (!task)
+ goto err;
+
+ dm_task_set_name (task, vol_name);
+ dm_task_add_target (task, 0, part->geom.length,
+ "linear", params);
+ if (dm_task_run (task)) {
+ dm_task_update_nodes ();
+ dm_task_destroy (task);
+ free (params);
+ free (vol_name);
+ return 1;
+ } else {
+ _dm_remove_partition (disk, part->num);
+ }
+err:
+ dm_task_update_nodes();
+ if (task)
+ dm_task_destroy (task);
+ free (params);
+ free (vol_name);
+ return 0;
+}
+#endif
+
/*
* Sync the partition table in two step process:
* 1. Remove all of the partitions from the kernel's tables, but do not attempt
@@ -2558,8 +2707,23 @@ _disk_sync_part_table (PedDisk* disk)
PED_ASSERT(disk != NULL);
PED_ASSERT(disk->dev != NULL);
int lpn;
-
unsigned int part_range = _device_get_partition_range(disk->dev);
+ int (*add_partition)(PedDisk* disk, const PedPartition *part);
+ int (*remove_partition)(PedDisk* disk, int partno);
+ bool (*get_partition_start_and_length)(PedPartition const *part,
+ unsigned long long *start,
+ unsigned long long *length);
+
+
+ if (disk->dev->type == PED_DEVICE_DM) {
+ add_partition = _dm_add_partition;
+ remove_partition = _dm_remove_partition;
+ get_partition_start_and_length = _dm_get_partition_start_and_length;
+ } else {
+ add_partition = _blkpg_add_partition;
+ remove_partition = _blkpg_remove_partition;
+ get_partition_start_and_length = _kernel_get_partition_start_and_length;
+ }
/* lpn = largest partition number. */
if (ped_disk_get_max_supported_partition_count(disk, &lpn))
@@ -2594,7 +2758,7 @@ _disk_sync_part_table (PedDisk* disk)
int j;
for (j = 0; j < lpn; j++) {
if (!ok[j]) {
- ok[j] = _blkpg_remove_partition (disk, j + 1);
+ ok[j] = remove_partition (disk, j + 1);
errnums[j] = errno;
if (!ok[j] && errnums[j] == EBUSY)
busy = true;
@@ -2611,8 +2775,8 @@ _disk_sync_part_table (PedDisk* disk)
unsigned long long length;
unsigned long long start;
/* get start and length of existing partition */
- if (!_kernel_get_partition_start_and_length(part,
- &start, &length))
+ if (!get_partition_start_and_length(part,
+ &start, &length))
goto cleanup;
if (start == part->geom.start
&& length == part->geom.length)
@@ -2625,7 +2789,7 @@ _disk_sync_part_table (PedDisk* disk)
}
/* add the (possibly modified or new) partition */
- if (!_blkpg_add_partition (disk, part)) {
+ if (!add_partition (disk, part)) {
ped_exception_throw (
PED_EXCEPTION_ERROR,
PED_EXCEPTION_RETRY_CANCEL,
@@ -2671,215 +2835,6 @@ _disk_sync_part_table (PedDisk* disk)
return ret;
}
-#ifdef ENABLE_DEVICE_MAPPER
-static int
-_dm_remove_map_name(char *name)
-{
- struct dm_task *task = NULL;
- int rc;
-
- task = dm_task_create(DM_DEVICE_REMOVE);
- if (!task)
- return 1;
-
- dm_task_set_name (task, name);
-
- rc = dm_task_run(task);
- dm_task_update_nodes();
- dm_task_destroy(task);
- if (!rc)
- return 1;
-
- return 0;
-}
-
-static int
-_dm_is_part (struct dm_info *this, char *name)
-{
- struct dm_task* task = NULL;
- struct dm_info* info = alloca(sizeof *info);
- struct dm_deps* deps = NULL;
- int rc = 0;
- unsigned int i;
-
- task = dm_task_create(DM_DEVICE_DEPS);
- if (!task)
- return 0;
-
- dm_task_set_name(task, name);
- if (!dm_task_run(task))
- goto err;
-
- memset(info, '\0', sizeof *info);
- dm_task_get_info(task, info);
- if (!info->exists)
- goto err;
-
- deps = dm_task_get_deps(task);
- if (!deps)
- goto err;
-
- for (i = 0; i < deps->count; i++) {
- unsigned int ma = major(deps->device[i]),
- mi = minor(deps->device[i]);
-
- if (ma == this->major && mi == this->minor)
- rc = 1;
- }
-
-err:
- dm_task_destroy(task);
- return rc;
-}
-
-static int
-_dm_remove_parts (PedDevice* dev)
-{
- struct dm_task* task = NULL;
- struct dm_info* info = alloca(sizeof *info);
- struct dm_names* names = NULL;
- unsigned int next = 0;
- int rc;
- LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
-
- task = dm_task_create(DM_DEVICE_LIST);
- if (!task)
- goto err;
-
- if (!dm_task_set_major_minor (task, arch_specific->major,
- arch_specific->minor, 0))
- goto err;
-
- if (!dm_task_run(task))
- goto err;
-
- memset(info, '\0', sizeof *info);
- dm_task_get_info(task, info);
- if (!info->exists)
- goto err;
-
- names = dm_task_get_names(task);
- if (!names)
- goto err;
-
- rc = 0;
- do {
- names = (void *) ((char *) names + next);
-
- if (_dm_is_part(info, names->name))
- rc += _dm_remove_map_name(names->name);
-
- next = names->next;
- } while (next);
-
- dm_task_update_nodes();
- dm_task_destroy(task);
- task = NULL;
-
- if (!rc)
- return 1;
-err:
- if (task)
- dm_task_destroy(task);
- ped_exception_throw (PED_EXCEPTION_WARNING, PED_EXCEPTION_IGNORE,
- _("parted was unable to re-read the partition "
- "table on %s (%s). This means Linux won't know "
- "anything about the modifications you made. "),
- dev->path, strerror (errno));
- return 0;
-}
-
-static int
-_dm_add_partition (PedDisk* disk, PedPartition* part)
-{
- char* vol_name = NULL;
- const char* dev_name = NULL;
- char* params = NULL;
- LinuxSpecific* arch_specific = LINUX_SPECIFIC (disk->dev);
-
- /* Get map name from devicemapper */
- struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
- if (!task)
- goto err;
-
- if (!dm_task_set_major_minor (task, arch_specific->major,
- arch_specific->minor, 0))
- goto err;
-
- if (!dm_task_run(task))
- goto err;
-
- dev_name = dm_task_get_name (task);
-
- if (isdigit (dev_name[strlen (dev_name) - 1])) {
- if ( ! (vol_name = zasprintf ("%sp%d", dev_name, part->num)))
- goto err;
- } else if ( ! (vol_name = zasprintf ("%s%d", dev_name, part->num)))
- goto err;
-
- /* Caution: dm_task_destroy frees dev_name. */
- dm_task_destroy (task);
- task = NULL;
-
- if ( ! (params = zasprintf ("%d:%d %lld", arch_specific->major,
- arch_specific->minor, part->geom.start)))
- goto err;
-
- task = dm_task_create (DM_DEVICE_CREATE);
- if (!task)
- goto err;
-
- dm_task_set_name (task, vol_name);
- dm_task_add_target (task, 0, part->geom.length,
- "linear", params);
- if (dm_task_run (task)) {
- //printf("0 %ld linear %s\n", part->geom.length, params);
- dm_task_update_nodes();
- dm_task_destroy(task);
- free(params);
- free(vol_name);
- return 1;
- } else {
- _dm_remove_map_name(vol_name);
- }
-err:
- dm_task_update_nodes();
- if (task)
- dm_task_destroy (task);
- free (params);
- free (vol_name);
- return 0;
-}
-
-static int
-_dm_reread_part_table (PedDisk* disk)
-{
- int largest_partnum = ped_disk_get_last_partition_num (disk);
- if (largest_partnum <= 0)
- return 1;
-
- int rc = 1;
- int last = PED_MIN (largest_partnum, 16);
- int i;
-
- sync();
- if (!_dm_remove_parts(disk->dev))
- rc = 0;
-
- for (i = 1; i <= last; i++) {
- PedPartition* part;
-
- part = ped_disk_get_partition (disk, i);
- if (!part)
- continue;
-
- if (!_dm_add_partition (disk, part))
- rc = 0;
- }
- return rc;
-}
-#endif
-
static int
_have_blkpg ()
{
@@ -2897,10 +2852,6 @@ _have_blkpg ()
static int
linux_disk_commit (PedDisk* disk)
{
-#ifdef ENABLE_DEVICE_MAPPER
- if (disk->dev->type == PED_DEVICE_DM)
- return _dm_reread_part_table (disk);
-#endif
if (disk->dev->type != PED_DEVICE_FILE) {
/* We now require BLKPG support. If this assertion fails,
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cdc1c4b..4649c0a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -58,6 +58,7 @@ TESTS = \
t5000-tags.sh \
t6000-dm.sh \
t6001-psep.sh \
+ t6002-dm-busy.sh \
t6100-mdraid-partitions.sh \
t7000-scripting.sh \
t8000-loop.sh \
diff --git a/tests/t6002-dm-busy.sh b/tests/t6002-dm-busy.sh
new file mode 100644
index 0000000..9807b40
--- /dev/null
+++ b/tests/t6002-dm-busy.sh
@@ -0,0 +1,92 @@
+#!/bin/sh
+# ensure that parted can alter a partition on a dmraid disk
+# while another one is mounted
+
+# Copyright (C) 2008-2012 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/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+
+require_root_
+
+# We could make this work for arbitrary sector size, but I'm lazy.
+require_512_byte_sector_size_
+
+test "x$ENABLE_DEVICE_MAPPER" = xyes \
+ || skip_ "no device-mapper support"
+
+# Device maps names - should be random to not conflict with existing ones on
+# the system
+linear_=plinear-$$
+
+d1=
+f1=
+dev=
+cleanup_fn_() {
+ umount "${dev}p2" > /dev/null 2>&1
+ dmsetup remove ${linear_}p1
+ dmsetup remove ${linear_}p2
+ dmsetup remove $linear_
+ test -n "$d1" && losetup -d "$d1"
+ rm -f "$f1"
+}
+
+f1=$(pwd)/1; d1=$(loop_setup_ "$f1") \
+ || fail=1
+
+# setup: create a mapping
+n=204800
+echo "0 $n linear $d1 0" | dmsetup create $linear_ || fail=1
+dev="/dev/mapper/$linear_"
+
+# Create msdos partition table
+parted -s $dev mklabel msdos > out 2>&1 || fail=1
+compare /dev/null out || fail=1
+
+parted -s $dev -a none mkpart primary fat32 1s 1000s > out 2>&1 || fail=1
+compare /dev/null out || fail=1
+
+parted -s $dev -a none mkpart primary fat32 1001s 200000s > out 2>&1 || fail=1
+compare /dev/null out || fail=1
+
+# wait for new partition device to appear
+wait_for_dev_to_appear_ ${dev}p2 || fail_ ${dev}p2 did not appear
+
+mkfs.vfat -F 32 ${dev}p2 || fail_ mkfs.vfat failed
+
+mount_point=$(pwd)/mnt
+
+mkdir $mount_point || fail=1
+mount "${dev}p2" "$mount_point" || fail=1
+
+# Removal of unmounted partition must succeed.
+parted -s "$dev" rm 1 > /dev/null 2>&1 || fail=1
+
+# Removal of mounted partition must fail.
+parted -s "$dev" rm 2 > /dev/null 2>&1 && fail=1
+
+parted -m -s "$dev" u s print > out 2>&1 || fail=1
+sed "s,^$dev,DEV," out > k; mv k out
+
+# Create expected output file.
+cat <<EOF >> exp || fail=1
+BYT;
+DEV:${n}s:dm:512:512:msdos:Linux device-mapper (linear):;
+2:1001s:200000s:199000s:fat32::lba;
+EOF
+
+compare exp out || fail=1
+
+Exit $fail
--
1.9.3

View File

@ -1,71 +0,0 @@
From f87ff28d1aa8eff085e737ab22d031b0519e5510 Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Sun, 14 Oct 2012 23:59:59 -0400
Subject: [PATCH 046/131] libparted: remove extraneous blkpg add partition ped
exception
_blkpg_add_partition was throwing an exception if it failed to add the
new partition, in addition to _disk_sync_part_table throwing one, and
then bailing out. Instead of bailing out, just log the error for
reporting later and continue.
---
libparted/arch/linux.c | 21 +++------------------
tests/t2310-dos-extended-2-sector-min-offset.sh | 3 +--
2 files changed, 4 insertions(+), 20 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 70b26a9..5721d4b 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2407,18 +2407,7 @@ _blkpg_add_partition (PedDisk* disk, const PedPartition *part)
if (!_blkpg_part_command (disk->dev, &linux_part,
BLKPG_ADD_PARTITION)) {
- return ped_exception_throw (
- PED_EXCEPTION_ERROR,
- PED_EXCEPTION_IGNORE_CANCEL,
- _("Error informing the kernel about modifications to "
- "partition %s -- %s. This means Linux won't know "
- "about any changes you made to %s until you reboot "
- "-- so you shouldn't mount it or use it in any way "
- "before rebooting."),
- linux_part.devname,
- strerror (errno),
- linux_part.devname)
- == PED_EXCEPTION_IGNORE;
+ return 0;
}
return 1;
@@ -2790,12 +2779,8 @@ _disk_sync_part_table (PedDisk* disk)
/* add the (possibly modified or new) partition */
if (!add_partition (disk, part)) {
- ped_exception_throw (
- PED_EXCEPTION_ERROR,
- PED_EXCEPTION_RETRY_CANCEL,
- _("Failed to add partition %d (%s)"),
- i, strerror (errno));
- goto cleanup;
+ ok[i - 1] = 0;
+ errnums[i - 1] = errno;
}
}
}
diff --git a/tests/t2310-dos-extended-2-sector-min-offset.sh b/tests/t2310-dos-extended-2-sector-min-offset.sh
index 89453ae..17c777c 100644
--- a/tests/t2310-dos-extended-2-sector-min-offset.sh
+++ b/tests/t2310-dos-extended-2-sector-min-offset.sh
@@ -39,8 +39,7 @@ $scsi_dev:2048s:scsi:512:512:msdos:Linux scsi_debug:;
EOF
cat <<EOF > err.exp || framework_failure
-Error: Error informing the kernel about modifications to partition $p5 -- Device or resource busy. This means Linux won't know about any changes you made to $p5 until you reboot -- so you shouldn't mount it or use it in any way before rebooting.
-Error: Failed to add partition 5 (Device or resource busy)
+Error: Partition(s) 5 on $scsi_dev have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.
EOF
# Create a DOS label with an extended partition starting at sector 64.
--
1.9.3

View File

@ -1,225 +0,0 @@
From 3cb820632a13a91e0c2e579aedbe8e86b4f0040e Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Fri, 19 Oct 2012 17:32:00 +0200
Subject: [PATCH 047/131] libparted: don't probe every dm device in probe_all
We were probing every dm device. Only probe dmraid whole disk
(non-partition) devices instead. This removes the clutter of
LVM logical volumes, and dmraid partitions from the list, which
usually do not make sense to partition.
* NEWS (Changes in behavior): Mention it.
* libparted/arch/linux.c (_is_dmraid_device): New function.
(_dm_is_part): Likewise.
(_probe_dm_devices): Use the latter.
* tests/t6003-dm-hide.sh: New test.
* tests/Makefile.am (TESTS): Add it.
---
NEWS | 3 ++
libparted/arch/linux.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++-
tests/Makefile.am | 1 +
tests/t6003-dm-hide.sh | 60 +++++++++++++++++++++++++++++++++++++
4 files changed, 144 insertions(+), 1 deletion(-)
create mode 100644 tests/t6003-dm-hide.sh
diff --git a/NEWS b/NEWS
index a40d69b..89541fd 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,9 @@ GNU parted NEWS -*- outline -*-
** Changes in behavior
+ parted -l no longer lists device-mapper devices other than
+ dmraid whole disks.
+
Added new Linux-specific partition GUID type code
(0FC63DAF-8483-4772-8E79-3D69D8477DE4) for Linux filesystem data on GPT
disks. This type code is now assigned as the default partition type code
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 5721d4b..083591f 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -65,6 +65,8 @@
# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
#endif
+#define STRPREFIX(a, b) (strncmp (a, b, strlen (b)) == 0)
+
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#ifndef __NR__llseek
@@ -478,6 +480,82 @@ bad:
return r;
}
+/* Return nonzero if device-mapper device, DEVPATH, is part of a dmraid
+ array. Use the heuristic of checking for the string "DMRAID-" at the
+ start of its UUID. */
+static int
+_is_dmraid_device (const char *devpath)
+{
+ int rc = 0;
+
+ char const *dm_name = strrchr (devpath, '/');
+ char const *dm_basename = dm_name && *(++dm_name) ? dm_name : devpath;
+ struct dm_task *task = dm_task_create (DM_DEVICE_DEPS);
+ if (!task)
+ return 0;
+
+ dm_task_set_name (task, dm_basename);
+ if (!dm_task_run (task))
+ goto err;
+
+ const char *dmraid_uuid = dm_task_get_uuid (task);
+ if (STRPREFIX (dmraid_uuid, "DMRAID-"))
+ rc = 1;
+
+err:
+ dm_task_destroy (task);
+ return rc;
+}
+
+/* We consider a dm device that is a linear mapping with a *
+ * single target that also is a dm device to be a partition */
+
+static int
+_dm_is_part (const char *path)
+{
+ int rc = 0;
+ struct dm_task *task = dm_task_create (DM_DEVICE_DEPS);
+ if (!task)
+ return 0;
+
+ dm_task_set_name(task, path);
+ if (!dm_task_run(task))
+ goto err;
+
+ struct dm_info *info = alloca (sizeof *info);
+ memset(info, '\0', sizeof *info);
+ dm_task_get_info (task, info);
+ if (!info->exists)
+ goto err;
+
+ struct dm_deps *deps = dm_task_get_deps (task);
+ if (!deps)
+ goto err;
+
+ if (deps->count != 1)
+ goto err;
+ if (!_is_dm_major (major (deps->device[0])))
+ goto err;
+ dm_task_destroy (task);
+ if (!(task = dm_task_create (DM_DEVICE_TABLE)))
+ return 0;
+ dm_task_set_name (task, path);
+ if (!dm_task_run (task))
+ goto err;
+
+ char *target_type = NULL;
+ char *params = NULL;
+ uint64_t start, length;
+
+ dm_get_next_target (task, NULL, &start, &length, &target_type, &params);
+ if (strcmp (target_type, "linear"))
+ goto err;
+ rc = 1;
+
+err:
+ dm_task_destroy(task);
+ return rc;
+}
static int
_probe_dm_devices ()
@@ -504,7 +582,8 @@ _probe_dm_devices ()
if (stat (buf, &st) != 0)
continue;
- if (_is_dm_major(major(st.st_rdev)))
+ if (_is_dm_major(major(st.st_rdev)) && _is_dmraid_device (buf)
+ && !_dm_is_part(buf))
_ped_device_probe (buf);
}
closedir (mapper_dir);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4649c0a..4ec08da 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -59,6 +59,7 @@ TESTS = \
t6000-dm.sh \
t6001-psep.sh \
t6002-dm-busy.sh \
+ t6003-dm-hide.sh \
t6100-mdraid-partitions.sh \
t7000-scripting.sh \
t8000-loop.sh \
diff --git a/tests/t6003-dm-hide.sh b/tests/t6003-dm-hide.sh
new file mode 100644
index 0000000..3cfdc43
--- /dev/null
+++ b/tests/t6003-dm-hide.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+# ensure that parted -l only shows dmraid device-mapper devices
+
+# Copyright (C) 2008-2012 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/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+
+require_root_
+lvm_init_root_dir_
+
+test "x$ENABLE_DEVICE_MAPPER" = xyes \
+ || skip_ "no device-mapper support"
+
+# Device maps names - should be random to not conflict with existing ones on
+# the system
+linear_=plinear-$$
+
+d1=
+f1=
+dev=
+cleanup_fn_() {
+ dmsetup remove $linear_
+ test -n "$d1" && losetup -d "$d1"
+ rm -f "$f1"
+}
+
+f1=$(pwd)/1; d1=$(loop_setup_ "$f1") \
+ || fail=1
+
+# setup: create a mapping
+echo "0 2048 linear $d1 0" | dmsetup create $linear_ || fail=1
+dev="$DM_DEV_DIR/mapper/$linear_"
+
+# device should not show up
+
+parted -l >out 2>&1
+! grep $linear_ out || fail=1
+
+dmsetup remove $linear_
+echo "0 2048 linear $d1 0" | dmsetup create $linear_ -u "DMRAID-fake" || fail=1
+
+# device should now show up
+
+parted -l >out 2>&1
+grep $linear_ out || fail=1
+
+Exit $fail
--
1.9.3

View File

@ -1,71 +0,0 @@
From 2224076fef1a54391cf090149ba9308ae90067eb Mon Sep 17 00:00:00 2001
From: Jim Meyering <jim@meyering.net>
Date: Fri, 19 Oct 2012 18:09:19 +0200
Subject: [PATCH 048/131] tests: make t6003-dm-hide work reliably on F17
* tests/t6003-dm-hide.sh: Adjust to work reliably on Fedora 17.
---
tests/t6003-dm-hide.sh | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/tests/t6003-dm-hide.sh b/tests/t6003-dm-hide.sh
index 3cfdc43..59baae9 100644
--- a/tests/t6003-dm-hide.sh
+++ b/tests/t6003-dm-hide.sh
@@ -19,7 +19,6 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
require_root_
-lvm_init_root_dir_
test "x$ENABLE_DEVICE_MAPPER" = xyes \
|| skip_ "no device-mapper support"
@@ -32,7 +31,10 @@ d1=
f1=
dev=
cleanup_fn_() {
- dmsetup remove $linear_
+ # Insist. Sometimes the initial removal fails (race?).
+ # When that happens, a second removal appears to be sufficient.
+ dmsetup remove $linear_ || dmsetup remove $linear_
+
test -n "$d1" && losetup -d "$d1"
rm -f "$f1"
}
@@ -41,20 +43,25 @@ f1=$(pwd)/1; d1=$(loop_setup_ "$f1") \
|| fail=1
# setup: create a mapping
-echo "0 2048 linear $d1 0" | dmsetup create $linear_ || fail=1
-dev="$DM_DEV_DIR/mapper/$linear_"
-
-# device should not show up
+echo 0 2048 linear $d1 0 | dmsetup create $linear_ || fail=1
+dev=/dev/mapper/$linear_
+# No "DMRAID-" UUID prefix, hence the device should not show up.
parted -l >out 2>&1
-! grep $linear_ out || fail=1
+grep "^Disk $dev:" out && fail=1
+# Unless we perform both dmsetup-remove *and* losetup -d,
+# the following dmsetup-create would fail with EBUSY.
dmsetup remove $linear_
-echo "0 2048 linear $d1 0" | dmsetup create $linear_ -u "DMRAID-fake" || fail=1
+losetup -d "$d1" || fail=1
+# Reopen (or get new) loop device.
+d1=$(loop_setup_ "$f1") || fail=1
-# device should now show up
+# This time, use a fake UUID.
+echo 0 2048 linear $d1 0 | dmsetup create $linear_ -u "DMRAID-fake-$$" || fail=1
+# Thus, the device should now show up.
parted -l >out 2>&1
-grep $linear_ out || fail=1
+grep "^Disk $dev:" out || fail=1
Exit $fail
--
1.9.3

View File

@ -1,77 +0,0 @@
From 21be64fc6ef60a1e9dc7bc352131be58cc59d61d Mon Sep 17 00:00:00 2001
From: Jim Meyering <jim@meyering.net>
Date: Wed, 2 Jan 2013 12:52:14 +0100
Subject: [PATCH 049/131] doc: 1MiB-alignment is not enough for cheap flash
drives
* doc/parted.texi: Add an example that aligns to 4GiB, and
reference Arnd Bergman's LWN article.
---
doc/parted.texi | 39 ++++++++++++++++++++++++++++++++++-----
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/doc/parted.texi b/doc/parted.texi
index b8db19d..008c383 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -14,7 +14,7 @@ and manipulating partition tables.
@ifnottex @c texi2pdf don't understand copying and insertcopying ???
@c modifications must also be done in the titlepage
@copying
-Copyright @copyright{} 1999-2012 Free Software Foundation, Inc.
+Copyright @copyright{} 1999-2013 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -577,15 +577,44 @@ partition table.
@item ufs
@end itemize
-Example:
+For example, the following creates a logical partition that will contain
+an ext2 file system. The partition will start at the beginning of the disk,
+and end 692.1 megabytes into the disk.
@example
(parted) @kbd{mkpart logical 0.0 692.1}
@end example
-Create a logical partition that will contain an ext2 file system. The
-partition will start at the beginning of the disk, and end 692.1
-megabytes into the disk.
+Now, we will show how to partition a low-end flash
+device (``low-end'', as of 2011/2012).
+For such devices, you should use 4MiB-aligned partitions@footnote{
+Cheap flash drives will be with us for a long time to
+come, and, for them, 1MiB alignment is not enough.
+Use at least 4MiB-aligned partitions.
+For details, see Arnd Bergman's article,
+@uref{http://http://lwn.net/Articles/428584/} and its many comments.}.
+This command creates a tiny place-holder partition at the beginning, and
+then uses all remaining space to create the partition you'll actually use:
+
+@example
+$ @kbd{parted -s /dev/sdX -- mklabel msdos \}
+@kbd{ mkpart primary fat32 64s 4MiB \}
+@kbd{ mkpart primary fat32 4MiB -1s}
+@end example
+
+Note the use of @samp{--}, to prevent the following @samp{-1s} last-sector
+indicator from being interpreted as an invalid command-line option.
+The above creates two empty partitions. The first is unaligned and tiny,
+with length less than 4MiB.
+The second partition starts precisely at the 4MiB mark
+and extends to the end of the device.
+
+The next step is typically to create a file system in the second partition:
+
+@example
+$ @kbd{mkfs.vfat /dev/sdX2}
+@end example
+
@end deffn
--
1.9.3

View File

@ -1,19 +0,0 @@
From 960eda93fc53ea18e8e98109a00661ac5e8a88f8 Mon Sep 17 00:00:00 2001
From: Jim Meyering <jim@meyering.net>
Date: Sun, 6 Jan 2013 11:06:23 +0100
Subject: [PATCH 050/131] build: update gnulib submodule to latest
---
gnulib | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gnulib b/gnulib
index e1abd50..164ebfe 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit e1abd50b01d6bd61bd0c996ca17378cd569c0aa1
+Subproject commit 164ebfe612d8460c15d7acf1927faef6943571b6
--
1.9.3

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +0,0 @@
From 1c659d5cc6830c6f4f26660e9049582afbad3fd3 Mon Sep 17 00:00:00 2001
From: Jim Meyering <jim@meyering.net>
Date: Sun, 6 Jan 2013 11:37:15 +0100
Subject: [PATCH 052/131] maint: avoid new warning/error with gcc-4.8.0
20130105
* configure.ac (WERROR_CFLAGS): Disable -Wsuggest-attribute=format.
It was suggesting to apply the gnu_printf attribute to vsnprintf.
---
configure.ac | 1 +
1 file changed, 1 insertion(+)
diff --git a/configure.ac b/configure.ac
index fef0b53..b04eb3f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -235,6 +235,7 @@ if test "$gl_gcc_warnings" = yes; then
nw="$nw -Wstrict-overflow" # expr.c, pr.c, tr.c, factor.c
nw="$nw -Wstack-protector" # libparted/label/gpt.c
# ?? -Wstrict-overflow
+ nw="$nw -Wsuggest-attribute=format" # suggests to use gnu_printf for vsnprintf
gl_MANYWARN_ALL_GCC([ws])
gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
--
1.9.3

View File

@ -1,158 +0,0 @@
From 70aa35b2b4d2e723fe82ac3184e5921a52be73ab Mon Sep 17 00:00:00 2001
From: Jonathan Liu <net147@gmail.com>
Date: Fri, 4 Oct 2013 07:32:12 -0700
Subject: [PATCH 053/131] dos: improve MBR signature generation
Using tv_usec in struct timeval from gettimeofday() doesn't provide
enough precision to fill an unsigned 32-bit integer and isn't really
random. It it always less than one million when using the GNU C library
while an unsigned 32-bit integer ranges between 0 and 4294967295.
In FAT filesystem creation, parted already uses a better random
generator, so move that code into a common function and use it
for MS-DOS MBR signature generation.
* libparted/fs/r/fat/fat.c (_gen_new_serial_number): Remove.
(fat_create): Use generate_random_uint32 instead of
_gen_new_serial_number.
* libparted/labels/dos.c (generate_random_id): Remove.
(msdos_write): Use generate_random_uint32 instead of
generate_random_id.
* libparted/labels/misc.h (generate_random_uint32): New function.
Created from _gen_new_serial_number in libparted/fs/r/fat/fat.c with
additional check to avoid returning zero, which may be interpreted
as no FAT serial number or no MBR signature.
---
NEWS | 4 ++++
libparted/fs/r/fat/fat.c | 19 ++-----------------
libparted/labels/dos.c | 12 +-----------
libparted/labels/misc.h | 21 +++++++++++++++++++++
4 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/NEWS b/NEWS
index 98f7c6e..50faf4d 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,10 @@ GNU parted NEWS -*- outline -*-
partprobe now tells the kernel to forget about any partitions
on a device that has no recognizable partition table.
+ dos: the range of random MBR signature values was artificially limited
+ to 0..999999, which mistakenly included 0. Now, we use the full 32-bit
+ range, but exclude 0.
+
** Changes in behavior
parted -l no longer lists device-mapper devices other than
diff --git a/libparted/fs/r/fat/fat.c b/libparted/fs/r/fat/fat.c
index 2ab9279..c8e4552 100644
--- a/libparted/fs/r/fat/fat.c
+++ b/libparted/fs/r/fat/fat.c
@@ -18,10 +18,10 @@
#include <config.h>
#include <string.h>
-#include <uuid/uuid.h>
#include "fat.h"
#include "calc.h"
+#include "../../../labels/misc.h"
PedFileSystem*
fat_alloc (const PedGeometry* geom)
@@ -202,21 +202,6 @@ fat_root_dir_clear (PedFileSystem* fs)
fs_info->root_dir_sector_count);
}
-/* hack: use the ext2 uuid library to generate a reasonably random (hopefully
- * with /dev/random) number. Unfortunately, we can only use 4 bytes of it
- */
-static uint32_t
-_gen_new_serial_number (void)
-{
- union {
- uuid_t uuid;
- uint32_t i;
- } uu32;
-
- uuid_generate (uu32.uuid);
- return uu32.i;
-}
-
PedFileSystem*
fat_create (PedGeometry* geom, FatType fat_type, PedTimer* timer)
{
@@ -316,7 +301,7 @@ fat_create (PedGeometry* geom, FatType fat_type, PedTimer* timer)
return 0;
}
- fs_info->serial_number = _gen_new_serial_number ();
+ fs_info->serial_number = generate_random_uint32 ();
if (!fat_boot_sector_set_boot_code (&fs_info->boot_sector))
goto error_free_buffers;
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index b8c161f..6bddd79 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -1236,16 +1236,6 @@ write_extended_partitions (const PedDisk* disk)
return write_empty_table (disk, ext_part->geom.start);
}
-static inline uint32_t generate_random_id (void)
-{
- struct timeval tv;
- int rc;
- rc = gettimeofday(&tv, NULL);
- if (rc == -1)
- return 0;
- return (uint32_t)(tv.tv_usec & 0xFFFFFFFFUL);
-}
-
static int
msdos_write (const PedDisk* disk)
{
@@ -1267,7 +1257,7 @@ msdos_write (const PedDisk* disk)
/* If there is no unique identifier, generate a random one */
if (!table->mbr_signature)
- table->mbr_signature = generate_random_id();
+ table->mbr_signature = generate_random_uint32 ();
memset (table->partitions, 0, sizeof (table->partitions));
table->magic = PED_CPU_TO_LE16 (MSDOS_MAGIC);
diff --git a/libparted/labels/misc.h b/libparted/labels/misc.h
index c2ccea1..c039c5f 100644
--- a/libparted/labels/misc.h
+++ b/libparted/labels/misc.h
@@ -16,6 +16,27 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#include <inttypes.h>
+#include <uuid/uuid.h>
+
+/* hack: use the ext2 uuid library to generate a reasonably random (hopefully
+ * with /dev/random) number. Unfortunately, we can only use 4 bytes of it.
+ * We make sure to avoid returning zero which may be interpreted as no FAT
+ * serial number or no MBR signature.
+ */
+static inline uint32_t
+generate_random_uint32 (void)
+{
+ union {
+ uuid_t uuid;
+ uint32_t i;
+ } uu32;
+
+ uuid_generate (uu32.uuid);
+
+ return uu32.i > 0 ? uu32.i : 0xffffffff;
+}
+
/* Return nonzero if FS_TYPE_NAME starts with "linux-swap".
This must match the NUL-terminated "linux-swap" as well
as "linux-swap(v0)" and "linux-swap(v1)". */
--
1.9.3

View File

@ -1,324 +0,0 @@
From 9b8f632e102c0d9e2187f0c8d8205862540cdcd1 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@fb.com>
Date: Wed, 9 Oct 2013 17:44:05 -0700
Subject: [PATCH 054/131] bootstrap: update to latest from gnulib
---
bootstrap | 159 ++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 87 insertions(+), 72 deletions(-)
diff --git a/bootstrap b/bootstrap
index 48181c9..e31d17d 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,6 +1,6 @@
#! /bin/sh
# Print a version string.
-scriptversion=2012-07-19.14; # UTC
+scriptversion=2013-08-15.22; # UTC
# Bootstrap this package from checked-out sources.
@@ -140,20 +140,21 @@ po_download_command_format2=\
"wget --mirror -nd -q -np -A.po -P '%s' \
http://translationproject.org/latest/%s/"
+# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
+# fall back to the package name (1st argument with munging)
extract_package_name='
- /^AC_INIT(/{
- /.*,.*,.*, */{
- s///
- s/[][]//g
- s/)$//
+ /^AC_INIT(\[*/{
+ s///
+ /^[^,]*,[^,]*,[^,]*,[ []*\([^][ ,)]\)/{
+ s//\1/
+ s/[],)].*//
p
q
}
- s/AC_INIT(\[*//
- s/]*,.*//
+ s/[],)].*//
s/^GNU //
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
- s/[^A-Za-z0-9_]/-/g
+ s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g
p
}
'
@@ -208,12 +209,16 @@ bootstrap_sync=false
# Use git to update gnulib sources
use_git=true
+check_exists() {
+ ($1 --version </dev/null) >/dev/null 2>&1
+ test $? -lt 126
+}
+
# find_tool ENVVAR NAMES...
# -------------------------
# Search for a required program. Use the value of ENVVAR, if set,
-# otherwise find the first of the NAMES that can be run (i.e.,
-# supports --version). If found, set ENVVAR to the program name,
-# die otherwise.
+# otherwise find the first of the NAMES that can be run.
+# If found, set ENVVAR to the program name, die otherwise.
#
# FIXME: code duplication, see also gnu-web-doc-update.
find_tool ()
@@ -223,27 +228,21 @@ find_tool ()
find_tool_names=$@
eval "find_tool_res=\$$find_tool_envvar"
if test x"$find_tool_res" = x; then
- for i
- do
- if ($i --version </dev/null) >/dev/null 2>&1; then
- find_tool_res=$i
- break
+ for i; do
+ if check_exists $i; then
+ find_tool_res=$i
+ break
fi
done
- else
- find_tool_error_prefix="\$$find_tool_envvar: "
fi
- test x"$find_tool_res" != x \
- || die "one of these is required: $find_tool_names"
- ($find_tool_res --version </dev/null) >/dev/null 2>&1 \
- || die "${find_tool_error_prefix}cannot run $find_tool_res --version"
+ if test x"$find_tool_res" = x; then
+ warn_ "one of these is required: $find_tool_names;"
+ die "alternatively set $find_tool_envvar to a compatible tool"
+ fi
eval "$find_tool_envvar=\$find_tool_res"
eval "export $find_tool_envvar"
}
-# Find sha1sum, named gsha1sum on MacPorts, and shasum on Mac OS X 10.6.
-find_tool SHA1SUM sha1sum gsha1sum shasum
-
# Override the default configuration, if necessary.
# Make sure that bootstrap.conf is sourced from the current directory
# if we were invoked as "sh bootstrap".
@@ -255,12 +254,12 @@ esac
# Extra files from gnulib, which override files from other sources.
test -z "${gnulib_extra_files}" && \
gnulib_extra_files="
- $build_aux/install-sh
- $build_aux/mdate-sh
- $build_aux/texinfo.tex
- $build_aux/depcomp
- $build_aux/config.guess
- $build_aux/config.sub
+ build-aux/install-sh
+ build-aux/mdate-sh
+ build-aux/texinfo.tex
+ build-aux/depcomp
+ build-aux/config.guess
+ build-aux/config.sub
doc/INSTALL
"
@@ -306,34 +305,34 @@ if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
die "Bootstrapping from a non-checked-out distribution is risky."
fi
-# Ensure that lines starting with ! sort last, per gitignore conventions
-# for whitelisting exceptions after a more generic blacklist pattern.
-sort_patterns() {
- sort -u "$@" | sed '/^!/ {
- H
- d
- }
- $ {
- P
- x
- s/^\n//
- }' | sed '/^$/d'
+# Strip blank and comment lines to leave significant entries.
+gitignore_entries() {
+ sed '/^#/d; /^$/d' "$@"
}
-# If $STR is not already on a line by itself in $FILE, insert it,
-# sorting the new contents of the file and replacing $FILE with the result.
-insert_sorted_if_absent() {
+# If $STR is not already on a line by itself in $FILE, insert it at the start.
+# Entries are inserted at the start of the ignore list to ensure existing
+# entries starting with ! are not overridden. Such entries support
+# whitelisting exceptions after a more generic blacklist pattern.
+insert_if_absent() {
file=$1
str=$2
test -f $file || touch $file
- echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \
- || { echo "$str" | sort_patterns - $file > $file.bak \
- && mv $file.bak $file; } \
- || die "insert_sorted_if_absent $file $str: failed"
+ test -r $file || die "Error: failed to read ignore file: $file"
+ duplicate_entries=$(gitignore_entries $file | sort | uniq -d)
+ if [ "$duplicate_entries" ] ; then
+ die "Error: Duplicate entries in $file: " $duplicate_entries
+ fi
+ linesold=$(gitignore_entries $file | wc -l)
+ linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l)
+ if [ $linesold != $linesnew ] ; then
+ { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \
+ || die "insert_if_absent $file $str: failed"
+ fi
}
# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
-# insert_sorted_if_absent.
+# insert_if_absent.
insert_vc_ignore() {
vc_ignore_file="$1"
pattern="$2"
@@ -344,7 +343,7 @@ insert_vc_ignore() {
# .gitignore entry.
pattern=$(echo "$pattern" | sed s,^,/,);;
esac
- insert_sorted_if_absent "$vc_ignore_file" "$pattern"
+ insert_if_absent "$vc_ignore_file" "$pattern"
}
# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
@@ -468,8 +467,7 @@ check_versions() {
if [ "$req_ver" = "-" ]; then
# Merely require app to exist; not all prereq apps are well-behaved
# so we have to rely on $? rather than get_version.
- $app --version >/dev/null 2>&1
- if [ 126 -le $? ]; then
+ if ! check_exists $app; then
warn_ "Error: '$app' not found"
ret=1
fi
@@ -502,6 +500,12 @@ print_versions() {
# can't depend on column -t
}
+# Find sha1sum, named gsha1sum on MacPorts, shasum on Mac OS X 10.6.
+# Also find the compatible sha1 utility on the BSDs
+if test x"$SKIP_PO" = x; then
+ find_tool SHA1SUM sha1sum gsha1sum shasum sha1
+fi
+
use_libtool=0
# We'd like to use grep -E, to see if any of LT_INIT,
# AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
@@ -550,10 +554,10 @@ fi
echo "$0: Bootstrapping from checked-out $package sources..."
# See if we can use gnulib's git-merge-changelog merge driver.
-if test -d .git && (git --version) >/dev/null 2>/dev/null ; then
+if $use_git && test -d .git && check_exists git; then
if git config merge.merge-changelog.driver >/dev/null ; then
:
- elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then
+ elif check_exists git-merge-changelog; then
echo "$0: initializing git-merge-changelog driver"
git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
@@ -573,13 +577,17 @@ git_modules_config () {
test -f .gitmodules && git config --file .gitmodules "$@"
}
-gnulib_path=$(git_modules_config submodule.gnulib.path)
-test -z "$gnulib_path" && gnulib_path=gnulib
+if $use_git; then
+ gnulib_path=$(git_modules_config submodule.gnulib.path)
+ test -z "$gnulib_path" && gnulib_path=gnulib
+fi
-# Get gnulib files.
+# Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a
+# submodule, for use in the rest of the script.
case ${GNULIB_SRCDIR--} in
-)
+ # Note that $use_git is necessarily true in this case.
if git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
git submodule init || exit $?
@@ -600,8 +608,8 @@ case ${GNULIB_SRCDIR--} in
GNULIB_SRCDIR=$gnulib_path
;;
*)
- # Use GNULIB_SRCDIR as a reference.
- if test -d "$GNULIB_SRCDIR"/.git && \
+ # Use GNULIB_SRCDIR directly or as a reference.
+ if $use_git && test -d "$GNULIB_SRCDIR"/.git && \
git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
if git submodule -h|grep -- --reference > /dev/null; then
@@ -627,12 +635,19 @@ case ${GNULIB_SRCDIR--} in
;;
esac
+# $GNULIB_SRCDIR now points to the version of gnulib to use, and
+# we no longer need to use git or $gnulib_path below here.
+
if $bootstrap_sync; then
cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || {
echo "$0: updating bootstrap and restarting..."
+ case $(sh -c 'echo "$1"' -- a) in
+ a) ignored=--;;
+ *) ignored=ignored;;
+ esac
exec sh -c \
'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
- -- "$GNULIB_SRCDIR/build-aux/bootstrap" \
+ $ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \
"$0" "$@" --no-bootstrap-sync
}
fi
@@ -680,11 +695,10 @@ update_po_files() {
cksum_file="$ref_po_dir/$po.s1"
if ! test -f "$cksum_file" ||
! test -f "$po_dir/$po.po" ||
- ! $SHA1SUM -c --status "$cksum_file" \
- < "$new_po" > /dev/null; then
+ ! $SHA1SUM -c "$cksum_file" < "$new_po" > /dev/null 2>&1; then
echo "$me: updated $po_dir/$po.po..."
cp "$new_po" "$po_dir/$po.po" \
- && $SHA1SUM < "$new_po" > "$cksum_file"
+ && $SHA1SUM < "$new_po" > "$cksum_file" || return
fi
done
}
@@ -889,20 +903,21 @@ find "$m4_base" "$source_base" \
-depth \( -name '*.m4' -o -name '*.[ch]' \) \
-type l -xtype l -delete > /dev/null 2>&1
+# Invoke autoreconf with --force --install to ensure upgrades of tools
+# such as ylwrap.
+AUTORECONFFLAGS="--verbose --install --force -I $m4_base $ACLOCAL_FLAGS"
+
# Some systems (RHEL 5) are using ancient autotools, for which the
# --no-recursive option had not been invented. Detect that lack and
# omit the option when it's not supported. FIXME in 2017: remove this
# hack when RHEL 5 autotools are updated, or when they become irrelevant.
-no_recursive=
case $($AUTORECONF --help) in
- *--no-recursive*) no_recursive=--no-recursive;;
+ *--no-recursive*) AUTORECONFFLAGS="$AUTORECONFFLAGS --no-recursive";;
esac
# Tell autoreconf not to invoke autopoint or libtoolize; they were run above.
-echo "running: AUTOPOINT=true LIBTOOLIZE=true " \
- "$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS"
-AUTOPOINT=true LIBTOOLIZE=true \
- $AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS \
+echo "running: AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS"
+AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS \
|| die "autoreconf failed"
# Get some extra files from gnulib, overriding existing files.
--
1.9.3

View File

@ -1,73 +0,0 @@
From 8ae195863e7d6950cfcc7a067f52e46f295655a7 Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Sat, 5 Jan 2013 15:13:50 -0500
Subject: [PATCH 055/131] parted: fix EOF and ctrl-c handling
feof() seems to not detect EOF after readline() hits it, so parted went
into an infinite loop prompting for input on EOF. Change test to use the
got_ctrl_c variable instead, which is set when readline hits EOF and
returns NULL. This also makes parted properly exit on ctrl-c.
---
NEWS | 4 ++++
parted/ui.c | 16 ++++++----------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/NEWS b/NEWS
index 50faf4d..a27200b 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,10 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ parted: fix EOF and ctrl-c handling. parted used to refuse to exit
+ in response to ctrl-c and would get stuck in an infinite loop
+ prompting for more input when it reached EOF on stdin.
+
libparted: Don't fail to manipulate partitions on dmraid disks that
have other partitions in use.
diff --git a/parted/ui.c b/parted/ui.c
index 22790bb..786deed 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -647,15 +647,7 @@ exception_handler (PedException* ex)
got_ctrl_c = 0;
- do {
- opt = command_line_get_ex_opt ("", ex->options);
- } while (opt == PED_EXCEPTION_UNHANDLED
- && (isatty (0) || pretend_input_tty) && !got_ctrl_c);
-
- if (got_ctrl_c) {
- got_ctrl_c = 0;
- opt = PED_EXCEPTION_UNHANDLED;
- }
+ opt = command_line_get_ex_opt ("", ex->options);
return opt;
}
@@ -900,6 +892,10 @@ command_line_get_word (const char* prompt, const char* def,
command_line_prompt_words (prompt, def, possibilities,
multi_word);
+ if (got_ctrl_c) {
+ got_ctrl_c = 0;
+ return NULL;
+ }
} while (command_line_get_word_count ());
return NULL;
@@ -1581,7 +1577,7 @@ interactive_mode (PedDevice** dev, Command* cmd_list[])
Command* cmd;
while (!command_line_get_word_count ()) {
- if (feof (stdin)) {
+ if (got_ctrl_c) {
putchar ('\n');
return 1;
}
--
1.9.3

View File

@ -1,37 +0,0 @@
From a1fc166a0791557a54d91e034dfefd994b11622b Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Sat, 5 Jan 2013 14:59:03 -0500
Subject: [PATCH 056/131] tests: t6003-dm-hide: don't hang on exception
If the parted -l found any exceptions, it would print the prompt, which was
redirected to the log, then hang waiting for input, which never came. Use
script mode to disable the prompts.
---
tests/t6003-dm-hide.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/t6003-dm-hide.sh b/tests/t6003-dm-hide.sh
index fce1f31..8618adc 100644
--- a/tests/t6003-dm-hide.sh
+++ b/tests/t6003-dm-hide.sh
@@ -47,7 +47,7 @@ echo 0 2048 linear $d1 0 | dmsetup create $linear_ || fail=1
dev=/dev/mapper/$linear_
# No "DMRAID-" UUID prefix, hence the device should not show up.
-parted -l >out 2>&1
+parted -s -l >out 2>&1
grep "^Disk $dev:" out && fail=1
# Unless we perform both dmsetup-remove *and* losetup -d,
@@ -61,7 +61,7 @@ d1=$(loop_setup_ "$f1") || fail=1
echo 0 2048 linear $d1 0 | dmsetup create $linear_ -u "DMRAID-fake-$$" || fail=1
# Thus, the device should now show up.
-parted -l >out 2>&1
+parted -s -l >out 2>&1
grep "^Disk $dev:" out || fail=1
Exit $fail
--
1.9.3

View File

@ -1,75 +0,0 @@
From 62a27ccbdaa29a825a593c9562a5cf55ff9e8db4 Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Sat, 29 Dec 2012 21:59:08 -0500
Subject: [PATCH 057/131] gpt: Revert small device commits
The following commit broke the position of the LastUsableLBA:
48f236f9: gpt: permit "mklabel gpt" on a 67-sector device
It introduced an off by one error, leaving LastUsableLBA pointing to
the first sector of the backup partition table instead.
This effectively reverts that commit, as well as adjusting the subsequent
commits to instead use 68 sectors as the minimum length. I believe
this is the minimum legal size as at 67 sectors, there is no valid
value for FirstUsableLBA and LastUsableLBA.
---
libparted/labels/gpt.c | 8 ++++----
tests/t0203-gpt-create-on-min-sized-device.sh | 7 +++----
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 490de70..eaf14b5 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -506,16 +506,16 @@ gpt_alloc (const PedDevice *dev)
goto error;
data_start = 2 + GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / dev->sector_size;
- data_end = dev->length - 1
+ data_end = dev->length - 2
- GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / dev->sector_size;
- /* If the device is too small to accommodate GPT headers, reject it. */
+ /* If the device is too small to accommodate GPT headers and one data
+ sector, reject it. */
if (data_end < data_start)
{
ped_exception_throw (PED_EXCEPTION_ERROR,
PED_EXCEPTION_OK,
- _("device is so small it cannot even"
- " accommodate GPT headers"));
+ _("device is too small for GPT"));
goto error_free_disk;
}
diff --git a/tests/t0203-gpt-create-on-min-sized-device.sh b/tests/t0203-gpt-create-on-min-sized-device.sh
index da291df..d95d9cd 100644
--- a/tests/t0203-gpt-create-on-min-sized-device.sh
+++ b/tests/t0203-gpt-create-on-min-sized-device.sh
@@ -24,7 +24,7 @@ dev=loop-file
ss=$sector_size_
# Create the smallest file that can accommodate a GPT partition table.
-dd if=/dev/null of=$dev bs=$ss seek=67 || framework_failure
+dd if=/dev/null of=$dev bs=$ss seek=68 || framework_failure
# create a GPT partition table
parted -s $dev mklabel gpt > out 2>&1 || fail=1
@@ -34,10 +34,9 @@ compare /dev/null out || fail=1
# Create a file that is 1 sector smaller, and require failure,
# *with* a diagnostic.
rm -f $dev
-dd if=/dev/null of=$dev bs=$ss seek=66 || framework_failure
+dd if=/dev/null of=$dev bs=$ss seek=67 || framework_failure
-echo Error: device is so small it cannot even accommodate GPT headers \
- > exp || framework_failure
+echo Error: device is too small for GPT > exp || framework_failure
# Try to create a GPT partition table in too little space. This must fail.
parted -s $dev mklabel gpt > out 2>&1 && fail=1
--
1.9.3

View File

@ -1,115 +0,0 @@
From f503870153eda7659b09e52e4adeda3bebf06471 Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Thu, 12 Jan 2012 14:53:56 -0500
Subject: [PATCH 058/131] libparted: handle logical partitions starting
immediately after the EBR
_blkpg_add_partition() set the length of the extended partition
to 2 sectors to allow LILO to be installed there, beacuse the
linux kernel does this. If a logical partition used that second
sector, adding it would fail beacuse of the overlap. Now
_blkpg_add_partition() will limit the length to only the first
sector if the second is used by a logical partition.
Previously parted did create the partition table, and after a
reboot, the kernel would recognize the table, and happily create
the extended partition as 2 sectors long, thus overlapping the
logical partition, but when parted tried to recreate the same
table with BLKPG, the kernel rightly rejected it.
---
NEWS | 8 ++++++++
libparted/arch/linux.c | 17 +++++++++++++++--
tests/t2310-dos-extended-2-sector-min-offset.sh | 16 ++++------------
3 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/NEWS b/NEWS
index a27200b..716e477 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,14 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ libparted: handle logical partitions starting immediately after
+ the EBR. Creating a logical partition one sector after the EBR
+ used to cause parted to complain that it could not inform the
+ kernel of the changes, but after a reboot, everything was fine.
+ Parted will now correctly inform the kernel of the changes, but
+ only set the length of the extended partition to 1 sector instead
+ of two, which would cause it to overlap the logical partition.
+
parted: fix EOF and ctrl-c handling. parted used to refuse to exit
in response to ctrl-c and would get stuck in an infinite loop
prompting for more input when it reached EOF on stdin.
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 2bb8774..05794d9 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2473,8 +2473,21 @@ _blkpg_add_partition (PedDisk* disk, const PedPartition *part)
memset (&linux_part, 0, sizeof (linux_part));
linux_part.start = part->geom.start * disk->dev->sector_size;
/* see fs/partitions/msdos.c:msdos_partition(): "leave room for LILO" */
- if (part->type & PED_PARTITION_EXTENDED)
- linux_part.length = part->geom.length == 1 ? 512 : 1024;
+ if (part->type & PED_PARTITION_EXTENDED) {
+ linux_part.length = 1;
+ if (disk->dev->sector_size == 512) {
+ if (linux_part.length == 1)
+ linux_part.length = 2;
+ PedPartition *walk;
+ /* if the second sector is claimed by a logical partition,
+ then there's just no room for lilo, so don't try to use it */
+ for (walk = part->part_list; walk; walk = walk->next) {
+ if (walk->geom.start == part->geom.start+1)
+ linux_part.length = 1;
+ }
+ }
+ linux_part.length *= disk->dev->sector_size;
+ }
else
linux_part.length = part->geom.length * disk->dev->sector_size;
linux_part.pno = part->num;
diff --git a/tests/t2310-dos-extended-2-sector-min-offset.sh b/tests/t2310-dos-extended-2-sector-min-offset.sh
index fe356dd..f74cba5 100644
--- a/tests/t2310-dos-extended-2-sector-min-offset.sh
+++ b/tests/t2310-dos-extended-2-sector-min-offset.sh
@@ -1,8 +1,6 @@
#!/bin/sh
-# Ensure that parted leaves at least 2 sectors between the beginning
+# Ensure that parted allows a single sector between the beginning
# of an extended partition and the first logical partition.
-# Before parted-2.3, it could be made to leave just one, and that
-# would cause trouble with the Linux kernel.
# Copyright (C) 2010-2012 Free Software Foundation, Inc.
@@ -35,7 +33,7 @@ cat <<EOF > exp || framework_failure
BYT;
$scsi_dev:2048s:scsi:512:512:msdos:Linux scsi_debug:;
1:64s:128s:65s:::lba;
-5:66s:128s:63s:::;
+5:65s:128s:64s:::;
EOF
cat <<EOF > err.exp || framework_failure
@@ -48,15 +46,9 @@ parted --align=min -s $scsi_dev mkpart extended 64s 128s> out 2>&1 || fail=1
parted -m -s $scsi_dev u s print
compare /dev/null out || fail=1
-# Provoke a failure by trying to create a partition that starts just
+# Trying to create a partition that starts just
# one sector after the start of the extended partition.
-parted --align=min -s $scsi_dev mkpart logical 65s 128s > err 2>&1 && fail=1
-compare err.exp err || fail=1
-
-# The above failed, but created the partition nonetheless. Remove it.
-parted -s $scsi_dev rm 5 || fail=1
-
-parted --align=min -s $scsi_dev mkpart logical 66s 128s > out 2>&1 || fail=1
+parted --align=min -s $scsi_dev mkpart logical 65s 128s > out 2>&1 || fail=1
compare /dev/null out || fail=1
parted -m -s $scsi_dev u s print > out 2>&1
--
1.9.3

View File

@ -1,458 +0,0 @@
From 9e9588c71e358244bd41f0ca15c10676784ed41d Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Tue, 1 Jan 2013 12:53:35 -0500
Subject: [PATCH 059/131] libparted: fix gpt end of disk handling
There are two checks for problems with the end of disk. The first checks
to make sure that the backup gpt is actually at the end of the disk as it
should be. The second checks to see that the gpt's idea of where the disk
ends is correct. The handling of the backup gpt location was wrong because
if you chose not to fix the error, then as soon as you made any changes the
backup would be written to the end of the disk anyhow, only the previous
backup would not be zeroed.
This patch fixes the write path to put the backup gpt where the gpt says
it goes, not where we think the disk ends. This allows you to choose
not to fix the problems, and the backup gpt will be written to the same
place it was before, not the new end of disk.
---
NEWS | 6 +++
libparted/labels/gpt.c | 52 ++++++++++++----------
tests/Makefile.am | 2 +
tests/gpt-header-move.py | 40 +++++++++++++++++
tests/t0281-gpt-grow.sh | 99 ++++++++++++++++++++++++++++++++++++++++++
tests/t0282-gpt-move-backup.sh | 99 ++++++++++++++++++++++++++++++++++++++++++
6 files changed, 275 insertions(+), 23 deletions(-)
create mode 100644 tests/gpt-header-move.py
create mode 100644 tests/t0281-gpt-grow.sh
create mode 100644 tests/t0282-gpt-move-backup.sh
diff --git a/NEWS b/NEWS
index 716e477..3f73434 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,12 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ libparted: fix gpt end of disk handling. Previously if the backup
+ copy of the gpt was not at the end of the disk and you chose to
+ ignore this error, parted would move it to the end of the disk
+ anyhow. It will now leave the backup in the same location if
+ you chose to ignore this error.
+
libparted: handle logical partitions starting immediately after
the EBR. Creating a logical partition one sector after the EBR
used to cause parted to complain that it could not inform the
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index eaf14b5..bcf7812 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -269,6 +269,7 @@ struct __attribute__ ((packed)) _GPTDiskData
int entry_count;
efi_guid_t uuid;
int pmbr_boot;
+ PedSector AlternateLBA;
};
/* uses libparted's disk_specific field in PedPartition, to store our info */
@@ -523,6 +524,7 @@ gpt_alloc (const PedDevice *dev)
if (!disk->disk_specific)
goto error_free_disk;
+ gpt_disk_data->AlternateLBA = dev->length - 1;
ped_geometry_init (&gpt_disk_data->data_area, dev, data_start,
data_end - data_start + 1);
gpt_disk_data->entry_count = GPT_DEFAULT_PARTITION_ENTRIES;
@@ -748,6 +750,11 @@ _parse_header (PedDisk *disk, const GuidPartitionTableHeader_t *gpt,
if (q == PED_EXCEPTION_FIX)
{
last_usable = last_usable_if_grown;
+ /* clear the old backup gpt header */
+ ptt_clear_sectors (disk->dev,
+ gpt_disk_data->AlternateLBA, 1);
+ gpt_disk_data->AlternateLBA = disk->dev->length - 1;
+ last_usable = last_usable_if_grown;
*update_needed = 1;
}
else if (q != PED_EXCEPTION_UNHANDLED)
@@ -869,13 +876,13 @@ gpt_read_headers (PedDisk const *disk,
else
pth_free (pri);
- PedSector backup_sector_num =
+ gpt_disk_data->AlternateLBA =
(valid_primary
? PED_LE64_TO_CPU (pri->AlternateLBA)
: dev->length - 1);
void *s_bak;
- if (!ptt_read_sector (dev, backup_sector_num, &s_bak))
+ if (!ptt_read_sector (dev, gpt_disk_data->AlternateLBA ,&s_bak))
return 1;
t = pth_new_from_raw (dev, s_bak);
free (s_bak);
@@ -883,10 +890,10 @@ gpt_read_headers (PedDisk const *disk,
return 1;
GuidPartitionTableHeader_t *bak = t;
- if (_header_is_valid (disk, bak, backup_sector_num))
+ if (_header_is_valid (disk, bak, gpt_disk_data->AlternateLBA))
{
*backup_gpt = bak;
- *backup_sector_num_p = backup_sector_num;
+ *backup_sector_num_p = gpt_disk_data->AlternateLBA;
}
else
pth_free (bak);
@@ -957,31 +964,30 @@ gpt_read (PedDisk *disk)
{
/* Both are valid. */
#ifndef DISCOVER_ONLY
- if (PED_LE64_TO_CPU (primary_gpt->AlternateLBA) < disk->dev->length - 1)
+ PedSector gpt_disk_end = PED_LE64_TO_CPU (primary_gpt->LastUsableLBA) + 1;
+ gpt_disk_end += ((PedSector) (PED_LE32_TO_CPU (primary_gpt->NumberOfPartitionEntries)) *
+ (PedSector) (PED_LE32_TO_CPU (primary_gpt->SizeOfPartitionEntry)) /
+ disk->dev->sector_size);
+
+ gpt_disk_data->AlternateLBA = PED_LE64_TO_CPU (primary_gpt->AlternateLBA);
+ if (PED_LE64_TO_CPU (primary_gpt->AlternateLBA) != gpt_disk_end)
{
- switch (ped_exception_throw
+ if (ped_exception_throw
(PED_EXCEPTION_ERROR,
- (PED_EXCEPTION_FIX | PED_EXCEPTION_CANCEL
- | PED_EXCEPTION_IGNORE),
+ (PED_EXCEPTION_FIX | PED_EXCEPTION_IGNORE),
_("The backup GPT table is not at the end of the disk, as it "
- "should be. This might mean that another operating system "
- "believes the disk is smaller. Fix, by moving the backup "
- "to the end (and removing the old backup)?")))
+ "should be. Fix, by moving the backup to the end "
+ "(and removing the old backup)?")) == PED_EXCEPTION_FIX)
{
- case PED_EXCEPTION_CANCEL:
- goto error_free_gpt;
- case PED_EXCEPTION_FIX:
ptt_clear_sectors (disk->dev,
PED_LE64_TO_CPU (primary_gpt->AlternateLBA), 1);
+ gpt_disk_data->AlternateLBA = gpt_disk_end;
write_back = 1;
- break;
- default:
- break;
}
}
#endif /* !DISCOVER_ONLY */
- gpt = primary_gpt;
pth_free (backup_gpt);
+ gpt = primary_gpt;
}
else if (!primary_gpt && !backup_gpt)
{
@@ -1149,15 +1155,15 @@ _generate_header (const PedDisk *disk, int alternate, uint32_t ptes_crc,
* sizeof (GuidPartitionEntry_t));
PedSector ptes_sectors = (ptes_bytes + ss - 1) / ss;
- gpt->MyLBA = PED_CPU_TO_LE64 (disk->dev->length - 1);
+ gpt->MyLBA = PED_CPU_TO_LE64 (gpt_disk_data->AlternateLBA);
gpt->AlternateLBA = PED_CPU_TO_LE64 (1);
gpt->PartitionEntryLBA
- = PED_CPU_TO_LE64 (disk->dev->length - 1 - ptes_sectors);
+ = PED_CPU_TO_LE64 (gpt_disk_data->AlternateLBA - ptes_sectors);
}
else
{
gpt->MyLBA = PED_CPU_TO_LE64 (1);
- gpt->AlternateLBA = PED_CPU_TO_LE64 (disk->dev->length - 1);
+ gpt->AlternateLBA = PED_CPU_TO_LE64 (gpt_disk_data->AlternateLBA);
gpt->PartitionEntryLBA = PED_CPU_TO_LE64 (2);
}
@@ -1262,12 +1268,12 @@ gpt_write (const PedDisk *disk)
pth_free (gpt);
if (pth_raw == NULL)
goto error_free_ptes;
- write_ok = ped_device_write (disk->dev, pth_raw, disk->dev->length - 1, 1);
+ write_ok = ped_device_write (disk->dev, pth_raw, gpt_disk_data->AlternateLBA, 1);
free (pth_raw);
if (!write_ok)
goto error_free_ptes;
if (!ped_device_write (disk->dev, ptes,
- disk->dev->length - 1 - ptes_sectors, ptes_sectors))
+ gpt_disk_data->AlternateLBA - ptes_sectors, ptes_sectors))
goto error_free_ptes;
free (ptes);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4ec08da..eaf44a5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -28,6 +28,8 @@ TESTS = \
t0220-gpt-msftres.sh \
t0250-gpt.sh \
t0280-gpt-corrupt.sh \
+ t0281-gpt-grow.sh \
+ t0282-gpt-move-backup.sh \
t0300-dos-on-gpt.sh \
t0301-overwrite-gpt-pmbr.sh \
t0350-mac-PT-increases-sector-size.sh \
diff --git a/tests/gpt-header-move.py b/tests/gpt-header-move.py
new file mode 100644
index 0000000..69d1479
--- /dev/null
+++ b/tests/gpt-header-move.py
@@ -0,0 +1,40 @@
+# open img file, subtract 33 from altlba address, and move the last 33 sectors
+# back by 33 sectors
+
+from struct import *
+from zipfile import crc32
+import array
+import sys
+file = open(sys.argv[1],'rb+')
+file.seek(512)
+gptheader = file.read(512)
+altlba = unpack_from('q', gptheader,offset=32)[0]
+gptheader = array.array('c',gptheader)
+pack_into('Q', gptheader, 32, altlba-33)
+#zero header crc
+pack_into('L', gptheader, 16, 0)
+#compute new crc
+newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
+pack_into('L', gptheader, 16, newcrc)
+file.seek(512)
+file.write(gptheader)
+file.seek(512*altlba)
+gptheader = file.read(512)
+file.seek(512*(altlba-32))
+backup = file.read(512*32)
+altlba -= 33
+gptheader = array.array('c',gptheader)
+#update mylba
+pack_into('Q', gptheader, 24, altlba)
+#update table lba
+pack_into('Q', gptheader, 72, altlba-32)
+#zero header crc
+pack_into('L', gptheader, 16, 0)
+#compute new crc
+newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
+pack_into('L', gptheader, 16, newcrc)
+file.seek(512*(altlba-32))
+file.write(backup)
+file.write(gptheader)
+file.write("\0" * (512 * 33))
+
diff --git a/tests/t0281-gpt-grow.sh b/tests/t0281-gpt-grow.sh
new file mode 100644
index 0000000..e373578
--- /dev/null
+++ b/tests/t0281-gpt-grow.sh
@@ -0,0 +1,99 @@
+#!/bin/sh
+# grow a gpt disk, ensure that parted offers to update the gpt size
+
+# Copyright (C) 2009-2012 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/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+require_512_byte_sector_size_
+dev=loop-file
+
+ss=$sector_size_
+n_sectors=5000
+
+dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
+
+# create gpt label
+parted -s $dev mklabel gpt > empty 2>&1 || fail=1
+compare /dev/null empty || fail=1
+
+# print the empty table
+parted -m -s $dev unit s print > t 2>&1 || fail=1
+sed "s,.*/$dev:,$dev:," t > out || fail=1
+
+# check for expected output
+printf "BYT;\n$dev:${n_sectors}s:file:$sector_size_:$sector_size_:gpt::;\n" \
+ > exp || fail=1
+compare exp out || fail=1
+
+# grow disk
+n_sectors=5500
+dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
+
+# printing must warn, but not fix in script mode
+parted -s $dev print > out 2>&1 || fail=1
+
+# Transform the actual output, to avoid spurious differences when
+# $PWD contains a symlink-to-dir. Also, remove the ^M ...^M bogosity.
+# normalize the actual output
+mv out o2 && sed -e "s,/.*/$dev,DEVICE,;s, * ,,g;s, $,," \
+ -e "s,^.*/lt-parted: ,parted: ," o2 > out
+
+# check for expected diagnostic
+cat <<EOF > exp || fail=1
+Warning: Not all of the space available to DEVICE appears to be used, you can fix the GPT to use all of the space (an extra 500 blocks) or continue with the current setting?
+Model: (file)
+Disk DEVICE: 2816kB
+Sector size (logical/physical): 512B/512B
+Partition Table: gpt
+Disk Flags:
+
+Number Start End Size File system Name Flags
+
+EOF
+compare exp out || fail=1
+
+# now we fix
+printf 'f\n' | parted ---pretend-input-tty $dev print > out 2>&1 || fail=1
+
+# Transform the actual output, to avoid spurious differences when
+# $PWD contains a symlink-to-dir. Also, remove the ^M ...^M bogosity.
+# normalize the actual output
+mv out o2 && sed -e "s,/.*/$dev,DEVICE,;s, * ,,g;s, $,," \
+ -e "s,^.*/lt-parted: ,parted: ," o2 > out
+
+# check for expected diagnostic
+cat <<EOF > exp || fail=1
+Warning: Not all of the space available to DEVICE appears to be used, you can fix the GPT to use all of the space (an extra 500 blocks) or continue with the current setting?
+Fix/Ignore? f
+Model: (file)
+Disk DEVICE: 2816kB
+Sector size (logical/physical): 512B/512B
+Partition Table: gpt
+Disk Flags:
+
+Number Start End Size File system Name Flags
+
+EOF
+compare exp out || fail=1
+
+
+# Now should not warn
+
+parted -s $dev print > err 2>&1 || fail=1
+grep Warning: err > k ; mv k err
+compare err /dev/null || fail=1
+
+Exit $fail
diff --git a/tests/t0282-gpt-move-backup.sh b/tests/t0282-gpt-move-backup.sh
new file mode 100644
index 0000000..9750ed7
--- /dev/null
+++ b/tests/t0282-gpt-move-backup.sh
@@ -0,0 +1,99 @@
+#!/bin/sh
+# put backup copy gpt in the wrong place, ensure that
+# parted offers to fix
+
+# Copyright (C) 2009-2012 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/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+require_512_byte_sector_size_
+dev=loop-file
+
+ss=$sector_size_
+n_sectors=5000
+
+dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
+
+# create gpt label
+parted -s $dev mklabel gpt > empty 2>&1 || fail=1
+compare /dev/null empty || fail=1
+
+# print the empty table
+parted -m -s $dev unit s print > t 2>&1 || fail=1
+sed "s,.*/$dev:,$dev:," t > out || fail=1
+
+# check for expected output
+printf "BYT;\n$dev:${n_sectors}s:file:$sector_size_:$sector_size_:gpt::;\n" \
+ > exp || fail=1
+compare exp out || fail=1
+
+# move the backup
+python ../gpt-header-move.py $dev || fail=1
+
+# printing must warn, but not fix in script mode
+parted -s $dev print > out 2>&1 || fail=1
+
+# Transform the actual output, to avoid spurious differences when
+# $PWD contains a symlink-to-dir. Also, remove the ^M ...^M bogosity.
+# normalize the actual output
+mv out o2 && sed -e "s,/.*/$dev,DEVICE,;s, * ,,g;s, $,," \
+ -e "s,^.*/lt-parted: ,parted: ," o2 > out
+
+# check for expected diagnostic
+cat <<EOF > exp || fail=1
+Error: The backup GPT table is not at the end of the disk, as it should be. Fix, by moving the backup to the end (and removing the old backup)?
+Model: (file)
+Disk DEVICE: 2560kB
+Sector size (logical/physical): 512B/512B
+Partition Table: gpt
+Disk Flags:
+
+Number Start End Size File system Name Flags
+
+EOF
+compare exp out || fail=1
+
+# now we fix
+printf 'f\n' | parted ---pretend-input-tty $dev print > out 2>&1 || fail=1
+
+# Transform the actual output, to avoid spurious differences when
+# $PWD contains a symlink-to-dir. Also, remove the ^M ...^M bogosity.
+# normalize the actual output
+mv out o2 && sed -e "s,/.*/$dev,DEVICE,;s, * ,,g;s, $,," \
+ -e "s,^.*/lt-parted: ,parted: ," o2 > out
+
+# check for expected diagnostic
+cat <<EOF > exp || fail=1
+Error: The backup GPT table is not at the end of the disk, as it should be. Fix, by moving the backup to the end (and removing the old backup)?
+Fix/Ignore? f
+Model: (file)
+Disk DEVICE: 2560kB
+Sector size (logical/physical): 512B/512B
+Partition Table: gpt
+Disk Flags:
+
+Number Start End Size File system Name Flags
+
+EOF
+compare exp out || fail=1
+
+
+# Now should not warn
+
+parted -s $dev print > err 2>&1 || fail=1
+grep Error: err > k ; mv k err
+compare err /dev/null || fail=1
+
+Exit $fail
--
1.9.3

View File

@ -1,387 +0,0 @@
From fa815ad05db248d78ef214ea79a78c22772a9ffe Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Sat, 5 Jan 2013 20:53:29 -0500
Subject: [PATCH 060/131] libparted: allow some common errors to be ignored
Partitions that overlap or extend beyond the end of the disk are common
errors that usually result in people having to use other tools to correct
because parted refuses to operate when it sees them. Change these errors
to allow you to ignore them and use parted to correct the problem.
---
NEWS | 6 ++
libparted/cs/geom.c | 8 +--
libparted/disk.c | 89 +++++++-----------------
tests/Makefile.am | 1 +
tests/t0283-overlap-partitions.sh | 143 ++++++++++++++++++++++++++++++++++++++
5 files changed, 176 insertions(+), 71 deletions(-)
create mode 100644 tests/t0283-overlap-partitions.sh
diff --git a/NEWS b/NEWS
index 3f73434..a05be02 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,12 @@ GNU parted NEWS -*- outline -*-
* Noteworthy changes in release ?.? (????-??-??) [?]
+** New Features
+
+ You can now choose to ignore errors about partitions that overlap,
+ or are longer than the disk. This allows you to use parted to
+ repair the problem.
+
** Bug Fixes
libparted: fix gpt end of disk handling. Previously if the backup
diff --git a/libparted/cs/geom.c b/libparted/cs/geom.c
index 65c10c5..b8726da 100644
--- a/libparted/cs/geom.c
+++ b/libparted/cs/geom.c
@@ -153,6 +153,7 @@ ped_geometry_set (PedGeometry* geom, PedSector start, PedSector length)
{
PED_ASSERT (geom != NULL);
PED_ASSERT (geom->dev != NULL);
+ PED_ASSERT (start >= 0);
if (length < 1) {
ped_exception_throw (
@@ -162,13 +163,6 @@ ped_geometry_set (PedGeometry* geom, PedSector start, PedSector length)
" (start sector=%jd length=%jd)"), start, length);
return 0;
}
- if (start < 0 || start + length - 1 >= geom->dev->length) {
- ped_exception_throw (
- PED_EXCEPTION_ERROR,
- PED_EXCEPTION_CANCEL,
- _("Can't have a partition outside the disk!"));
- return 0;
- }
geom->start = start;
geom->length = length;
diff --git a/libparted/disk.c b/libparted/disk.c
index d3cd5bb..ce71bfc 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -36,6 +36,7 @@
#include <parted/parted.h>
#include <parted/debug.h>
#include <stdbool.h>
+#include <limits.h>
#include "architecture.h"
#include "labels/pt-tools.h"
@@ -404,6 +405,7 @@ _ped_disk_alloc (const PedDevice* dev, const PedDiskType* disk_type)
disk->type = disk_type;
disk->update_mode = 1;
disk->part_list = NULL;
+ disk->needs_clobber = 0;
return disk;
error:
@@ -917,6 +919,8 @@ _partition_align (PedPartition* part, const PedConstraint* constraint)
PED_ASSERT (disk_type->ops->partition_align != NULL);
PED_ASSERT (part->disk->update_mode);
+ if (part->disk->needs_clobber)
+ return 1; /* do not attempt to align partitions while reading them */
return disk_type->ops->partition_align (part, constraint);
}
@@ -1771,7 +1775,7 @@ _partition_get_overlap_constraint (PedPartition* part, PedGeometry* geom)
walk = ext_part->part_list;
} else {
min_start = 0;
- max_end = part->disk->dev->length - 1;
+ max_end = LLONG_MAX - 1;
walk = part->disk->part_list;
}
@@ -1797,48 +1801,6 @@ _partition_get_overlap_constraint (PedPartition* part, PedGeometry* geom)
return ped_constraint_new_from_max (&free_space);
}
-/*
- * Returns \c 0 if the partition, \p part overlaps with any partitions on the
- * \p disk. The geometry of \p part is taken to be \p geom, NOT \p part->geom
- * (the idea here is to check if \p geom is valid, before changing \p part).
- *
- * This is useful for seeing if a resized partitions new geometry is going to
- * fit, without the existing geomtry getting in the way.
- *
- * Note: overlap with an extended partition is also allowed, provided that
- * \p geom lies completely inside the extended partition.
- */
-static int _GL_ATTRIBUTE_PURE
-_disk_check_part_overlaps (PedDisk* disk, PedPartition* part)
-{
- PedPartition* walk;
-
- PED_ASSERT (disk != NULL);
- PED_ASSERT (part != NULL);
-
- for (walk = ped_disk_next_partition (disk, NULL); walk;
- walk = ped_disk_next_partition (disk, walk)) {
- if (walk->type & PED_PARTITION_FREESPACE)
- continue;
- if (walk == part)
- continue;
- if (part->type & PED_PARTITION_EXTENDED
- && walk->type & PED_PARTITION_LOGICAL)
- continue;
-
- if (ped_geometry_test_overlap (&walk->geom, &part->geom)) {
- if (walk->type & PED_PARTITION_EXTENDED
- && part->type & PED_PARTITION_LOGICAL
- && ped_geometry_test_inside (&walk->geom,
- &part->geom))
- continue;
- return 0;
- }
- }
-
- return 1;
-}
-
static int
_partition_check_basic_sanity (PedDisk* disk, PedPartition* part)
{
@@ -1847,7 +1809,6 @@ _partition_check_basic_sanity (PedDisk* disk, PedPartition* part)
PED_ASSERT (part->disk == disk);
PED_ASSERT (part->geom.start >= 0);
- PED_ASSERT (part->geom.end < disk->dev->length);
PED_ASSERT (part->geom.start <= part->geom.end);
if (!ped_disk_type_check_feature (disk->type, PED_DISK_TYPE_EXTENDED)
@@ -1934,29 +1895,30 @@ _check_partition (PedDisk* disk, PedPartition* part)
if (part->type & PED_PARTITION_LOGICAL
&& !ped_geometry_test_inside (&ext_part->geom, &part->geom)) {
- ped_exception_throw (
+ if (ped_exception_throw (
PED_EXCEPTION_ERROR,
- PED_EXCEPTION_CANCEL,
+ PED_EXCEPTION_IGNORE_CANCEL,
_("Can't have a logical partition outside of the "
"extended partition on %s."),
- disk->dev->path);
- return 0;
- }
-
- if (!_disk_check_part_overlaps (disk, part)) {
- ped_exception_throw (
- PED_EXCEPTION_ERROR,
- PED_EXCEPTION_CANCEL,
- _("Can't have overlapping partitions."));
- return 0;
+ disk->dev->path) != PED_EXCEPTION_IGNORE)
+ return 0;
}
if (! (part->type & PED_PARTITION_LOGICAL)
&& ext_part && ext_part != part
&& ped_geometry_test_inside (&ext_part->geom, &part->geom)) {
- ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
+ if (ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_IGNORE_CANCEL,
_("Can't have a primary partition inside an extended "
- "partition."));
+ "partition.")) != PED_EXCEPTION_IGNORE)
+ return 0;
+ }
+
+ if (part->geom.end >= disk->dev->length) {
+ if (ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_IGNORE_CANCEL,
+ _("Can't have a partition outside the disk!"))
+ != PED_EXCEPTION_IGNORE )
return 0;
}
@@ -2003,16 +1965,15 @@ ped_disk_add_partition (PedDisk* disk, PedPartition* part,
constraint);
if (!constraints && constraint) {
- ped_exception_throw (
+ if (ped_exception_throw (
PED_EXCEPTION_ERROR,
- PED_EXCEPTION_CANCEL,
- _("Can't have overlapping partitions."));
+ PED_EXCEPTION_IGNORE_CANCEL,
+ _("Can't have overlapping partitions.")) != PED_EXCEPTION_IGNORE)
goto error;
- }
-
+ } else constraint = constraints;
if (!_partition_enumerate (part))
goto error;
- if (!_partition_align (part, constraints))
+ if (!_partition_align (part, constraint))
goto error;
}
/* FIXME: when _check_partition fails, we end up leaking PART
diff --git a/tests/Makefile.am b/tests/Makefile.am
index eaf44a5..16ec5d2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -30,6 +30,7 @@ TESTS = \
t0280-gpt-corrupt.sh \
t0281-gpt-grow.sh \
t0282-gpt-move-backup.sh \
+ t0283-overlap-partitions.sh \
t0300-dos-on-gpt.sh \
t0301-overwrite-gpt-pmbr.sh \
t0350-mac-PT-increases-sector-size.sh \
diff --git a/tests/t0283-overlap-partitions.sh b/tests/t0283-overlap-partitions.sh
new file mode 100644
index 0000000..2a53407
--- /dev/null
+++ b/tests/t0283-overlap-partitions.sh
@@ -0,0 +1,143 @@
+#!/bin/sh
+# ensure parted can ignore partitions that overlap or are
+# longer than the disk and remove them
+
+# Copyright (C) 2009-2012 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/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+require_512_byte_sector_size_
+dev=loop-file
+
+truncate -s 10m $dev || fail=1
+
+# write damaged label
+xxd -r - $dev <<EOF
+0000000: fab8 0010 8ed0 bc00 b0b8 0000 8ed8 8ec0 ................
+0000010: fbbe 007c bf00 06b9 0002 f3a4 ea21 0600 ...|.........!..
+0000020: 00be be07 3804 750b 83c6 1081 fefe 0775 ....8.u........u
+0000030: f3eb 16b4 02b0 01bb 007c b280 8a74 018b .........|...t..
+0000040: 4c02 cd13 ea00 7c00 00eb fe00 0000 0000 L.....|.........
+0000050: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000060: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000070: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000080: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000090: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00000a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00000b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00000c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00000d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00000e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00000f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000100: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000110: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000120: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000130: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000140: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000150: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000160: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000170: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000180: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+0000190: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00001a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00001b0: 0000 0000 0000 0000 72f5 0000 0000 0000 ........r.......
+00001c0: 0110 8303 204f 0008 0000 0020 0000 0000 .... O..... ....
+00001d0: 0050 8300 0a7a ff27 0000 0a15 0000 0000 .P...z.'........
+00001e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
+00001f0: 0000 0000 0000 0000 0000 0000 0000 55aa ..............U.
+EOF
+
+# print the empty table
+parted ---pretend-input-tty $dev <<EOF > out 2>&1 || fail=1
+print
+ignore
+rm
+ignore
+2
+EOF
+
+# $PWD contains a symlink-to-dir. Also, remove the ^M ...^M bogosity.
+# normalize the actual output
+mv out o2 && sed -e "s,/.*/$dev,DEVICE,;s, * ,,g;s, $,," \
+ -e "s,^.*/lt-parted: ,parted: ," -e "s/^GNU Parted .*$/GNU Parted VERSION/" o2 > out
+
+# check for expected output
+cat <<EOF > exp || fail=1
+GNU Parted VERSION
+Using DEVICE
+Welcome to GNU Parted! Type 'help' to view a list of commands.
+(parted) print
+Error: Can't have overlapping partitions.
+Ignore/Cancel? ignore
+Model: (file)
+Disk DEVICE: 10.5MB
+Sector size (logical/physical): 512B/512B
+Partition Table: msdos
+Disk Flags:
+
+Number Start End Size Type File system Flags
+ 1 1049kB 5243kB 4194kB primary
+ 2 5242kB 8000kB 2758kB primary
+
+(parted) rm
+Error: Can't have overlapping partitions.
+Ignore/Cancel? ignore
+Partition number? 2
+(parted)
+EOF
+compare exp out || fail=1
+
+truncate -s 3m $dev || fail=1
+
+# print the table, verify error, ignore it, and remove the partition
+parted ---pretend-input-tty $dev <<EOF > out 2>&1 || fail=1
+print
+ignore
+rm
+ignore
+1
+EOF
+
+# $PWD contains a symlink-to-dir. Also, remove the ^M ...^M bogosity.
+# normalize the actual output
+mv out o2 && sed -e "s,/.*/$dev,DEVICE,;s, * ,,g;s, $,," \
+ -e "s,^.*/lt-parted: ,parted: ," -e "s/^GNU Parted .*$/GNU Parted VERSION/" o2 > out
+
+# check for expected output
+cat <<EOF > exp || fail=1
+GNU Parted VERSION
+Using DEVICE
+Welcome to GNU Parted! Type 'help' to view a list of commands.
+(parted) print
+Error: Can't have a partition outside the disk!
+Ignore/Cancel? ignore
+Model: (file)
+Disk DEVICE: 3146kB
+Sector size (logical/physical): 512B/512B
+Partition Table: msdos
+Disk Flags:
+
+Number Start End Size Type File system Flags
+ 1 1049kB 5243kB 4194kB primary
+
+(parted) rm
+Error: Can't have a partition outside the disk!
+Ignore/Cancel? ignore
+Partition number? 1
+(parted)
+EOF
+compare exp out || fail=1
+
+Exit $fail
--
1.9.3

View File

@ -1,93 +0,0 @@
From fb99ba5ebd0dc34204fc9f1014131d5d494805bc Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Sat, 5 Jan 2013 22:59:35 -0500
Subject: [PATCH 061/131] Revert "linux-commit: do not unnecessarily open
partition device nodes"
This reverts commit 2a6936fab4d4499a4b812dd330d3db50549029e0. The commit
disabled flushing the block buffer caches on the partition nodes to ensure
cache consistency on 2.6 kernels, supposedly because this was no longer
required. It appears this was incorrect, and the caches DO still need
flushed, otherwise a new fs written to the partition device does not show
up in the disk device cache, causing parted to still identify the old fs.
---
NEWS | 5 +++++
libparted/arch/linux.c | 25 +++----------------------
2 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/NEWS b/NEWS
index a05be02..6538c96 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,11 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ Fix cache coherency issue by flushing partition block devices.
+ This had been mistakenly disabled in parted 2.0, and resulted
+ in parted sometimes identifying the previous filesystem type
+ after running an mkfs to format a partition to a new type.
+
libparted: fix gpt end of disk handling. Previously if the backup
copy of the gpt was not at the end of the disk and you chose to
ignore this error, parted would move it to the end of the disk
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 05794d9..4b1b438 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -703,19 +703,6 @@ _get_linux_version ()
return kver = KERNEL_VERSION (major, minor, teeny);
}
-static int
-_have_kern26 ()
-{
- static int have_kern26 = -1;
- int kver;
-
- if (have_kern26 != -1)
- return have_kern26;
-
- kver = _get_linux_version();
- return have_kern26 = kver >= KERNEL_VERSION (2,6,0) ? 1 : 0;
-}
-
#if USE_BLKID
static void
get_blkid_topology (LinuxSpecific *arch_specific)
@@ -1567,8 +1554,8 @@ linux_is_busy (PedDevice* dev)
return 0;
}
-/* we need to flush the master device, and with kernel < 2.6 all the partition
- * devices, because there is no coherency between the caches with old kernels.
+/* we need to flush the master device, and all the partition devices,
+ * because there is no coherency between the caches.
* We should only flush unmounted partition devices, because:
* - there is never a need to flush them (we're not doing IO there)
* - flushing a device that is mounted causes unnecessary IO, and can
@@ -1586,10 +1573,6 @@ _flush_cache (PedDevice* dev)
ioctl (arch_specific->fd, BLKFLSBUF);
- /* With linux-2.6.0 and newer, we're done. */
- if (_have_kern26())
- return;
-
for (i = 1; i < 16; i++) {
char* name;
int fd;
@@ -1654,9 +1637,7 @@ retry:
dev->read_only = 0;
}
- /* With kernels < 2.6 flush cache for cache coherence issues */
- if (!_have_kern26())
- _flush_cache (dev);
+ _flush_cache (dev);
return 1;
}
--
1.9.3

View File

@ -1,141 +0,0 @@
From 5910f1bc983fbab31f9ec86a7166feee4869c21a Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Sun, 29 Sep 2013 12:38:29 -0400
Subject: [PATCH 062/131] libparted: avoid disturbing partitions
The partition sync logic was first removing all
partitions, then trying to re-add them. This resulted in many
udev events triggering annoying behavior like auto mounting.
Refactor the code to avoid removing and re-adding unmodified
partitions.
---
NEWS | 3 ++
libparted/arch/linux.c | 84 ++++++++++++++++++++++++++++----------------------
2 files changed, 50 insertions(+), 37 deletions(-)
diff --git a/NEWS b/NEWS
index 6538c96..cb725e7 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,9 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ Avoid generating udev add/remove events for all unmodified partitions
+ when writing a new table.
+
Fix cache coherency issue by flushing partition block devices.
This had been mistakenly disabled in parted 2.0, and resulted
in parted sometimes identifying the previous filesystem type
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 4b1b438..f43eae1 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2670,6 +2670,11 @@ _dm_get_partition_start_and_length(PedPartition const *part,
return 0;
char *path = _device_get_part_path (part->disk->dev, part->num);
PED_ASSERT(path);
+ /* libdevmapper likes to complain on stderr instead of quietly
+ returning ENOENT or ENXIO, so try to stat first */
+ struct stat st;
+ if (stat(path, &st))
+ goto err;
dm_task_set_name(task, path);
if (!dm_task_run(task))
goto err;
@@ -2806,50 +2811,55 @@ _disk_sync_part_table (PedDisk* disk)
if (!errnums)
goto cleanup;
- /* Attempt to remove each and every partition, retrying for
- up to max_sleep_seconds upon any failure due to EBUSY. */
- unsigned int sleep_microseconds = 10000;
- unsigned int max_sleep_seconds = 1;
- unsigned int n_sleep = (max_sleep_seconds
- * 1000000 / sleep_microseconds);
int i;
- for (i = 0; i < n_sleep; i++) {
- if (i)
- usleep (sleep_microseconds);
- bool busy = false;
- int j;
- for (j = 0; j < lpn; j++) {
- if (!ok[j]) {
- ok[j] = remove_partition (disk, j + 1);
- errnums[j] = errno;
- if (!ok[j] && errnums[j] == EBUSY)
- busy = true;
+ /* remove old partitions first */
+ for (i = 1; i <= lpn; i++) {
+ PedPartition *part = ped_disk_get_partition (disk, i);
+ if (part) {
+ unsigned long long length;
+ unsigned long long start;
+ /* get start and length of existing partition */
+ if (get_partition_start_and_length(part,
+ &start, &length)
+ && start == part->geom.start
+ && length == part->geom.length)
+ {
+ ok[i - 1] = 1;
+ continue;
+ }
}
- }
- if (!busy)
- break;
- }
-
+ }
for (i = 1; i <= lpn; i++) {
PedPartition *part = ped_disk_get_partition (disk, i);
if (part) {
- if (!ok[i - 1] && errnums[i - 1] == EBUSY) {
- unsigned long long length;
- unsigned long long start;
- /* get start and length of existing partition */
- if (!get_partition_start_and_length(part,
- &start, &length))
- goto cleanup;
- if (start == part->geom.start
- && length == part->geom.length)
- ok[i - 1] = 1;
- /* If the new partition is unchanged and the
- existing one was not removed because it was
- in use, then reset the error flag and do not
- try to add it since it is already there. */
+ unsigned long long length;
+ unsigned long long start;
+ /* get start and length of existing partition */
+ if (get_partition_start_and_length(part,
+ &start, &length)
+ && start == part->geom.start
+ && length == part->geom.length) {
+ ok[i - 1] = 1;
+ /* partition is unchanged, so nothing to do */
continue;
}
-
+ }
+ /* Attempt to remove the partition, retrying for
+ up to max_sleep_seconds upon any failure due to EBUSY. */
+ unsigned int sleep_microseconds = 10000;
+ unsigned int max_sleep_seconds = 1;
+ unsigned int n_sleep = (max_sleep_seconds
+ * 1000000 / sleep_microseconds);
+ do {
+ ok[i - 1] = remove_partition (disk, i);
+ errnums[i - 1] = errno;
+ if (ok[i - 1] || errnums[i - 1] != EBUSY)
+ break;
+ usleep (sleep_microseconds);
+ } while (n_sleep--);
+ if (!ok[i - 1] && errnums[i - 1] == ENXIO)
+ ok[i - 1] = 1; /* it already doesn't exist */
+ if (part && ok[i - 1]) {
/* add the (possibly modified or new) partition */
if (!add_partition (disk, part)) {
ok[i - 1] = 0;
--
1.9.3

View File

@ -1,28 +0,0 @@
From 02fc13fb6611b68d7d3275777f5674192b2f2bb5 Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Sun, 17 Nov 2013 22:45:39 -0500
Subject: [PATCH 063/131] Fix test compilation
The tests were not being linked against libpthread but were using
it, and recent versions of gcc refuse to implicitly pull it in.
---
libparted/tests/Makefile.am | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libparted/tests/Makefile.am b/libparted/tests/Makefile.am
index bfa5790..12abe60 100644
--- a/libparted/tests/Makefile.am
+++ b/libparted/tests/Makefile.am
@@ -10,7 +10,8 @@ AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
LDADD = \
$(top_builddir)/libparted/libparted.la \
- $(CHECK_LIBS)
+ $(CHECK_LIBS) \
+ -lpthread
AM_CPPFLAGS = \
$(CHECK_CFLAGS) \
--
1.9.3

View File

@ -1,210 +0,0 @@
From d151cc20af79c89383ffacc89c1f646f831fc3e6 Mon Sep 17 00:00:00 2001
From: Daniel Battaiola Kreling <dbkreling@br.ibm.com>
Date: Mon, 7 Oct 2013 11:51:50 +0530
Subject: [PATCH 064/131] GPT: add support for PReP GUID
PReP (PowerPC Reference Platform) boot partition is the first partition used in
PowerPC platform for containing the bootable kernel or bootloader. The firmware
searches for this partition and jumps to it for booting. So far no GUID was
specified for this partition type and hence booting from GPT disk was not
supported on this platform. A new GUID 9e1a2d38-c612-4316-aa26-8b49521e5a8b for
PReP partition is proposed to be included in GPT.
---
NEWS | 3 +++
doc/parted.texi | 2 +-
libparted/labels/gpt.c | 38 ++++++++++++++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index cb725e7..22e6109 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,9 @@ GNU parted NEWS -*- outline -*-
or are longer than the disk. This allows you to use parted to
repair the problem.
+ Add support for prep flag to GPT to select PowerPC Reference Platform
+ boot partition type.
+
** Bug Fixes
Avoid generating udev add/remove events for all unmodified partitions
diff --git a/doc/parted.texi b/doc/parted.texi
index 008c383..25a02c7 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -865,7 +865,7 @@ physical volume.
by the Linux/PA-RISC boot loader, palo.
@item PREP
-(MS-DOS) - this flag can be enabled so that the partition can be used
+(MS-DOS, GPT) - this flag can be enabled so that the partition can be used
as a PReP boot partition on PowerPC PReP or IBM RS6K/CHRP hardware.
@item DIAG
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index bcf7812..66c96e6 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -146,6 +146,10 @@ typedef struct
((efi_guid_t) { PED_CPU_TO_LE32 (0x5265636F), PED_CPU_TO_LE16 (0x7665), \
PED_CPU_TO_LE16 (0x11AA), 0xaa, 0x11, \
{ 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC }})
+#define PARTITION_PREP_GUID \
+ ((efi_guid_t) { PED_CPU_TO_LE32 (0x9e1a2d38), PED_CPU_TO_LE16 (0xc612), \
+ PED_CPU_TO_LE16 (0x4316), 0xaa, 0x26, \
+ { 0x8b, 0x49, 0x52, 0x1e, 0x5a, 0x8b }})
struct __attribute__ ((packed)) _GuidPartitionTableHeader_t
{
@@ -289,6 +293,7 @@ typedef struct _GPTPartitionData
int atvrecv;
int msftrecv;
int legacy_boot;
+ int prep;
} GPTPartitionData;
static PedDiskType gpt_disk_type;
@@ -803,6 +808,7 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
= gpt_part_data->msftdata
= gpt_part_data->msftrecv
= gpt_part_data->legacy_boot
+ = gpt_part_data->prep
= gpt_part_data->bios_grub = gpt_part_data->atvrecv = 0;
if (pte->Attributes.RequiredToFunction & 0x1)
@@ -828,6 +834,8 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
gpt_part_data->msftrecv = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_APPLE_TV_RECOVERY_GUID))
gpt_part_data->atvrecv = 1;
+ else if (!guid_cmp (gpt_part_data->type, PARTITION_PREP_GUID))
+ gpt_part_data->prep = 1;
return part;
}
@@ -1344,6 +1352,7 @@ gpt_partition_new (const PedDisk *disk,
gpt_part_data->msftrecv = 0;
gpt_part_data->atvrecv = 0;
gpt_part_data->legacy_boot = 0;
+ gpt_part_data->prep = 0;
uuid_generate ((unsigned char *) &gpt_part_data->uuid);
swap_uuid_and_efi_guid ((unsigned char *) (&gpt_part_data->uuid));
memset (gpt_part_data->name, 0, sizeof gpt_part_data->name);
@@ -1417,6 +1426,11 @@ gpt_partition_set_system (PedPartition *part,
gpt_part_data->type = PARTITION_RAID_GUID;
return 1;
}
+ if (gpt_part_data->prep)
+ {
+ gpt_part_data->type = PARTITION_PREP_GUID;
+ return 1;
+ }
if (gpt_part_data->boot)
{
gpt_part_data->type = PARTITION_SYSTEM_GUID;
@@ -1593,6 +1607,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftres
= gpt_part_data->msftdata
= gpt_part_data->msftrecv
+ = gpt_part_data->prep
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_BIOS_GRUB:
@@ -1605,6 +1620,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftres
= gpt_part_data->msftdata
= gpt_part_data->msftrecv
+ = gpt_part_data->prep
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_RAID:
@@ -1617,6 +1633,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftres
= gpt_part_data->msftdata
= gpt_part_data->msftrecv
+ = gpt_part_data->prep
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_LVM:
@@ -1629,6 +1646,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftres
= gpt_part_data->msftdata
= gpt_part_data->msftrecv
+ = gpt_part_data->prep
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_HPSERVICE:
@@ -1641,6 +1659,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftres
= gpt_part_data->msftdata
= gpt_part_data->msftrecv
+ = gpt_part_data->prep
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_MSFT_RESERVED:
@@ -1653,6 +1672,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->hp_service
= gpt_part_data->msftdata
= gpt_part_data->msftrecv
+ = gpt_part_data->prep
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_MSFT_DATA:
@@ -1665,6 +1685,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->hp_service
= gpt_part_data->msftres
= gpt_part_data->msftrecv
+ = gpt_part_data->prep
= gpt_part_data->atvrecv = 0;
gpt_part_data->msftdata = 1;
} else {
@@ -1681,6 +1702,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->hp_service
= gpt_part_data->msftdata
= gpt_part_data->msftres
+ = gpt_part_data->prep
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_APPLE_TV_RECOVERY:
@@ -1693,8 +1715,21 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->hp_service
= gpt_part_data->msftres
= gpt_part_data->msftdata
+ = gpt_part_data->prep
= gpt_part_data->msftrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
+ case PED_PARTITION_PREP:
+ gpt_part_data->prep = state;
+ if (state)
+ gpt_part_data->boot
+ = gpt_part_data->raid
+ = gpt_part_data->lvm
+ = gpt_part_data->bios_grub
+ = gpt_part_data->hp_service
+ = gpt_part_data->msftres
+ = gpt_part_data->msftrecv
+ = gpt_part_data->atvrecv = 0;
+ return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_HIDDEN:
gpt_part_data->hidden = state;
return 1;
@@ -1741,6 +1776,8 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag)
return gpt_part_data->hidden;
case PED_PARTITION_LEGACY_BOOT:
return gpt_part_data->legacy_boot;
+ case PED_PARTITION_PREP:
+ return gpt_part_data->prep;
case PED_PARTITION_SWAP:
case PED_PARTITION_LBA:
case PED_PARTITION_ROOT:
@@ -1767,6 +1804,7 @@ gpt_partition_is_flag_available (const PedPartition *part,
case PED_PARTITION_APPLE_TV_RECOVERY:
case PED_PARTITION_HIDDEN:
case PED_PARTITION_LEGACY_BOOT:
+ case PED_PARTITION_PREP:
return 1;
case PED_PARTITION_SWAP:
case PED_PARTITION_ROOT:
--
1.9.3

View File

@ -1,45 +0,0 @@
From 01900e056ec250836d15b5f5c3f59a8e1454b781 Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Mon, 4 Nov 2013 13:10:09 -0500
Subject: [PATCH 065/131] libparted: make sure not to treat percentages as
exact
If 1% of the drive size worked out ot be an even power of
two, it would trigger the exact placement. Add an exception
for the percent units.
---
NEWS | 4 ++++
libparted/unit.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 22e6109..9d0d931 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,10 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ If a drive was 100 times an even multiple of two, sizes specified as
+ a percentage would trigger the exact placement rule and refuse to round
+ to the nearest half percent.
+
Avoid generating udev add/remove events for all unmodified partitions
when writing a new table.
diff --git a/libparted/unit.c b/libparted/unit.c
index e545985..ff479f1 100644
--- a/libparted/unit.c
+++ b/libparted/unit.c
@@ -548,7 +548,7 @@ ped_unit_parse_custom (const char* str, const PedDevice* dev, PedUnit unit,
do not use 4MiB as the range. Rather, presume that they
are specifying precisely the starting or ending number,
and treat "4MiB" just as we would treat "4194304B". */
- if (is_power_of_2 (unit_size))
+ if (is_power_of_2 (unit_size) && unit != PED_UNIT_PERCENT)
radius = 0;
*sector = num * unit_size / dev->sector_size;
--
1.9.3

View File

@ -1,232 +0,0 @@
From cf16ea884fc72aa99b49f721fc186429cec9fa87 Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Sun, 22 Dec 2013 22:13:12 -0500
Subject: [PATCH 066/131] bug#15591: [PATCH] libparted: handle i18n gpt
partition names correctly
gpt.c was simply truncating the UTF-16 characters stored
in the partition name field to 8 bits. This corrupted non
ascii characters which later resulted in parted crashing in
strlist.c trying to convert the now invalid multi byte
characters to wchar.
gpt.c will now properly convert the UTF-16 to the current
locale encoding.
---
NEWS | 1 +
libparted/labels/gpt.c | 63 ++++++++++++++++++++++++++++++++++++++++------
tests/Makefile.am | 1 +
tests/t0251-gpt-unicode.sh | 38 ++++++++++++++++++++++++++++
4 files changed, 96 insertions(+), 7 deletions(-)
create mode 100755 tests/t0251-gpt-unicode.sh
diff --git a/NEWS b/NEWS
index 9d0d931..935fa33 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ GNU parted NEWS -*- outline -*-
boot partition type.
** Bug Fixes
+ Fix gpt to correctly handle non ASCII charcters in partition names
If a drive was 100 times an even multiple of two, sizes specified as
a percentage would trigger the exact placement rule and refuse to round
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 66c96e6..dce89b1 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -39,6 +39,8 @@
#include <uuid/uuid.h>
#include <stdbool.h>
#include <errno.h>
+#include <iconv.h>
+#include <langinfo.h>
#include "xalloc.h"
#include "verify.h"
@@ -196,7 +198,7 @@ struct __attribute__ ((packed)) _GuidPartitionEntry_t
uint64_t StartingLBA;
uint64_t EndingLBA;
GuidPartitionEntryAttributes_t Attributes;
- efi_char16_t PartitionName[72 / sizeof (efi_char16_t)];
+ efi_char16_t PartitionName[36];
};
#define GPT_PMBR_LBA 0
@@ -281,7 +283,8 @@ typedef struct _GPTPartitionData
{
efi_guid_t type;
efi_guid_t uuid;
- char name[37];
+ efi_char16_t name[37];
+ char *translated_name;
int lvm;
int raid;
int boot;
@@ -797,10 +800,11 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
gpt_part_data = part->disk_specific;
gpt_part_data->type = pte->PartitionTypeGuid;
gpt_part_data->uuid = pte->UniquePartitionGuid;
- for (i = 0; i < 72 / sizeof (efi_char16_t); i++)
+ for (i = 0; i < 36; i++)
gpt_part_data->name[i] =
(efi_char16_t) PED_LE16_TO_CPU ((uint16_t) pte->PartitionName[i]);
gpt_part_data->name[i] = 0;
+ gpt_part_data->translated_name = 0;
gpt_part_data->lvm = gpt_part_data->raid
= gpt_part_data->boot = gpt_part_data->hp_service
@@ -1210,7 +1214,7 @@ _partition_generate_part_entry (PedPartition *part, GuidPartitionEntry_t *pte)
if (gpt_part_data->legacy_boot)
pte->Attributes.LegacyBIOSBootable = 1;
- for (i = 0; i < 72 / sizeof (efi_char16_t); i++)
+ for (i = 0; i < 36; i++)
pte->PartitionName[i]
= (efi_char16_t) PED_CPU_TO_LE16 ((uint16_t) gpt_part_data->name[i]);
}
@@ -1353,6 +1357,7 @@ gpt_partition_new (const PedDisk *disk,
gpt_part_data->atvrecv = 0;
gpt_part_data->legacy_boot = 0;
gpt_part_data->prep = 0;
+ gpt_part_data->translated_name = 0;
uuid_generate ((unsigned char *) &gpt_part_data->uuid);
swap_uuid_and_efi_guid ((unsigned char *) (&gpt_part_data->uuid));
memset (gpt_part_data->name, 0, sizeof gpt_part_data->name);
@@ -1386,6 +1391,9 @@ gpt_partition_duplicate (const PedPartition *part)
goto error_free_part;
*result_data = *part_data;
+ if (part_data->translated_name)
+ result_data->translated_name = xstrdup (part_data->translated_name);
+ else part_data->translated_name = 0;
return result;
error_free_part:
@@ -1400,6 +1408,8 @@ gpt_partition_destroy (PedPartition *part)
if (part->type == 0)
{
PED_ASSERT (part->disk_specific != NULL);
+ GPTPartitionData *gpt_part_data = part->disk_specific;
+ free (gpt_part_data->translated_name);
free (part->disk_specific);
}
@@ -1820,15 +1830,54 @@ gpt_partition_set_name (PedPartition *part, const char *name)
{
GPTPartitionData *gpt_part_data = part->disk_specific;
- strncpy (gpt_part_data->name, name, 36);
- gpt_part_data->name[36] = 0;
+ free(gpt_part_data->translated_name);
+ gpt_part_data->translated_name = xstrdup(name);
+ iconv_t conv = iconv_open ("UTF-16", nl_langinfo (CODESET));
+ if (conv == (iconv_t)-1)
+ goto err;
+ char *inbuff = gpt_part_data->translated_name;
+ char *outbuff = (char *)&gpt_part_data->name;
+ size_t inbuffsize = strlen (inbuff) + 1;
+ size_t outbuffsize = 72;
+ if (iconv (conv, &inbuff, &inbuffsize, &outbuff, &outbuffsize) == -1)
+ goto err;
+ iconv_close (conv);
+ return;
+ err:
+ ped_exception_throw (PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_IGNORE,
+ _("Can not translate partition name"));
+ iconv_close (conv);
}
static const char *
gpt_partition_get_name (const PedPartition *part)
{
GPTPartitionData *gpt_part_data = part->disk_specific;
- return gpt_part_data->name;
+ if (gpt_part_data->translated_name == NULL)
+ {
+ char buffer[200];
+ iconv_t conv = iconv_open (nl_langinfo (CODESET), "UTF-16");
+ if (conv == (iconv_t)-1)
+ goto err;
+ char *inbuff = (char *)&gpt_part_data->name;
+ char *outbuff = buffer;
+ size_t inbuffsize = 72;
+ size_t outbuffsize = sizeof(buffer);
+ if (iconv (conv, &inbuff, &inbuffsize, &outbuff, &outbuffsize) == -1)
+ goto err;
+ iconv_close (conv);
+ *outbuff = 0;
+ gpt_part_data->translated_name = xstrdup (buffer);
+ return gpt_part_data->translated_name;
+ err:
+ ped_exception_throw (PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_IGNORE,
+ _("Can not translate partition name"));
+ iconv_close (conv);
+ return "";
+ }
+ return gpt_part_data->translated_name;
}
static int
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 16ec5d2..7a6fe8f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -27,6 +27,7 @@ TESTS = \
t0212-gpt-many-partitions.sh \
t0220-gpt-msftres.sh \
t0250-gpt.sh \
+ t0251-gpt-unicode.sh \
t0280-gpt-corrupt.sh \
t0281-gpt-grow.sh \
t0282-gpt-move-backup.sh \
diff --git a/tests/t0251-gpt-unicode.sh b/tests/t0251-gpt-unicode.sh
new file mode 100755
index 0000000..36a4c26
--- /dev/null
+++ b/tests/t0251-gpt-unicode.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Test unicode partition names
+# Copyright (C) 2013 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/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+
+dev=loop-file
+
+# create zeroed device
+truncate -s 10m $dev || fail=1
+
+export LC_ALL=en_US.UTF-8
+# create gpt label with named partition
+part_name=$(printf 'foo\341\264\244')
+parted -s $dev mklabel gpt mkpart primary ext2 1MiB 2MiB name 1 $part_name > empty 2>&1 || fail=1
+
+# ensure there was no output
+compare /dev/null empty || fail=1
+
+# check for expected output
+dd if=$dev bs=1 skip=$(($sector_size_+$sector_size_+58)) count=10 2>/dev/null | od -An -tx1 > out || fail=1
+echo ' 66 00 6f 00 6f 00 24 1d 00 00' >> exp
+compare exp out || fail=1
+
+Exit $fail
--
1.9.3

View File

@ -1,98 +0,0 @@
From 3e005b4644d2a97da85c251f93d32d93e94bcccf Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Mon, 24 Feb 2014 11:29:43 -0500
Subject: [PATCH 067/131] Fix help text for disk_{set,toggle}
Fix the help text to show *disk* flags instead of partition flags.
---
NEWS | 4 ++++
parted/parted.c | 23 +++++++++++++++++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 935fa33..40ce370 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,10 @@ GNU parted NEWS -*- outline -*-
boot partition type.
** Bug Fixes
+
+ Fix help text for disk_{set,toggle} to show *disk* flags instead
+ of partition flags.
+
Fix gpt to correctly handle non ASCII charcters in partition names
If a drive was 100 times an even multiple of two, sizes specified as
diff --git a/parted/parted.c b/parted/parted.c
index b20d432..a7d9363 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -144,6 +144,7 @@ static const char* number_msg = N_(
static const char* label_type_msg_start = N_("LABEL-TYPE is one of: ");
static const char* flag_msg_start = N_("FLAG is one of: ");
+static const char* disk_flag_msg_start = N_("FLAG is one of: ");
static const char* unit_msg_start = N_("UNIT is one of: ");
static const char* min_or_opt_msg = N_("desired alignment: minimum or optimal");
static const char* part_type_msg = N_("PART-TYPE is one of: primary, logical, "
@@ -167,6 +168,7 @@ static const char* copyright_msg = N_(
static char* label_type_msg;
static char* flag_msg;
+static char* disk_flag_msg;
static char* unit_msg;
static char* mkpart_fs_type_msg;
@@ -1710,6 +1712,7 @@ _init_messages ()
PedFileSystemAlias* fs_alias;
PedDiskType* disk_type;
PedPartitionFlag part_flag;
+ PedDiskFlag disk_flag;
PedUnit unit;
/* flags */
@@ -1728,6 +1731,22 @@ _init_messages ()
flag_msg = str_list_convert (list);
str_list_destroy (list);
+/* disk flags */
+ first = 1;
+ list = str_list_create (_(disk_flag_msg_start), NULL);
+ for (disk_flag = ped_disk_flag_next (0); disk_flag;
+ disk_flag = ped_disk_flag_next (disk_flag)) {
+ if (first)
+ first = 0;
+ else
+ str_list_append (list, ", ");
+ str_list_append (list,
+ _(ped_disk_flag_get_name (disk_flag)));
+ }
+ str_list_append (list, "\n");
+
+ disk_flag_msg = str_list_convert (list);
+ str_list_destroy (list);
/* units */
first = 1;
@@ -1912,7 +1931,7 @@ command_register (commands, command_create (
str_list_create (
_("disk_set FLAG STATE change the FLAG on selected device"),
NULL),
- str_list_create (flag_msg, _(state_msg), NULL), 1));
+ str_list_create (disk_flag_msg, _(state_msg), NULL), 1));
command_register (commands, command_create (
str_list_create_unique ("disk_toggle", _("disk_toggle"), NULL),
@@ -1921,7 +1940,7 @@ command_register (commands, command_create (
_("disk_toggle [FLAG] toggle the state of FLAG on "
"selected device"),
NULL),
- str_list_create (flag_msg, NULL), 1));
+ str_list_create (disk_flag_msg, NULL), 1));
command_register (commands, command_create (
str_list_create_unique ("set", _("set"), NULL),
--
1.9.3

View File

@ -1,25 +0,0 @@
From c261a9b340e2982a49e055ea6332fd0f49f3d531 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 11 Sep 2013 12:24:51 -0700
Subject: [PATCH 068/131] libparted: copy pmbr_boot when duplicating GPT disk
* libparted/labels/gpt.c (gpt_duplicate): copy pmbr_boot flag
---
libparted/labels/gpt.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index dce89b1..6fd8880 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -566,6 +566,7 @@ gpt_duplicate (const PedDisk *disk)
old_disk_data->data_area.length);
new_disk_data->entry_count = old_disk_data->entry_count;
new_disk_data->uuid = old_disk_data->uuid;
+ new_disk_data->pmbr_boot = old_disk_data->pmbr_boot;
return new_disk;
}
--
1.9.3

View File

@ -1,95 +0,0 @@
From d19d16357aff6bff634ad134597c0626c21496ac Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 11 Sep 2013 12:24:52 -0700
Subject: [PATCH 069/131] tests: test creating 20 device-mapper partitions
(#803108)
* tests/t6004-dm-many-partitions.sh: Make sure > 17 partitions appear in
device mapper.
---
tests/Makefile.am | 1 +
tests/t6004-dm-many-partitions.sh | 60 +++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+)
create mode 100755 tests/t6004-dm-many-partitions.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7a6fe8f..13fdde5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -64,6 +64,7 @@ TESTS = \
t6001-psep.sh \
t6002-dm-busy.sh \
t6003-dm-hide.sh \
+ t6004-dm-many-partitions.sh \
t6100-mdraid-partitions.sh \
t7000-scripting.sh \
t8000-loop.sh \
diff --git a/tests/t6004-dm-many-partitions.sh b/tests/t6004-dm-many-partitions.sh
new file mode 100755
index 0000000..4d08e72
--- /dev/null
+++ b/tests/t6004-dm-many-partitions.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+# device-mapper: create many partitions
+# This would not create partitions > 16 when using device-mapper
+
+# Copyright (C) 2012 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/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+
+require_root_
+(dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed"
+
+ss=$sector_size_
+ns=300
+n_partitions=20
+start_sector=34
+loop_file=loop-file-$$
+dm_name=dm-test-$$
+
+cleanup_() {
+ dmsetup remove $dm_name
+ test -n "$dev" && losetup -d "$dev"
+ rm -f $loop_file;
+}
+
+# create a file large enough to hold a GPT partition table
+dd if=/dev/null of=$loop_file bs=$ss seek=$ns || framework_failure
+dev=$(losetup --show -f $loop_file) || framework_failure
+dmsetup create $dm_name --table "0 $ns linear $dev 0" || framework_failure
+
+cmd=
+for ((i=1; i<=$n_partitions; i+=1)); do
+ s=$((start_sector + i - 1))
+ cmd="$cmd mkpart p$i ${s}s ${s}s"
+done
+parted -m -a min -s /dev/mapper/$dm_name mklabel gpt $cmd > /dev/null 2>&1 || fail=1
+
+# Make sure all the partitions appeared under /dev/mapper/
+for ((i=1; i<=$n_partitions; i+=1)); do
+ if [ ! -e "/dev/mapper/${dm_name}p$i" ]; then
+ fail=1
+ break
+ fi
+ # remove the partitions as we go, otherwise cleanup won't work.
+ dmsetup remove /dev/mapper/${dm_name}p$i
+done
+
+Exit $fail
--
1.9.3

View File

@ -1,140 +0,0 @@
From 60fe959e1446337c3455656daad2c2b7114a1dcd Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 11 Sep 2013 12:24:53 -0700
Subject: [PATCH 070/131] libparted: use dm_udev_wait (#698121)
This is based on Peter Rajnoha's patch to use dm_udev_wait to
synchronize with udev.
This requires libdevmapper v1.02.39 and higher.
mailing list thread:
https://lists.gnu.org/archive/html/bug-parted/2010-09/msg00007.html
* libparted/arch/linux.c (_dm_task_run_wait): New function
(_is_dm_major): Add cookie and change call to _dm_task_run_wait
(_is_dmraid_device): Same
(_dm_is_part): Same
(dm_canonical_path): Same
(_dm_remove_partition): Same
(_dm_get_partition_start_and_length): Same
(_dm_add_partition): Same
(linux_new): Enable udev sync support
---
NEWS | 5 +++++
libparted/arch/linux.c | 42 +++++++++++++++++++++++++++++-------------
2 files changed, 34 insertions(+), 13 deletions(-)
diff --git a/NEWS b/NEWS
index 40ce370..9f51f85 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,11 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ libparted: On multipath systems new partitions would sometimes not
+ appear, reporting 'device-mapper: create ioctl failed: Device or
+ resource busy' until the system was rebooted. Added dm_udev_wait
+ calls to synchronize parted with udev.
+
Fix help text for disk_{set,toggle} to show *disk* flags instead
of partition flags.
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index f43eae1..452ea7f 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -438,6 +438,17 @@ _is_virtblk_major (int major)
#ifdef ENABLE_DEVICE_MAPPER
static int
+_dm_task_run_wait (struct dm_task *task, uint32_t cookie)
+{
+ int rc = 0;
+
+ rc = dm_task_run (task);
+ dm_udev_wait (cookie);
+
+ return rc;
+}
+
+static int
_is_dm_major (int major)
{
return _major_type_in_devices (major, "device-mapper");
@@ -1385,6 +1396,10 @@ linux_new (const char* path)
dev->dirty = 0;
dev->boot_dirty = 0;
+#ifdef ENABLE_DEVICE_MAPPER
+ dm_udev_set_sync_support(1);
+#endif
+
if (!_device_probe_type (dev))
goto error_free_arch_specific;
@@ -2631,31 +2646,29 @@ _device_get_partition_range(PedDevice const* dev)
static int
_dm_remove_partition(PedDisk* disk, int partno)
{
- int rc;
+ int rc = 0;
+ uint32_t cookie = 0;
char *part_name = _device_get_part_path (disk->dev, partno);
int fd = open (part_name, O_RDONLY | O_EXCL);
if (fd == -1) {
if (errno == ENOENT)
errno = ENXIO; /* nothing to remove, device already doesn't exist */
- free (part_name);
- return 0;
+ goto err;
}
close (fd);
struct dm_task *task = dm_task_create(DM_DEVICE_REMOVE);
- if (!task) {
- free (part_name);
- return 0;
- }
+ if (!task)
+ goto err;
dm_task_set_name (task, part_name);
- rc = dm_task_run(task);
+ if (!dm_task_set_cookie (task, &cookie, 0))
+ goto err;
+ rc = _dm_task_run_wait (task, cookie);
dm_task_update_nodes();
dm_task_destroy(task);
+err:
free (part_name);
- if (!rc)
- return 0;
-
- return 1;
+ return rc;
}
static bool
@@ -2699,6 +2712,7 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
LinuxSpecific* arch_specific = LINUX_SPECIFIC (disk->dev);
char *params = NULL;
char *vol_name = NULL;
+ uint32_t cookie = 0;
/* Get map name from devicemapper */
struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
@@ -2735,7 +2749,9 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
dm_task_set_name (task, vol_name);
dm_task_add_target (task, 0, part->geom.length,
"linear", params);
- if (dm_task_run (task)) {
+ if (!dm_task_set_cookie (task, &cookie, 0))
+ goto err;
+ if (_dm_task_run_wait (task, cookie)) {
dm_task_update_nodes ();
dm_task_destroy (task);
free (params);
--
1.9.3

View File

@ -1,81 +0,0 @@
From 39e38c0a4c0f3ad0e029792e0ddee9761b956c1e Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 11 Sep 2013 12:24:54 -0700
Subject: [PATCH 071/131] libparted: preserve the uuid on dm partitions
(#832145)
* libparted/arch/linux.c (_dm_add_partition): Set the uuid if there was
one.
---
libparted/arch/linux.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 452ea7f..4376d17 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2710,9 +2710,12 @@ static int
_dm_add_partition (PedDisk* disk, const PedPartition* part)
{
LinuxSpecific* arch_specific = LINUX_SPECIFIC (disk->dev);
- char *params = NULL;
- char *vol_name = NULL;
- uint32_t cookie = 0;
+ char* params = NULL;
+ char* vol_name = NULL;
+ const char* dev_name = NULL;
+ char* vol_uuid = NULL;
+ const char* dev_uuid = NULL;
+ uint32_t cookie = 0;
/* Get map name from devicemapper */
struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
@@ -2726,7 +2729,7 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
if (!dm_task_run(task))
goto err;
- const char *dev_name = dm_task_get_name (task);
+ dev_name = dm_task_get_name (task);
size_t name_len = strlen (dev_name);
vol_name = zasprintf ("%s%s%d",
dev_name,
@@ -2735,6 +2738,11 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
if (vol_name == NULL)
goto err;
+ dev_uuid = dm_task_get_uuid (task);
+ if (dev_uuid && (strlen(dev_uuid) > 0)
+ && !(vol_uuid = zasprintf ("part%d-%s", part->num, dev_uuid)))
+ goto err;
+
/* Caution: dm_task_destroy frees dev_name. */
dm_task_destroy (task);
task = NULL;
@@ -2747,6 +2755,8 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
goto err;
dm_task_set_name (task, vol_name);
+ if (vol_uuid)
+ dm_task_set_uuid (task, vol_uuid);
dm_task_add_target (task, 0, part->geom.length,
"linear", params);
if (!dm_task_set_cookie (task, &cookie, 0))
@@ -2755,6 +2765,7 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
dm_task_update_nodes ();
dm_task_destroy (task);
free (params);
+ free (vol_uuid);
free (vol_name);
return 1;
} else {
@@ -2765,6 +2776,7 @@ err:
if (task)
dm_task_destroy (task);
free (params);
+ free (vol_uuid);
free (vol_name);
return 0;
}
--
1.9.3

View File

@ -1,91 +0,0 @@
From a963cd53ab1f14ef7f9a9b84a2536103ad690479 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 11 Sep 2013 12:24:55 -0700
Subject: [PATCH 072/131] tests: Make sure dm UUIDs are not erased
* tests/t6005-dm-uuid.sh: Make sure dm UUIDs are not erased
---
tests/Makefile.am | 1 +
tests/t6005-dm-uuid.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
create mode 100755 tests/t6005-dm-uuid.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 13fdde5..9100a81 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -65,6 +65,7 @@ TESTS = \
t6002-dm-busy.sh \
t6003-dm-hide.sh \
t6004-dm-many-partitions.sh \
+ t6005-dm-uuid.sh \
t6100-mdraid-partitions.sh \
t7000-scripting.sh \
t8000-loop.sh \
diff --git a/tests/t6005-dm-uuid.sh b/tests/t6005-dm-uuid.sh
new file mode 100755
index 0000000..f58cb06
--- /dev/null
+++ b/tests/t6005-dm-uuid.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+# device-mapper: preserve uuid
+# The dm's partitions uuid would be removed when creating new partitions
+
+# Copyright (C) 2012 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/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+
+require_root_
+(dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed"
+
+ss=$sector_size_
+ns=300
+n_partitions=3
+start_sector=34
+loop_file=loop-file-$$
+dm_name=dm-test-$$
+
+cleanup_() {
+ dmsetup remove $dm_name
+ test -n "$dev" && losetup -d "$dev"
+ rm -f $loop_file;
+}
+
+# create a file large enough to hold a GPT partition table
+dev=$(loop_setup_ $loop_file) || framework_failure
+dmsetup create $dm_name --table "0 $ns linear $dev 0" || framework_failure
+dmsetup rename $dm_name --setuuid f139317b-f98a-45d7-ab3b-9b4e0a336872 || framework_failure
+
+cmd=
+for ((i=1; i<=$n_partitions; i+=1)); do
+ s=$((start_sector + i - 1))
+ cmd="$cmd mkpart p$i ${s}s ${s}s"
+done
+parted -m -a min -s /dev/mapper/$dm_name mklabel gpt $cmd > /dev/null 2>&1 || fail=1
+
+# Make sure all the partitions have UUIDs
+for ((i=1; i<=$n_partitions; i+=1)); do
+ dmsetup info /dev/mapper/${dm_name}p$i | grep UUID || fail=1
+
+ # remove the partitions as we go, otherwise cleanup won't work.
+ dmsetup remove /dev/mapper/${dm_name}p$i
+done
+
+Exit $fail
--
1.9.3

View File

@ -1,54 +0,0 @@
From 7be35be5de01fa90f23810fb66efc3ccdbe5679a Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 11 Sep 2013 12:25:01 -0700
Subject: [PATCH 073/131] libparted: don't canonicalize /dev/md/ paths
(#872361)
This is the same issue we have with /dev/mapper/ paths that was fixed in
commit c1eb485b9fd8919e18f192d678bc52b0488e6ee0. When libparted
is used to setup the device the symlink should be used to reference it,
not the backing device name which could change.
* libparted/device.c (ped_device_get): Don't canonicalize names
that start with "/dev/md/".
---
NEWS | 4 ++++
libparted/device.c | 7 +++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 9f51f85..74b7697 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,10 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ libparted: /dev/md/ symlink can change after libparted dereferences it,
+ instead it should just use the symlink as given by the caller in the
+ same way we do with /dev/mapper/.
+
libparted: On multipath systems new partitions would sometimes not
appear, reporting 'device-mapper: create ioctl failed: Device or
resource busy' until the system was rebooted. Added dm_udev_wait
diff --git a/libparted/device.c b/libparted/device.c
index 738b320..cdcc117 100644
--- a/libparted/device.c
+++ b/libparted/device.c
@@ -152,8 +152,11 @@ ped_device_get (const char* path)
char* normal_path = NULL;
PED_ASSERT (path != NULL);
- /* Don't canonicalize /dev/mapper paths, see tests/symlink.c */
- if (strncmp (path, "/dev/mapper/", 12))
+ /* Don't canonicalize /dev/mapper or /dev/md/ paths, see
+ tests/symlink.c
+ */
+ if (strncmp (path, "/dev/mapper/", 12) &&
+ strncmp (path, "/dev/md/", 8))
normal_path = canonicalize_file_name (path);
if (!normal_path)
/* Well, maybe it is just that the file does not exist.
--
1.9.3

View File

@ -1,92 +0,0 @@
From 6a3194bf13d23c4e7fcc346f7188060d50f3cedc Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 11 Sep 2013 12:25:02 -0700
Subject: [PATCH 074/131] tests: rewrite t6001 to use /dev/mapper
This test began failing because using a private copy of /dev/mapper
confuses the system. This fixes that and generally cleans up the test.
tests/t6001.sh: update to use /dev/mapper directly
---
tests/t6001-psep.sh | 42 +++++++++++++++++-------------------------
1 file changed, 17 insertions(+), 25 deletions(-)
diff --git a/tests/t6001-psep.sh b/tests/t6001-psep.sh
index da6b8a1..809ff9e 100644
--- a/tests/t6001-psep.sh
+++ b/tests/t6001-psep.sh
@@ -19,10 +19,7 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
require_root_
-lvm_init_root_dir_
-
-test "x$ENABLE_DEVICE_MAPPER" = xyes \
- || skip_ "no device-mapper support"
+(dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed"
# Device maps names - should be random to not conflict with existing ones on
# the system
@@ -41,25 +38,19 @@ cleanup_fn_() {
rm -f "$f1 $f2";
}
-# create a file of size N bytes
-N=10M
-
-f1=$(pwd)/1; d1=$(loop_setup_ "$f1") \
- || skip_ "is this partition mounted with 'nodev'?"
+loop_file_1=loop-file-1-$$
+loop_file_2=loop-file-2-$$
-f2=$(pwd)/2 ;d2=$(loop_setup_ "$f2") \
- || skip_ "is this partition mounted with 'nodev'?"
+d1=$(loop_setup_ $loop_file_1) || framework_failure
+d1_size=$(blockdev --getsz $d1)
+d2=$(loop_setup_ $loop_file_2) || framework_failure
+d2_size=$(blockdev --getsz $d2)
-dmsetup_cmd="0 `blockdev --getsz $d1` linear $d1 0"
-# setup: create a mapping
-echo "$dmsetup_cmd" | dmsetup create "$linear_" || fail=1
-dev="$DM_DEV_DIR/mapper/$linear_"
+dmsetup create $linear_ --table "0 $d1_size linear $d1 0" || framework_failure
+dev="/dev/mapper/$linear_"
# Create msdos partition table
-parted -s $dev mklabel msdos > out 2>&1 || fail=1
-compare /dev/null out || fail=1
-
-parted -s $dev mkpart primary fat32 1m 5m > out 2>&1 || fail=1
+parted -s $dev mklabel msdos mkpart primary fat32 1m 5m > out 2>&1 || fail=1
compare /dev/null out || fail=1
#make sure device name is correct
@@ -67,17 +58,18 @@ test -e ${dev}p1 || fail=1
#repeat on name not ending in a digit
# setup: create a mapping
-echo "$dmsetup_cmd" | dmsetup create "$linear2_" || fail=1
-dev="$DM_DEV_DIR/mapper/$linear2_"
+dmsetup create $linear2_ --table "0 $d2_size linear $d2 0" || framework_failure
+dev="/dev/mapper/$linear2_"
# Create msdos partition table
-parted -s $dev mklabel msdos > out 2>&1 || fail=1
-compare /dev/null out || fail=1
-
-parted -s $dev mkpart primary fat32 1m 5m > out 2>&1 || fail=1
+parted -s $dev mklabel msdos mkpart primary fat32 1m 5m > out 2>&1 || fail=1
compare /dev/null out || fail=1
#make sure device name is correct
test -e ${dev}1 || fail=1
+if [ -n "$fail" ]; then
+ ls /dev/mapper
+fi
+
Exit $fail
--
1.9.3

View File

@ -1,384 +0,0 @@
From 4d0cd271069997e7d44ed3b52426ccf2570048c8 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 11 Sep 2013 12:25:03 -0700
Subject: [PATCH 075/131] libparted: Add Intel Rapid Start Technology partition
flag.
This adds support for the irst partition type flag. Sets the type to
0x84 on MS-DOS and D3BFE2DE-3DAF-11DF-BA-40-E3A556D89593 on GPT.
* NEWS (New Features): Mention it.
* doc/C/parted.8: Document irst flag.
* doc/parted.texti: Document irst flag.
* include/parted/disk.in.h (_PedPartitionFlag): Add PED_PARTITION_IRST flag
* libparted/disk.c (ped_partition_flag_get_name): Add irst flag
* libparted/labels/dos.c (DosPartitionData): Likewise
(raw_part_parse): Likewise
(msdos_partition_new): Likewise
(msdos_partition_duplicate): Likewise
(msdos_partition_set_system): Likewise
(clear_flags): Likewise
(msdos_partition_set_flag): Likewise
(msdos_partition_get_flag): Likewise
(msdos_partition_is_flag_available): Likewise
* libparted/labels/gpt.c: Add PARTITION_IRST_GUID
(GPTPartitionData): Add irst flag
(_parse_part_entry): Likewise
(gpt_partition_new): Likewise
(gpt_partition_set_system): Likewise
(gpt_partition_set_flag): Likewise
(gpt_partition_get_flag): Likewise
(gpt_partition_is_flag_available): Likewise
---
NEWS | 4 ++++
doc/C/parted.8 | 2 +-
doc/parted.texi | 4 ++++
include/parted/disk.in.h | 5 +++--
libparted/disk.c | 2 ++
libparted/labels/dos.c | 21 +++++++++++++++++++++
libparted/labels/gpt.c | 40 ++++++++++++++++++++++++++++++++++++++++
7 files changed, 75 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index 74b7697..27710b6 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,10 @@ GNU parted NEWS -*- outline -*-
** New Features
+ Added new partition type flag, irst, for use with Intel Rapid Start
+ Technology. On MS-DOS disk labels it sets the type to 0x84 and on GPT
+ it sets the GUID to D3BFE2DE-3DAF-11DF-BA-40-E3A556D89593.
+
You can now choose to ignore errors about partitions that overlap,
or are longer than the disk. This allows you to use parted to
repair the problem.
diff --git a/doc/C/parted.8 b/doc/C/parted.8
index a9f73f5..2f8e9f5 100644
--- a/doc/C/parted.8
+++ b/doc/C/parted.8
@@ -104,7 +104,7 @@ or an LVM logical volume if necessary.
.B set \fIpartition\fP \fIflag\fP \fIstate\fP
Change the state of the \fIflag\fP on \fIpartition\fP to \fIstate\fP.
Supported flags are: "boot", "root", "swap", "hidden", "raid", "lvm", "lba",
-"legacy_boot" and "palo".
+"legacy_boot", "irst" and "palo".
\fIstate\fP should be either "on" or "off".
.TP
.B unit \fIunit\fP
diff --git a/doc/parted.texi b/doc/parted.texi
index 25a02c7..4c63fe3 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -836,6 +836,10 @@ used by Windows on GPT disks. Note that this flag should not normally be
set on Windows filesystem partitions (those that contain NTFS or FAT
filesystems).
+@item irst
+(MS-DOS, GPT) - this flag identifies an Intel Rapid Start Technology
+partition.
+
@item lba
(MS-DOS) - this flag can be enabled to tell MS DOS, MS Windows 9x and
MS Windows ME based operating systems to use Linear (LBA) mode.
diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h
index aa905c5..585383d 100644
--- a/include/parted/disk.in.h
+++ b/include/parted/disk.in.h
@@ -73,10 +73,11 @@ enum _PedPartitionFlag {
PED_PARTITION_APPLE_TV_RECOVERY=13,
PED_PARTITION_DIAG=14,
PED_PARTITION_LEGACY_BOOT=15,
- PED_PARTITION_MSFT_DATA=16
+ PED_PARTITION_MSFT_DATA=16,
+ PED_PARTITION_IRST=17
};
#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT
-#define PED_PARTITION_LAST_FLAG PED_PARTITION_MSFT_DATA
+#define PED_PARTITION_LAST_FLAG PED_PARTITION_IRST
enum _PedDiskTypeFeature {
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
diff --git a/libparted/disk.c b/libparted/disk.c
index ce71bfc..18c94ac 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -2402,6 +2402,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
return N_("diag");
case PED_PARTITION_LEGACY_BOOT:
return N_("legacy_boot");
+ case PED_PARTITION_IRST:
+ return N_("irst");
default:
ped_exception_throw (
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index 6bddd79..c754970 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -85,6 +85,7 @@ static const char MBR_BOOT_CODE[] = {
#define PARTITION_LDM 0x42
#define PARTITION_LINUX_SWAP 0x82
#define PARTITION_LINUX 0x83
+#define PARTITION_IRST 0x84
#define PARTITION_LINUX_EXT 0x85
#define PARTITION_LINUX_LVM 0x8e
#define PARTITION_HFS 0xaf
@@ -159,6 +160,7 @@ typedef struct {
int palo;
int prep;
int diag;
+ int irst;
OrigState* orig; /* used for CHS stuff */
} DosPartitionData;
@@ -924,6 +926,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->irst = raw_part->type == PARTITION_IRST;
dos_data->orig = ped_malloc (sizeof (OrigState));
if (!dos_data->orig) {
ped_partition_destroy (part);
@@ -1316,6 +1319,7 @@ msdos_partition_new (const PedDisk* disk, PedPartitionType part_type,
dos_data->lba = 0;
dos_data->palo = 0;
dos_data->prep = 0;
+ dos_data->irst = 0;
} else {
part->disk_specific = NULL;
}
@@ -1351,6 +1355,7 @@ msdos_partition_duplicate (const PedPartition* part)
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->irst = old_dos_data->irst;
if (old_dos_data->orig) {
new_dos_data->orig = ped_malloc (sizeof (OrigState));
@@ -1399,6 +1404,7 @@ msdos_partition_set_system (PedPartition* part,
dos_data->lvm = 0;
dos_data->palo = 0;
dos_data->prep = 0;
+ dos_data->irst = 0;
if (dos_data->lba)
dos_data->system = PARTITION_EXT_LBA;
else
@@ -1431,6 +1437,10 @@ msdos_partition_set_system (PedPartition* part,
dos_data->system = PARTITION_PREP;
return 1;
}
+ if (dos_data->irst) {
+ dos_data->system = PARTITION_IRST;
+ return 1;
+ }
if (!fs_type)
dos_data->system = PARTITION_LINUX;
@@ -1467,6 +1477,7 @@ clear_flags (DosPartitionData *dos_data)
dos_data->lvm = 0;
dos_data->palo = 0;
dos_data->prep = 0;
+ dos_data->irst = 0;
dos_data->raid = 0;
}
@@ -1545,6 +1556,12 @@ msdos_partition_set_flag (PedPartition* part,
dos_data->prep = state;
return ped_partition_set_system (part, part->fs_type);
+ case PED_PARTITION_IRST:
+ if (state)
+ clear_flags (dos_data);
+ dos_data->irst = state;
+ return ped_partition_set_system (part, part->fs_type);
+
default:
return 0;
}
@@ -1587,6 +1604,9 @@ msdos_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
case PED_PARTITION_PREP:
return dos_data->prep;
+ case PED_PARTITION_IRST:
+ return dos_data->irst;
+
default:
return 0;
}
@@ -1609,6 +1629,7 @@ msdos_partition_is_flag_available (const PedPartition* part,
case PED_PARTITION_LBA:
case PED_PARTITION_PALO:
case PED_PARTITION_PREP:
+ case PED_PARTITION_IRST:
case PED_PARTITION_DIAG:
return 1;
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 6fd8880..ff87708 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -152,6 +152,10 @@ typedef struct
((efi_guid_t) { PED_CPU_TO_LE32 (0x9e1a2d38), PED_CPU_TO_LE16 (0xc612), \
PED_CPU_TO_LE16 (0x4316), 0xaa, 0x26, \
{ 0x8b, 0x49, 0x52, 0x1e, 0x5a, 0x8b }})
+#define PARTITION_IRST_GUID \
+ ((efi_guid_t) { PED_CPU_TO_LE32 (0xD3BFE2DE), PED_CPU_TO_LE16 (0x3DAF), \
+ PED_CPU_TO_LE16 (0x11DF), 0xba, 0x40, \
+ { 0xE3, 0xA5, 0x56, 0xD8, 0x95, 0x93 }})
struct __attribute__ ((packed)) _GuidPartitionTableHeader_t
{
@@ -297,6 +301,7 @@ typedef struct _GPTPartitionData
int msftrecv;
int legacy_boot;
int prep;
+ int irst;
} GPTPartitionData;
static PedDiskType gpt_disk_type;
@@ -814,6 +819,7 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
= gpt_part_data->msftrecv
= gpt_part_data->legacy_boot
= gpt_part_data->prep
+ = gpt_part_data->irst
= gpt_part_data->bios_grub = gpt_part_data->atvrecv = 0;
if (pte->Attributes.RequiredToFunction & 0x1)
@@ -841,6 +847,8 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
gpt_part_data->atvrecv = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_PREP_GUID))
gpt_part_data->prep = 1;
+ else if (!guid_cmp (gpt_part_data->type, PARTITION_IRST_GUID))
+ gpt_part_data->irst = 1;
return part;
}
@@ -1359,6 +1367,7 @@ gpt_partition_new (const PedDisk *disk,
gpt_part_data->legacy_boot = 0;
gpt_part_data->prep = 0;
gpt_part_data->translated_name = 0;
+ gpt_part_data->irst = 0;
uuid_generate ((unsigned char *) &gpt_part_data->uuid);
swap_uuid_and_efi_guid ((unsigned char *) (&gpt_part_data->uuid));
memset (gpt_part_data->name, 0, sizeof gpt_part_data->name);
@@ -1477,6 +1486,11 @@ gpt_partition_set_system (PedPartition *part,
gpt_part_data->type = PARTITION_APPLE_TV_RECOVERY_GUID;
return 1;
}
+ if (gpt_part_data->irst)
+ {
+ gpt_part_data->type = PARTITION_IRST_GUID;
+ return 1;
+ }
if (fs_type)
{
@@ -1619,6 +1633,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftdata
= gpt_part_data->msftrecv
= gpt_part_data->prep
+ = gpt_part_data->irst
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_BIOS_GRUB:
@@ -1632,6 +1647,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftdata
= gpt_part_data->msftrecv
= gpt_part_data->prep
+ = gpt_part_data->irst
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_RAID:
@@ -1645,6 +1661,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftdata
= gpt_part_data->msftrecv
= gpt_part_data->prep
+ = gpt_part_data->irst
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_LVM:
@@ -1658,6 +1675,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftdata
= gpt_part_data->msftrecv
= gpt_part_data->prep
+ = gpt_part_data->irst
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_HPSERVICE:
@@ -1671,6 +1689,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftdata
= gpt_part_data->msftrecv
= gpt_part_data->prep
+ = gpt_part_data->irst
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_MSFT_RESERVED:
@@ -1684,6 +1703,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftdata
= gpt_part_data->msftrecv
= gpt_part_data->prep
+ = gpt_part_data->irst
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_MSFT_DATA:
@@ -1697,6 +1717,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftres
= gpt_part_data->msftrecv
= gpt_part_data->prep
+ = gpt_part_data->irst
= gpt_part_data->atvrecv = 0;
gpt_part_data->msftdata = 1;
} else {
@@ -1714,6 +1735,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftdata
= gpt_part_data->msftres
= gpt_part_data->prep
+ = gpt_part_data->irst
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_APPLE_TV_RECOVERY:
@@ -1738,7 +1760,22 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
+ = gpt_part_data->irst
+ = gpt_part_data->atvrecv
+ = gpt_part_data->msftrecv = 0;
+ return gpt_partition_set_system (part, part->fs_type);
+ case PED_PARTITION_IRST:
+ gpt_part_data->irst = state;
+ if (state)
+ gpt_part_data->boot
+ = gpt_part_data->raid
+ = gpt_part_data->lvm
+ = gpt_part_data->bios_grub
+ = gpt_part_data->hp_service
+ = gpt_part_data->msftres
+ = gpt_part_data->msftdata
= gpt_part_data->msftrecv
+ = gpt_part_data->prep
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_HIDDEN:
@@ -1789,6 +1826,8 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag)
return gpt_part_data->legacy_boot;
case PED_PARTITION_PREP:
return gpt_part_data->prep;
+ case PED_PARTITION_IRST:
+ return gpt_part_data->irst;
case PED_PARTITION_SWAP:
case PED_PARTITION_LBA:
case PED_PARTITION_ROOT:
@@ -1816,6 +1855,7 @@ gpt_partition_is_flag_available (const PedPartition *part,
case PED_PARTITION_HIDDEN:
case PED_PARTITION_LEGACY_BOOT:
case PED_PARTITION_PREP:
+ case PED_PARTITION_IRST:
return 1;
case PED_PARTITION_SWAP:
case PED_PARTITION_ROOT:
--
1.9.3

View File

@ -1,241 +0,0 @@
From 6a5b3b5727845af0c5cef35dee3d8e8c69262fdc Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 11 Sep 2013 12:25:04 -0700
Subject: [PATCH 076/131] libparted: Add UEFI System Partition flag.
This adds support for the ESP partition type on MS-DOS. It also aliases
it to the boot flag on GPT which sets the ESP GUID type.
* NEWS (New Features): Mention it.
* doc/C/parted.8: Document esp flag.
* doc/parted.texti: Document esp flag.
* include/parted/disk.in.h (_PedPartitionFlag): Add PED_PARTITION_ESP flag
* libparted/disk.c (ped_partition_flag_get_name): Add esp flag
* libparted/labels/dos.c (DosPartitionData): Likewise
(raw_part_parse): Likewise
(msdos_partition_new): Likewise
(msdos_partition_duplicate): Likewise
(msdos_partition_set_system): Likewise
(clear_flags): Likewise
(msdos_partition_set_flag): Likewise
(msdos_partition_get_flag): Likewise
(msdos_partition_is_flag_available): Likewise
* libparted/labels/gpt.c (gpt_partition_set_flag): Add PED_PARTITION_ESP
(gpt_partition_get_flag): Likewise
(gpt_partition_is_flag_available): Likewise
---
NEWS | 3 +++
doc/C/parted.8 | 2 +-
doc/parted.texi | 4 ++++
include/parted/disk.in.h | 5 +++--
libparted/disk.c | 2 ++
libparted/labels/dos.c | 21 +++++++++++++++++++++
libparted/labels/gpt.c | 3 +++
7 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index 27710b6..abb73c6 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ GNU parted NEWS -*- outline -*-
** New Features
+ Added new partition type flag, esp, to set the type to 0xEF on MS-DOS.
+ Also aliased to boot on GPT to set the UEFI ESP GUID.
+
Added new partition type flag, irst, for use with Intel Rapid Start
Technology. On MS-DOS disk labels it sets the type to 0x84 and on GPT
it sets the GUID to D3BFE2DE-3DAF-11DF-BA-40-E3A556D89593.
diff --git a/doc/C/parted.8 b/doc/C/parted.8
index 2f8e9f5..f8e6a3d 100644
--- a/doc/C/parted.8
+++ b/doc/C/parted.8
@@ -104,7 +104,7 @@ or an LVM logical volume if necessary.
.B set \fIpartition\fP \fIflag\fP \fIstate\fP
Change the state of the \fIflag\fP on \fIpartition\fP to \fIstate\fP.
Supported flags are: "boot", "root", "swap", "hidden", "raid", "lvm", "lba",
-"legacy_boot", "irst" and "palo".
+"legacy_boot", "irst", "esp" and "palo".
\fIstate\fP should be either "on" or "off".
.TP
.B unit \fIunit\fP
diff --git a/doc/parted.texi b/doc/parted.texi
index 4c63fe3..9e00808 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -840,6 +840,10 @@ filesystems).
(MS-DOS, GPT) - this flag identifies an Intel Rapid Start Technology
partition.
+@item esp
+(MS-DOS, GPT) - this flag identifies a UEFI System Partition. On GPT
+it is an alias for boot.
+
@item lba
(MS-DOS) - this flag can be enabled to tell MS DOS, MS Windows 9x and
MS Windows ME based operating systems to use Linear (LBA) mode.
diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h
index 585383d..d144e21 100644
--- a/include/parted/disk.in.h
+++ b/include/parted/disk.in.h
@@ -74,10 +74,11 @@ enum _PedPartitionFlag {
PED_PARTITION_DIAG=14,
PED_PARTITION_LEGACY_BOOT=15,
PED_PARTITION_MSFT_DATA=16,
- PED_PARTITION_IRST=17
+ PED_PARTITION_IRST=17,
+ PED_PARTITION_ESP=18
};
#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT
-#define PED_PARTITION_LAST_FLAG PED_PARTITION_IRST
+#define PED_PARTITION_LAST_FLAG PED_PARTITION_ESP
enum _PedDiskTypeFeature {
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
diff --git a/libparted/disk.c b/libparted/disk.c
index 18c94ac..5421c03 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -2404,6 +2404,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
return N_("legacy_boot");
case PED_PARTITION_IRST:
return N_("irst");
+ case PED_PARTITION_ESP:
+ return N_("esp");
default:
ped_exception_throw (
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index c754970..eff1c03 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -92,6 +92,7 @@ static const char MBR_BOOT_CODE[] = {
#define PARTITION_SUN_UFS 0xbf
#define PARTITION_DELL_DIAG 0xde
#define PARTITION_GPT 0xee
+#define PARTITION_ESP 0xef
#define PARTITION_PALO 0xf0
#define PARTITION_PREP 0x41
#define PARTITION_LINUX_RAID 0xfd
@@ -161,6 +162,7 @@ typedef struct {
int prep;
int diag;
int irst;
+ int esp;
OrigState* orig; /* used for CHS stuff */
} DosPartitionData;
@@ -927,6 +929,7 @@ raw_part_parse (const PedDisk* disk, const DosRawPartition* raw_part,
dos_data->palo = raw_part->type == PARTITION_PALO;
dos_data->prep = raw_part->type == PARTITION_PREP;
dos_data->irst = raw_part->type == PARTITION_IRST;
+ dos_data->esp = raw_part->type == PARTITION_ESP;
dos_data->orig = ped_malloc (sizeof (OrigState));
if (!dos_data->orig) {
ped_partition_destroy (part);
@@ -1320,6 +1323,7 @@ msdos_partition_new (const PedDisk* disk, PedPartitionType part_type,
dos_data->palo = 0;
dos_data->prep = 0;
dos_data->irst = 0;
+ dos_data->esp = 0;
} else {
part->disk_specific = NULL;
}
@@ -1356,6 +1360,7 @@ msdos_partition_duplicate (const PedPartition* part)
new_dos_data->palo = old_dos_data->palo;
new_dos_data->prep = old_dos_data->prep;
new_dos_data->irst = old_dos_data->irst;
+ new_dos_data->esp = old_dos_data->esp;
if (old_dos_data->orig) {
new_dos_data->orig = ped_malloc (sizeof (OrigState));
@@ -1405,6 +1410,7 @@ msdos_partition_set_system (PedPartition* part,
dos_data->palo = 0;
dos_data->prep = 0;
dos_data->irst = 0;
+ dos_data->esp = 0;
if (dos_data->lba)
dos_data->system = PARTITION_EXT_LBA;
else
@@ -1441,6 +1447,10 @@ msdos_partition_set_system (PedPartition* part,
dos_data->system = PARTITION_IRST;
return 1;
}
+ if (dos_data->esp) {
+ dos_data->system = PARTITION_ESP;
+ return 1;
+ }
if (!fs_type)
dos_data->system = PARTITION_LINUX;
@@ -1478,6 +1488,7 @@ clear_flags (DosPartitionData *dos_data)
dos_data->palo = 0;
dos_data->prep = 0;
dos_data->irst = 0;
+ dos_data->esp = 0;
dos_data->raid = 0;
}
@@ -1562,6 +1573,12 @@ msdos_partition_set_flag (PedPartition* part,
dos_data->irst = state;
return ped_partition_set_system (part, part->fs_type);
+ case PED_PARTITION_ESP:
+ if (state)
+ clear_flags (dos_data);
+ dos_data->esp = state;
+ return ped_partition_set_system (part, part->fs_type);
+
default:
return 0;
}
@@ -1607,6 +1624,9 @@ msdos_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
case PED_PARTITION_IRST:
return dos_data->irst;
+ case PED_PARTITION_ESP:
+ return dos_data->esp;
+
default:
return 0;
}
@@ -1630,6 +1650,7 @@ msdos_partition_is_flag_available (const PedPartition* part,
case PED_PARTITION_PALO:
case PED_PARTITION_PREP:
case PED_PARTITION_IRST:
+ case PED_PARTITION_ESP:
case PED_PARTITION_DIAG:
return 1;
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index ff87708..42b0360 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1622,6 +1622,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
switch (flag)
{
+ case PED_PARTITION_ESP:
case PED_PARTITION_BOOT:
gpt_part_data->boot = state;
if (state)
@@ -1806,6 +1807,7 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag)
return gpt_part_data->raid;
case PED_PARTITION_LVM:
return gpt_part_data->lvm;
+ case PED_PARTITION_ESP:
case PED_PARTITION_BOOT:
return gpt_part_data->boot;
case PED_PARTITION_BIOS_GRUB:
@@ -1856,6 +1858,7 @@ gpt_partition_is_flag_available (const PedPartition *part,
case PED_PARTITION_LEGACY_BOOT:
case PED_PARTITION_PREP:
case PED_PARTITION_IRST:
+ case PED_PARTITION_ESP:
return 1;
case PED_PARTITION_SWAP:
case PED_PARTITION_ROOT:
--
1.9.3

View File

@ -1,184 +0,0 @@
From 33273acc7822b382b5e8226ba65453b6229f5dd6 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 11 Sep 2013 12:25:06 -0700
Subject: [PATCH 077/131] libparted: Recognize btrfs filesystem
Add support for showing 'btrfs' in the 'file system' column. Also
allows the used to enter btrfs as the fs type. It doesn't really do
anything -- just sets the partition type to linux.
* NEWS (Changes in behavior): Mention it.
* doc/parted.texti: Document btrfs fs.
* (libparted/fs/Makefile.am): Add btrfs.c
* (libparted/fs/btrfs/btrfs.c): Probe for btrfs
* (libparted/libparted.c): Register btrfs
---
NEWS | 3 ++
doc/parted.texi | 1 +
libparted/fs/Makefile.am | 1 +
libparted/fs/btrfs/btrfs.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++
libparted/libparted.c | 4 +++
5 files changed, 87 insertions(+)
create mode 100644 libparted/fs/btrfs/btrfs.c
diff --git a/NEWS b/NEWS
index abb73c6..7b69d3d 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ GNU parted NEWS -*- outline -*-
** New Features
+ Added support for recognizing btrfs filesystem. This simply displays
+ btrfs in the 'file system' column of the parted output.
+
Added new partition type flag, esp, to set the type to 0xEF on MS-DOS.
Also aliased to boot on GPT to set the UEFI ESP GUID.
diff --git a/doc/parted.texi b/doc/parted.texi
index 9e00808..97ce203 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -575,6 +575,7 @@ partition table.
@item NTFS
@item reiserfs
@item ufs
+@item btrfs
@end itemize
For example, the following creates a logical partition that will contain
diff --git a/libparted/fs/Makefile.am b/libparted/fs/Makefile.am
index aac03cc..1949617 100644
--- a/libparted/fs/Makefile.am
+++ b/libparted/fs/Makefile.am
@@ -23,6 +23,7 @@ libfs_la_SOURCES = \
amiga/asfs.c \
amiga/asfs.h \
amiga/a-interface.c \
+ btrfs/btrfs.c \
ext2/ext2.h \
ext2/ext2_fs.h \
ext2/interface.c \
diff --git a/libparted/fs/btrfs/btrfs.c b/libparted/fs/btrfs/btrfs.c
new file mode 100644
index 0000000..e5abed6
--- /dev/null
+++ b/libparted/fs/btrfs/btrfs.c
@@ -0,0 +1,78 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 2013 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/>.
+*/
+
+#include <config.h>
+
+#include <parted/parted.h>
+#include <parted/endian.h>
+
+/* Located 64k inside the partition (start of the first btrfs superblock) */
+#define BTRFS_MAGIC 0x4D5F53665248425FULL /* ascii _BHRfS_M, no null */
+#define BTRFS_CSUM_SIZE 32
+#define BTRFS_FSID_SIZE 16
+
+
+static PedGeometry*
+btrfs_probe (PedGeometry* geom)
+{
+ union {
+ struct {
+ /* Just enough of the btrfs_super_block to get the magic */
+ uint8_t csum[BTRFS_CSUM_SIZE];
+ uint8_t fsid[BTRFS_FSID_SIZE];
+ uint64_t bytenr;
+ uint64_t flags;
+ uint64_t magic;
+ } sb;
+ int8_t sector[8192];
+ } buf;
+ PedSector offset = (64*1024)/geom->dev->sector_size;
+
+ if (geom->length < offset+1)
+ return 0;
+ if (!ped_geometry_read (geom, &buf, offset, 1))
+ return 0;
+
+ if (PED_LE64_TO_CPU(buf.sb.magic) == BTRFS_MAGIC) {
+ return ped_geometry_new (geom->dev, geom->start, geom->length);
+ }
+ return NULL;
+}
+
+static PedFileSystemOps btrfs_ops = {
+ probe: btrfs_probe,
+};
+
+static PedFileSystemType btrfs_type = {
+ next: NULL,
+ ops: &btrfs_ops,
+ name: "btrfs",
+ block_sizes: ((int[2]){512, 0})
+};
+
+void
+ped_file_system_btrfs_init ()
+{
+ ped_file_system_type_register (&btrfs_type);
+}
+
+void
+ped_file_system_btrfs_done ()
+{
+ ped_file_system_type_unregister (&btrfs_type);
+}
diff --git a/libparted/libparted.c b/libparted/libparted.c
index 9923bfa..3afbf8e 100644
--- a/libparted/libparted.c
+++ b/libparted/libparted.c
@@ -109,6 +109,7 @@ extern void ped_file_system_hfs_init (void);
extern void ped_file_system_fat_init (void);
extern void ped_file_system_ext2_init (void);
extern void ped_file_system_nilfs2_init (void);
+extern void ped_file_system_btrfs_init (void);
static void
init_file_system_types ()
@@ -124,6 +125,7 @@ init_file_system_types ()
ped_file_system_fat_init ();
ped_file_system_ext2_init ();
ped_file_system_nilfs2_init ();
+ ped_file_system_btrfs_init ();
}
extern void ped_disk_aix_done ();
@@ -186,6 +188,7 @@ extern void ped_file_system_reiserfs_done (void);
extern void ped_file_system_ufs_done (void);
extern void ped_file_system_xfs_done (void);
extern void ped_file_system_amiga_done (void);
+extern void ped_file_system_btrfs_done (void);
static void
done_file_system_types ()
@@ -201,6 +204,7 @@ done_file_system_types ()
ped_file_system_ufs_done ();
ped_file_system_xfs_done ();
ped_file_system_amiga_done ();
+ ped_file_system_btrfs_done ();
}
static void _done() __attribute__ ((destructor));
--
1.9.3

View File

@ -1,26 +0,0 @@
From 9279fc06572959c4698deb2f1d3df8daaed66e87 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 11 Sep 2013 12:25:07 -0700
Subject: [PATCH 078/131] tests: Add btrfs and xfs to the fs probe test
* tests/tests/t1700-probe-fs.sh: Add btrfs and xfs
---
tests/t1700-probe-fs.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/t1700-probe-fs.sh b/tests/t1700-probe-fs.sh
index 7ce53d0..0418e73 100755
--- a/tests/t1700-probe-fs.sh
+++ b/tests/t1700-probe-fs.sh
@@ -22,7 +22,7 @@ require_512_byte_sector_size_
dev=loop-file
ss=$sector_size_
-for type in ext2 ext3 ext4 nilfs2; do
+for type in ext2 ext3 ext4 btrfs xfs nilfs2; do
( mkfs.$type -V ) >/dev/null 2>&1 \
|| { warn_ "$ME: no $type support"; continue; }
--
1.9.3

View File

@ -1,52 +0,0 @@
From fec001a2c83750c35f47e6e621f3acb22e459c7a Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 11 Sep 2013 12:25:09 -0700
Subject: [PATCH 079/131] tests: Restrict gpt-header-munge to little-endian
systems
gpt-header-munge uses perl to manipulate the gpt header for the test. It
only works on 64 bit little-endian systems so restrict it to x86_64
only.
* tests/t0210-gpt-resized-partition-entry-array.sh: Skip if not x86_64
* tests/t0211-gpt-rewrite-header.sh: Skip if not x86_64
---
tests/t0210-gpt-resized-partition-entry-array.sh | 5 +++++
tests/t0211-gpt-rewrite-header.sh | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/tests/t0210-gpt-resized-partition-entry-array.sh b/tests/t0210-gpt-resized-partition-entry-array.sh
index 8854018..512f342 100755
--- a/tests/t0210-gpt-resized-partition-entry-array.sh
+++ b/tests/t0210-gpt-resized-partition-entry-array.sh
@@ -19,6 +19,11 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../parted $srcdir
require_perl_digest_crc_
+# gpt-header-munge will fail on big-endian systems
+if test $(uname -m) != x86_64; then
+ skip_ 'this test only works on little-endian systems'
+fi
+
ss=$sector_size_
N=2M
diff --git a/tests/t0211-gpt-rewrite-header.sh b/tests/t0211-gpt-rewrite-header.sh
index 58625a2..a87e753 100644
--- a/tests/t0211-gpt-rewrite-header.sh
+++ b/tests/t0211-gpt-rewrite-header.sh
@@ -23,6 +23,11 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../parted $srcdir
require_perl_digest_crc_
+# gpt-header-munge will fail on big-endian systems
+if test $(uname -m) != x86_64; then
+ skip_ 'this test only works on little-endian systems'
+fi
+
ss=$sector_size_
ns=100 # Initial number of sectors.
--
1.9.3

View File

@ -1,68 +0,0 @@
From 80f4f42c805ee37392c5cc43d8ac08772b7b1cf1 Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Sat, 1 Mar 2014 21:23:39 -0500
Subject: [PATCH 080/131] libparted: don't require a system id string
Historically the system ID field of a fat boot sector contains a
string identifying the OS that formatted it. It appears that some
recent versions of Windows have stopped bothering with this. Stop
requiring this string to recognize fat as valid.
---
NEWS | 3 +++
libparted/fs/fat/bootsector.c | 7 -------
libparted/fs/r/fat/bootsector.c | 7 -------
3 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/NEWS b/NEWS
index 7b69d3d..88dd1fe 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,9 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ Do not reject a FAT boot sector as invalid because it has no
+ system ID string.
+
libparted: /dev/md/ symlink can change after libparted dereferences it,
instead it should just use the symlink as given by the caller in the
same way we do with /dev/mapper/.
diff --git a/libparted/fs/fat/bootsector.c b/libparted/fs/fat/bootsector.c
index d4f8dc4..dacc79c 100644
--- a/libparted/fs/fat/bootsector.c
+++ b/libparted/fs/fat/bootsector.c
@@ -51,13 +51,6 @@ fat_boot_sector_read (FatBootSector* bs, const PedGeometry *geom)
return 0;
}
- if (!bs->system_id[0]) {
- ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
- _("File system has an invalid signature for a FAT "
- "file system."));
- return 0;
- }
-
if (!bs->sector_size
|| PED_LE16_TO_CPU (bs->sector_size) % PED_SECTOR_SIZE_DEFAULT) {
ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
diff --git a/libparted/fs/r/fat/bootsector.c b/libparted/fs/r/fat/bootsector.c
index 07b39cf..3aff1d7 100644
--- a/libparted/fs/r/fat/bootsector.c
+++ b/libparted/fs/r/fat/bootsector.c
@@ -51,13 +51,6 @@ fat_boot_sector_read (FatBootSector* bs, const PedGeometry *geom)
return 0;
}
- if (!bs->system_id[0]) {
- ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
- _("File system has an invalid signature for a FAT "
- "file system."));
- return 0;
- }
-
if (!bs->sector_size
|| PED_LE16_TO_CPU (bs->sector_size) % PED_SECTOR_SIZE_DEFAULT) {
ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
--
1.9.3

View File

@ -1,58 +0,0 @@
From 026736e9fed89ef00e6e6e84c7e422639ac2715c Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Mon, 23 Dec 2013 15:28:22 -0500
Subject: [PATCH 081/131] libparted: sync partitions > 16
The linux partition sync code was hard coded to only flush
the first 16 partitions.
---
NEWS | 2 ++
libparted/arch/linux.c | 5 ++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 88dd1fe..9ef8bf4 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,8 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ Fix linux partition sync code to flush partitions > 16
+
Do not reject a FAT boot sector as invalid because it has no
system ID string.
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 4376d17..71f5034 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -289,6 +289,8 @@ struct blkdev_ioctl_param {
static char* _device_get_part_path (PedDevice const *dev, int num);
static int _partition_is_mounted_by_path (const char* path);
+static unsigned int _device_get_partition_range(PedDevice const* dev);
+
static int
_read_fd (int fd, char **buf)
@@ -1581,6 +1583,7 @@ _flush_cache (PedDevice* dev)
{
LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
int i;
+ int lpn = _device_get_partition_range(dev);
if (dev->read_only)
return;
@@ -1588,7 +1591,7 @@ _flush_cache (PedDevice* dev)
ioctl (arch_specific->fd, BLKFLSBUF);
- for (i = 1; i < 16; i++) {
+ for (i = 1; i < lpn; i++) {
char* name;
int fd;
--
1.9.3

View File

@ -1,32 +0,0 @@
From cc382c3753e1b430c00df46f0937b74db36ccb8a Mon Sep 17 00:00:00 2001
From: Gustavo Zacarias <gustavo@zacarias.com.ar>
Date: Mon, 3 Mar 2014 10:40:08 -0300
Subject: [PATCH 082/131] ui: switch to new-style readline typedef
The CPPFunction typedef (among others) have been deprecated in favour of
specific prototyped typedefs since readline 4.2 (circa 2001).
It's been working since because compatibility typedefs have been in
place until they where removed in the recent readline 6.3 release.
Switch to the new style to avoid build breakage.
Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
---
parted/ui.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/parted/ui.c b/parted/ui.c
index 786deed..b33f6fc 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -1470,7 +1470,7 @@ init_readline (void)
#ifdef HAVE_LIBREADLINE
if (!opt_script_mode) {
rl_initialize ();
- rl_attempted_completion_function = (CPPFunction*) complete_function;
+ rl_attempted_completion_function = (rl_completion_func_t *) complete_function;
readline_state.in_readline = 0;
}
#endif
--
1.9.3

View File

@ -1,87 +0,0 @@
From 8993950f50275724b2cb1c4960977dc78eec2ed2 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 8 Apr 2014 10:54:27 -0700
Subject: [PATCH 083/131] libparted: Fix check for backup header location
Add a couple of helper functions for calculating the partition table
entry size (in sectors) and for guessing the end of the disk based on
the LastUsableLBA and the Partition Table Entry size.
The backup header should be either at the end of the disk, or at what
the primary header thinks is the end of the disk. Prompt to fix the
backup header if it is located any other place.
* libparted/labels/gpt.c (_ptes_sectors): New function
(_hdr_disk_end): New function
(gpt_read): Use new function to test for pri's idea of end of disk
---
libparted/labels/gpt.c | 38 +++++++++++++++++++++++++++++++-------
1 file changed, 31 insertions(+), 7 deletions(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 42b0360..c5dea2f 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -693,6 +693,29 @@ _header_is_valid (PedDisk const *disk, GuidPartitionTableHeader_t *gpt,
return crc == PED_LE32_TO_CPU (origcrc);
}
+/* Return the number of sectors that should be used by the
+ * partition entry table.
+ */
+static PedSector
+_ptes_sectors(PedDisk const *disk, GuidPartitionTableHeader_t const *gpt)
+{
+ size_t ptes_bytes = PED_LE32_TO_CPU (gpt->SizeOfPartitionEntry) *
+ PED_LE32_TO_CPU (gpt->NumberOfPartitionEntries);
+ /* Minimum amount of space reserved is 128 128 byte entries */
+ if (ptes_bytes < 128*128)
+ ptes_bytes = 128*128;
+ return ped_div_round_up (ptes_bytes, disk->dev->sector_size);
+}
+
+/* Return the header's idea of the last sector of the disk
+ * based on LastUsableLBA and the Partition Entry table.
+ */
+static PedSector
+_hdr_disk_end(PedDisk const *disk, GuidPartitionTableHeader_t const *gpt)
+{
+ return PED_LE64_TO_CPU (gpt->LastUsableLBA) + 1 + _ptes_sectors(disk, gpt);
+}
+
static int
_parse_header (PedDisk *disk, const GuidPartitionTableHeader_t *gpt,
int *update_needed)
@@ -985,13 +1008,14 @@ gpt_read (PedDisk *disk)
{
/* Both are valid. */
#ifndef DISCOVER_ONLY
- PedSector gpt_disk_end = PED_LE64_TO_CPU (primary_gpt->LastUsableLBA) + 1;
- gpt_disk_end += ((PedSector) (PED_LE32_TO_CPU (primary_gpt->NumberOfPartitionEntries)) *
- (PedSector) (PED_LE32_TO_CPU (primary_gpt->SizeOfPartitionEntry)) /
- disk->dev->sector_size);
-
+ /* The backup header must be at the end of the disk, or at what the primary
+ * header thinks is the end of the disk.
+ */
gpt_disk_data->AlternateLBA = PED_LE64_TO_CPU (primary_gpt->AlternateLBA);
- if (PED_LE64_TO_CPU (primary_gpt->AlternateLBA) != gpt_disk_end)
+ PedSector pri_disk_end = _hdr_disk_end(disk, primary_gpt);
+
+ if (gpt_disk_data->AlternateLBA != disk->dev->length -1 &&
+ gpt_disk_data->AlternateLBA != pri_disk_end)
{
if (ped_exception_throw
(PED_EXCEPTION_ERROR,
@@ -1002,7 +1026,7 @@ gpt_read (PedDisk *disk)
{
ptt_clear_sectors (disk->dev,
PED_LE64_TO_CPU (primary_gpt->AlternateLBA), 1);
- gpt_disk_data->AlternateLBA = gpt_disk_end;
+ gpt_disk_data->AlternateLBA = disk->dev->length -1;
write_back = 1;
}
}
--
1.9.3

View File

@ -1,48 +0,0 @@
From 3398e82af3d26cc1ab938f2e0896204f11bce4ca Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 8 Apr 2014 11:12:17 -0700
Subject: [PATCH 084/131] libparted: Use common function to calculate PTE
sectors
Use _ptes_sectors in _parse_header's calculation to determine if the
disk has been grown.
* libparted/labels/gpt.c (_parse_header): use _ptes_sectors
---
libparted/labels/gpt.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index c5dea2f..6eff38a 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -751,17 +751,7 @@ _parse_header (PedDisk *disk, const GuidPartitionTableHeader_t *gpt,
space or continue with the current usable area. Only ask once per
parted invocation. */
- last_usable_if_grown
- = (disk->dev->length - 2 -
- ((PedSector) (PED_LE32_TO_CPU (gpt->NumberOfPartitionEntries)) *
- (PedSector) (PED_LE32_TO_CPU (gpt->SizeOfPartitionEntry)) /
- disk->dev->sector_size));
-
- last_usable_min_default = disk->dev->length - 2 -
- GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / disk->dev->sector_size;
-
- if (last_usable_if_grown > last_usable_min_default)
- last_usable_if_grown = last_usable_min_default;
+ last_usable_if_grown = disk->dev->length - 2 - _ptes_sectors(disk, gpt);
if (last_usable <= first_usable
|| disk->dev->length < last_usable)
@@ -791,7 +781,6 @@ _parse_header (PedDisk *disk, const GuidPartitionTableHeader_t *gpt,
ptt_clear_sectors (disk->dev,
gpt_disk_data->AlternateLBA, 1);
gpt_disk_data->AlternateLBA = disk->dev->length - 1;
- last_usable = last_usable_if_grown;
*update_needed = 1;
}
else if (q != PED_EXCEPTION_UNHANDLED)
--
1.9.3

View File

@ -1,73 +0,0 @@
From 368e47b1c00ed36c07275815f69274a985b4aab8 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 25 Mar 2014 17:44:08 -0700
Subject: [PATCH 085/131] tests: Add emit_superuser_warning for gpt tests
When parted runs without script mode it will print a warning about not
being superuser. Add the library call to add this to expected output
from the tests.
* tests/t0281-gpt-grow.sh: Add emit_superuser_warning
* tests/t0282-gpt-move-backup.sh: Add emit_superuser_warning
* tests/t0283-overlap-partitions.sh: Add emit_superuser_warning
---
tests/t0281-gpt-grow.sh | 3 ++-
tests/t0282-gpt-move-backup.sh | 3 ++-
tests/t0283-overlap-partitions.sh | 6 ++++--
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/tests/t0281-gpt-grow.sh b/tests/t0281-gpt-grow.sh
index e373578..0cef138 100644
--- a/tests/t0281-gpt-grow.sh
+++ b/tests/t0281-gpt-grow.sh
@@ -75,7 +75,8 @@ mv out o2 && sed -e "s,/.*/$dev,DEVICE,;s, * ,,g;s, $,," \
-e "s,^.*/lt-parted: ,parted: ," o2 > out
# check for expected diagnostic
-cat <<EOF > exp || fail=1
+emit_superuser_warning > exp || fail=1
+cat <<EOF >> exp || fail=1
Warning: Not all of the space available to DEVICE appears to be used, you can fix the GPT to use all of the space (an extra 500 blocks) or continue with the current setting?
Fix/Ignore? f
Model: (file)
diff --git a/tests/t0282-gpt-move-backup.sh b/tests/t0282-gpt-move-backup.sh
index 9750ed7..1a296ad 100644
--- a/tests/t0282-gpt-move-backup.sh
+++ b/tests/t0282-gpt-move-backup.sh
@@ -75,7 +75,8 @@ mv out o2 && sed -e "s,/.*/$dev,DEVICE,;s, * ,,g;s, $,," \
-e "s,^.*/lt-parted: ,parted: ," o2 > out
# check for expected diagnostic
-cat <<EOF > exp || fail=1
+emit_superuser_warning > exp || fail=1
+cat <<EOF >> exp || fail=1
Error: The backup GPT table is not at the end of the disk, as it should be. Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore? f
Model: (file)
diff --git a/tests/t0283-overlap-partitions.sh b/tests/t0283-overlap-partitions.sh
index 2a53407..c7ae52a 100644
--- a/tests/t0283-overlap-partitions.sh
+++ b/tests/t0283-overlap-partitions.sh
@@ -74,7 +74,8 @@ mv out o2 && sed -e "s,/.*/$dev,DEVICE,;s, * ,,g;s, $,," \
-e "s,^.*/lt-parted: ,parted: ," -e "s/^GNU Parted .*$/GNU Parted VERSION/" o2 > out
# check for expected output
-cat <<EOF > exp || fail=1
+emit_superuser_warning > exp || fail=1
+cat <<EOF >> exp || fail=1
GNU Parted VERSION
Using DEVICE
Welcome to GNU Parted! Type 'help' to view a list of commands.
@@ -116,7 +117,8 @@ mv out o2 && sed -e "s,/.*/$dev,DEVICE,;s, * ,,g;s, $,," \
-e "s,^.*/lt-parted: ,parted: ," -e "s/^GNU Parted .*$/GNU Parted VERSION/" o2 > out
# check for expected output
-cat <<EOF > exp || fail=1
+emit_superuser_warning > exp || fail=1
+cat <<EOF >> exp || fail=1
GNU Parted VERSION
Using DEVICE
Welcome to GNU Parted! Type 'help' to view a list of commands.
--
1.9.3

View File

@ -1,102 +0,0 @@
From 2ee70befff05e6d5004df7491b373445531318e7 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 26 Mar 2014 09:35:07 -0700
Subject: [PATCH 086/131] tests: Use msdos-overlap to setup t0283
xxd isn't present in minimal build systems, as it is part of vim. Change
to using a simple python script to mangle the msdos disklabel for the
test.
* tests/msdos-overlap.py: New file
* tests/t0283-overlap-partitions.sh: Use msdos-overlap.py
---
tests/msdos-overlap.py | 25 ++++++++++++++++++++++++
tests/t0283-overlap-partitions.sh | 40 +++------------------------------------
2 files changed, 28 insertions(+), 37 deletions(-)
create mode 100755 tests/msdos-overlap.py
diff --git a/tests/msdos-overlap.py b/tests/msdos-overlap.py
new file mode 100755
index 0000000..5bddfb0
--- /dev/null
+++ b/tests/msdos-overlap.py
@@ -0,0 +1,25 @@
+#!/usr/bin/python
+"""
+ Write an overlapping partition to a msdos disk
+
+ Call with disk image/device to mangle
+"""
+import sys
+
+BAD_ENTRY = (0x72, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x10, 0x83, 0x03, 0x20, 0x4f, 0x00, 0x08,
+ 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x50, 0x83, 0x00, 0x0a, 0x7a, 0xff, 0x27,
+ 0x00, 0x00, 0x0a, 0x15, 0x00, 0x00, 0x00, 0x00 )
+OFFSET = 0x1b8
+
+if len(sys.argv) < 2:
+ print "%s: <image or device>"
+ sys.exit(1)
+
+data = "".join(chr(c) for c in BAD_ENTRY)
+with open(sys.argv[1], "rb+") as f:
+ f.seek(OFFSET, 0)
+ f.write(data)
+
+sys.exit(0)
diff --git a/tests/t0283-overlap-partitions.sh b/tests/t0283-overlap-partitions.sh
index c7ae52a..221332d 100644
--- a/tests/t0283-overlap-partitions.sh
+++ b/tests/t0283-overlap-partitions.sh
@@ -21,43 +21,9 @@
require_512_byte_sector_size_
dev=loop-file
-truncate -s 10m $dev || fail=1
-
-# write damaged label
-xxd -r - $dev <<EOF
-0000000: fab8 0010 8ed0 bc00 b0b8 0000 8ed8 8ec0 ................
-0000010: fbbe 007c bf00 06b9 0002 f3a4 ea21 0600 ...|.........!..
-0000020: 00be be07 3804 750b 83c6 1081 fefe 0775 ....8.u........u
-0000030: f3eb 16b4 02b0 01bb 007c b280 8a74 018b .........|...t..
-0000040: 4c02 cd13 ea00 7c00 00eb fe00 0000 0000 L.....|.........
-0000050: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-0000060: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-0000070: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-0000080: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-0000090: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-00000a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-00000b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-00000c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-00000d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-00000e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-00000f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-0000100: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-0000110: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-0000120: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-0000130: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-0000140: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-0000150: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-0000160: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-0000170: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-0000180: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-0000190: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-00001a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-00001b0: 0000 0000 0000 0000 72f5 0000 0000 0000 ........r.......
-00001c0: 0110 8303 204f 0008 0000 0020 0000 0000 .... O..... ....
-00001d0: 0050 8300 0a7a ff27 0000 0a15 0000 0000 .P...z.'........
-00001e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
-00001f0: 0000 0000 0000 0000 0000 0000 0000 55aa ..............U.
-EOF
+truncate -s 10m $dev || framework_failure
+parted -s $dev mklabel msdos || framework_failure
+python ../msdos-overlap.py $dev || framework_failure
# print the empty table
parted ---pretend-input-tty $dev <<EOF > out 2>&1 || fail=1
--
1.9.3

View File

@ -1,152 +0,0 @@
From dbcd731411369cd40c842ca492988308b444c42c Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 8 Apr 2014 17:08:22 -0700
Subject: [PATCH 087/131] testing: Use little-endian packing in gpt tests
Fix gpt-header-move.py and gpt-header-munge to use little endian when
packing and unpacking. This allows us to turn the t0210 and t0211 tests
back on for big-endian systems.
* tests/gpt-header-move.py: Use little endian for pack/unpack
* tests/gpt-header-munge: Same
* tests/t-lib-helpers.sh: Add requires_64bit_ that checks for x86_64 and ppc64
* tests/t0210-gpt-resized-partition-entry-array.sh: Remove x86_64 test
* tests/t0211-gpt-rewrite-header.sh: Same
---
tests/gpt-header-move.py | 16 ++++++++--------
tests/gpt-header-munge | 6 +++---
tests/t-lib-helpers.sh | 12 ++++++++++++
tests/t0210-gpt-resized-partition-entry-array.sh | 6 ++----
tests/t0211-gpt-rewrite-header.sh | 6 ++----
5 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/tests/gpt-header-move.py b/tests/gpt-header-move.py
index 69d1479..977febb 100644
--- a/tests/gpt-header-move.py
+++ b/tests/gpt-header-move.py
@@ -8,14 +8,14 @@ import sys
file = open(sys.argv[1],'rb+')
file.seek(512)
gptheader = file.read(512)
-altlba = unpack_from('q', gptheader,offset=32)[0]
+altlba = unpack_from('<q', gptheader,offset=32)[0]
gptheader = array.array('c',gptheader)
-pack_into('Q', gptheader, 32, altlba-33)
+pack_into('<Q', gptheader, 32, altlba-33)
#zero header crc
-pack_into('L', gptheader, 16, 0)
+pack_into('<L', gptheader, 16, 0)
#compute new crc
newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
-pack_into('L', gptheader, 16, newcrc)
+pack_into('<L', gptheader, 16, newcrc)
file.seek(512)
file.write(gptheader)
file.seek(512*altlba)
@@ -25,14 +25,14 @@ backup = file.read(512*32)
altlba -= 33
gptheader = array.array('c',gptheader)
#update mylba
-pack_into('Q', gptheader, 24, altlba)
+pack_into('<Q', gptheader, 24, altlba)
#update table lba
-pack_into('Q', gptheader, 72, altlba-32)
+pack_into('<Q', gptheader, 72, altlba-32)
#zero header crc
-pack_into('L', gptheader, 16, 0)
+pack_into('<L', gptheader, 16, 0)
#compute new crc
newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
-pack_into('L', gptheader, 16, newcrc)
+pack_into('<L', gptheader, 16, newcrc)
file.seek(512*(altlba-32))
file.write(backup)
file.write(gptheader)
diff --git a/tests/gpt-header-munge b/tests/gpt-header-munge
index e7d3d43..5c0dd80 100755
--- a/tests/gpt-header-munge
+++ b/tests/gpt-header-munge
@@ -107,7 +107,7 @@ sub check_GPT_header ($$$)
}
# Save a copy of the CRC, then zero that field, bytes 16..19:
- my $orig_crc = unpack ('L', substr ($buf, 16, 4));
+ my $orig_crc = unpack ('L<', substr ($buf, 16, 4));
substr ($buf, 16, 4) = "\0" x 4;
# Compute CRC32 of header: it'd better match.
@@ -133,7 +133,7 @@ sub set_CRCs ($$$$)
# Compute CRC of primary partition array and put it in substr ($pri, 88, 4)
my $pa_crc = partition_array_crc $pri_or_backup, $n_pe, $in;
- substr ($$buf, 88, 4) = pack ('L', $pa_crc);
+ substr ($$buf, 88, 4) = pack ('L<', $pa_crc);
# In the backup header, we must also set the 8-byte "Partition entries
# starting LBA number" field to reflect our new value of $n_pe.
@@ -151,7 +151,7 @@ sub set_CRCs ($$$$)
# slot into which we'll store the result.
substr ($$buf, 16, 4) = "\0" x 4;
my $crc = crc32($$buf);
- substr ($$buf, 16, 4) = pack ('L', $crc);
+ substr ($$buf, 16, 4) = pack ('L<', $crc);
}
sub usage ($)
diff --git a/tests/t-lib-helpers.sh b/tests/t-lib-helpers.sh
index 6721003..4e83a05 100644
--- a/tests/t-lib-helpers.sh
+++ b/tests/t-lib-helpers.sh
@@ -398,3 +398,15 @@ device_mapper_required_()
. "$abs_top_srcdir/tests/t-lvm.sh"
lvm_init_root_dir_ || fail_ "device mapper setup failed"
}
+
+# Require a 64bit system
+require_64bit_()
+{
+ case $(uname -m) in
+ x86_64|ppc64)
+ return 0;;
+ *)
+ skip_ "This test requires a 64 bit system"
+ ;;
+ esac
+}
diff --git a/tests/t0210-gpt-resized-partition-entry-array.sh b/tests/t0210-gpt-resized-partition-entry-array.sh
index 512f342..86fb8ce 100755
--- a/tests/t0210-gpt-resized-partition-entry-array.sh
+++ b/tests/t0210-gpt-resized-partition-entry-array.sh
@@ -19,10 +19,8 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../parted $srcdir
require_perl_digest_crc_
-# gpt-header-munge will fail on big-endian systems
-if test $(uname -m) != x86_64; then
- skip_ 'this test only works on little-endian systems'
-fi
+# gpt-header-munge won't work on 32bit systems
+require_64bit_
ss=$sector_size_
diff --git a/tests/t0211-gpt-rewrite-header.sh b/tests/t0211-gpt-rewrite-header.sh
index a87e753..ee33e43 100644
--- a/tests/t0211-gpt-rewrite-header.sh
+++ b/tests/t0211-gpt-rewrite-header.sh
@@ -23,10 +23,8 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../parted $srcdir
require_perl_digest_crc_
-# gpt-header-munge will fail on big-endian systems
-if test $(uname -m) != x86_64; then
- skip_ 'this test only works on little-endian systems'
-fi
+# gpt-header-munge won't work on 32bit systems
+require_64bit_
ss=$sector_size_
--
1.9.3

View File

@ -1,50 +0,0 @@
From fcf8dc3741c27602c64e5c4164ac26eca17ed5f3 Mon Sep 17 00:00:00 2001
From: Ming Liu <ming.liu@windriver.com>
Date: Sat, 16 Feb 2013 10:16:20 +0800
Subject: [PATCH 088/131] libparted: fix several integer overflows with dvh
labels
Integer overflows was found in libparted/labels/dvh.c, while attemptting
assign unsigned int values to int types in some places.
Defined by unsigned int instead.
* libparted/labels/dvh.h: Change int to unsigned int
Signed-off-by: Ming Liu <ming.liu@windriver.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/labels/dvh.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libparted/labels/dvh.h b/libparted/labels/dvh.h
index 4c25c99..7e7fae7 100644
--- a/libparted/labels/dvh.h
+++ b/libparted/labels/dvh.h
@@ -112,8 +112,8 @@ struct device_parameters {
struct volume_directory {
char vd_name[VDNAMESIZE]; /* name */
- int vd_lbn; /* logical block number */
- int vd_nbytes; /* file length in bytes */
+ unsigned int vd_lbn; /* logical block number */
+ unsigned int vd_nbytes; /* file length in bytes */
};
/*
@@ -125,9 +125,9 @@ struct volume_directory {
* NOTE: pt_firstlbn SHOULD BE CYLINDER ALIGNED
*/
struct partition_table { /* one per logical partition */
- int pt_nblks; /* # of logical blks in partition */
- int pt_firstlbn; /* first lbn of partition */
- int pt_type; /* use of partition */
+ unsigned int pt_nblks; /* # of logical blks in partition */
+ unsigned int pt_firstlbn; /* first lbn of partition */
+ int pt_type; /* use of partition */
};
#define PTYPE_VOLHDR 0 /* partition is volume header */
--
1.9.3

View File

@ -1,52 +0,0 @@
From bb181a7ec46f2820368359b7aba0917be089e0c5 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 14 Apr 2014 15:04:17 -0700
Subject: [PATCH 089/131] tests: Use force for xfs in t1700 and a larger file
Also use sparse files that are (with 512B blocks) 128M so that they are
large enough for all the filesystems.
* tests/t1700-probe-fs.sh: Make changes.
---
tests/t1700-probe-fs.sh | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tests/t1700-probe-fs.sh b/tests/t1700-probe-fs.sh
index 0418e73..08ec7d9 100755
--- a/tests/t1700-probe-fs.sh
+++ b/tests/t1700-probe-fs.sh
@@ -21,17 +21,19 @@ require_512_byte_sector_size_
dev=loop-file
ss=$sector_size_
+n_sectors=$((257*1024))
for type in ext2 ext3 ext4 btrfs xfs nilfs2; do
( mkfs.$type -V ) >/dev/null 2>&1 \
|| { warn_ "$ME: no $type support"; continue; }
- case $type in ext*) n_sectors=8000 force=-F;;
- *) n_sectors=$((257*1024)) force=;; esac
+ case $type in ext*) force=-F;;
+ xfs) force=-f;;
+ *) force=;; esac
# create an $type file system
- dd if=/dev/zero of=$dev bs=$ss count=$n_sectors >/dev/null || fail=1
+ dd if=/dev/null of=$dev bs=$ss count=$n_sectors >/dev/null || fail=1
mkfs.$type $force $dev || { warn_ $ME: mkfs.$type failed; fail=1; continue; }
# probe the $type file system
@@ -43,7 +45,7 @@ done
# Some features should indicate ext4 by themselves.
for feature in uninit_bg flex_bg; do
# create an ext3 file system
- dd if=/dev/zero of=$dev bs=1024 count=4096 >/dev/null || fail=1
+ dd if=/dev/null of=$dev bs=1024 count=4096 >/dev/null || fail=1
mkfs.ext3 -F $dev >/dev/null || skip_ "mkfs.ext3 failed"
# set the feature
--
1.9.3

View File

@ -1,37 +0,0 @@
From 33fdfa0f29d0d9c0135da6da80e6953d8f509b7b Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 17 Apr 2014 12:12:29 -0700
Subject: [PATCH 090/131] tests: t1700 change count to seek
Fix a typo when changing to sparse images.
* tests/t1700-probe-fs.sh: count should be seek.
---
tests/t1700-probe-fs.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/t1700-probe-fs.sh b/tests/t1700-probe-fs.sh
index 08ec7d9..bf6ad9c 100755
--- a/tests/t1700-probe-fs.sh
+++ b/tests/t1700-probe-fs.sh
@@ -33,7 +33,7 @@ for type in ext2 ext3 ext4 btrfs xfs nilfs2; do
*) force=;; esac
# create an $type file system
- dd if=/dev/null of=$dev bs=$ss count=$n_sectors >/dev/null || fail=1
+ dd if=/dev/null of=$dev bs=$ss seek=$n_sectors >/dev/null || fail=1
mkfs.$type $force $dev || { warn_ $ME: mkfs.$type failed; fail=1; continue; }
# probe the $type file system
@@ -45,7 +45,7 @@ done
# Some features should indicate ext4 by themselves.
for feature in uninit_bg flex_bg; do
# create an ext3 file system
- dd if=/dev/null of=$dev bs=1024 count=4096 >/dev/null || fail=1
+ dd if=/dev/null of=$dev bs=1024 seek=4096 >/dev/null || fail=1
mkfs.ext3 -F $dev >/dev/null || skip_ "mkfs.ext3 failed"
# set the feature
--
1.9.3

View File

@ -1,28 +0,0 @@
From d1ca2a5eacc2de4b9f755c10fcf8b14e6c1d2dc1 Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Fri, 18 Apr 2014 11:01:03 -0400
Subject: [PATCH 091/131] libparted: remove last_usable_if_grown
Commit 3398e82a: "libparted: Use common function to calculate PTE sectors"
removed usage of the last_usable_if_grown variable, resulting in an error
because it is now unused but still defined.
---
libparted/labels/gpt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 6eff38a..5c8df59 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -723,7 +723,7 @@ _parse_header (PedDisk *disk, const GuidPartitionTableHeader_t *gpt,
GPTDiskData *gpt_disk_data = disk->disk_specific;
PedSector first_usable;
PedSector last_usable;
- PedSector last_usable_if_grown, last_usable_min_default;
+ PedSector last_usable_if_grown;
static int asked_already;
#ifndef DISCOVER_ONLY
--
1.9.3

View File

@ -1,29 +0,0 @@
From 60d7ceec9cbabbf114bb05b391f355fdbe418571 Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Fri, 18 Apr 2014 12:29:57 -0400
Subject: [PATCH 092/131] tests: fix t1700
bb181a7e: "tests: Use force for xfs in t1700 and a larger file" caused
the previous filesystem signatures to be left in the image file
causing mkfs.nilfs2 to complain that there is already an xfs filesystem
there, and hang the test suite waiting for an answer to proceed or not.
Remove the file between filesystems so it is recreated cleanly again.
---
tests/t1700-probe-fs.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/t1700-probe-fs.sh b/tests/t1700-probe-fs.sh
index bf6ad9c..2ba2f95 100755
--- a/tests/t1700-probe-fs.sh
+++ b/tests/t1700-probe-fs.sh
@@ -39,6 +39,7 @@ for type in ext2 ext3 ext4 btrfs xfs nilfs2; do
# probe the $type file system
parted -m -s $dev u s print >out 2>&1 || fail=1
grep '^1:.*:'$type'::;$' out || { cat out; fail=1; }
+ rm $dev
done
--
1.9.3

View File

@ -1,45 +0,0 @@
From d0a4cc1b57750a92afb48b229e4791154afa322b Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Sat, 29 Mar 2014 16:29:06 -0400
Subject: [PATCH 093/131] tests: fix t2310-dos-extended-2-sector-min-offset.sh
This test was ignoring the requested sector size and always using
512 bytes per sector. Fix it to use the requested sector size.
---
tests/t2310-dos-extended-2-sector-min-offset.sh | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/tests/t2310-dos-extended-2-sector-min-offset.sh b/tests/t2310-dos-extended-2-sector-min-offset.sh
index f74cba5..53843ab 100644
--- a/tests/t2310-dos-extended-2-sector-min-offset.sh
+++ b/tests/t2310-dos-extended-2-sector-min-offset.sh
@@ -23,7 +23,8 @@ require_root_
require_scsi_debug_module_
# create memory-backed device
-scsi_debug_setup_ dev_size_mb=1 > dev-name ||
+ss=$sector_size_
+scsi_debug_setup_ sector_size=$ss dev_size_mb=1 > dev-name ||
skip_ 'failed to create scsi_debug device'
scsi_dev=$(cat dev-name)
p1=${scsi_dev}1
@@ -31,15 +32,11 @@ p5=${scsi_dev}5
cat <<EOF > exp || framework_failure
BYT;
-$scsi_dev:2048s:scsi:512:512:msdos:Linux scsi_debug:;
+$scsi_dev:$((2048*512/$ss))s:scsi:$ss:$ss:msdos:Linux scsi_debug:;
1:64s:128s:65s:::lba;
5:65s:128s:64s:::;
EOF
-cat <<EOF > err.exp || framework_failure
-Error: Partition(s) 5 on $scsi_dev have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.
-EOF
-
# Create a DOS label with an extended partition starting at sector 64.
parted -s $scsi_dev mklabel msdos || fail=1
parted --align=min -s $scsi_dev mkpart extended 64s 128s> out 2>&1 || fail=1
--
1.9.3

File diff suppressed because it is too large Load Diff

View File

@ -1,197 +0,0 @@
From f70ff1fc474764c3a71318ddb4e0d26afc52ac47 Mon Sep 17 00:00:00 2001
From: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
Date: Wed, 21 Aug 2013 16:09:56 -0700
Subject: [PATCH 095/131] libparted: add support for implicit FBA DASD
partitions
Fixed Block Access (FBA) DASDs are mainframe-specific disk devices
which are layed out as a sequence of 512-byte sectors. In contrast
to ECKD DASDs, these disks do not require formatting and resemble
the LBA layout of non-mainframe disks. Despite this resemblance,
the Linux kernel applies special handling during partition detection
for FBA DASDs, resulting in a single, immutable partition being
reported.
While actual FBA DASD hardware is no longer available, the z/VM
hypervisor can simulate FBA DASD disks, backed by either ECKD or
SCSI devices.
This patch adds support for recognizing FBA DASD partitions
to parted.
Signed-off-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
---
include/parted/fdasd.in.h | 2 ++
libparted/labels/dasd.c | 63 ++++++++++++++++++++++++++++++++++++++++-------
libparted/labels/fdasd.c | 5 ++++
3 files changed, 61 insertions(+), 9 deletions(-)
diff --git a/include/parted/fdasd.in.h b/include/parted/fdasd.in.h
index ac30134..a755246 100644
--- a/include/parted/fdasd.in.h
+++ b/include/parted/fdasd.in.h
@@ -194,6 +194,8 @@ typedef struct fdasd_anchor {
volume_label_t *vlabel;
config_data_t confdata[USABLE_PARTITIONS];
struct fdasd_hd_geometry geo;
+ unsigned int label_block;
+ unsigned int FBA_layout;
} fdasd_anchor_t;
enum offset {lower, upper};
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index a769866..b4e80b1 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -71,6 +71,7 @@ typedef struct {
typedef struct {
unsigned int format_type;
+ unsigned int label_block;
volume_label_t vlabel;
} DasdDiskSpecific;
@@ -151,6 +152,7 @@ dasd_alloc (const PedDevice* dev)
/* CDL format, newer */
disk_specific->format_type = 2;
+ disk_specific->label_block = 2;
/* Setup volume label (for fresh disks) */
snprintf(volser, sizeof(volser), "0X%04X", arch_specific->devno);
@@ -226,7 +228,9 @@ dasd_probe (const PedDevice *dev)
fdasd_check_api_version(&anchor, arch_specific->fd);
- if (fdasd_check_volume(&anchor, arch_specific->fd))
+ /* Labels are required on CDL formatted DASDs. */
+ if (fdasd_check_volume(&anchor, arch_specific->fd) &&
+ anchor.FBA_layout == 0)
goto error_cleanup;
fdasd_cleanup(&anchor);
@@ -273,17 +277,53 @@ dasd_read (PedDisk* disk)
fdasd_initialize_anchor(&anchor);
fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd);
+ disk_specific->label_block = anchor.label_block;
+
+ if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE)
+ anchor.big_disk++;
/* check dasd for labels and vtoc */
- if (fdasd_check_volume(&anchor, arch_specific->fd))
- goto error_close_dev;
+ if (fdasd_check_volume(&anchor, arch_specific->fd)) {
+ DasdPartitionData* dasd_data;
+
+ /* Kernel partitioning code will report 'implicit' partitions
+ * for non-CDL format DASDs even when there is no
+ * label/VTOC. */
+ if (anchor.FBA_layout == 0)
+ goto error_close_dev;
+
+ disk_specific->format_type = 1;
+
+ /* Register implicit partition */
+ ped_disk_delete_all (disk);
+
+ start = (PedSector) arch_specific->real_sector_size /
+ (PedSector) disk->dev->sector_size *
+ (PedSector) (anchor.label_block + 1);
+ end = disk->dev->length - 1;
+ part = ped_partition_new (disk, PED_PARTITION_NORMAL, NULL,
+ start, end);
+ if (!part)
+ goto error_close_dev;
+
+ part->num = 1;
+ part->fs_type = ped_file_system_probe (&part->geom);
+ dasd_data = part->disk_specific;
+ dasd_data->raid = 0;
+ dasd_data->lvm = 0;
+ dasd_data->type = 0;
+
+ if (!ped_disk_add_partition (disk, part, NULL))
+ goto error_close_dev;
+
+ fdasd_cleanup(&anchor);
+
+ return 1;
+ }
/* Save volume label (read by fdasd_check_volume) for writing */
memcpy(&disk_specific->vlabel, anchor.vlabel, sizeof(volume_label_t));
- if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE)
- anchor.big_disk++;
-
ped_disk_delete_all (disk);
bool is_ldl = strncmp(anchor.vlabel->volkey,
@@ -348,7 +388,7 @@ dasd_read (PedDisk* disk)
/ (long long) disk->dev->sector_size
* (long long) (cms_ptr->block_count - 1) - 1;
- part = ped_partition_new (disk, PED_PARTITION_PROTECTED, NULL, start, end);
+ part = ped_partition_new (disk, PED_PARTITION_NORMAL, NULL, start, end);
if (!part)
goto error_close_dev;
@@ -923,7 +963,12 @@ dasd_alloc_metadata (PedDisk* disk)
the start of the first partition */
if (disk_specific->format_type == 1) {
part = ped_disk_get_partition(disk, 1);
- vtoc_end = part->geom.start - 1;
+ if (part)
+ vtoc_end = part->geom.start - 1;
+ else
+ vtoc_end = (PedSector) arch_specific->real_sector_size /
+ (PedSector) disk->dev->sector_size *
+ (PedSector) disk_specific->label_block;
}
else {
if (disk->dev->type == PED_DEVICE_FILE)
@@ -943,7 +988,7 @@ dasd_alloc_metadata (PedDisk* disk)
goto error;
}
- if (disk_specific->format_type == 1) {
+ if (disk_specific->format_type == 1 && part) {
/*
For LDL or CMS there may be trailing metadata as well.
For example: the last block of a CMS reserved file,
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index e235dd3..f92065f 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -721,6 +721,7 @@ fdasd_check_volume (fdasd_anchor_t *anc, int fd)
unsigned long b = -1;
char str[LINE_LENGTH];
+ memset(v, 0, sizeof(volume_label_t));
vtoc_read_volume_label (fd, anc->label_pos, v);
if (strncmp(v->vollbl, vtoc_ebcdic_enc ("VOL1", str, 4), 4) == 0) {
@@ -800,6 +801,8 @@ fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f)
dasd_info.dev_type = 13200;
dasd_info.label_block = 2;
dasd_info.devno = 513;
+ dasd_info.label_block = 2;
+ dasd_info.FBA_layout = 0;
} else {
if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0)
fdasd_error(anc, unable_to_ioctl,
@@ -820,6 +823,8 @@ fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f)
anc->label_pos = dasd_info.label_block * blksize;
anc->devno = dasd_info.devno;
anc->fspace_trk = anc->geo.cylinders * anc->geo.heads - FIRST_USABLE_TRK;
+ anc->label_block = dasd_info.label_block;
+ anc->FBA_layout = dasd_info.FBA_layout;
}
/*
--
1.9.3

File diff suppressed because it is too large Load Diff

View File

@ -1,159 +0,0 @@
From 95649fc7d025a68074c8a00581bd24d2bd7751bc Mon Sep 17 00:00:00 2001
From: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
Date: Wed, 21 Aug 2013 16:36:08 -0700
Subject: [PATCH 097/131] libparted: mklabel to support EAV DASD
Extended Address Volume (EAV) DASDs are ECKD DASDs with more than
65520 cylinders. This patch adds support for mklabel to properly
handle unformatted EAV DASDs.
Signed-off-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
---
include/parted/fdasd.in.h | 1 -
libparted/labels/fdasd.c | 92 +++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 90 insertions(+), 3 deletions(-)
diff --git a/include/parted/fdasd.in.h b/include/parted/fdasd.in.h
index b4e7dd1..3692596 100644
--- a/include/parted/fdasd.in.h
+++ b/include/parted/fdasd.in.h
@@ -288,7 +288,6 @@ void fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int fd);
void fdasd_check_api_version (fdasd_anchor_t *anc, int fd);
int fdasd_check_volume (fdasd_anchor_t *anc, int fd);
int fdasd_write_labels (fdasd_anchor_t *anc, int fd);
-int fdasd_invalid_vtoc_pointer(fdasd_anchor_t *anc);
void fdasd_recreate_vtoc(fdasd_anchor_t *anc);
partition_info_t * fdasd_add_partition (fdasd_anchor_t *anc,
unsigned int start, unsigned int stop);
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index 2735b2a..b58b2be 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -581,6 +581,22 @@ fdasd_recreate_vtoc (fdasd_anchor_t *anc)
anc->vtoc_changed++;
}
+ /*
+ * initialize the VOL1 volume label
+ */
+static void
+fdasd_init_volume_label(fdasd_anchor_t *anc, int fd)
+{
+ volume_label_t *vlabel = anc->vlabel;
+
+ vtoc_volume_label_init(vlabel);
+ vtoc_volume_label_set_key(vlabel, "VOL1");
+ vtoc_volume_label_set_label(vlabel, "VOL1");
+
+ vtoc_set_cchhb(&vlabel->vtoc, VTOC_START_CC, VTOC_START_HH, 0x01);
+}
+
+
/*
* sets some important partition data
* (like used, start_trk, end_trk, len_trk)
@@ -769,6 +785,52 @@ fdasd_process_valid_vtoc (fdasd_anchor_t * anc, unsigned long b, int fd)
fdasd_update_partition_info (anc);
}
+static void
+fdasd_invalid_vtoc_pointer(fdasd_anchor_t *anc)
+{
+ PDEBUG
+ anc->formatted_cylinders = anc->hw_cylinders;
+ anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
+ - FIRST_USABLE_TRK;
+ vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS,
+ anc->geo.cylinders, anc->formatted_cylinders,
+ anc->geo.heads, anc->geo.sectors,
+ anc->blksize, anc->dev_type);
+
+ vtoc_init_format5_label(anc->f5);
+ vtoc_init_format7_label(anc->f7);
+
+ vtoc_set_freespace(anc->f4, anc->f5, anc->f7, '+', anc->verbose,
+ FIRST_USABLE_TRK,
+ anc->formatted_cylinders * anc->geo.heads - 1,
+ anc->formatted_cylinders, anc->geo.heads);
+
+ vtoc_set_cchhb(&anc->vlabel->vtoc, VTOC_START_CC, VTOC_START_HH, 0x01);
+}
+
+/*
+ * we have a invalid FMT4 DSCB and therefore we will re-create the VTOC
+ */
+static void
+fdasd_process_invalid_vtoc(fdasd_anchor_t *anc)
+{
+ anc->formatted_cylinders = anc->hw_cylinders;
+ anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
+ - FIRST_USABLE_TRK;
+ vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS,
+ anc->geo.cylinders, anc->formatted_cylinders,
+ anc->geo.heads, anc->geo.sectors,
+ anc->blksize, anc->dev_type);
+
+ vtoc_init_format5_label(anc->f5);
+ vtoc_init_format7_label(anc->f7);
+ vtoc_set_freespace(anc->f4, anc->f5, anc->f7, '+', anc->verbose,
+ FIRST_USABLE_TRK,
+ anc->formatted_cylinders * anc->geo.heads - 1,
+ anc->formatted_cylinders, anc->geo.heads);
+}
+
+
static int
fdasd_valid_vtoc_pointer(fdasd_anchor_t *anc, unsigned long b, int fd)
{
@@ -781,6 +843,8 @@ fdasd_valid_vtoc_pointer(fdasd_anchor_t *anc, unsigned long b, int fd)
if (anc->f4->DS4IDFMT == 0xf4) {
fdasd_process_valid_vtoc (anc, b, fd);
return 0;
+ } else {
+ fdasd_process_invalid_vtoc(anc);
}
if (strncmp(anc->vlabel->volkey, vtoc_ebcdic_enc("LNX1",str,4),4) == 0 ||
strncmp(anc->vlabel->volkey, vtoc_ebcdic_enc("CMS1",str,4),4) == 0)
@@ -817,13 +881,37 @@ fdasd_check_volume (fdasd_anchor_t *anc, int fd)
else
return 0;
} else {
- return 1;
+ fdasd_invalid_vtoc_pointer(anc);
}
} else if (strncmp (v->volkey, vtoc_ebcdic_enc ("LNX1", str, 4), 4) == 0 ||
strncmp (v->volkey, vtoc_ebcdic_enc ("CMS1", str, 4), 4) == 0) {
return 0;
- }
+ } else if (anc->FBA_layout == 1) {
+ /* Some times LDL formatted disks does not
+ contain any volume label */
+ return 1;
+ } else {
+ /* didn't find VOL1 volume label */
+ anc->formatted_cylinders = anc->hw_cylinders;
+ anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
+ - FIRST_USABLE_TRK;
+
+ fdasd_init_volume_label(anc, fd);
+ vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS,
+ anc->geo.cylinders, anc->formatted_cylinders,
+ anc->geo.heads, anc->geo.sectors,
+ anc->blksize, anc->dev_type);
+
+ vtoc_init_format5_label(anc->f5);
+ vtoc_init_format7_label(anc->f7);
+
+ vtoc_set_freespace(anc->f4, anc->f5, anc->f7, '+',
+ anc->verbose, FIRST_USABLE_TRK,
+ anc->formatted_cylinders * anc->geo.heads - 1,
+ anc->formatted_cylinders, anc->geo.heads);
+ return 0;
+ }
return 1;
}
--
1.9.3

View File

@ -1,68 +0,0 @@
From 0673dabee6f5b19317b0d85e399e9f876a2c2ea7 Mon Sep 17 00:00:00 2001
From: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
Date: Wed, 21 Aug 2013 16:37:17 -0700
Subject: [PATCH 098/131] libparted: Avoid dasd as default disk type while
probe
This patch avoids setting 'dasd' as a default disk type for
'disk image file' at the time of probe.
Signed-off-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
---
include/parted/fdasd.in.h | 1 +
libparted/labels/fdasd.c | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/parted/fdasd.in.h b/include/parted/fdasd.in.h
index 3692596..6f6a7e0 100644
--- a/include/parted/fdasd.in.h
+++ b/include/parted/fdasd.in.h
@@ -261,6 +261,7 @@ typedef struct fdasd_anchor {
struct fdasd_hd_geometry geo;
unsigned int label_block;
unsigned int FBA_layout;
+ bool is_file;
} fdasd_anchor_t;
enum offset {lower, upper};
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index b58b2be..7de5f34 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -301,6 +301,7 @@ fdasd_initialize_anchor (fdasd_anchor_t * anc)
}
anc->hw_cylinders = 0;
anc->formatted_cylinders = 0;
+ anc->is_file = 0;
}
/*
@@ -890,7 +891,7 @@ fdasd_check_volume (fdasd_anchor_t *anc, int fd)
/* Some times LDL formatted disks does not
contain any volume label */
return 1;
- } else {
+ } else if (! anc->is_file) {
/* didn't find VOL1 volume label */
anc->formatted_cylinders = anc->hw_cylinders;
anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
@@ -974,6 +975,7 @@ fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f)
dasd_info.FBA_layout = 0;
anc->hw_cylinders = ((st.st_size / blksize) / anc->geo.sectors) /
anc->geo.heads;
+ anc->is_file = 1;
} else {
if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0)
fdasd_error(anc, unable_to_ioctl,
@@ -995,6 +997,8 @@ fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f)
anc->hw_cylinders = characteristics->long_no_cyl;
else
anc->hw_cylinders = characteristics->no_cyl;
+
+ anc->is_file = 0;
}
anc->dev_type = dasd_info.dev_type;
--
1.9.3

View File

@ -1,56 +0,0 @@
From bdb439f660344404f27084c48fe7b9429436b9e9 Mon Sep 17 00:00:00 2001
From: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
Date: Wed, 21 Aug 2013 16:37:17 -0700
Subject: [PATCH 099/131] libparted: mklabel to support EDEV DASD
Fixed Block Access (FBA) DASDs are mainframe-specific disk devices
which are layed out as a sequence of 512-byte sectors. This patch adds
support for mklabel to properly handle FBA devices.
Signed-off-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
---
libparted/labels/fdasd.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index 7de5f34..1f87937 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -870,19 +870,21 @@ fdasd_check_volume (fdasd_anchor_t *anc, int fd)
vtoc_read_volume_label (fd, anc->label_pos, v);
if (strncmp(v->vollbl, vtoc_ebcdic_enc ("VOL1", str, 4), 4) == 0) {
- /* found VOL1 volume label */
- b = (cchhb2blk (&v->vtoc, &anc->geo) - 1) * anc->blksize;
-
- if (b > 0) {
- int rc;
- rc = fdasd_valid_vtoc_pointer (anc, b, fd);
-
- if (rc < 0)
- return 1;
- else
- return 0;
- } else {
- fdasd_invalid_vtoc_pointer(anc);
+ if (anc->FBA_layout != 1 ) {
+ /* found VOL1 volume label */
+ b = (cchhb2blk (&v->vtoc, &anc->geo) - 1) * anc->blksize;
+
+ if (b > 0) {
+ int rc;
+ rc = fdasd_valid_vtoc_pointer (anc, b, fd);
+
+ if (rc < 0)
+ return 1;
+ else
+ return 0;
+ } else {
+ fdasd_invalid_vtoc_pointer(anc);
+ }
}
} else if (strncmp (v->volkey, vtoc_ebcdic_enc ("LNX1", str, 4), 4) == 0 ||
strncmp (v->volkey, vtoc_ebcdic_enc ("CMS1", str, 4), 4) == 0) {
--
1.9.3

Some files were not shown because too many files have changed in this diff Show More