summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-08-03 15:09:19 +0000
committerGerrit Code Review <review@openstack.org>2018-08-03 15:09:19 +0000
commit627224770e08e31d37a76c349804551f491abeab (patch)
treecb5a7b0912c678a0246bec25d60571334e9e7f76
parent03fc758672f5eb235aed8548a6de61e7eb8926cd (diff)
parenta66e1b0e4ab61612d28eafcbbd66b598d9a49954 (diff)
Merge "Relocate parted to stx-integ/filesystem/parted"
-rw-r--r--centos_pkg_dirs1
-rw-r--r--parted/PKG-INFO14
-rw-r--r--parted/centos/build_srpm.data3
-rw-r--r--parted/centos/meta_patches/0001-Update-package-versioning-for-TIS-format.patch25
-rw-r--r--parted/centos/meta_patches/0003-fix-dev-nodes-getting-removed-for-100-to-300-ms-on-p.patch33
-rw-r--r--parted/centos/meta_patches/PATCH_ORDER3
-rw-r--r--parted/centos/meta_patches/syscalls.patch63
-rw-r--r--parted/centos/patches/fix-dev-nodes-getting-removed-for-100-to-300-ms-on-parted-print.patch1103
-rw-r--r--parted/centos/patches/syscalls.patch42
-rw-r--r--parted/centos/srpm_path1
-rw-r--r--parted/files/Makefile285
-rw-r--r--parted/files/fix-compile-failure-while-dis.patch57
-rw-r--r--parted/files/fix-doc-mandir.patch20
-rw-r--r--parted/files/no_check.patch20
-rw-r--r--parted/files/resizepart.sh24
-rw-r--r--parted/files/run-ptest3
-rw-r--r--parted/files/syscalls.patch55
17 files changed, 0 insertions, 1752 deletions
diff --git a/centos_pkg_dirs b/centos_pkg_dirs
index d56cc52..0fa12fc 100644
--- a/centos_pkg_dirs
+++ b/centos_pkg_dirs
@@ -1,4 +1,3 @@
1parted
2python-keyring 1python-keyring
3seabios 2seabios
4grub2 3grub2
diff --git a/parted/PKG-INFO b/parted/PKG-INFO
deleted file mode 100644
index c886bc5..0000000
--- a/parted/PKG-INFO
+++ /dev/null
@@ -1,14 +0,0 @@
1Metadata-Version: 1.1
2Name: parted
3Version: 2.0.21
4Summary: Disk partition editing/resizing utility
5Home-page:
6Author:
7Author-email:
8License: GPLv3+
9
10Description:
11Disk partition editing/resizing utility
12
13
14Platform: UNKNOWN
diff --git a/parted/centos/build_srpm.data b/parted/centos/build_srpm.data
deleted file mode 100644
index b7ca4ec..0000000
--- a/parted/centos/build_srpm.data
+++ /dev/null
@@ -1,3 +0,0 @@
1COPY_LIST="files/resizepart.sh"
2TIS_PATCH_VER=3
3BUILD_IS_SLOW=5
diff --git a/parted/centos/meta_patches/0001-Update-package-versioning-for-TIS-format.patch b/parted/centos/meta_patches/0001-Update-package-versioning-for-TIS-format.patch
deleted file mode 100644
index 0c37184..0000000
--- a/parted/centos/meta_patches/0001-Update-package-versioning-for-TIS-format.patch
+++ /dev/null
@@ -1,25 +0,0 @@
1From 74ab16d7e0c23b933b3d6f42eac63d70d07ab62d Mon Sep 17 00:00:00 2001
2From: Don Penney <don.penney@windriver.com>
3Date: Tue, 27 Sep 2016 10:50:03 -0400
4Subject: [PATCH] Update package versioning for TIS format
5
6---
7 SPECS/parted.spec | 2 +-
8 1 file changed, 1 insertion(+), 1 deletion(-)
9
10diff --git a/SPECS/parted.spec b/SPECS/parted.spec
11index 644c2df..b79ca4a 100644
12--- a/SPECS/parted.spec
13+++ b/SPECS/parted.spec
14@@ -4,7 +4,7 @@
15 Summary: The GNU disk partition manipulation program
16 Name: parted
17 Version: 3.1
18-Release: 28%{?dist}
19+Release: 28.el7%{?_tis_dist}.%{tis_patch_ver}
20 License: GPLv3+
21 Group: Applications/System
22 URL: http://www.gnu.org/software/parted
23--
241.8.3.1
25
diff --git a/parted/centos/meta_patches/0003-fix-dev-nodes-getting-removed-for-100-to-300-ms-on-p.patch b/parted/centos/meta_patches/0003-fix-dev-nodes-getting-removed-for-100-to-300-ms-on-p.patch
deleted file mode 100644
index de2d8b8..0000000
--- a/parted/centos/meta_patches/0003-fix-dev-nodes-getting-removed-for-100-to-300-ms-on-p.patch
+++ /dev/null
@@ -1,33 +0,0 @@
1From cfa8f478bd19cf706f87c3c5a8baf54df7f2ea16 Mon Sep 17 00:00:00 2001
2From: Ovidiu Poncea <ovidiu.poncea@windriver.com>
3Date: Fri, 2 Mar 2018 17:22:52 +0200
4Subject: [PATCH]
5 fix-dev-nodes-getting-removed-for-100-to-300-ms-on-parted-print.patch
6
7---
8 SPECS/parted.spec | 2 ++
9 1 file changed, 2 insertions(+)
10
11diff --git a/SPECS/parted.spec b/SPECS/parted.spec
12index 6979b14..06a09f8 100644
13--- a/SPECS/parted.spec
14+++ b/SPECS/parted.spec
15@@ -15,6 +15,7 @@ Source0: ftp://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
16 Source1: ftp://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz.sig
17 Source2: pubkey.jim.meyering
18 Source3: resizepart.sh
19+Source4: fix-dev-nodes-getting-removed-for-100-to-300-ms-on-parted-print.patch
20
21 Patch0: parted-3.0-libparted-copy-pmbr_boot-when-duplicating-GPT-disk.patch
22 Patch1: parted-3.1-libparted-check-PMBR-before-GPT-partition-table-8052.patch
23@@ -64,6 +65,7 @@ Patch42: 0042-tests-Set-optimal-blocks-to-64-for-scsi_debug-device.patch
24
25 # WRS
26 Patch43: syscalls.patch
27+Patch44: fix-dev-nodes-getting-removed-for-100-to-300-ms-on-parted-print.patch
28
29 Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
30 BuildRequires: e2fsprogs-devel
31--
321.9.1
33
diff --git a/parted/centos/meta_patches/PATCH_ORDER b/parted/centos/meta_patches/PATCH_ORDER
deleted file mode 100644
index 3cd0fe8..0000000
--- a/parted/centos/meta_patches/PATCH_ORDER
+++ /dev/null
@@ -1,3 +0,0 @@
1syscalls.patch
20001-Update-package-versioning-for-TIS-format.patch
30003-fix-dev-nodes-getting-removed-for-100-to-300-ms-on-p.patch
diff --git a/parted/centos/meta_patches/syscalls.patch b/parted/centos/meta_patches/syscalls.patch
deleted file mode 100644
index 1dd07c4..0000000
--- a/parted/centos/meta_patches/syscalls.patch
+++ /dev/null
@@ -1,63 +0,0 @@
1From 4859fab94b298a4ca449216c3035b8b024c661a3 Mon Sep 17 00:00:00 2001
2From: Kristine Bujold <kristine.bujold@windriver.com>
3Date: Wed, 21 Dec 2016 15:28:53 -0500
4Subject: [PATCH 1/2] WRS: syscalls.patch
5
6---
7 SPECS/parted.spec | 12 +++++++++++-
8 1 file changed, 11 insertions(+), 1 deletion(-)
9
10diff --git a/SPECS/parted.spec b/SPECS/parted.spec
11index 749687f..644c2df 100644
12--- a/SPECS/parted.spec
13+++ b/SPECS/parted.spec
14@@ -12,6 +12,7 @@ URL: http://www.gnu.org/software/parted
15 Source0: ftp://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
16 Source1: ftp://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz.sig
17 Source2: pubkey.jim.meyering
18+Source3: resizepart.sh
19
20 Patch0: parted-3.0-libparted-copy-pmbr_boot-when-duplicating-GPT-disk.patch
21 Patch1: parted-3.1-libparted-check-PMBR-before-GPT-partition-table-8052.patch
22@@ -59,6 +60,9 @@ Patch40: 0040-partprobe-Open-the-device-once-for-probing-1339705.patch
23 Patch41: 0041-tests-Stop-timing-t9040-1172675.patch
24 Patch42: 0042-tests-Set-optimal-blocks-to-64-for-scsi_debug-device.patch
25
26+# WRS
27+Patch43: syscalls.patch
28+
29 Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
30 BuildRequires: e2fsprogs-devel
31 BuildRequires: readline-devel
32@@ -121,7 +125,7 @@ git commit -a -m "run iconv"
33 autoreconf
34 autoconf
35 CFLAGS="$RPM_OPT_FLAGS -Wno-unused-but-set-variable"; export CFLAGS
36-%configure --enable-selinux --disable-static
37+%configure --enable-selinux --disable-static --disable-device-mapper
38 # Don't use rpath!
39 %{__sed} -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
40 %{__sed} -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
41@@ -150,6 +154,9 @@ popd
42
43 %find_lang %{name}
44
45+# WRS
46+install -d %{buildroot}%{_sbindir}
47+install -m 755 %{SOURCE3} %{buildroot}%{_sbindir}/resizepart.sh
48
49 %check
50 export LD_LIBRARY_PATH=$(pwd)/libparted/.libs
51@@ -185,6 +192,9 @@ fi
52 %{_libdir}/libparted-fs-resize.so*
53 %{_infodir}/parted.info.gz
54
55+# WRS
56+%{_sbindir}/resizepart.sh
57+
58 %files devel
59 %defattr(-,root,root,-)
60 %{_includedir}/parted
61--
621.8.3.1
63
diff --git a/parted/centos/patches/fix-dev-nodes-getting-removed-for-100-to-300-ms-on-parted-print.patch b/parted/centos/patches/fix-dev-nodes-getting-removed-for-100-to-300-ms-on-parted-print.patch
deleted file mode 100644
index 74cc157..0000000
--- a/parted/centos/patches/fix-dev-nodes-getting-removed-for-100-to-300-ms-on-parted-print.patch
+++ /dev/null
@@ -1,1103 +0,0 @@
1From 9e7ad12a13665d975ddb9ee4669f781a1a695f8a Mon Sep 17 00:00:00 2001
2From: Phillip Susi <psusi@ubuntu.com>
3Date: Sun, 14 Oct 2012 23:59:58 -0400
4Subject: [PATCH] 'parted -s <dev_node> print' causes device nodes to be
5 deleted from /dev for ~100-300ms
6
7The main problem is that, immediately after 'parted <dev_node> print', device
8nodes for block devices that exist are deleted for brief moments of time then
9are readded by udev. This causes commands accessing these nodes to fail.
10Although probability of this happening is small (after mount, partitions no
11longer disappear), it can cause critical error as we now believe to have
12happened in CGTS-8785 (ceph tried to configure an OSD at exactly the moment
13parted was gathering info).
14
15To fix this the following commit where patched from upstream:
160. f0c0d53f998964e187f59de32ac92a2c0e2d5da9 libparted: refactor device-mapper partition sync code
171. 5910f1bc983fbab31f9ec86a7166feee4869c21a libparted: avoid disturbing partitions
182. 026736e9fed89ef00e6e6e84c7e422639ac2715c libparted: sync partitions > 16
193. 9e07d797b18609613c53ceb2dabbb5e69d961186 libparted: remove old partitions *first* before adding new ones
204. dfdd8b0dd99b7fa990f40a3d3a225c5b3ef13c57 libparted: remove all old partitions, even if new label allows less
215. 7feb3b452c5ae57e75e16f8c00f46c9aa564a4cc libparted: don't create partition on loop label
226. 7e87ca3c531228d35e13e802d2622006138b104c libparted/arch/linux.c: Compile without ENABLE_DEVICE_MAPPER
237. 7cde99849ed321da2712248bc27c14a954d6b481 libparted: give correct partition device name on loop labels
24
25The most important is commit #1. Commit #0 is a prerequisite and the rest are bug fixes introduced by them.
26
27Details:
28
29libparted: refactor device-mapper partition sync code
30
31The device-mapper partition sync code was still using the remove all
32partitions, then add new partitions method. Refactor to use the same
33algorithm as regular disks: try to remove all, and ignore any that could
34not be removed but have not changed.
35
36Conflicts:
37 NEWS
38 libparted/arch/linux.c
39 tests/Makefile.am
40
41libparted: avoid disturbing partitions
42
43The partition sync logic was first removing all
44partitions, then trying to re-add them. This resulted in many
45udev events triggering annoying behavior like auto mounting.
46Refactor the code to avoid removing and re-adding unmodified
47partitions.
48
49Conflicts:
50 NEWS
51
52libparted: sync partitions > 16
53
54The linux partition sync code was hard coded to only flush
55the first 16 partitions.
56
57Conflicts:
58 NEWS
59 libparted/arch/linux.c
60
61libparted: remove old partitions *first* before adding new ones
62
63"libparted: avoid disturbing partitions" put the remove of the old
64partition in second pass. If you simultaneously removed partitions 1
65and 2, and created a new partition #1 that overlapped the previous second
66partition, the sync would fail because it would try to create the new,
67larger partition #1 before removing the old partition #2.
68
69Conflicts:
70 libparted/arch/linux.c
71
72libparted: remove all old partitions, even if new label allows less
73
74We were limiting partition sync operations to the lesser number allowed
75by the device, or the label. This meant that when creating a new label
76over an old label that had more partitions than the new one allows, the
77higher partitions would not be removed. Use the greater of the two values
78for the remove pass, and the lesser for the add.
79
80Conflicts:
81 NEWS
82
83libparted: don't create partition on loop label
84
85The loop label represents an unpartitioned disk, but creates
86a dummy partition to represent the whole disk. This dummy partition
87was actually being loaded into the kernel. Don't do that.
88
89Conflicts:
90 NEWS
91
92libparted/arch/linux.c: Compile without ENABLE_DEVICE_MAPPER
93
94Signed-off-by: Brian C. Lane <bcl@redhat.com>
95
96libparted: give correct partition device name on loop labels
97
98ped_partition_get_path() was returning "/dev/foo1" instead of
99"/dev/foo" on loop labels. This caused gparted to run tools like mkfs on
100a device node that did not actually exist.
101
102Conflicts:
103 NEWS
104---
105 NEWS | 94 +++++-
106 libparted/arch/linux.c | 565 +++++++++++++++-----------------
107 tests/Makefile.am | 2 +
108 tests/t1104-remove-and-add-partition.sh | 50 +++
109 tests/t6010-dm-busy.sh | 92 ++++++
110 5 files changed, 499 insertions(+), 304 deletions(-)
111 create mode 100644 tests/t1104-remove-and-add-partition.sh
112 create mode 100644 tests/t6010-dm-busy.sh
113
114diff --git a/NEWS b/NEWS
115index d1ab2a6..42ee12c 100644
116--- a/NEWS
117+++ b/NEWS
118@@ -2,10 +2,98 @@ GNU parted NEWS -*- outline -*-
119
120 * Noteworthy changes in release 3.1-18 (2014-08-12) [RHEL7.1]
121
122-** New features
123+** New Features
124+
125+ You can now choose to ignore errors about partitions that overlap,
126+ or are longer than the disk. This allows you to use parted to
127+ repair the problem.
128+
129+** Bug Fixes
130+
131+ libparted: ped_partition_get_path() was returning "/dev/foo1" instead
132+ of "/dev/foo" for loop labels.
133+
134+ partprobe: when called on a disk that has become a loop label,
135+ remove any partitions left over from a previous label.
136+
137+ libparted: The loop label represents an unpartitioned disk, but creates
138+ a dummy partition to represent the whole disk. This dummy partition
139+ was actually being loaded into the kernel. Don't do that.
140+
141+ libparted: fix loop labels to not vanish if you don't create
142+ a filesystem, and to not return an error syncing when you do.
143+
144+ libparted: remove all old partitions, even if new label does not allow
145+ as many.
146+
147+ libparted: fat and ntfs boot sectors were misdetected as dos
148+ partition tables instead of being treated as a loop label.
149+
150+ libparted: previously if you chose to ignore the warning about
151+ the gpt thinking the disk was smaller than it appears to be on
152+ on disk, subsequent warnings on other disks would be suppressed.
153+ Now parted will warn once per disk.
154+
155+ Fix filesystem detection on non 512 byte sector sizes
156+
157+ Fix linux partition sync code to flush partitions > 16
158+
159+ Do not reject a FAT boot sector as invalid because it has no
160+ system ID string.
161+
162+ libparted: /dev/md/ symlink can change after libparted dereferences it,
163+ instead it should just use the symlink as given by the caller in the
164+ same way we do with /dev/mapper/.
165+
166+ libparted: On multipath systems new partitions would sometimes not
167+ appear, reporting 'device-mapper: create ioctl failed: Device or
168+ resource busy' until the system was rebooted. Added dm_udev_wait
169+ calls to synchronize parted with udev.
170+
171+ Fix help text for disk_{set,toggle} to show *disk* flags instead
172+ of partition flags.
173+
174+ Fix gpt to correctly handle non ASCII charcters in partition names
175+
176+ If a drive was 100 times an even multiple of two, sizes specified as
177+ a percentage would trigger the exact placement rule and refuse to round
178+ to the nearest half percent.
179+
180+ Avoid generating udev add/remove events for all unmodified partitions
181+ when writing a new table.
182+
183+ Fix cache coherency issue by flushing partition block devices.
184+ This had been mistakenly disabled in parted 2.0, and resulted
185+ in parted sometimes identifying the previous filesystem type
186+ after running an mkfs to format a partition to a new type.
187+
188+ libparted: fix gpt end of disk handling. Previously if the backup
189+ copy of the gpt was not at the end of the disk and you chose to
190+ ignore this error, parted would move it to the end of the disk
191+ anyhow. It will now leave the backup in the same location if
192+ you chose to ignore this error.
193+
194+ libparted: handle logical partitions starting immediately after
195+ the EBR. Creating a logical partition one sector after the EBR
196+ used to cause parted to complain that it could not inform the
197+ kernel of the changes, but after a reboot, everything was fine.
198+ Parted will now correctly inform the kernel of the changes, but
199+ only set the length of the extended partition to 1 sector instead
200+ of two, which would cause it to overlap the logical partition.
201+
202+ parted: fix EOF and ctrl-c handling. parted used to refuse to exit
203+ in response to ctrl-c and would get stuck in an infinite loop
204+ prompting for more input when it reached EOF on stdin.
205+
206+ libparted: Don't fail to manipulate partitions on dmraid disks that
207+ have other partitions in use.
208
209- Add support for prep flag to GPT to select PowerPC Reference Platform
210- boot partition type.
211+ libparted: mac: a MAC partition table could have a block_size larger
212+ than the one the kernel told us about. Upon reading that partition
213+ table, libparted would ask if it's ok to use the larger block size.
214+ If you were to respond in the affirmative, libparted would read the
215+ larger number of bytes into a buffer of the shorter length,
216+ overrunning it.
217
218 * Noteworthy changes in release 3.1-16 (2014-01-22) [RHEL7]
219
220diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
221index 67a5c2e..adb82f2 100644
222--- a/libparted/arch/linux.c
223+++ b/libparted/arch/linux.c
224@@ -48,6 +48,7 @@
225 #include "../architecture.h"
226 #include "dirname.h"
227 #include "xstrtol.h"
228+#include "xalloc.h"
229
230 #if ENABLE_NLS
231 # include <libintl.h>
232@@ -285,11 +286,12 @@ struct blkdev_ioctl_param {
233 /* Maximum number of partitions supported by linux. */
234 #define MAX_NUM_PARTS 64
235
236-static char* _device_get_part_path (PedDevice* dev, int num);
237+static char* _device_get_part_path (PedDevice const *dev, int num);
238 static int _partition_is_mounted_by_path (const char* path);
239 static int _device_open (PedDevice* dev, int flags);
240 static int _device_open_ro (PedDevice* dev);
241 static int _device_close (PedDevice* dev);
242+static unsigned int _device_get_partition_range(PedDevice const* dev);
243
244 static int
245 _read_fd (int fd, char **buf)
246@@ -1495,8 +1497,8 @@ linux_is_busy (PedDevice* dev)
247 return 0;
248 }
249
250-/* we need to flush the master device, and with kernel < 2.6 all the partition
251- * devices, because there is no coherency between the caches with old kernels.
252+/* we need to flush the master device, and all the partition devices,
253+ * * because there is no coherency between the caches.
254 * We should only flush unmounted partition devices, because:
255 * - there is never a need to flush them (we're not doing IO there)
256 * - flushing a device that is mounted causes unnecessary IO, and can
257@@ -1507,6 +1509,7 @@ _flush_cache (PedDevice* dev)
258 {
259 LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
260 int i;
261+ int lpn = _device_get_partition_range(dev);
262
263 if (dev->read_only)
264 return;
265@@ -1514,11 +1517,7 @@ _flush_cache (PedDevice* dev)
266
267 ioctl (arch_specific->fd, BLKFLSBUF);
268
269- /* With linux-2.6.0 and newer, we're done. */
270- if (_have_kern26())
271- return;
272-
273- for (i = 1; i < 16; i++) {
274+ for (i = 1; i < lpn; i++) {
275 char* name;
276 int fd;
277
278@@ -2265,34 +2264,72 @@ zasprintf (const char *format, ...)
279 return r < 0 ? NULL : resultp;
280 }
281
282-static char*
283-_device_get_part_path (PedDevice *dev, int num)
284+#ifdef ENABLE_DEVICE_MAPPER
285+static char *
286+dm_canonical_path (PedDevice const *dev)
287 {
288- size_t path_len = strlen (dev->path);
289+ LinuxSpecific const *arch_specific = LINUX_SPECIFIC (dev);
290
291+ /* Get map name from devicemapper */
292+ struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
293+ if (!task)
294+ goto err;
295+ if (!dm_task_set_major_minor (task, arch_specific->major,
296+ arch_specific->minor, 0))
297+ goto err;
298+ if (!dm_task_run(task))
299+ goto err;
300+ char *dev_name = zasprintf ("/dev/mapper/%s", dm_task_get_name (task));
301+ if (dev_name == NULL)
302+ goto err;
303+ dm_task_destroy (task);
304+ return dev_name;
305+err:
306+ return NULL;
307+}
308+#endif
309+
310+static char*
311+_device_get_part_path (PedDevice const *dev, int num)
312+{
313+ char *devpath;
314+ size_t path_len;
315 char *result;
316+#ifdef ENABLE_DEVICE_MAPPER
317+ devpath = (dev->type == PED_DEVICE_DM
318+ ? dm_canonical_path (dev) : dev->path);
319+#else
320+ devpath = dev->path;
321+#endif
322+ path_len = strlen (devpath);
323 /* Check for devfs-style /disc => /partN transformation
324 unconditionally; the system might be using udev with devfs rules,
325 and if not the test is harmless. */
326- if (5 < path_len && !strcmp (dev->path + path_len - 5, "/disc")) {
327+ if (5 < path_len && !strcmp (devpath + path_len - 5, "/disc")) {
328 /* replace /disc with /part%d */
329 result = zasprintf ("%.*s/part%d",
330- (int) (path_len - 5), dev->path, num);
331+ (int) (path_len - 5), devpath, num);
332 } else {
333 char const *p = (dev->type == PED_DEVICE_DAC960
334 || dev->type == PED_DEVICE_CPQARRAY
335 || dev->type == PED_DEVICE_ATARAID
336- || isdigit (dev->path[path_len - 1])
337+ || isdigit (devpath[path_len - 1])
338 ? "p" : "");
339- result = zasprintf ("%s%s%d", dev->path, p, num);
340+ result = zasprintf ("%s%s%d", devpath, p, num);
341 }
342-
343+#ifdef ENABLE_DEVICE_MAPPER
344+ if (dev->type == PED_DEVICE_DM)
345+ free (devpath);
346+#endif
347 return result;
348 }
349
350 static char*
351 linux_partition_get_path (const PedPartition* part)
352 {
353+ /* loop label means use the whole disk */
354+ if (strcmp (part->disk->type->name, "loop") == 0)
355+ return xstrdup (part->disk->dev->path);
356 return _device_get_part_path (part->disk->dev, part->num);
357 }
358
359@@ -2361,6 +2398,8 @@ linux_partition_is_busy (const PedPartition* part)
360
361 PED_ASSERT (part != NULL);
362
363+ if (strcmp (part->disk->type->name, "loop") == 0)
364+ return linux_is_busy (part->disk->dev);
365 if (_partition_is_mounted (part))
366 return 1;
367 if (part->type == PED_PARTITION_EXTENDED) {
368@@ -2494,7 +2533,7 @@ _sysfs_ull_entry_from_part(PedPartition const* part, const char *entry,
369 unsigned long long *val)
370 {
371 char path[128];
372- char *part_name = linux_partition_get_path(part);
373+ char *part_name = _device_get_part_path (part->disk->dev, part->num);
374 if (!part_name)
375 return false;
376
377@@ -2529,7 +2568,7 @@ _kernel_get_partition_start_and_length(PedPartition const *part,
378 PED_ASSERT(start);
379 PED_ASSERT(length);
380
381- char *dev_name = linux_partition_get_path (part);
382+ char *dev_name = _device_get_part_path (part->disk->dev, part->num);
383 if (!dev_name)
384 return false;
385
386@@ -2583,6 +2622,8 @@ static unsigned int
387 _device_get_partition_range(PedDevice const* dev)
388 {
389 int range;
390+ if (dev->type == PED_DEVICE_DM)
391+ return MAX_NUM_PARTS;
392 bool ok = _sysfs_int_entry_from_dev(dev, "ext_range", &range);
393
394 if (!ok)
395@@ -2591,6 +2632,133 @@ _device_get_partition_range(PedDevice const* dev)
396 return range > 1 ? range : 0;
397 }
398
399+#ifdef ENABLE_DEVICE_MAPPER
400+static int
401+_dm_remove_partition(PedDisk* disk, int partno)
402+{
403+ int rc;
404+ char *part_name = _device_get_part_path (disk->dev, partno);
405+
406+ int fd = open (part_name, O_RDONLY | O_EXCL);
407+ if (fd == -1) {
408+ if (errno == ENOENT)
409+ errno = ENXIO; /* nothing to remove, device already doesn't exist */
410+ free (part_name);
411+ return 0;
412+ }
413+ close (fd);
414+ struct dm_task *task = dm_task_create(DM_DEVICE_REMOVE);
415+ if (!task) {
416+ free (part_name);
417+ return 0;
418+ }
419+ dm_task_set_name (task, part_name);
420+ rc = dm_task_run(task);
421+ dm_task_update_nodes();
422+ dm_task_destroy(task);
423+ free (part_name);
424+ if (!rc)
425+ return 0;
426+
427+ return 1;
428+}
429+
430+static bool
431+_dm_get_partition_start_and_length(PedPartition const *part,
432+ unsigned long long *start,
433+ unsigned long long *length)
434+{
435+ struct dm_task* task = NULL;
436+ int rc = 0;
437+
438+ if (!(task = dm_task_create(DM_DEVICE_TABLE)))
439+ return 0;
440+ char *path = _device_get_part_path (part->disk->dev, part->num);
441+ PED_ASSERT(path);
442+ /* libdevmapper likes to complain on stderr instead of quietly
443+ returning ENOENT or ENXIO, so try to stat first */
444+ struct stat st;
445+ if (stat(path, &st))
446+ goto err;
447+ dm_task_set_name(task, path);
448+ if (!dm_task_run(task))
449+ goto err;
450+
451+ int major, minor;
452+ char *params;
453+ char *target_type;
454+ dm_get_next_target(task, NULL, (uint64_t *)start, (uint64_t *)length, &target_type, &params);
455+ if (sscanf (params, "%d:%d %Ld", &major, &minor, start) != 3)
456+ goto err;
457+ rc = 1;
458+err:
459+ free (path);
460+ dm_task_destroy(task);
461+ return rc;
462+}
463+
464+
465+static int
466+_dm_add_partition (PedDisk* disk, const PedPartition* part)
467+{
468+ LinuxSpecific* arch_specific = LINUX_SPECIFIC (disk->dev);
469+ char *params = NULL;
470+ char *vol_name = NULL;
471+
472+ /* Get map name from devicemapper */
473+ struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
474+ if (!task)
475+ goto err;
476+
477+ if (!dm_task_set_major_minor (task, arch_specific->major,
478+ arch_specific->minor, 0))
479+ goto err;
480+
481+ if (!dm_task_run(task))
482+ goto err;
483+
484+ const char *dev_name = dm_task_get_name (task);
485+ size_t name_len = strlen (dev_name);
486+ vol_name = zasprintf ("%s%s%d",
487+ dev_name,
488+ isdigit (dev_name[name_len - 1]) ? "p" : "",
489+ part->num);
490+ if (vol_name == NULL)
491+ goto err;
492+
493+ /* Caution: dm_task_destroy frees dev_name. */
494+ dm_task_destroy (task);
495+ task = NULL;
496+ if ( ! (params = zasprintf ("%d:%d %lld", arch_specific->major,
497+ arch_specific->minor, part->geom.start)))
498+ goto err;
499+
500+ task = dm_task_create (DM_DEVICE_CREATE);
501+ if (!task)
502+ goto err;
503+
504+ dm_task_set_name (task, vol_name);
505+ dm_task_add_target (task, 0, part->geom.length,
506+ "linear", params);
507+ if (dm_task_run (task)) {
508+ dm_task_update_nodes ();
509+ dm_task_destroy (task);
510+ free (params);
511+ free (vol_name);
512+ return 1;
513+ } else {
514+ _dm_remove_partition (disk, part->num);
515+ }
516+err:
517+ dm_task_update_nodes();
518+ if (task)
519+ dm_task_destroy (task);
520+ free (params);
521+ free (vol_name);
522+ return 0;
523+}
524+#endif
525+
526 /*
527 * Sync the partition table in two step process:
528 * 1. Remove all of the partitions from the kernel's tables, but do not attempt
529@@ -2611,12 +2779,31 @@ _disk_sync_part_table (PedDisk* disk)
530 PED_ASSERT(disk != NULL);
531 PED_ASSERT(disk->dev != NULL);
532 int lpn;
533-
534 unsigned int part_range = _device_get_partition_range(disk->dev);
535+ int (*add_partition)(PedDisk* disk, const PedPartition *part);
536+ int (*remove_partition)(PedDisk* disk, int partno);
537+ bool (*get_partition_start_and_length)(PedPartition const *part,
538+ unsigned long long *start,
539+ unsigned long long *length);
540+
541
542- /* lpn = largest partition number. */
543+#ifdef ENABLE_DEVICE_MAPPER
544+ if (disk->dev->type == PED_DEVICE_DM) {
545+ add_partition = _dm_add_partition;
546+ remove_partition = _dm_remove_partition;
547+ get_partition_start_and_length = _dm_get_partition_start_and_length;
548+ } else
549+#endif
550+ {
551+ add_partition = _blkpg_add_partition;
552+ remove_partition = _blkpg_remove_partition;
553+ get_partition_start_and_length = _kernel_get_partition_start_and_length;
554+ }
555+
556+ /* lpn = largest partition number.
557+ * for remove pass, use greater of device or label limit */
558 if (ped_disk_get_max_supported_partition_count(disk, &lpn))
559- lpn = PED_MIN(lpn, part_range);
560+ lpn = PED_MAX(lpn, part_range);
561 else
562 lpn = part_range;
563
564@@ -2633,59 +2820,68 @@ _disk_sync_part_table (PedDisk* disk)
565 if (!errnums)
566 goto cleanup;
567
568- /* Attempt to remove each and every partition, retrying for
569- up to max_sleep_seconds upon any failure due to EBUSY. */
570- unsigned int sleep_microseconds = 10000;
571- unsigned int max_sleep_seconds = 1;
572- unsigned int n_sleep = (max_sleep_seconds
573- * 1000000 / sleep_microseconds);
574 int i;
575- for (i = 0; i < n_sleep; i++) {
576- if (i)
577- usleep (sleep_microseconds);
578- bool busy = false;
579- int j;
580- for (j = 0; j < lpn; j++) {
581- if (!ok[j]) {
582- ok[j] = _blkpg_remove_partition (disk, j + 1);
583- errnums[j] = errno;
584- if (!ok[j] && errnums[j] == EBUSY)
585- busy = true;
586- }
587- }
588- if (!busy)
589- break;
590- }
591-
592+ /* remove old partitions first */
593 for (i = 1; i <= lpn; i++) {
594 PedPartition *part = ped_disk_get_partition (disk, i);
595 if (part) {
596- if (!ok[i - 1] && errnums[i - 1] == EBUSY) {
597- unsigned long long length;
598- unsigned long long start;
599- /* get start and length of existing partition */
600- if (!_kernel_get_partition_start_and_length(part,
601- &start, &length))
602- goto cleanup;
603- if (start == part->geom.start
604- && length == part->geom.length)
605- ok[i - 1] = 1;
606- /* If the new partition is unchanged and the
607- existing one was not removed because it was
608- in use, then reset the error flag and do not
609- try to add it since it is already there. */
610+ unsigned long long length;
611+ unsigned long long start;
612+ /* get start and length of existing partition */
613+ if (get_partition_start_and_length(part,
614+ &start, &length)
615+ && start == part->geom.start
616+ && length == part->geom.length)
617+ {
618+ /* partition is unchanged, so nothing to do */
619+ ok[i - 1] = 1;
620 continue;
621 }
622-
623- /* add the (possibly modified or new) partition */
624- if (!_blkpg_add_partition (disk, part)) {
625- ped_exception_throw (
626- PED_EXCEPTION_ERROR,
627- PED_EXCEPTION_RETRY_CANCEL,
628- _("Failed to add partition %d (%s)"),
629- i, strerror (errno));
630- goto cleanup;
631- }
632+ }
633+ /* Attempt to remove the partition, retrying for
634+ up to max_sleep_seconds upon any failure due to EBUSY. */
635+ unsigned int sleep_microseconds = 10000;
636+ unsigned int max_sleep_seconds = 1;
637+ unsigned int n_sleep = (max_sleep_seconds
638+ * 1000000 / sleep_microseconds);
639+ do {
640+ ok[i - 1] = remove_partition (disk, i);
641+ errnums[i - 1] = errno;
642+ if (ok[i - 1] || errnums[i - 1] != EBUSY)
643+ break;
644+ usleep (sleep_microseconds);
645+ } while (n_sleep--);
646+ if (!ok[i - 1] && errnums[i - 1] == ENXIO)
647+ ok[i - 1] = 1; /* it already doesn't exist */
648+ }
649+ /* lpn = largest partition number.
650+ * for add pass, use lesser of device or label limit */
651+ if (ped_disk_get_max_supported_partition_count(disk, &lpn))
652+ lpn = PED_MIN(lpn, part_range);
653+ else
654+ lpn = part_range;
655+ /* don't actually add partitions for loop */
656+ if (strcmp (disk->type->name, "loop") == 0)
657+ lpn = 0;
658+ for (i = 1; i <= lpn; i++) {
659+ PedPartition *part = ped_disk_get_partition (disk, i);
660+ if (!part)
661+ continue;
662+ unsigned long long length;
663+ unsigned long long start;
664+ /* get start and length of existing partition */
665+ if (get_partition_start_and_length(part,
666+ &start, &length)
667+ && start == part->geom.start
668+ && length == part->geom.length) {
669+ ok[i - 1] = 1;
670+ /* partition is unchanged, so nothing to do */
671+ continue;
672+ }
673+ /* add the (possibly modified or new) partition */
674+ if (!add_partition (disk, part)) {
675+ ok[i - 1] = 0;
676+ errnums[i - 1] = errno;
677 }
678 }
679
680@@ -2724,235 +2920,6 @@ _disk_sync_part_table (PedDisk* disk)
681 return ret;
682 }
683
684-#ifdef ENABLE_DEVICE_MAPPER
685-static int
686-_dm_remove_map_name(char *name)
687-{
688- struct dm_task *task = NULL;
689- int rc = 0;
690- uint32_t cookie = 0;
691-
692- task = dm_task_create(DM_DEVICE_REMOVE);
693- if (!task)
694- return 1;
695-
696- dm_task_set_name (task, name);
697- if (!dm_task_set_cookie(task, &cookie, 0))
698- goto err;
699-
700- rc = dm_task_run(task);
701- dm_udev_wait(cookie);
702- dm_task_update_nodes();
703-err:
704- dm_task_destroy(task);
705- if (!rc)
706- return 1;
707-
708- return 0;
709-}
710-
711-static int
712-_dm_is_part (struct dm_info *this, char *name)
713-{
714- struct dm_task* task = NULL;
715- struct dm_info* info = alloca(sizeof *info);
716- struct dm_deps* deps = NULL;
717- int rc = 0;
718- unsigned int i;
719-
720- task = dm_task_create(DM_DEVICE_DEPS);
721- if (!task)
722- return 0;
723-
724- dm_task_set_name(task, name);
725- if (!dm_task_run(task))
726- goto err;
727-
728- memset(info, '\0', sizeof *info);
729- dm_task_get_info(task, info);
730- if (!info->exists)
731- goto err;
732-
733- deps = dm_task_get_deps(task);
734- if (!deps)
735- goto err;
736-
737- for (i = 0; i < deps->count; i++) {
738- unsigned int ma = major(deps->device[i]),
739- mi = minor(deps->device[i]);
740-
741- if (ma == this->major && mi == this->minor)
742- rc = 1;
743- }
744-
745-err:
746- dm_task_destroy(task);
747- return rc;
748-}
749-
750-static int
751-_dm_remove_parts (PedDevice* dev)
752-{
753- struct dm_task* task = NULL;
754- struct dm_info* info = alloca(sizeof *info);
755- struct dm_names* names = NULL;
756- unsigned int next = 0;
757- int rc;
758- LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
759-
760- task = dm_task_create(DM_DEVICE_LIST);
761- if (!task)
762- goto err;
763-
764- if (!dm_task_set_major_minor (task, arch_specific->major,
765- arch_specific->minor, 0))
766- goto err;
767-
768- if (!dm_task_run(task))
769- goto err;
770-
771- memset(info, '\0', sizeof *info);
772- dm_task_get_info(task, info);
773- if (!info->exists)
774- goto err;
775-
776- names = dm_task_get_names(task);
777- if (!names)
778- goto err;
779-
780- rc = 0;
781- do {
782- names = (void *) ((char *) names + next);
783-
784- if (_dm_is_part(info, names->name))
785- rc += _dm_remove_map_name(names->name);
786-
787- next = names->next;
788- } while (next);
789-
790- dm_task_update_nodes();
791- dm_task_destroy(task);
792- task = NULL;
793-
794- if (!rc)
795- return 1;
796-err:
797- if (task)
798- dm_task_destroy(task);
799- ped_exception_throw (PED_EXCEPTION_WARNING, PED_EXCEPTION_IGNORE,
800- _("parted was unable to re-read the partition "
801- "table on %s (%s). This means Linux won't know "
802- "anything about the modifications you made. "),
803- dev->path, strerror (errno));
804- return 0;
805-}
806-
807-static int
808-_dm_add_partition (PedDisk* disk, PedPartition* part)
809-{
810- char* vol_name = NULL;
811- const char* dev_name = NULL;
812- char* vol_uuid = NULL;
813- const char* dev_uuid = NULL;
814- char* params = NULL;
815- LinuxSpecific* arch_specific = LINUX_SPECIFIC (disk->dev);
816- uint32_t cookie = 0;
817-
818- /* Get map name from devicemapper */
819- struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
820- if (!task)
821- goto err;
822-
823- if (!dm_task_set_major_minor (task, arch_specific->major,
824- arch_specific->minor, 0))
825- goto err;
826-
827- if (!dm_task_run(task))
828- goto err;
829-
830- dev_name = dm_task_get_name (task);
831- dev_uuid = dm_task_get_uuid (task);
832-
833- if (isdigit (dev_name[strlen (dev_name) - 1])) {
834- if ( ! (vol_name = zasprintf ("%sp%d", dev_name, part->num)))
835- goto err;
836- } else if ( ! (vol_name = zasprintf ("%s%d", dev_name, part->num)))
837- goto err;
838-
839- if ( dev_uuid && (strlen(dev_uuid) > 0) \
840- && ! (vol_uuid = zasprintf ("part%d-%s", part->num, dev_uuid)))
841- goto err;
842-
843- /* Caution: dm_task_destroy frees dev_name. */
844- dm_task_destroy (task);
845- task = NULL;
846-
847- /* device-mapper uses 512b units, not the device's sector size */
848- if ( ! (params = zasprintf ("%d:%d %lld", arch_specific->major,
849- arch_specific->minor,
850- part->geom.start * (disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT))))
851- goto err;
852-
853- task = dm_task_create (DM_DEVICE_CREATE);
854- if (!task)
855- goto err;
856-
857- dm_task_set_name (task, vol_name);
858- if (vol_uuid)
859- dm_task_set_uuid (task, vol_uuid);
860- /* device-mapper uses 512b units, not the device's sector size */
861- dm_task_add_target (task, 0, part->geom.length * (disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT),
862- "linear", params);
863- if (!dm_task_set_cookie(task, &cookie, 0))
864- goto err;
865- if (dm_task_run (task)) {
866- //printf("0 %ld linear %s\n", part->geom.length, params);
867- dm_udev_wait(cookie);
868- dm_task_update_nodes();
869- dm_task_destroy(task);
870- free(params);
871- free(vol_uuid);
872- free(vol_name);
873- return 1;
874- } else {
875- dm_udev_wait(cookie);
876- _dm_remove_map_name(vol_name);
877- }
878-err:
879- dm_task_update_nodes();
880- if (task)
881- dm_task_destroy (task);
882- free (params);
883- free (vol_uuid);
884- free (vol_name);
885- return 0;
886-}
887-
888-static int
889-_dm_reread_part_table (PedDisk* disk)
890-{
891- int largest_partnum = ped_disk_get_last_partition_num (disk);
892- int rc = 1;
893- int i;
894-
895- sync();
896- if (!_dm_remove_parts(disk->dev))
897- rc = 0;
898-
899- for (i = 1; i <= largest_partnum; i++) {
900- PedPartition* part;
901-
902- part = ped_disk_get_partition (disk, i);
903- if (!part)
904- continue;
905-
906- if (!_dm_add_partition (disk, part))
907- rc = 0;
908- }
909- return rc;
910-}
911-#endif
912-
913 static int
914 _have_blkpg ()
915 {
916@@ -2970,10 +2937,6 @@ _have_blkpg ()
917 static int
918 linux_disk_commit (PedDisk* disk)
919 {
920-#ifdef ENABLE_DEVICE_MAPPER
921- if (disk->dev->type == PED_DEVICE_DM)
922- return _dm_reread_part_table (disk);
923-#endif
924 if (disk->dev->type != PED_DEVICE_FILE) {
925
926 /* We now require BLKPG support. If this assertion fails,
927diff --git a/tests/Makefile.am b/tests/Makefile.am
928index 1cf859c..44518c8 100644
929--- a/tests/Makefile.am
930+++ b/tests/Makefile.am
931@@ -34,6 +34,7 @@ TESTS = \
932 t0501-duplicate.sh \
933 t1100-busy-label.sh \
934 t1101-busy-partition.sh \
935+ t1104-remove-and-add-partition.sh \
936 t1700-probe-fs.sh \
937 t2200-dos-label-recog.sh \
938 t2201-pc98-label-recog.sh \
939@@ -58,6 +59,7 @@ TESTS = \
940 t6002-dm-many-partitions.sh \
941 t6003-dm-uuid.sh \
942 t6004-dm-512b-sectors.sh \
943+ t6010-dm-busy.sh \
944 t6100-mdraid-partitions.sh \
945 t7000-scripting.sh \
946 t8000-loop.sh \
947diff --git a/tests/t1104-remove-and-add-partition.sh b/tests/t1104-remove-and-add-partition.sh
948new file mode 100644
949index 0000000..61cc392
950--- /dev/null
951+++ b/tests/t1104-remove-and-add-partition.sh
952@@ -0,0 +1,50 @@
953+#!/bin/sh
954+# make sure that removing a higher numbered partition and adding a lower
955+# one using that space at the same time works
956+
957+# Copyright (C) 2014 Free Software Foundation, Inc.
958+
959+# This program is free software; you can redistribute it and/or modify
960+# it under the terms of the GNU General Public License as published by
961+# the Free Software Foundation; either version 3 of the License, or
962+# (at your option) any later version.
963+
964+# This program is distributed in the hope that it will be useful,
965+# but WITHOUT ANY WARRANTY; without even the implied warranty of
966+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
967+# GNU General Public License for more details.
968+
969+# You should have received a copy of the GNU General Public License
970+# along with this program. If not, see <http://www.gnu.org/licenses/>.
971+
972+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
973+path_prepend_ ../partprobe
974+require_root_
975+ss=$sector_size_
976+
977+d1= f1=
978+cleanup_fn_()
979+{
980+ test -n "$d1" && losetup -d "$d1"
981+ rm -f "$f1"
982+}
983+
984+f1=$(pwd)/1; d1=$(loop_setup_ "$f1") \
985+ || skip_ "is this partition mounted with 'nodev'?"
986+
987+require_partitionable_loop_device_ $d1
988+
989+# create one big partition
990+parted -s $d1 mklabel msdos mkpart primary ext2 1m 10m || fail=1
991+
992+# save this table
993+dd if=$d1 of=saved count=1 || fail=1
994+
995+# create two small partitions
996+parted -s $d1 mklabel msdos mkpart primary ext2 1m 5m mkpart primary ext2 5m 10m || fail=1
997+
998+# restore first table and make sure partprobe works
999+dd if=saved of=$d1 || fail=1
1000+partprobe $d1 || fail=1
1001+
1002+Exit $fail
1003diff --git a/tests/t6010-dm-busy.sh b/tests/t6010-dm-busy.sh
1004new file mode 100644
1005index 0000000..9807b40
1006--- /dev/null
1007+++ b/tests/t6010-dm-busy.sh
1008@@ -0,0 +1,92 @@
1009+#!/bin/sh
1010+# ensure that parted can alter a partition on a dmraid disk
1011+# while another one is mounted
1012+
1013+# Copyright (C) 2008-2012 Free Software Foundation, Inc.
1014+
1015+# This program is free software; you can redistribute it and/or modify
1016+# it under the terms of the GNU General Public License as published by
1017+# the Free Software Foundation; either version 3 of the License, or
1018+# (at your option) any later version.
1019+
1020+# This program is distributed in the hope that it will be useful,
1021+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1022+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1023+# GNU General Public License for more details.
1024+
1025+# You should have received a copy of the GNU General Public License
1026+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1027+
1028+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
1029+
1030+require_root_
1031+
1032+# We could make this work for arbitrary sector size, but I'm lazy.
1033+require_512_byte_sector_size_
1034+
1035+test "x$ENABLE_DEVICE_MAPPER" = xyes \
1036+ || skip_ "no device-mapper support"
1037+
1038+# Device maps names - should be random to not conflict with existing ones on
1039+# the system
1040+linear_=plinear-$$
1041+
1042+d1=
1043+f1=
1044+dev=
1045+cleanup_fn_() {
1046+ umount "${dev}p2" > /dev/null 2>&1
1047+ dmsetup remove ${linear_}p1
1048+ dmsetup remove ${linear_}p2
1049+ dmsetup remove $linear_
1050+ test -n "$d1" && losetup -d "$d1"
1051+ rm -f "$f1"
1052+}
1053+
1054+f1=$(pwd)/1; d1=$(loop_setup_ "$f1") \
1055+ || fail=1
1056+
1057+# setup: create a mapping
1058+n=204800
1059+echo "0 $n linear $d1 0" | dmsetup create $linear_ || fail=1
1060+dev="/dev/mapper/$linear_"
1061+
1062+# Create msdos partition table
1063+parted -s $dev mklabel msdos > out 2>&1 || fail=1
1064+compare /dev/null out || fail=1
1065+
1066+parted -s $dev -a none mkpart primary fat32 1s 1000s > out 2>&1 || fail=1
1067+compare /dev/null out || fail=1
1068+
1069+parted -s $dev -a none mkpart primary fat32 1001s 200000s > out 2>&1 || fail=1
1070+compare /dev/null out || fail=1
1071+
1072+# wait for new partition device to appear
1073+wait_for_dev_to_appear_ ${dev}p2 || fail_ ${dev}p2 did not appear
1074+
1075+mkfs.vfat -F 32 ${dev}p2 || fail_ mkfs.vfat failed
1076+
1077+mount_point=$(pwd)/mnt
1078+
1079+mkdir $mount_point || fail=1
1080+mount "${dev}p2" "$mount_point" || fail=1
1081+
1082+# Removal of unmounted partition must succeed.
1083+parted -s "$dev" rm 1 > /dev/null 2>&1 || fail=1
1084+
1085+# Removal of mounted partition must fail.
1086+parted -s "$dev" rm 2 > /dev/null 2>&1 && fail=1
1087+
1088+parted -m -s "$dev" u s print > out 2>&1 || fail=1
1089+sed "s,^$dev,DEV," out > k; mv k out
1090+
1091+# Create expected output file.
1092+cat <<EOF >> exp || fail=1
1093+BYT;
1094+DEV:${n}s:dm:512:512:msdos:Linux device-mapper (linear):;
1095+2:1001s:200000s:199000s:fat32::lba;
1096+EOF
1097+
1098+compare exp out || fail=1
1099+
1100+Exit $fail
1101--
11021.9.1
1103
diff --git a/parted/centos/patches/syscalls.patch b/parted/centos/patches/syscalls.patch
deleted file mode 100644
index 287a305..0000000
--- a/parted/centos/patches/syscalls.patch
+++ /dev/null
@@ -1,42 +0,0 @@
1From: "Allain Legacy" <allain.legacy@windriver.com>
2---
3Index: parted-3.1/libparted/arch/linux.c
4===================================================================
5--- parted-3.1.orig/libparted/arch/linux.c
6+++ parted-3.1/libparted/arch/linux.c
7@@ -1646,12 +1646,14 @@ _device_close (PedDevice* dev)
8
9 #if SIZEOF_OFF_T < 8
10
11+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
12 static _syscall5(int,_llseek,
13 unsigned int, fd,
14 unsigned long, offset_high,
15 unsigned long, offset_low,
16 loff_t*, result,
17 unsigned int, origin)
18+#endif
19
20 loff_t
21 llseek (unsigned int fd, loff_t offset, unsigned int whence)
22@@ -1659,11 +1661,20 @@ llseek (unsigned int fd, loff_t offset,
23 loff_t result;
24 int retval;
25
26+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
27 retval = _llseek(fd,
28 ((unsigned long long)offset) >> 32,
29 ((unsigned long long)offset) & 0xffffffff,
30 &result,
31 whence);
32+#else
33+ retval = syscall(__NR__llseek, fd,
34+ ((unsigned long long)offset) >> 32,
35+ ((unsigned long long)offset) & 0xffffffff,
36+ &result,
37+ whence);
38+#endif
39+
40 return (retval==-1 ? (loff_t) retval : result);
41 }
42
diff --git a/parted/centos/srpm_path b/parted/centos/srpm_path
deleted file mode 100644
index 97272a9..0000000
--- a/parted/centos/srpm_path
+++ /dev/null
@@ -1 +0,0 @@
1mirror:Source/parted-3.1-28.el7.src.rpm
diff --git a/parted/files/Makefile b/parted/files/Makefile
deleted file mode 100644
index ee90be0..0000000
--- a/parted/files/Makefile
+++ /dev/null
@@ -1,285 +0,0 @@
1am__tty_colors_dummy = \
2 mgn= red= grn= lgn= blu= brg= std=; \
3 am__color_tests=no
4
5am__tty_colors = \
6$(am__tty_colors_dummy); \
7test "X$(AM_COLOR_TESTS)" != Xno \
8&& test "X$$TERM" != Xdumb \
9&& { test "X$(AM_COLOR_TESTS)" = Xalways || test -t 1 2>/dev/null; } \
10&& { \
11 am__color_tests=yes; \
12 red=''; \
13 grn=''; \
14 lgn=''; \
15 blu=''; \
16 mgn=''; \
17 brg=''; \
18 std=''; \
19}
20
21am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
22am__vpath_adj = case $$p in \
23 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
24 *) f=$$p;; \
25 esac;
26am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
27am__rst_section = { sed 'p;s/./=/g;' && echo; }
28am__sh_e_setup = case $$- in *e*) set +e;; esac
29
30am__common_driver_flags = \
31 --color-tests "$$am__color_tests" \
32 --enable-hard-errors "$$am__enable_hard_errors" \
33 --expect-failure "$$am__expect_failure"
34am__check_pre = \
35$(am__sh_e_setup); \
36$(am__vpath_adj_setup) $(am__vpath_adj) \
37$(am__tty_colors); \
38srcdir=$(srcdir); export srcdir; \
39am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`; \
40test "x$$am__odir" = x. || $(MKDIR_P) "$$am__odir" || exit $$?; \
41if test -f "./$$f"; then dir=./; \
42elif test -f "$$f"; then dir=; \
43else dir="$(srcdir)/"; fi; \
44tst=$$dir$$f; log='$@'; \
45if test -n '$(DISABLE_HARD_ERRORS)'; then \
46 am__enable_hard_errors=no; \
47else \
48 am__enable_hard_errors=yes; \
49fi; \
50$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
51
52am__set_TESTS_bases = \
53 bases='$(TEST_LOGS)'; \
54 bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
55 bases=`echo $$bases`
56
57RECHECK_LOGS = $(TEST_LOGS)
58TEST_SUITE_LOG = test-suite.log
59am__test_logs1 = $(TESTS:=.log)
60am__test_logs2 = $(am__test_logs1:.log=.log)
61TEST_LOGS = $(am__test_logs2:.sh.log=.log)
62SH_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver
63SH_LOG_COMPILE = $(SH_LOG_COMPILER)
64
65am__set_b = \
66 case '$@' in \
67 */*) \
68 case '$*' in \
69 */*) b='$*';; \
70 *) b=`echo '$@' | sed 's/\.log$$//'`; \
71 esac;; \
72 *) \
73 b='$*';; \
74 esac
75
76MKDIR_P = /bin/mkdir -p
77SHELL = /bin/bash
78VERSION = 3.1
79PACKAGE_STRING = GNU parted 3.1
80PACKAGE_BUGREPORT = bug-parted@gnu.org
81abs_srcdir = $(PWD)
82abs_top_builddir = $(PWD)/..
83abs_top_srcdir = $(PWD)/..
84srcdir = .
85top_srcdir = ..
86subdir = tests
87SH_LOG_COMPILER = $(SHELL)
88
89TESTS = \
90 help-version.sh \
91 t0000-basic.sh \
92 t0001-tiny.sh \
93 t0010-script-no-ctrl-chars.sh \
94 t0100-print.sh \
95 t0101-print-empty.sh \
96 t0200-gpt.sh \
97 t0201-gpt.sh \
98 t0202-gpt-pmbr.sh \
99 t0203-gpt-tiny-device-abort.sh \
100 t0203-gpt-shortened-device-primary-valid.sh \
101 t0205-gpt-list-clobbers-pmbr.sh \
102 t0206-gpt-print-with-corrupt-primary-clobbers-pmbr.sh \
103 t0207-IEC-binary-notation.sh \
104 t0208-mkpart-end-in-IEC.sh \
105 t0209-gpt-pmbr_boot.sh \
106 t0210-gpt-resized-partition-entry-array.sh \
107 t0211-gpt-rewrite-header.sh \
108 t0212-gpt-many-partitions.sh \
109 t0220-gpt-msftres.sh \
110 t0250-gpt.sh \
111 t0280-gpt-corrupt.sh \
112 t0300-dos-on-gpt.sh \
113 t0400-loop-clobber-infloop.sh \
114 t0500-dup-clobber.sh \
115 t0501-duplicate.sh \
116 t1100-busy-label.sh \
117 t1101-busy-partition.sh \
118 t1700-probe-fs.sh \
119 t2200-dos-label-recog.sh \
120 t2201-pc98-label-recog.sh \
121 t2300-dos-label-extended-bootcode.sh \
122 t2310-dos-extended-2-sector-min-offset.sh \
123 t2400-dos-hfs-partition-type.sh \
124 t2500-probe-corrupt-hfs.sh \
125 t3000-resize-fs.sh \
126 t3200-type-change.sh \
127 t3300-palo-prep.sh \
128 t3310-flags.sh \
129 t3400-whole-disk-FAT-partition.sh \
130 t4000-sun-raid-type.sh \
131 t4001-sun-vtoc.sh \
132 t4100-msdos-partition-limits.sh \
133 t4100-dvh-partition-limits.sh \
134 t4100-msdos-starting-sector.sh \
135 t4200-partprobe.sh \
136 t4300-nilfs2-tiny.sh \
137 t5000-tags.sh \
138 t6000-dm.sh \
139 t6001-psep.sh \
140 t6100-mdraid-partitions.sh \
141 t7000-scripting.sh \
142 t8000-loop.sh \
143 t8001-loop-blkpg.sh \
144 t9010-big-sector.sh \
145 t9020-alignment.sh \
146 t9021-maxima.sh \
147 t9022-one-unit-snap.sh \
148 t9023-value-lt-one.sh \
149 t9030-align-check.sh \
150 t9040-many-partitions.sh \
151 t9041-undetected-in-use-16th-partition.sh \
152 t9042-dos-partition-limit.sh \
153 t9050-partition-table-types.sh
154
155TESTS_ENVIRONMENT = \
156 export \
157 abs_top_builddir='$(abs_top_builddir)' \
158 abs_top_srcdir='$(abs_top_srcdir)' \
159 abs_srcdir='$(abs_srcdir)' \
160 built_programs=parted \
161 srcdir='$(srcdir)' \
162 top_srcdir='$(top_srcdir)' \
163 VERSION=$(VERSION) \
164 ; 9>&2
165
166.SUFFIXES: .log
167
168$(TEST_SUITE_LOG): $(TEST_LOGS)
169 @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
170 ws='[ ]'; \
171 results=`for b in $$bases; do echo $$b.trs; done`; \
172 test -n "$$results" || results=/dev/null; \
173 all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
174 pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
175 fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
176 skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
177 xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
178 xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
179 error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
180 if test `expr $$fail + $$xpass + $$error` -eq 0; then \
181 success=true; \
182 else \
183 success=false; \
184 fi; \
185 br='==================='; br=$$br$$br$$br$$br; \
186 result_count () \
187 { \
188 if test x"$$1" = x"--maybe-color"; then \
189 maybe_colorize=yes; \
190 elif test x"$$1" = x"--no-color"; then \
191 maybe_colorize=no; \
192 else \
193 echo "$@: invalid 'result_count' usage" >&2; exit 4; \
194 fi; \
195 shift; \
196 desc=$$1 count=$$2; \
197 if test $$maybe_colorize = yes && test $$count -gt 0; then \
198 color_start=$$3 color_end=$$std; \
199 else \
200 color_start= color_end=; \
201 fi; \
202 echo "$${color_start}# $$desc $$count$${color_end}"; \
203 }; \
204 create_testsuite_report () \
205 { \
206 result_count $$1 "TOTAL:" $$all "$$brg"; \
207 result_count $$1 "PASS: " $$pass "$$grn"; \
208 result_count $$1 "SKIP: " $$skip "$$blu"; \
209 result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
210 result_count $$1 "FAIL: " $$fail "$$red"; \
211 result_count $$1 "XPASS:" $$xpass "$$red"; \
212 result_count $$1 "ERROR:" $$error "$$mgn"; \
213 }; \
214 { \
215 echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
216 $(am__rst_title); \
217 create_testsuite_report --no-color; \
218 echo; \
219 echo ".. contents:: :depth: 2"; \
220 echo; \
221 for i in $$bases; do \
222 if grep "^$$ws*:copy-in-global-log:$$ws*no$$ws*$$" $$i.trs \
223 >/dev/null; then continue; \
224 fi; \
225 glob_res=`sed -n -e "s/$$ws*$$//" \
226 -e "s/^$$ws*:global-test-result:$$ws*//p" \
227 $$i.trs`; \
228 test -n "$$glob_res" || glob_res=RUN; \
229 echo "$$glob_res: $$i" | $(am__rst_section); \
230 if test ! -r $$i.log; then \
231 echo "fatal: making $@: $$i.log is unreadable" >&2; \
232 exit 1; \
233 fi; \
234 cat $$i.log; echo; \
235 done; \
236 } >$(TEST_SUITE_LOG).tmp; \
237 mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
238 if $$success; then \
239 col="$$grn"; \
240 else \
241 col="$$red"; \
242 test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
243 fi; \
244 echo "$${col}$$br$${std}"; \
245 echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
246 echo "$${col}$$br$${std}"; \
247 create_testsuite_report --maybe-color; \
248 echo "$$col$$br$$std"; \
249 if $$success; then :; else \
250 echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
251 if test -n "$(PACKAGE_BUGREPORT)"; then \
252 echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
253 fi; \
254 echo "$$col$$br$$std"; \
255 fi; \
256 $$success || exit 1
257
258check-TESTS:
259 @if test $@ != recheck; then \
260 list='$(RECHECK_LOGS)'; \
261 test -z "$$list" || rm -f $$list; \
262 fi
263 @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
264 @ws='[ ]'; \
265 log_list='' trs_list=''; $(am__set_TESTS_bases); \
266 for i in $$bases; do \
267 if test -z "$$log_list"; then \
268 log_list="$$i.log"; \
269 else \
270 log_list="$$log_list $$i.log"; \
271 fi; \
272 if test -z "$$trs_list"; then \
273 trs_list="$$i.trs"; \
274 else \
275 trs_list="$$trs_list $$i.trs"; \
276 fi; \
277 done; \
278 $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"
279
280.sh.log:
281 @p='$<'; \
282 $(am__set_b); \
283 $(am__check_pre) $(SH_LOG_DRIVER) --test-name "$$f" \
284 --log-file $$b.log --trs-file $$b.trs \
285 $(am__common_driver_flags) -- $(SH_LOG_COMPILE) "$$tst"
diff --git a/parted/files/fix-compile-failure-while-dis.patch b/parted/files/fix-compile-failure-while-dis.patch
deleted file mode 100644
index 68ab715..0000000
--- a/parted/files/fix-compile-failure-while-dis.patch
+++ /dev/null
@@ -1,57 +0,0 @@
1From 060e74354774d36d2c11ef08e3e7ea9b9b6e23fb Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Thu, 13 Nov 2014 11:29:33 +0800
4Subject: [PATCH] libparted/arch/linux.c: fix compile failure while
5 --disable-device-mapper
6
7While --disable-device-mapper, the MACRO ENABLE_DEVICE_MAPPER is
8undef, but it missed to scope some device mapper functions.
9
10Upstream-Status: Pending
11
12Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
13---
14 libparted/arch/linux.c | 8 ++++++--
15 1 file changed, 6 insertions(+), 2 deletions(-)
16
17diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
18index 6fd73c5..2afa479 100644
19--- a/libparted/arch/linux.c
20+++ b/libparted/arch/linux.c
21@@ -2320,6 +2320,7 @@ zasprintf (const char *format, ...)
22 static char *
23 dm_canonical_path (PedDevice const *dev)
24 {
25+#ifdef ENABLE_DEVICE_MAPPER
26 LinuxSpecific const *arch_specific = LINUX_SPECIFIC (dev);
27
28 /* Get map name from devicemapper */
29@@ -2337,6 +2338,7 @@ dm_canonical_path (PedDevice const *dev)
30 dm_task_destroy (task);
31 return dev_name;
32 err:
33+#endif
34 return NULL;
35 }
36
37@@ -2957,13 +2959,15 @@ _disk_sync_part_table (PedDisk* disk)
38 unsigned long long *start,
39 unsigned long long *length);
40
41-
42+#ifdef ENABLE_DEVICE_MAPPER
43 if (disk->dev->type == PED_DEVICE_DM) {
44 add_partition = _dm_add_partition;
45 remove_partition = _dm_remove_partition;
46 resize_partition = _dm_resize_partition;
47 get_partition_start_and_length = _dm_get_partition_start_and_length;
48- } else {
49+ } else
50+#endif
51+ {
52 add_partition = _blkpg_add_partition;
53 remove_partition = _blkpg_remove_partition;
54 #ifdef BLKPG_RESIZE_PARTITION
55--
561.9.1
57
diff --git a/parted/files/fix-doc-mandir.patch b/parted/files/fix-doc-mandir.patch
deleted file mode 100644
index 0711d4e..0000000
--- a/parted/files/fix-doc-mandir.patch
+++ /dev/null
@@ -1,20 +0,0 @@
1Upstream-Status: Submitted [bug-parted@gnu.org]
2
3| for po in `ls -1 ./*.pt_BR.po 2>/dev/null`; do \
4| make $(basename ${po%.pt_BR.po}); \
5| done
6| Makefile:904: *** Recursive variable `mandir' references itself (eventually). Stop.
7
8Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
9
10--- parted-3.1/doc/po4a.mk.orig 2012-03-15 14:09:11.555831872 +0100
11+++ parted-3.1/doc/po4a.mk 2012-03-15 14:10:44.243830985 +0100
12@@ -23,7 +23,7 @@
13 # threshold is 80%), it won't be distributed, and the build won't fail.
14 #
15
16-mandir = $(mandir)/$(lang)
17+mandir := $(mandir)/$(lang)
18
19 # Inform automake that we want to install some man pages in section 1, 5
20 # and 8.
diff --git a/parted/files/no_check.patch b/parted/files/no_check.patch
deleted file mode 100644
index 58d8db4..0000000
--- a/parted/files/no_check.patch
+++ /dev/null
@@ -1,20 +0,0 @@
1Upstream-Status: Inappropriate [configuration]
2
3If check is detected, it makes the builds non-determinstic so just force
4it to be disabled.
5
6RP - 4/11/08
7
8Index: parted-1.9.0/configure.ac
9===================================================================
10--- parted-1.9.0.orig/configure.ac 2009-07-23 18:52:08.000000000 +0100
11+++ parted-1.9.0/configure.ac 2010-02-02 14:13:56.013905093 +0000
12@@ -477,7 +477,7 @@
13 AM_CONDITIONAL([BUILD_LINUX], [test "$OS" = linux])
14
15 dnl check for "check", unit testing library/header
16-PKG_CHECK_MODULES([CHECK], [check >= 0.9.3], have_check=yes, have_check=no)
17+have_check=no
18 if test "$have_check" != "yes"; then
19 AC_MSG_RESULT([Unable to locate check version 0.9.3 or higher: not building])
20 fi
diff --git a/parted/files/resizepart.sh b/parted/files/resizepart.sh
deleted file mode 100644
index 29be2a0..0000000
--- a/parted/files/resizepart.sh
+++ /dev/null
@@ -1,24 +0,0 @@
1#!/bin/bash
2
3################################################################################
4# Copyright (c) 2015 Wind River Systems, Inc.
5#
6# SPDX-License-Identifier: Apache-2.0
7#
8################################################################################
9
10DEVICE=$1
11PARTITION=$2
12SIZE=$(blockdev --getsize64 ${DEVICE})
13SIZE_MB=$((SIZE / (1024*1024)))
14
15## This is a workaround to allow cloud-init to invoke parted without needing to
16## handle command prompts interactively. Support for non-interactive parted
17## commands are not supported on mounted partitions.
18##
19/usr/sbin/parted ---pretend-input-tty ${DEVICE} resizepart ${PARTITION} << EOF
20yes
21${SIZE_MB}
22EOF
23
24exit $?
diff --git a/parted/files/run-ptest b/parted/files/run-ptest
deleted file mode 100644
index 695c5e8..0000000
--- a/parted/files/run-ptest
+++ /dev/null
@@ -1,3 +0,0 @@
1#!/bin/sh
2
3make -C tests check-TESTS
diff --git a/parted/files/syscalls.patch b/parted/files/syscalls.patch
deleted file mode 100644
index e9bbe9a..0000000
--- a/parted/files/syscalls.patch
+++ /dev/null
@@ -1,55 +0,0 @@
1Upstream-Status: Pending
2
3---
4 libparted/arch/linux.c | 13 +++++++++++++
5 1 file changed, 13 insertions(+)
6
7Index: parted-1.9.0/libparted/arch/linux.c
8===================================================================
9--- parted-1.9.0.orig/libparted/arch/linux.c 2009-07-23 18:52:08.000000000 +0100
10+++ parted-1.9.0/libparted/arch/linux.c 2010-02-02 14:14:16.523904768 +0000
11@@ -17,6 +17,8 @@
12
13 #define PROC_DEVICES_BUFSIZ 16384
14
15+#include <linux/version.h>
16+
17 #include <config.h>
18 #include <arch/linux.h>
19
20@@ -1477,12 +1479,14 @@
21
22 #if SIZEOF_OFF_T < 8
23
24+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
25 static _syscall5(int,_llseek,
26 unsigned int, fd,
27 unsigned long, offset_high,
28 unsigned long, offset_low,
29 loff_t*, result,
30 unsigned int, origin)
31+#endif
32
33 loff_t
34 llseek (unsigned int fd, loff_t offset, unsigned int whence)
35@@ -1490,11 +1494,20 @@
36 loff_t result;
37 int retval;
38
39+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
40 retval = _llseek(fd,
41 ((unsigned long long)offset) >> 32,
42 ((unsigned long long)offset) & 0xffffffff,
43 &result,
44 whence);
45+#else
46+ retval = syscall(__NR__llseek, fd,
47+ ((unsigned long long)offset) >> 32,
48+ ((unsigned long long)offset) & 0xffffffff,
49+ &result,
50+ whence);
51+#endif
52+
53 return (retval==-1 ? (loff_t) retval : result);
54 }
55