- Rebase on new upstream master commit cc382c3

- Drop patches incorporated into upstream
- Still adds the various DASD patches
This commit is contained in:
Brian C. Lane 2014-03-24 17:09:24 -07:00
parent 191b34d33b
commit 0b7af917e2
93 changed files with 3307 additions and 381 deletions

View File

@ -1,7 +1,7 @@
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 01/69] maint: post-release administrivia
Subject: [PATCH 01/89] maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
@ -46,5 +46,5 @@ index ba8ba77..c6a00c8 100644
include $(srcdir)/dist-check.mk
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 02/69] libparted: check PMBR before GPT partition table
Subject: [PATCH 02/89] 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,
@ -96,5 +96,5 @@ index 84bdc12..91ad71a 100644
static PedDisk *
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 03/69] tests: add t0301-overwrite-gpt-pmbr.sh
Subject: [PATCH 03/89] tests: add t0301-overwrite-gpt-pmbr.sh
Make sure parted checks the PMBR before the GPT partition table.
@ -94,5 +94,5 @@ index 0000000..e7edb66
+
+Exit $fail
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 04/69] tests: remove bogus envvar setting from
Subject: [PATCH 04/89] tests: remove bogus envvar setting from
t0300-dos-on-gpt.sh
* tests/t0300-dos-on-gpt.sh: Remove envvar setting that effectively
@ -33,5 +33,5 @@ index 41bc391..fbe8d7c 100755
# create a GPT partition table
parted -s $dev mklabel gpt > out 2>&1 || fail=1
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 05/69] gpt: fix endianness bug in
Subject: [PATCH 05/89] gpt: fix endianness bug in
gpt_get_max_supported_partition_count
* libparted/labels/gpt.c (gpt_get_max_supported_partition_count):
@ -47,5 +47,5 @@ index 91ad71a..6032e3f 100644
pth_free (pth);
return true;
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 06/69] tests: add a test to exercise just-fixed code
Subject: [PATCH 06/89] 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.
@ -106,5 +106,5 @@ index 0570585..ca10d17 100755
done
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 07/69] maint: avoid new syntax-check failure re @xref
Subject: [PATCH 07/89] maint: avoid new syntax-check failure re @xref
* doc/parted.texi: Adjust @xref usage: it must be used only
at start of sentence.
@ -47,5 +47,5 @@ index 6561d0e..1601151 100644
If you don't give a parameter to a command, Parted will prompt you for it.
For example:
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 08/69] maint: don't prohibit strncpy just yet
Subject: [PATCH 08/89] 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.
@ -24,5 +24,5 @@ index 45d2ac2..3d3014c 100644
sc_require_test_exit_idiom \
sc_space_tab \
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 09/69] build: update gnulib, bootstrap and init.sh
Subject: [PATCH 09/89] build: update gnulib, bootstrap and init.sh
---
bootstrap | 267 ++++++++++++++++++++++++++++++++++++++--------------------
@ -572,5 +572,5 @@ index ae86714..5f6e638 100644
# As autoconf-generated configure scripts do, ensure that IFS
# is defined initially, so that saving and restoring $IFS works.
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 10/69] build: prefer $(AM_CPPFLAGS) over $(INCLUDES)
Subject: [PATCH 10/89] 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
@ -82,5 +82,5 @@ index dbe2c9f..c0304a0 100644
-INCLUDES = $(partedincludedir) $(INTLINCS)
+AM_CPPFLAGS = $(partedincludedir) $(INTLINCS)
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 11/69] build: don't list files with unknown suffix in _SOURCES
Subject: [PATCH 11/89] 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
@ -43,5 +43,5 @@ index ec8abeb..f4e4d27 100644
mv $@-tmp $@
+EXTRA_DIST += pt-limit.gperf
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 12/69] build: prefer pattern rules over suffix rules
Subject: [PATCH 12/89] 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
@ -32,5 +32,5 @@ index 19236f0..6f808c6 100644
$(AM_V_at)perl -p \
-e '$(subst_const_attr);' \
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 13/69] build: enable subdir-objects Automake option globally
Subject: [PATCH 13/89] 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
@ -49,5 +49,5 @@ index 7fe364a..064f11a 100644
AM_CFLAGS = $(WARN_CFLAGS)
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 14/69] tests: prefer AM_TESTS_ENVIRONMENT over
Subject: [PATCH 14/89] tests: prefer AM_TESTS_ENVIRONMENT over
TESTS_ENVIRONMENT
The latter should be reserved for user overrides.
@ -28,5 +28,5 @@ index 1264812..33e8f8e 100644
TMPDIR=$$tmp__; export TMPDIR; \
export \
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 15/69] tests: remove unused AM_TESTS_ENVIRONMENT entries
Subject: [PATCH 15/89] 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.
@ -37,5 +37,5 @@ index 33e8f8e..c97400b 100644
VERSION=$(VERSION) \
; 9>&2
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 16/69] build: require Automake >= 1.11.6
Subject: [PATCH 16/89] 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
@ -47,5 +47,5 @@ index 49ef75c..832fc20 100644
AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 17/69] maint: make Autoconf version requirement consistent
Subject: [PATCH 17/89] 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
@ -25,5 +25,5 @@ index 39a5506..a5d5910 100644
autopoint -
bc -
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 18/69] maint: tighten per version requirement
Subject: [PATCH 18/89] 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
@ -26,5 +26,5 @@ index a5d5910..7f4ee53 100644
tar -
"
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 19/69] maint: remove unnecessary wcslen use
Subject: [PATCH 19/89] maint: remove unnecessary wcslen use
* parted/strlist.c (gettext_to_wchar): Tighten up test for
mbsrtowcs failure and remove unnecessary wcslen use.
@ -27,5 +27,5 @@ index d34fb56..1f90c0e 100644
error:
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 20/69] tests: clarify a comment: _reading_ gpt tables on tiny
Subject: [PATCH 20/89] tests: clarify a comment: _reading_ gpt tables on tiny
devices
* tests/t0203-gpt-tiny-device-abort.sh: Clarify.
@ -23,5 +23,5 @@ index 7283c55..bf281ff 100644
# Copyright (C) 2009-2012 Free Software Foundation, Inc.
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 21/69] gpt: require first_usable_LBA <= last_usable_LBA
Subject: [PATCH 21/89] 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.
@ -27,5 +27,5 @@ index 6032e3f..83e518f 100644
gpt->HeaderCRC32 = 0;
if (pth_crc32 (dev, gpt, &crc) != 0)
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 22/69] tests: update t7000-scripting.sh to avoid new FP
Subject: [PATCH 22/89] 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.
@ -34,5 +34,5 @@ index e64814b..859acda 100755
# We have to format the output before comparing.
# normalize the actual output
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 23/69] gpt: permit "mklabel gpt" on a 67-sector device
Subject: [PATCH 23/89] 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.
@ -33,5 +33,5 @@ index 83e518f..564a889 100644
disk->disk_specific = gpt_disk_data = ped_malloc (sizeof (GPTDiskData));
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 24/69] gpt: when "mklabel gpt" fails, always provide a
Subject: [PATCH 24/89] gpt: when "mklabel gpt" fails, always provide a
diagnostic
* libparted/labels/gpt.c (gpt_alloc): When rejecting a device because
@ -34,5 +34,5 @@ index 564a889..63b30b9 100644
disk->disk_specific = gpt_disk_data = ped_malloc (sizeof (GPTDiskData));
if (!disk->disk_specific)
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 25/69] tests: show that small dev now evokes "mklabel gpt"
Subject: [PATCH 25/89] tests: show that small dev now evokes "mklabel gpt"
diagnostic
* tests/t0203-gpt-create-on-min-sized-device.sh: New test.
@ -78,5 +78,5 @@ index 0000000..113e191
+
+Exit $fail
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 26/69] tests: avoid syntax-check failure for reversed compare
Subject: [PATCH 26/89] tests: avoid syntax-check failure for reversed compare
args
* tests/t0203-gpt-create-on-min-sized-device.sh: Reverse args,
@ -23,5 +23,5 @@ index 113e191..4cec64c 100644
Exit $fail
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 27/69] mac: don't let larger partition-table-specified block
Subject: [PATCH 27/89] 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
@ -74,5 +74,5 @@ index 1f59a1a..2485187 100644
void *raw_part = buf;
if (!ped_device_read (disk->dev, raw_part,
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 28/69] tests: mac: exercise the just-fixed bug
Subject: [PATCH 28/89] tests: mac: exercise the just-fixed bug
* tests/t0350-mac-PT-increases-sector-size.sh: New test.
* tests/Makefile.am (TESTS): Add it.
@ -79,5 +79,5 @@ index 0000000..2dbd8cd
+
+Exit $fail
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 29/69] add support for a new Linux-specific GPT partition type
Subject: [PATCH 29/89] add support for a new Linux-specific GPT partition type
code
* NEWS: Describe the new Linux-specific partition type code
@ -329,5 +329,5 @@ index d522aec..bd14c84 100755
compare /dev/null err || fail=1
parted -s $dev name $i $type > err 2>&1 || fail=1
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 30/69] tests: clean up tests
Subject: [PATCH 30/89] tests: clean up tests
Use warn_ and $ME_ in place of warn and $ME; remove definitions of
the latter two. Remove unused code.
@ -337,5 +337,5 @@ index b3618a7..f0830f0 100644
Exit $fail
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 31/69] doc: libparted/disk.c: correct doxygen comment typo
Subject: [PATCH 31/89] doc: libparted/disk.c: correct doxygen comment typo
* libparted/disk.c: s/PedPartition/PedDisk/
Copyright-paperwork-exempt: yes
@ -23,5 +23,5 @@ index c4b1a01..d283674 100644
* \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.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 32/69] tests: stop using private "dev" directory for losetup
Subject: [PATCH 32/89] 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.
@ -43,5 +43,5 @@ index 9cee155..cf1b8b8 100644
echo "$dev"
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 33/69] maint: fix an error in the preceding commit log
Subject: [PATCH 33/89] 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
@ -55,5 +55,5 @@ index 0000000..e2a68ee
+# Fix the log message:
+s,stderr,/dev/null,
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 34/69] tests: improve test for partitionable loop devices
Subject: [PATCH 34/89] tests: improve test for partitionable loop devices
* tests/init.cfg (require_partitionable_loop_device_): Skip
when cat fails.
@ -26,5 +26,5 @@ index 24b10bc..dc8b2bc 100644
}
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 35/69] tests: t8001: do not rely on "modprobe loop"
Subject: [PATCH 35/89] 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,
@ -54,5 +54,5 @@ index deef18b..9afde4a 100755
# Expect this to succeed
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 36/69] build: do not rely on automake's AM_TESTS_ENVIRONMENT
Subject: [PATCH 36/89] 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
@ -26,5 +26,5 @@ index 80d5525..cdc1c4b 100644
TMPDIR=$$tmp__; export TMPDIR; \
export \
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 37/69] build: .gitignore: ignore tests/fs-resize
Subject: [PATCH 37/89] build: .gitignore: ignore tests/fs-resize
---
.gitignore | 1 +
@ -20,5 +20,5 @@ index 5bb95d4..c2ccd4b 100644
tests/old-init.sh
tests/print-align
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 38/69] partprobe: remove --no-update long option
Subject: [PATCH 38/89] partprobe: remove --no-update long option
It was deprecated and scheduled for removal in 2009.
* partprobe/partprobe.c (long_options): Remove "no-update" entry.
@ -24,5 +24,5 @@ index 8bccc4f..b8dca5e 100644
{"summary", no_argument, NULL, 's'},
{"help", no_argument, NULL, 'h'},
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 39/69] doc: update partprobe manpage
Subject: [PATCH 39/89] doc: update partprobe manpage
* doc/C/partprobe.8: Add long options, REPORTING BUGS section
and adjust DESCRIPTION section because it wasn't quite correct.
@ -44,5 +44,5 @@ index 6abf97d..48ae5dc 100644
.BR parted (8).
.SH AUTHOR
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 40/69] partprobe: remove partitions when there is no partition
Subject: [PATCH 40/89] partprobe: remove partitions when there is no partition
table
When partprobe detects no partition table on a device, it should
@ -63,5 +63,5 @@ index b8dca5e..0919d3f 100644
if (!ped_disk_commit_to_os (disk))
goto error_destroy_disk;
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 41/69] maint: use $(AM_V_GEN) to cut down on build noise
Subject: [PATCH 41/89] 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.
@ -61,5 +61,5 @@ index b378121..aaf4024 100644
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.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 42/69] maint: regenerate .po, .pot files
Subject: [PATCH 42/89] maint: regenerate .po, .pot files
---
doc/C/po/partprobe.8.pot | 59 ++++++++++++++++--------------
@ -333,5 +333,5 @@ index ffa47d7..4870d09 100644
+#~ msgid "B<-v>"
+#~ msgstr "B<-v>"
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 43/69] tests: cleanup losetup usage
Subject: [PATCH 43/89] 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
@ -79,5 +79,5 @@ index 490c6d2..1859ac9 100644
dmsetup_cmd="0 `blockdev --getsz $d1` linear $d1 0"
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 44/69] build: default to --enable-gcc-warnings in a git tree
Subject: [PATCH 44/89] 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
@ -30,5 +30,5 @@ index 832fc20..417f325 100644
if test "$gl_gcc_warnings" = yes; then
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 45/69] libparted: refactor device-mapper partition sync code
Subject: [PATCH 45/89] 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
@ -634,5 +634,5 @@ index 0000000..9807b40
+
+Exit $fail
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 46/69] libparted: remove extraneous blkpg add partition ped
Subject: [PATCH 46/89] libparted: remove extraneous blkpg add partition ped
exception
_blkpg_add_partition was throwing an exception if it failed to add the
@ -67,5 +67,5 @@ index 89453ae..17c777c 100644
# Create a DOS label with an extended partition starting at sector 64.
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 47/69] libparted: don't probe every dm device in probe_all
Subject: [PATCH 47/89] 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
@ -221,5 +221,5 @@ index 0000000..3cfdc43
+
+Exit $fail
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 48/69] tests: make t6003-dm-hide work reliably on F17
Subject: [PATCH 48/89] tests: make t6003-dm-hide work reliably on F17
* tests/t6003-dm-hide.sh: Adjust to work reliably on Fedora 17.
---
@ -67,5 +67,5 @@ index 3cfdc43..59baae9 100644
Exit $fail
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 49/69] doc: 1MiB-alignment is not enough for cheap flash
Subject: [PATCH 49/89] doc: 1MiB-alignment is not enough for cheap flash
drives
* doc/parted.texi: Add an example that aligns to 4GiB, and
@ -73,5 +73,5 @@ index b8db19d..008c383 100644
@end deffn
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 50/69] build: update gnulib submodule to latest
Subject: [PATCH 50/89] build: update gnulib submodule to latest
---
gnulib | 2 +-
@ -15,5 +15,5 @@ index e1abd50..164ebfe 160000
-Subproject commit e1abd50b01d6bd61bd0c996ca17378cd569c0aa1
+Subproject commit 164ebfe612d8460c15d7acf1927faef6943571b6
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
From ab9aecfc64b5a7f6ad70ea93bf76c007614220fd Mon Sep 17 00:00:00 2001
From: Jim Meyering <jim@meyering.net>
Date: Sun, 6 Jan 2013 11:08:39 +0100
Subject: [PATCH 51/69] maint: update all copyright year number ranges
Subject: [PATCH 51/89] maint: update all copyright year number ranges
Run "make update-copyright".
---
@ -2866,5 +2866,5 @@ index 04dc5c6..d73f45e 100755
# 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
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
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 52/69] maint: avoid new warning/error with gcc-4.8.0 20130105
Subject: [PATCH 52/89] 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.
@ -22,5 +22,5 @@ index fef0b53..b04eb3f 100644
gl_MANYWARN_ALL_GCC([ws])
gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
--
1.8.3.1
1.8.5.3

View File

@ -0,0 +1,158 @@
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 53/89] 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.8.5.3

View File

@ -0,0 +1,324 @@
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 54/89] 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.8.5.3

View File

@ -0,0 +1,73 @@
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 55/89] 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.8.5.3

View File

@ -0,0 +1,37 @@
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 56/89] 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.8.5.3

View File

@ -0,0 +1,75 @@
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 57/89] 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.8.5.3

View File

@ -0,0 +1,118 @@
From fab679e6ffad84f3454b73529ef0a444b1d2f7ec Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Thu, 12 Jan 2012 14:53:56 -0500
Subject: [PATCH] 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 | 18 +++++-------------
3 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/NEWS b/NEWS
index 04b905c..c884eac 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 083591f..1f1d67f 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 17c777c..f74cba5 100644
--- a/tests/t2310-dos-extended-2-sector-min-offset.sh
+++ b/tests/t2310-dos-extended-2-sector-min-offset.sh
@@ -1,10 +1,8 @@
#!/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.
+# Copyright (C) 2010-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
@@ -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.8.5.3

View File

@ -0,0 +1,458 @@
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 59/89] 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.8.5.3

View File

@ -0,0 +1,387 @@
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 60/89] 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.8.5.3

View File

@ -0,0 +1,93 @@
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 61/89] 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.8.5.3

View File

@ -0,0 +1,141 @@
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 62/89] 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.8.5.3

View File

@ -0,0 +1,28 @@
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 63/89] 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.8.5.3

View File

@ -0,0 +1,210 @@
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 64/89] 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.8.5.3

View File

@ -0,0 +1,44 @@
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 65/89] 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.8.5.3

View File

@ -0,0 +1,232 @@
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 66/89] 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.8.5.3

View File

@ -0,0 +1,98 @@
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 67/89] 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.8.5.3

View File

@ -1,7 +1,7 @@
From f29ccfe5b9639d8626db50e9f4ecbe10d6cd7736 Mon Sep 17 00:00:00 2001
From c261a9b340e2982a49e055ea6332fd0f49f3d531 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Fri, 3 Feb 2012 13:03:27 -0800
Subject: [PATCH 53/69] libparted: copy pmbr_boot when duplicating GPT disk
Date: Wed, 11 Sep 2013 12:24:51 -0700
Subject: [PATCH 68/89] libparted: copy pmbr_boot when duplicating GPT disk
* libparted/labels/gpt.c (gpt_duplicate): copy pmbr_boot flag
---
@ -9,10 +9,10 @@ Subject: [PATCH 53/69] libparted: copy pmbr_boot when duplicating GPT disk
1 file changed, 1 insertion(+)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 490de70..25490af 100644
index dce89b1..6fd8880 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -556,6 +556,7 @@ gpt_duplicate (const PedDisk *disk)
@@ -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;
@ -21,5 +21,5 @@ index 490de70..25490af 100644
}
--
1.8.3.1
1.8.5.3

View File

@ -1,35 +0,0 @@
From eee862e3c183946a2e71f7606e98eca67ab363e9 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 4 Sep 2013 11:45:44 -0700
Subject: [PATCH 69/70] libparted: Flush parent device on open (#962611)
Parted probes for filesystems using geometry offsets into the parent
device, not the partition device itself. This means it may get stale
information if a partition has just been formatted.
On kernels before 2.6 this will also flush all partition devices. On 2.6
and newer kernels it will only flush the parent device.
* libparted/arch/linux.c (linux_open): Always call _flush_cache
---
libparted/arch/linux.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 375be83..492f828 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1669,9 +1669,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.8.5.3

View File

@ -1,7 +1,7 @@
From 516c821481540ca74490ce3374eac2f801c4908d Mon Sep 17 00:00:00 2001
From d19d16357aff6bff634ad134597c0626c21496ac Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 19 Apr 2012 17:11:09 -0700
Subject: [PATCH 54/69] tests: test creating 20 device-mapper partitions
Date: Wed, 11 Sep 2013 12:24:52 -0700
Subject: [PATCH 69/89] tests: test creating 20 device-mapper partitions
(#803108)
* tests/t6004-dm-many-partitions.sh: Make sure > 17 partitions appear in
@ -13,10 +13,10 @@ Subject: [PATCH 54/69] tests: test creating 20 device-mapper partitions
create mode 100755 tests/t6004-dm-many-partitions.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4ec08da..923839d 100644
index 7a6fe8f..13fdde5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -60,6 +60,7 @@ TESTS = \
@@ -64,6 +64,7 @@ TESTS = \
t6001-psep.sh \
t6002-dm-busy.sh \
t6003-dm-hide.sh \
@ -91,5 +91,5 @@ index 0000000..4d08e72
+
+Exit $fail
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
From d74a3657dcd9341e54aa28deecf3e21d72cb3207 Mon Sep 17 00:00:00 2001
From 60fe959e1446337c3455656daad2c2b7114a1dcd Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 22 Aug 2013 18:08:30 -0700
Subject: [PATCH 55/69] libparted: use dm_udev_wait (#698121)
Date: Wed, 11 Sep 2013 12:24:53 -0700
Subject: [PATCH 70/89] libparted: use dm_udev_wait (#698121)
This is based on Peter Rajnoha's patch to use dm_udev_wait to
synchronize with udev.
@ -21,11 +21,28 @@ https://lists.gnu.org/archive/html/bug-parted/2010-09/msg00007.html
(_dm_add_partition): Same
(linux_new): Enable udev sync support
---
libparted/arch/linux.c | 52 +++++++++++++++++++++++++++++++++-----------------
1 file changed, 34 insertions(+), 18 deletions(-)
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 2bb8774..1c5faa5 100644
index f43eae1..452ea7f 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -438,6 +438,17 @@ _is_virtblk_major (int major)
@ -34,37 +51,19 @@ index 2bb8774..1c5faa5 100644
static int
+_dm_task_run_wait (struct dm_task *task, uint32_t cookie)
+{
+ int rc = 0;
+ int rc = 0;
+
+ rc = dm_task_run (task);
+ dm_udev_wait (cookie);
+ rc = dm_task_run (task);
+ dm_udev_wait (cookie);
+
+ return rc;
+ return rc;
+}
+
+static int
_is_dm_major (int major)
{
return _major_type_in_devices (major, "device-mapper");
@@ -466,7 +477,7 @@ _dm_maptype (PedDevice *dev)
dm_task_no_open_count(dmt);
- if (!dm_task_run(dmt))
+ if (!dm_task_run (dmt))
goto bad;
dm_get_next_target(dmt, NULL, &start, &length, &target_type, &params);
@@ -519,7 +530,7 @@ _dm_is_part (const char *path)
return 0;
dm_task_set_name(task, path);
- if (!dm_task_run(task))
+ if (!dm_task_run (task))
goto err;
struct dm_info *info = alloca (sizeof *info);
@@ -1398,6 +1409,10 @@ linux_new (const char* path)
@@ -1385,6 +1396,10 @@ linux_new (const char* path)
dev->dirty = 0;
dev->boot_dirty = 0;
@ -75,16 +74,7 @@ index 2bb8774..1c5faa5 100644
if (!_device_probe_type (dev))
goto error_free_arch_specific;
@@ -2316,7 +2331,7 @@ dm_canonical_path (PedDevice const *dev)
if (!dm_task_set_major_minor (task, arch_specific->major,
arch_specific->minor, 0))
goto err;
- if (!dm_task_run(task))
+ if (!dm_task_run (task))
goto err;
char *dev_name = zasprintf ("/dev/mapper/%s", dm_task_get_name (task));
if (dev_name == NULL)
@@ -2637,31 +2652,29 @@ _device_get_partition_range(PedDevice const* dev)
@@ -2631,31 +2646,29 @@ _device_get_partition_range(PedDevice const* dev)
static int
_dm_remove_partition(PedDisk* disk, int partno)
{
@ -126,16 +116,7 @@ index 2bb8774..1c5faa5 100644
}
static bool
@@ -2677,7 +2690,7 @@ _dm_get_partition_start_and_length(PedPartition const *part,
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))
+ if (!dm_task_run (task))
goto err;
int major, minor;
@@ -2700,6 +2713,7 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
@@ -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;
@ -143,16 +124,7 @@ index 2bb8774..1c5faa5 100644
/* Get map name from devicemapper */
struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
@@ -2710,7 +2724,7 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
arch_specific->minor, 0))
goto err;
- if (!dm_task_run(task))
+ if (!dm_task_run (task))
goto err;
const char *dev_name = dm_task_get_name (task);
@@ -2736,7 +2750,9 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
@@ -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);
@ -164,5 +136,5 @@ index 2bb8774..1c5faa5 100644
dm_task_destroy (task);
free (params);
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
From 2fb2bce8db7e7ea035bd288a8f1c9ef8ad4c0f5b Mon Sep 17 00:00:00 2001
From 39e38c0a4c0f3ad0e029792e0ddee9761b956c1e Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Fri, 23 Aug 2013 11:45:25 -0700
Subject: [PATCH 56/69] libparted: preserve the uuid on dm partitions (#832145)
Date: Wed, 11 Sep 2013 12:24:54 -0700
Subject: [PATCH 71/89] libparted: preserve the uuid on dm partitions (#832145)
* libparted/arch/linux.c (_dm_add_partition): Set the uuid if there was
one.
@ -10,10 +10,10 @@ Subject: [PATCH 56/69] libparted: preserve the uuid on dm partitions (#832145)
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 1c5faa5..375be83 100644
index 452ea7f..4376d17 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2711,9 +2711,12 @@ static int
@@ -2710,9 +2710,12 @@ static int
_dm_add_partition (PedDisk* disk, const PedPartition* part)
{
LinuxSpecific* arch_specific = LINUX_SPECIFIC (disk->dev);
@ -29,8 +29,8 @@ index 1c5faa5..375be83 100644
/* Get map name from devicemapper */
struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
@@ -2727,7 +2730,7 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
if (!dm_task_run (task))
@@ -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);
@ -38,7 +38,7 @@ index 1c5faa5..375be83 100644
size_t name_len = strlen (dev_name);
vol_name = zasprintf ("%s%s%d",
dev_name,
@@ -2736,6 +2739,11 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
@@ -2735,6 +2738,11 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
if (vol_name == NULL)
goto err;
@ -50,7 +50,7 @@ index 1c5faa5..375be83 100644
/* Caution: dm_task_destroy frees dev_name. */
dm_task_destroy (task);
task = NULL;
@@ -2748,6 +2756,8 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
@@ -2747,6 +2755,8 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
goto err;
dm_task_set_name (task, vol_name);
@ -59,7 +59,7 @@ index 1c5faa5..375be83 100644
dm_task_add_target (task, 0, part->geom.length,
"linear", params);
if (!dm_task_set_cookie (task, &cookie, 0))
@@ -2756,6 +2766,7 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
@@ -2755,6 +2765,7 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
dm_task_update_nodes ();
dm_task_destroy (task);
free (params);
@ -67,7 +67,7 @@ index 1c5faa5..375be83 100644
free (vol_name);
return 1;
} else {
@@ -2766,6 +2777,7 @@ err:
@@ -2765,6 +2776,7 @@ err:
if (task)
dm_task_destroy (task);
free (params);
@ -76,5 +76,5 @@ index 1c5faa5..375be83 100644
return 0;
}
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
From 06bbbc8aff0c2d495941b36da1dfa24b00eb2bba Mon Sep 17 00:00:00 2001
From a963cd53ab1f14ef7f9a9b84a2536103ad690479 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 7 Aug 2012 10:14:03 -0700
Subject: [PATCH 57/69] tests: Make sure dm UUIDs are not erased
Date: Wed, 11 Sep 2013 12:24:55 -0700
Subject: [PATCH 72/89] tests: Make sure dm UUIDs are not erased
* tests/t6005-dm-uuid.sh: Make sure dm UUIDs are not erased
---
@ -11,10 +11,10 @@ Subject: [PATCH 57/69] tests: Make sure dm UUIDs are not erased
create mode 100755 tests/t6005-dm-uuid.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 923839d..57e8642 100644
index 13fdde5..9100a81 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -61,6 +61,7 @@ TESTS = \
@@ -65,6 +65,7 @@ TESTS = \
t6002-dm-busy.sh \
t6003-dm-hide.sh \
t6004-dm-many-partitions.sh \
@ -87,5 +87,5 @@ index 0000000..f58cb06
+
+Exit $fail
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
From 73ed3e0ba21afec398f3b1cfb6ee013cf4ce3fc2 Mon Sep 17 00:00:00 2001
From 7be35be5de01fa90f23810fb66efc3ccdbe5679a Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 1 Nov 2012 16:22:42 -0700
Subject: [PATCH 63/69] libparted: don't canonicalize /dev/md/ paths (#872361)
Date: Wed, 11 Sep 2013 12:25:01 -0700
Subject: [PATCH 73/89] 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
@ -11,9 +11,25 @@ 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 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
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
@ -33,5 +49,5 @@ index 738b320..cdcc117 100644
if (!normal_path)
/* Well, maybe it is just that the file does not exist.
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
From ea9d81655bbcd5e125ae6bd36a7ac0b95b00ec15 Mon Sep 17 00:00:00 2001
From 6a3194bf13d23c4e7fcc346f7188060d50f3cedc Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 17 Apr 2013 14:59:36 -0700
Subject: [PATCH 64/69] tests: rewrite t6001 to use /dev/mapper
Date: Wed, 11 Sep 2013 12:25:02 -0700
Subject: [PATCH 74/89] 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.
@ -88,5 +88,5 @@ index da6b8a1..809ff9e 100644
+
Exit $fail
--
1.8.3.1
1.8.5.3

View File

@ -1,13 +1,13 @@
From e6a23531e0cb40c2cc75f1e8fbb86ab872cb6f1b Mon Sep 17 00:00:00 2001
From 4d0cd271069997e7d44ed3b52426ccf2570048c8 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 26 Aug 2013 16:27:00 -0700
Subject: [PATCH 65/69] libparted: Add Intel Rapid Start Technology partition
Date: Wed, 11 Sep 2013 12:25:03 -0700
Subject: [PATCH 75/89] 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 (Changes in behavior): Mention it.
* 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
@ -36,24 +36,24 @@ This adds support for the irst partition type flag. Sets the type to
include/parted/disk.in.h | 5 +++--
libparted/disk.c | 2 ++
libparted/labels/dos.c | 21 +++++++++++++++++++++
libparted/labels/gpt.c | 39 +++++++++++++++++++++++++++++++++++++++
7 files changed, 74 insertions(+), 3 deletions(-)
libparted/labels/gpt.c | 40 ++++++++++++++++++++++++++++++++++++++++
7 files changed, 75 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index 98f7c6e..b53a9d0 100644
index 74b7697..27710b6 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,10 @@ GNU parted NEWS -*- outline -*-
@@ -4,6 +4,10 @@ GNU parted NEWS -*- outline -*-
** Changes in behavior
** 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.
+
parted -l no longer lists device-mapper devices other than
dmraid whole disks.
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
@ -68,7 +68,7 @@ index a9f73f5..2f8e9f5 100644
.TP
.B unit \fIunit\fP
diff --git a/doc/parted.texi b/doc/parted.texi
index 008c383..fd8ccb9 100644
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
@ -101,10 +101,10 @@ index aa905c5..585383d 100644
enum _PedDiskTypeFeature {
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
diff --git a/libparted/disk.c b/libparted/disk.c
index d3cd5bb..4ca7255 100644
index ce71bfc..18c94ac 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -2441,6 +2441,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
@@ -2402,6 +2402,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
return N_("diag");
case PED_PARTITION_LEGACY_BOOT:
return N_("legacy_boot");
@ -114,7 +114,7 @@ index d3cd5bb..4ca7255 100644
default:
ped_exception_throw (
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index b8c161f..f8591ff 100644
index 6bddd79..c754970 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -85,6 +85,7 @@ static const char MBR_BOOT_CODE[] = {
@ -141,7 +141,7 @@ index b8c161f..f8591ff 100644
dos_data->orig = ped_malloc (sizeof (OrigState));
if (!dos_data->orig) {
ped_partition_destroy (part);
@@ -1326,6 +1329,7 @@ msdos_partition_new (const PedDisk* disk, PedPartitionType part_type,
@@ -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;
@ -149,7 +149,7 @@ index b8c161f..f8591ff 100644
} else {
part->disk_specific = NULL;
}
@@ -1361,6 +1365,7 @@ msdos_partition_duplicate (const PedPartition* part)
@@ -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;
@ -157,7 +157,7 @@ index b8c161f..f8591ff 100644
if (old_dos_data->orig) {
new_dos_data->orig = ped_malloc (sizeof (OrigState));
@@ -1409,6 +1414,7 @@ msdos_partition_set_system (PedPartition* part,
@@ -1399,6 +1404,7 @@ msdos_partition_set_system (PedPartition* part,
dos_data->lvm = 0;
dos_data->palo = 0;
dos_data->prep = 0;
@ -165,7 +165,7 @@ index b8c161f..f8591ff 100644
if (dos_data->lba)
dos_data->system = PARTITION_EXT_LBA;
else
@@ -1441,6 +1447,10 @@ msdos_partition_set_system (PedPartition* part,
@@ -1431,6 +1437,10 @@ msdos_partition_set_system (PedPartition* part,
dos_data->system = PARTITION_PREP;
return 1;
}
@ -176,7 +176,7 @@ index b8c161f..f8591ff 100644
if (!fs_type)
dos_data->system = PARTITION_LINUX;
@@ -1477,6 +1487,7 @@ clear_flags (DosPartitionData *dos_data)
@@ -1467,6 +1477,7 @@ clear_flags (DosPartitionData *dos_data)
dos_data->lvm = 0;
dos_data->palo = 0;
dos_data->prep = 0;
@ -184,7 +184,7 @@ index b8c161f..f8591ff 100644
dos_data->raid = 0;
}
@@ -1555,6 +1566,12 @@ msdos_partition_set_flag (PedPartition* part,
@@ -1545,6 +1556,12 @@ msdos_partition_set_flag (PedPartition* part,
dos_data->prep = state;
return ped_partition_set_system (part, part->fs_type);
@ -197,7 +197,7 @@ index b8c161f..f8591ff 100644
default:
return 0;
}
@@ -1597,6 +1614,9 @@ msdos_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
@@ -1587,6 +1604,9 @@ msdos_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
case PED_PARTITION_PREP:
return dos_data->prep;
@ -207,7 +207,7 @@ index b8c161f..f8591ff 100644
default:
return 0;
}
@@ -1619,6 +1639,7 @@ msdos_partition_is_flag_available (const PedPartition* part,
@@ -1609,6 +1629,7 @@ msdos_partition_is_flag_available (const PedPartition* part,
case PED_PARTITION_LBA:
case PED_PARTITION_PALO:
case PED_PARTITION_PREP:
@ -216,13 +216,13 @@ index b8c161f..f8591ff 100644
return 1;
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 25490af..0b7d08b 100644
index 6fd8880..ff87708 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 }})
@@ -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, \
@ -230,40 +230,40 @@ index 25490af..0b7d08b 100644
struct __attribute__ ((packed)) _GuidPartitionTableHeader_t
{
@@ -288,6 +292,7 @@ typedef struct _GPTPartitionData
int atvrecv;
@@ -297,6 +301,7 @@ typedef struct _GPTPartitionData
int msftrecv;
int legacy_boot;
int prep;
+ int irst;
} GPTPartitionData;
static PedDiskType gpt_disk_type;
@@ -797,6 +802,7 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
= gpt_part_data->msftdata
@@ -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)
@@ -822,6 +828,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))
@@ -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;
}
@@ -1339,6 +1347,7 @@ gpt_partition_new (const PedDisk *disk,
gpt_part_data->msftrecv = 0;
gpt_part_data->atvrecv = 0;
@@ -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);
@@ -1447,6 +1456,11 @@ gpt_partition_set_system (PedPartition *part,
@@ -1477,6 +1486,11 @@ gpt_partition_set_system (PedPartition *part,
gpt_part_data->type = PARTITION_APPLE_TV_RECOVERY_GUID;
return 1;
}
@ -275,77 +275,78 @@ index 25490af..0b7d08b 100644
if (fs_type)
{
@@ -1588,6 +1602,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftres
@@ -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:
@@ -1600,6 +1615,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftres
@@ -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:
@@ -1612,6 +1628,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftres
@@ -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:
@@ -1624,6 +1641,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftres
@@ -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:
@@ -1636,6 +1654,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->msftres
@@ -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:
@@ -1648,6 +1667,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->hp_service
@@ -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:
@@ -1660,6 +1680,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->hp_service
@@ -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 {
@@ -1676,6 +1697,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->hp_service
@@ -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:
@@ -1688,8 +1710,22 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
@@ -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->msftdata
+ = gpt_part_data->irst
= gpt_part_data->msftrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
+ = 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)
@ -356,29 +357,28 @@ index 25490af..0b7d08b 100644
+ = 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);
= 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:
gpt_part_data->hidden = state;
return 1;
@@ -1736,6 +1772,8 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag)
return gpt_part_data->hidden;
case PED_PARTITION_LEGACY_BOOT:
@@ -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:
@@ -1762,6 +1800,7 @@ gpt_partition_is_flag_available (const PedPartition *part,
case PED_PARTITION_APPLE_TV_RECOVERY:
@@ -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.8.3.1
1.8.5.3

View File

@ -1,12 +1,12 @@
From 1cb8a0e1c6a459b1f9e77501f0e7c582a031fdef Mon Sep 17 00:00:00 2001
From 6a5b3b5727845af0c5cef35dee3d8e8c69262fdc Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 26 Aug 2013 17:43:09 -0700
Subject: [PATCH 66/69] libparted: Add UEFI System Partition flag.
Date: Wed, 11 Sep 2013 12:25:04 -0700
Subject: [PATCH 76/89] 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 (Changes in behavior): Mention it.
* 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
@ -34,12 +34,12 @@ it to the boot flag on GPT which sets the ESP GUID type.
7 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index b53a9d0..541ea1c 100644
index 27710b6..abb73c6 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,9 @@ GNU parted NEWS -*- outline -*-
@@ -4,6 +4,9 @@ GNU parted NEWS -*- outline -*-
** Changes in behavior
** 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.
@ -61,7 +61,7 @@ index 2f8e9f5..f8e6a3d 100644
.TP
.B unit \fIunit\fP
diff --git a/doc/parted.texi b/doc/parted.texi
index fd8ccb9..a5effd5 100644
index 4c63fe3..9e00808 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -840,6 +840,10 @@ filesystems).
@ -94,10 +94,10 @@ index 585383d..d144e21 100644
enum _PedDiskTypeFeature {
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
diff --git a/libparted/disk.c b/libparted/disk.c
index 4ca7255..c22b2a2 100644
index 18c94ac..5421c03 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -2443,6 +2443,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
@@ -2404,6 +2404,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
return N_("legacy_boot");
case PED_PARTITION_IRST:
return N_("irst");
@ -107,7 +107,7 @@ index 4ca7255..c22b2a2 100644
default:
ped_exception_throw (
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index f8591ff..fc7292a 100644
index c754970..eff1c03 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -92,6 +92,7 @@ static const char MBR_BOOT_CODE[] = {
@ -134,7 +134,7 @@ index f8591ff..fc7292a 100644
dos_data->orig = ped_malloc (sizeof (OrigState));
if (!dos_data->orig) {
ped_partition_destroy (part);
@@ -1330,6 +1333,7 @@ msdos_partition_new (const PedDisk* disk, PedPartitionType part_type,
@@ -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;
@ -142,7 +142,7 @@ index f8591ff..fc7292a 100644
} else {
part->disk_specific = NULL;
}
@@ -1366,6 +1370,7 @@ msdos_partition_duplicate (const PedPartition* part)
@@ -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;
@ -150,7 +150,7 @@ index f8591ff..fc7292a 100644
if (old_dos_data->orig) {
new_dos_data->orig = ped_malloc (sizeof (OrigState));
@@ -1415,6 +1420,7 @@ msdos_partition_set_system (PedPartition* part,
@@ -1405,6 +1410,7 @@ msdos_partition_set_system (PedPartition* part,
dos_data->palo = 0;
dos_data->prep = 0;
dos_data->irst = 0;
@ -158,7 +158,7 @@ index f8591ff..fc7292a 100644
if (dos_data->lba)
dos_data->system = PARTITION_EXT_LBA;
else
@@ -1451,6 +1457,10 @@ msdos_partition_set_system (PedPartition* part,
@@ -1441,6 +1447,10 @@ msdos_partition_set_system (PedPartition* part,
dos_data->system = PARTITION_IRST;
return 1;
}
@ -169,7 +169,7 @@ index f8591ff..fc7292a 100644
if (!fs_type)
dos_data->system = PARTITION_LINUX;
@@ -1488,6 +1498,7 @@ clear_flags (DosPartitionData *dos_data)
@@ -1478,6 +1488,7 @@ clear_flags (DosPartitionData *dos_data)
dos_data->palo = 0;
dos_data->prep = 0;
dos_data->irst = 0;
@ -177,7 +177,7 @@ index f8591ff..fc7292a 100644
dos_data->raid = 0;
}
@@ -1572,6 +1583,12 @@ msdos_partition_set_flag (PedPartition* part,
@@ -1562,6 +1573,12 @@ msdos_partition_set_flag (PedPartition* part,
dos_data->irst = state;
return ped_partition_set_system (part, part->fs_type);
@ -190,7 +190,7 @@ index f8591ff..fc7292a 100644
default:
return 0;
}
@@ -1617,6 +1634,9 @@ msdos_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
@@ -1607,6 +1624,9 @@ msdos_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
case PED_PARTITION_IRST:
return dos_data->irst;
@ -200,7 +200,7 @@ index f8591ff..fc7292a 100644
default:
return 0;
}
@@ -1640,6 +1660,7 @@ msdos_partition_is_flag_available (const PedPartition* part,
@@ -1630,6 +1650,7 @@ msdos_partition_is_flag_available (const PedPartition* part,
case PED_PARTITION_PALO:
case PED_PARTITION_PREP:
case PED_PARTITION_IRST:
@ -209,10 +209,10 @@ index f8591ff..fc7292a 100644
return 1;
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 0b7d08b..64b92b4 100644
index ff87708..42b0360 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1592,6 +1592,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
@@ -1622,6 +1622,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
switch (flag)
{
@ -220,7 +220,7 @@ index 0b7d08b..64b92b4 100644
case PED_PARTITION_BOOT:
gpt_part_data->boot = state;
if (state)
@@ -1754,6 +1755,7 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag)
@@ -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;
@ -228,14 +228,14 @@ index 0b7d08b..64b92b4 100644
case PED_PARTITION_BOOT:
return gpt_part_data->boot;
case PED_PARTITION_BIOS_GRUB:
@@ -1801,6 +1803,7 @@ gpt_partition_is_flag_available (const PedPartition *part,
case PED_PARTITION_HIDDEN:
@@ -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.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
From d1667924c6b9de17b335864293aecd43b4701a3c Mon Sep 17 00:00:00 2001
From 33273acc7822b382b5e8226ba65453b6229f5dd6 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 27 Aug 2013 17:27:07 -0700
Subject: [PATCH 67/70] libparted: Recognize btrfs filesystem
Date: Wed, 11 Sep 2013 12:25:06 -0700
Subject: [PATCH 77/89] 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
@ -22,12 +22,12 @@ anything -- just sets the partition type to linux.
create mode 100644 libparted/fs/btrfs/btrfs.c
diff --git a/NEWS b/NEWS
index 541ea1c..3292fa9 100644
index abb73c6..7b69d3d 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,9 @@ GNU parted NEWS -*- outline -*-
@@ -4,6 +4,9 @@ GNU parted NEWS -*- outline -*-
** Changes in behavior
** New Features
+ Added support for recognizing btrfs filesystem. This simply displays
+ btrfs in the 'file system' column of the parted output.
@ -36,7 +36,7 @@ index 541ea1c..3292fa9 100644
Also aliased to boot on GPT to set the UEFI ESP GUID.
diff --git a/doc/parted.texi b/doc/parted.texi
index a5effd5..ea2c771 100644
index 9e00808..97ce203 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -575,6 +575,7 @@ partition table.

View File

@ -1,7 +1,7 @@
From 39cc999710703bb5577e4ef276ca3926cb00af92 Mon Sep 17 00:00:00 2001
From 9279fc06572959c4698deb2f1d3df8daaed66e87 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 28 Aug 2013 08:47:26 -0700
Subject: [PATCH 68/70] tests: Add btrfs and xfs to the fs probe test
Date: Wed, 11 Sep 2013 12:25:07 -0700
Subject: [PATCH 78/89] tests: Add btrfs and xfs to the fs probe test
* tests/tests/t1700-probe-fs.sh: Add btrfs and xfs
---

View File

@ -1,7 +1,7 @@
From 54e59b08f70cb5b3419ef02137e0b42da0fab617 Mon Sep 17 00:00:00 2001
From fec001a2c83750c35f47e6e621f3acb22e459c7a Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 11 Sep 2013 09:09:42 -0700
Subject: [PATCH 70/70] tests: Restrict gpt-header-munge to little-endian
Date: Wed, 11 Sep 2013 12:25:09 -0700
Subject: [PATCH 79/89] tests: Restrict gpt-header-munge to little-endian
systems
gpt-header-munge uses perl to manipulate the gpt header for the test. It

View File

@ -0,0 +1,68 @@
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 80/89] 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.8.5.3

View File

@ -0,0 +1,58 @@
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 81/89] 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.8.5.3

View File

@ -0,0 +1,32 @@
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 82/89] 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.8.5.3

View File

@ -1,7 +1,7 @@
From 1b8d3ef06b3ea813bb02f6ef85d77a4162d57064 Mon Sep 17 00:00:00 2001
From 23aa4931695ab570c52c2be9c5144fc61825be1a 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 58/69] libparted: add support for implicit FBA DASD partitions
Subject: [PATCH 83/89] 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
@ -192,5 +192,5 @@ index e235dd3..f92065f 100644
/*
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
From 72e2982d5767be628fd9380ce9f16ba2d2f474ae Mon Sep 17 00:00:00 2001
From 0c63ddb9fb21bda584e60e501ac51c93a7eb2d14 Mon Sep 17 00:00:00 2001
From: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
Date: Wed, 21 Aug 2013 16:27:13 -0700
Subject: [PATCH 59/69] libparted: add support for EAV DASD partitions
Subject: [PATCH 84/89] libparted: add support for EAV DASD partitions
Extended Address Volume (EAV) DASDs are ECKD DASDs with more than
65520 cylinders. This patch adds support for recognizing and
@ -1067,5 +1067,5 @@ index cf2990e..fdfa94f 100644
puts ("BUG: syntax error in vtoc_set_freespace call");
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
From 4e9468fe51b6183936a7564dc51da389b89fe15d Mon Sep 17 00:00:00 2001
From 2a84a5a219fb5d42e7b9e59f00c4cba78f4451fb 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 60/69] libparted: mklabel to support EAV DASD
Subject: [PATCH 85/89] 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
@ -155,5 +155,5 @@ index 2735b2a..b58b2be 100644
}
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
From 0dadb22c962c33149dbce5808ebfb43cc799c242 Mon Sep 17 00:00:00 2001
From ce6edd81fa7dc0babd8a8353973f09a2db1035a6 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 61/69] libparted: Avoid dasd as default disk type while probe
Subject: [PATCH 86/89] 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.
@ -63,5 +63,5 @@ index b58b2be..7de5f34 100644
anc->dev_type = dasd_info.dev_type;
--
1.8.3.1
1.8.5.3

View File

@ -1,7 +1,7 @@
From b4758f5b4af423174871a68c235d20a646f4807b Mon Sep 17 00:00:00 2001
From 606c5aa22cf47bddf64b51a54b1fe516dcd9a5e0 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 62/69] libparted: mklabel to support EDEV DASD
Subject: [PATCH 87/89] 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
@ -52,5 +52,5 @@ index 7de5f34..1f87937 100644
} 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.8.3.1
1.8.5.3

View File

@ -0,0 +1,87 @@
From 503e98c49fa06512fd1b0318aba6ee5de6cbd7b4 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 88/91] 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.0

View File

@ -0,0 +1,47 @@
From e64081878775a6f34b5206dd066a47ed2496cbab 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 89/91] 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.0

View File

@ -0,0 +1,73 @@
From 5652c9fc136ecf1a209bae40ba25fde2a44d8edc 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 90/91] 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.0

View File

@ -0,0 +1,102 @@
From bd3f8d6be818acc711056372870da2c915a9fd36 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 91/91] 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.0

View File

@ -4,7 +4,7 @@
Summary: The GNU disk partition manipulation program
Name: parted
Version: 3.1
Release: 17%{?dist}
Release: 18%{?dist}
License: GPLv3+
Group: Applications/System
URL: http://www.gnu.org/software/parted
@ -72,24 +72,49 @@ Patch0049: 0049-doc-1MiB-alignment-is-not-enough-for-cheap-flash-dri.patch
#Patch0050: 0050-build-update-gnulib-submodule-to-latest.patch
#Patch0051: 0051-maint-update-all-copyright-year-number-ranges.patch
Patch0052: 0052-maint-avoid-new-warning-error-with-gcc-4.8.0-2013010.patch
Patch0053: 0053-libparted-copy-pmbr_boot-when-duplicating-GPT-disk.patch
Patch0054: 0054-tests-test-creating-20-device-mapper-partitions-8031.patch
Patch0055: 0055-libparted-use-dm_udev_wait-698121.patch
Patch0056: 0056-libparted-preserve-the-uuid-on-dm-partitions-832145.patch
Patch0057: 0057-tests-Make-sure-dm-UUIDs-are-not-erased.patch
Patch0058: 0058-libparted-add-support-for-implicit-FBA-DASD-partitio.patch
Patch0059: 0059-libparted-add-support-for-EAV-DASD-partitions.patch
Patch0060: 0060-libparted-mklabel-to-support-EAV-DASD.patch
Patch0061: 0061-libparted-Avoid-dasd-as-default-disk-type-while-prob.patch
Patch0062: 0062-libparted-mklabel-to-support-EDEV-DASD.patch
Patch0063: 0063-libparted-don-t-canonicalize-dev-md-paths-872361.patch
Patch0064: 0064-tests-rewrite-t6001-to-use-dev-mapper.patch
Patch0065: 0065-libparted-Add-Intel-Rapid-Start-Technology-partition.patch
Patch0066: 0066-libparted-Add-UEFI-System-Partition-flag.patch
Patch0068: 0067-libparted-Recognize-btrfs-filesystem.patch
Patch0069: 0068-tests-Add-btrfs-and-xfs-to-the-fs-probe-test.patch
Patch0070: 0069-libparted-Flush-parent-device-on-open-962611.patch
Patch0071: 0070-tests-Restrict-gpt-header-munge-to-little-endian-sys.patch
Patch0053: 0053-dos-improve-MBR-signature-generation.patch
# Won't work on tar.xz
#Patch0054: 0054-bootstrap-update-to-latest-from-gnulib.patch
Patch0055: 0055-parted-fix-EOF-and-ctrl-c-handling.patch
Patch0056: 0056-tests-t6003-dm-hide-don-t-hang-on-exception.patch
Patch0057: 0057-gpt-Revert-small-device-commits.patch
# XXX Locally modified patch to apply without date changes
Patch0058: 0058-libparted-handle-logical-partitions-starting-immedia.patch
Patch0059: 0059-libparted-fix-gpt-end-of-disk-handling.patch
Patch0060: 0060-libparted-allow-some-common-errors-to-be-ignored.patch
Patch0061: 0061-Revert-linux-commit-do-not-unnecessarily-open-partit.patch
Patch0062: 0062-libparted-avoid-disturbing-partitions.patch
Patch0063: 0063-Fix-test-compilation.patch
Patch0064: 0064-GPT-add-support-for-PReP-GUID.patch
Patch0065: 0065-libparted-make-sure-not-to-treat-percentages-as-exac.patch
Patch0066: 0066-bug-15591-PATCH-libparted-handle-i18n-gpt-partition-.patch
Patch0067: 0067-Fix-help-text-for-disk_-set-toggle.patch
Patch0068: 0068-libparted-copy-pmbr_boot-when-duplicating-GPT-disk.patch
Patch0069: 0069-tests-test-creating-20-device-mapper-partitions-8031.patch
Patch0070: 0070-libparted-use-dm_udev_wait-698121.patch
Patch0071: 0071-libparted-preserve-the-uuid-on-dm-partitions-832145.patch
Patch0072: 0072-tests-Make-sure-dm-UUIDs-are-not-erased.patch
Patch0073: 0073-libparted-don-t-canonicalize-dev-md-paths-872361.patch
Patch0074: 0074-tests-rewrite-t6001-to-use-dev-mapper.patch
Patch0075: 0075-libparted-Add-Intel-Rapid-Start-Technology-partition.patch
Patch0076: 0076-libparted-Add-UEFI-System-Partition-flag.patch
Patch0077: 0077-libparted-Recognize-btrfs-filesystem.patch
Patch0078: 0078-tests-Add-btrfs-and-xfs-to-the-fs-probe-test.patch
Patch0079: 0079-tests-Restrict-gpt-header-munge-to-little-endian-sys.patch
Patch0080: 0080-libparted-don-t-require-a-system-id-string.patch
Patch0081: 0081-libparted-sync-partitions-16.patch
Patch0082: 0082-ui-switch-to-new-style-readline-typedef.patch
Patch0083: 0083-libparted-add-support-for-implicit-FBA-DASD-partitio.patch
Patch0084: 0084-libparted-add-support-for-EAV-DASD-partitions.patch
Patch0085: 0085-libparted-mklabel-to-support-EAV-DASD.patch
Patch0086: 0086-libparted-Avoid-dasd-as-default-disk-type-while-prob.patch
Patch0087: 0087-libparted-mklabel-to-support-EDEV-DASD.patch
Patch0088: 0088-libparted-Fix-check-for-backup-header-location.patch
Patch0089: 0089-libparted-Use-common-function-to-calculate-PTE-secto.patch
Patch0090: 0090-tests-Add-emit_superuser_warning-for-gpt-tests.patch
Patch0091: 0091-tests-Use-msdos-overlap-to-setup-t0283.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: e2fsprogs-devel
@ -226,6 +251,11 @@ fi
%changelog
* Tue Apr 08 2014 Brian C. Lane <bcl@redhat.com> 3.1-18
- Rebase on new upstream master commit cc382c3
- Drop patches incorporated into upstream
- Still adds the various DASD patches
* Thu Feb 27 2014 Brian C. Lane <bcl@redhat.com> 3.1-17
- Drop hfs_esp patch. Idea didn't work.