Accepting request 36773 from home:puzel:branches:Base:System

Copy from home:puzel:branches:Base:System/parted via accept of submit request 36773 revision 8.
Request was accepted with message:

OBS-URL: https://build.opensuse.org/request/show/36773
OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=19
This commit is contained in:
Petr Uzel 2010-04-02 11:35:12 +00:00 committed by Git OBS Bridge
parent d019fa6416
commit 0b7af5fbb2
24 changed files with 465 additions and 722 deletions

View File

@ -1,9 +1,13 @@
---
parted/parted.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
Index: parted/parted.c
===================================================================
--- parted/parted.c.orig 2009-07-30 16:28:06.000000000 +0200
+++ parted/parted.c 2009-07-30 16:28:07.000000000 +0200
@@ -1779,7 +1779,7 @@ do_resize (PedDevice** dev)
{
--- parted/parted.c.orig 2010-02-02 11:28:07.000000000 +0100
+++ parted/parted.c 2010-02-02 11:31:00.000000000 +0100
@@ -1853,7 +1853,7 @@ do_resize (PedDevice** dev)
issue_fs_op_warning ("resize");
PedDisk *disk;
PedPartition *part = NULL;
- PedFileSystem *fs;
@ -11,39 +15,39 @@ Index: parted/parted.c
PedConstraint *constraint;
PedSector start, end;
PedGeometry *range_start = NULL, *range_end = NULL;
@@ -1816,22 +1816,39 @@ do_resize (PedDevice** dev)
@@ -1890,22 +1890,39 @@ do_resize (PedDevice** dev)
goto error_destroy_constraint;
ped_partition_set_system (part, NULL);
} else {
+ int always_resize = getenv( "YAST_IS_RUNNING" ) != NULL;
+ const char* fsname = "";
+ if( always_resize )
+ {
+ PedFileSystemType* fst = ped_file_system_probe( &part->geom );
+ if( fst )
+ fsname = fst->name;
+ }
+ int always_resize = getenv( "YAST_IS_RUNNING" ) != NULL;
+ const char* fsname = "";
+ if( always_resize )
+ {
+ PedFileSystemType* fst = ped_file_system_probe( &part->geom );
+ if( fst )
+ fsname = fst->name;
+ }
fs = ped_file_system_open (&part->geom);
- if (!fs)
+ if (!fs && (!always_resize || strncmp(fsname,"fat",3)==0) )
+ if (!fs && (!always_resize || strncmp(fsname,"fat",3)==0) )
goto error_destroy_disk;
+ if (fs)
+ if (fs)
constraint = constraint_intersect_and_destroy (
ped_file_system_get_resize_constraint (fs),
constraint_from_start_end (
*dev, range_start, range_end));
+ else
+ {
+ new_geom.start = part->geom.start;
+ constraint = ped_constraint_exact(&new_geom);
+ }
+ else
+ {
+ new_geom.start = part->geom.start;
+ constraint = ped_constraint_exact(&new_geom);
+ }
if (!ped_disk_set_partition_geom (disk, part, constraint,
new_geom.start, new_geom.end))
goto error_close_fs;
- if (!ped_file_system_resize (fs, &part->geom, g_timer))
+ if(fs)
+ {
+ if (!ped_file_system_resize (fs, &part->geom, g_timer) && !always_resize )
+ if(fs)
+ {
+ if (!ped_file_system_resize (fs, &part->geom, g_timer) && !always_resize )
goto error_close_fs;
/* may have changed... eg fat16 -> fat32 */
ped_partition_set_system (part, fs->type);
@ -53,7 +57,7 @@ Index: parted/parted.c
ped_disk_commit (disk);
ped_constraint_destroy (constraint);
@@ -1847,6 +1864,7 @@ do_resize (PedDevice** dev)
@@ -1921,6 +1938,7 @@ do_resize (PedDevice** dev)
return 1;
error_close_fs:

View File

@ -1,26 +1,26 @@
Index: parted/parted.c
===================================================================
--- parted/parted.c.orig 2009-07-29 14:41:35.000000000 +0200
+++ parted/parted.c 2009-07-29 14:41:59.000000000 +0200
@@ -1312,7 +1312,21 @@ do_print (PedDevice** dev)
--- parted/parted.c.orig 2010-04-02 10:22:16.000000000 +0200
+++ parted/parted.c 2010-04-02 10:40:03.000000000 +0200
@@ -1435,8 +1435,20 @@ do_print (PedDevice** dev)
wchar_t* table_rendered;
disk = ped_disk_new (*dev);
if (!disk)
+ {
+ if (ped_unit_get_default () == PED_UNIT_CHS ||
+ ped_unit_get_default () == PED_UNIT_CYLINDER)
+ {
+ PedCHSGeometry* chs = &(*dev)->bios_geom;
+ char* cyl_size = ped_unit_format_custom (*dev,
+ chs->heads * chs->sectors,
+ PED_UNIT_KILOBYTE);
+ printf (_("BIOS cylinder,head,sector geometry: %d,%d,%d. "
+ "Each cylinder is %s.\n"),
+ chs->cylinders, chs->heads, chs->sectors, cyl_size);
+ free (cyl_size);
+ }
- if (!disk)
+ if (!disk) {
+ if (ped_unit_get_default () == PED_UNIT_CHS ||
+ ped_unit_get_default () == PED_UNIT_CYLINDER) {
+ PedCHSGeometry* chs = &(*dev)->bios_geom;
+ char* cyl_size = ped_unit_format_custom (*dev,
+ chs->heads * chs->sectors,
+ PED_UNIT_KILOBYTE);
+ printf (_("BIOS cylinder,head,sector geometry: %d,%d,%d. "
+ "Each cylinder is %s.\n"),
+ chs->cylinders, chs->heads, chs->sectors, cyl_size);
+ free (cyl_size);
+ }
goto error;
+ }
+ }
peek_word = command_line_peek_word ();
if (peek_word) {
if (ped_disk_is_flag_available(disk, PED_DISK_CYLINDER_ALIGNMENT))
if (!ped_disk_set_flag(disk, PED_DISK_CYLINDER_ALIGNMENT,

View File

@ -1,61 +0,0 @@
From ad25892bb995f61b0ddf801ed1f74e0b1e7390ce Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Thu, 27 Aug 2009 20:16:09 +0200
Subject: [PATCH] parted: avoid unnecessary open/close on commit, and thus udev activity
* libparted/disk.c (ped_disk_commit): Open/close the underlying file
descriptor in this function, so that callees, ped_disk_commit_to_dev
and ped_disk_commit_to_os do not each perform open/close syscalls.
This saves an open/close pair, and thus avoids unneeded udev
activity on Linux.
Before this change, when calling commit() on a ped_disk, the
following would happen:
open /dev/sda
write partition table
close /dev/sda
open /dev/sda
ioctl (BLKRRPART)
close /dev/sda
This is rather inefficient, and causes 2 udev change events to be fired
for /dev/sda (+ the change events from the BLKRRPART), causing all kind
of scanning (blkid & friends) twice.
This patch fixes things to only open the device once.
---
libparted/disk.c | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
Index: parted-1.9.0/libparted/disk.c
===================================================================
--- parted-1.9.0.orig/libparted/disk.c 2009-12-03 15:09:44.000000000 +0100
+++ parted-1.9.0/libparted/disk.c 2009-12-03 15:10:13.000000000 +0100
@@ -489,9 +489,25 @@ error:
int
ped_disk_commit (PedDisk* disk)
{
+ /* Open the device here, so that the underlying fd is not closed
+ between commit_to_dev and commit_to_os (closing causes unwanted
+ udev events to be sent under Linux). */
+ if (!ped_device_open (disk->dev))
+ goto error;
+
if (!ped_disk_commit_to_dev (disk))
+ goto error_close_dev;
+
+ if (!ped_disk_commit_to_os (disk))
+ goto error_close_dev;
+
+ ped_device_close (disk->dev);
+ return 1;
+
+error_close_dev:
+ ped_device_close (disk->dev);
+error:
return 0;
- return ped_disk_commit_to_os (disk);
}
/**

View File

@ -58,7 +58,7 @@ Index: parted-1.9.0/libparted/arch/linux.c
+ fclose(f);
+
+ /* Wait for udev to finish */
+ if (system ("/sbin/udevadm settle") != 0) {
+ if (system ("/sbin/udevadm settle --timeout=20") != 0) {
+ /* udevadm settle failed - let's sleep for a while */
+ sleep (2);
}

View File

@ -1,24 +0,0 @@
Index: parted-1.9.0/libparted/labels/dos.c
===================================================================
--- parted-1.9.0.orig/libparted/labels/dos.c 2009-07-30 16:28:28.000000000 +0200
+++ parted-1.9.0/libparted/labels/dos.c 2009-07-30 16:28:53.000000000 +0200
@@ -1066,7 +1066,8 @@ write_ext_table (const PedDisk* disk,
lba_offset = ped_disk_extended_partition (disk)->geom.start;
- memset (&table, 0, sizeof (DosRawTable));
+ ped_device_read (disk->dev, &table, sector, 1);
+ memset (&(table.partitions), 0, 4 * sizeof(DosRawPartition));
table.magic = PED_CPU_TO_LE16 (MSDOS_MAGIC);
if (!fill_raw_part (&table.partitions[0], logical, sector))
@@ -1100,7 +1101,8 @@ write_empty_table (const PedDisk* disk,
PED_ASSERT (disk != NULL, return 0);
- memset (&table, 0, sizeof (DosRawTable));
+ ped_device_read (disk->dev, &table, sector, 1);
+ memset (&(table.partitions), 0, 4 * sizeof(DosRawPartition));
table.magic = PED_CPU_TO_LE16 (MSDOS_MAGIC);
return ped_device_write (disk->dev, (void*) &table, sector, 1);

View File

@ -1,96 +0,0 @@
From 2a6936fab4d4499a4b812dd330d3db50549029e0 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Fri, 28 Aug 2009 17:05:55 +0200
Subject: [PATCH] linux-commit: do not unnecessarily open partition device nodes
After patching parted with my do-not-use-BLKPG patch, I started
to get EBUSY errors on commit_to_os. Note this is not caused
by the do-not-use-BLKPG patch, this was already happening, but
parted was silently ignoring the errors (and the kernel was
not notified of the changes, which is bad). The error now
actually gets reported.
The problem turns out to be in libparted/arch/linux.c's
_flush_cache function, which walks all the partitions of the
disk and does BLKFLSBUF calls on them. This causes the following:
commit_to_os -> device_open -> fd = open /dev/sda ->
_flush_cache -> for each /dev/sda# open, ioctl, close
-> ioctl(fd, BLKRRPART) -> EBUSY
What is happening here is that the:
for each /dev/sda# open, ioctl, close
Is causing udev change events for all the /dev/sda#
nodes, which causes udev to call blkid on all these nodes
(on systems which use DeviceKit), so blkid has /dev/sda# nodes
open while BLKRRPART gets called on /dev/sda -> EBUSY.
I've checked with two independend storage subsystem kernel
developers, and /dev/sda and /dev/sda#, guarantee cache coherency
now-a-days. So there is no need to do this for 2.6, which also
eliminates the need to call _flush_cache() on device open at all.
* libparted/arch/linux.c (_have_kern26): New function.
(_flush_cache): For linux kernels 2.6 and newer, don't flush
partition devices.
(linux_open): Skip _flush_cache on newer kernels here, too.
---
libparted/arch/linux.c | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
Index: parted-1.9.0/libparted/arch/linux.c
===================================================================
--- parted-1.9.0.orig/libparted/arch/linux.c 2009-12-03 17:04:44.000000000 +0100
+++ parted-1.9.0/libparted/arch/linux.c 2009-12-03 17:05:06.000000000 +0100
@@ -601,6 +601,19 @@ _have_devfs ()
return have_devfs = S_ISCHR(sb.st_mode) ? 1 : 0;
}
+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;
+}
+
static void
_device_set_sector_size (PedDevice* dev)
{
@@ -1374,8 +1387,8 @@ linux_is_busy (PedDevice* dev)
return 0;
}
-/* we need to flush the master device, and all the partition devices,
- * because there is no coherency between the caches.
+/* 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 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
@@ -1393,6 +1406,10 @@ _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;
@@ -1449,6 +1466,8 @@ retry:
dev->read_only = 0;
}
+ /* With kernels < 2.6 flush cache for cache coherence issues */
+ if (!_have_kern26())
_flush_cache (dev);
return 1;

View File

@ -1,7 +1,12 @@
---
include/parted/device.h | 3 ++-
libparted/arch/linux.c | 3 +++
2 files changed, 5 insertions(+), 1 deletion(-)
Index: include/parted/device.h
===================================================================
--- include/parted/device.h.orig 2009-07-23 19:52:08.000000000 +0200
+++ include/parted/device.h 2009-07-30 16:24:58.000000000 +0200
--- include/parted/device.h.orig 2009-11-06 19:31:18.000000000 +0100
+++ include/parted/device.h 2010-02-02 13:10:06.000000000 +0100
@@ -46,7 +46,8 @@ typedef enum {
PED_DEVICE_DM = 12,
PED_DEVICE_XVD = 13,
@ -14,9 +19,9 @@ Index: include/parted/device.h
typedef struct _PedDevice PedDevice;
Index: libparted/arch/linux.c
===================================================================
--- libparted/arch/linux.c.orig 2009-07-23 19:52:08.000000000 +0200
+++ libparted/arch/linux.c 2009-07-30 16:24:58.000000000 +0200
@@ -251,6 +251,7 @@ struct blkdev_ioctl_param {
--- libparted/arch/linux.c.orig 2009-12-20 12:38:23.000000000 +0100
+++ libparted/arch/linux.c 2010-02-02 13:13:27.000000000 +0100
@@ -248,6 +248,7 @@ struct blkdev_ioctl_param {
#define I2O_MAJOR7 86
#define I2O_MAJOR8 87
#define UBD_MAJOR 98
@ -24,24 +29,24 @@ Index: libparted/arch/linux.c
#define DASD_MAJOR 94
#define VIODASD_MAJOR 112
#define SX8_MAJOR1 160
@@ -530,6 +531,8 @@ _device_probe_type (PedDevice* dev)
@@ -541,6 +542,8 @@ _device_probe_type (PedDevice* dev)
dev->type = PED_DEVICE_DAC960;
} else if (dev_major == ATARAID_MAJOR && (dev_minor % 0x10 == 0)) {
dev->type = PED_DEVICE_ATARAID;
+ } else if (dev_major == AOE_MAJOR && (dev_minor % 0x10 == 0)) {
+ dev->type = PED_DEVICE_AOE;
+ } else if (dev_major == AOE_MAJOR && (dev_minor % 0x10 == 0)) {
+ dev->type = PED_DEVICE_AOE;
} else if (dev_major == DASD_MAJOR && (dev_minor % 0x4 == 0)) {
dev->type = PED_DEVICE_DASD;
} else if (dev_major == VIODASD_MAJOR && (dev_minor % 0x8 == 0)) {
@@ -1250,6 +1253,11 @@ linux_new (const char* path)
@@ -1310,6 +1313,11 @@ linux_new (const char* path)
goto error_free_arch_specific;
break;
+ case PED_DEVICE_AOE:
+ if (!init_generic (dev, _("AoE Driver")))
+ goto error_free_arch_specific;
+ break;
+ case PED_DEVICE_AOE:
+ if (!init_generic (dev, _("AoE Driver")))
+ goto error_free_arch_specific;
+ break;
+
#if defined __s390__ || defined __s390x__
case PED_DEVICE_DASD:
if (!init_dasd (dev, _("IBM S390 DASD drive")))
goto error_free_arch_specific;

View File

@ -1,13 +0,0 @@
Index: parted-1.9.0/libparted/arch/linux.c
===================================================================
--- parted-1.9.0.orig/libparted/arch/linux.c 2009-07-30 16:28:43.000000000 +0200
+++ parted-1.9.0/libparted/arch/linux.c 2009-07-30 16:28:49.000000000 +0200
@@ -2232,7 +2232,7 @@ _blkpg_add_partition (PedDisk* disk, con
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;
+ linux_part.length = PED_SECTOR_SIZE_DEFAULT;
else
linux_part.length = part->geom.length * disk->dev->sector_size;
linux_part.pno = part->num;

View File

@ -1,19 +0,0 @@
---
libparted/arch/linux.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Index: parted-1.9.0/libparted/arch/linux.c
===================================================================
--- parted-1.9.0.orig/libparted/arch/linux.c 2009-12-11 12:04:43.000000000 +0100
+++ parted-1.9.0/libparted/arch/linux.c 2009-12-11 12:10:22.000000000 +0100
@@ -2224,7 +2224,9 @@ _blkpg_part_command (PedDevice* dev, str
ioctl_arg.datalen = sizeof (struct blkpg_partition);
ioctl_arg.data = (void*) part;
- return ioctl (arch_specific->fd, BLKPG, &ioctl_arg) == 0;
+ int ret = (ioctl (arch_specific->fd, BLKPG, &ioctl_arg) == 0);
+ system("/sbin/udevadm settle");
+ return ret;
}
static int

View File

@ -1,54 +0,0 @@
# Change parted testsuite so that it passes with SuSE patchset
# It is not obvious why the t7000 test fails with SuSE, but seems harmless.
# It is reported upstream and probably is SuSE specific (some lib behaves differently) ???
Index: parted-1.9.0/tests/t7000-scripting.sh
===================================================================
--- parted-1.9.0.orig/tests/t7000-scripting.sh 2009-07-23 19:52:08.000000000 +0200
+++ parted-1.9.0/tests/t7000-scripting.sh 2009-07-30 16:01:58.000000000 +0200
@@ -28,7 +28,7 @@ EOF
{ emit_superuser_warning
sed s/Error/Warning/ errS
- printf 'Is this still acceptable to you?\nYes/No?'; } >> errI || fail=1
+ printf 'Is this still acceptable to you?\nYes/No? n\n'; } >> errI || fail=1
for mkpart in mkpart mkpartfs; do
Index: parted-1.9.0/tests/t2000-mkfs.sh
===================================================================
--- parted-1.9.0.orig/tests/t2000-mkfs.sh 2009-07-23 19:52:08.000000000 +0200
+++ parted-1.9.0/tests/t2000-mkfs.sh 2009-07-30 16:01:58.000000000 +0200
@@ -97,6 +97,7 @@ test_expect_failure \
test_expect_success \
'normalize the actual output' \
'mv out o2 && sed -e "s, * ,,;s, $,," \
+ -e "s,^.*\.libs/parted: ,parted: ," \
-e "s,^.*/lt-parted: ,parted: ," o2 > out'
test_expect_success \
Index: parted-1.9.0/tests/t2200-dos-label-recog.sh
===================================================================
--- parted-1.9.0.orig/tests/t2200-dos-label-recog.sh 2009-07-23 19:52:08.000000000 +0200
+++ parted-1.9.0/tests/t2200-dos-label-recog.sh 2009-07-30 16:02:59.000000000 +0200
@@ -54,7 +54,7 @@ test_expect_success \
'
parted -m -s $dev unit s p > out &&
tail -2 out > k && mv k out &&
- printf "1:1s:40s:40s:::;\n2:41s:80s:40s:::;\n" > exp
+ printf "1:1s:40s:40s:::type=83;\n2:41s:80s:40s:::type=83;\n" > exp
'
test_expect_success 'expect two partitions' 'compare out exp'
Index: parted-1.9.0/tests/t4100-msdos-starting-sector.sh
===================================================================
--- parted-1.9.0.orig/tests/t4100-msdos-starting-sector.sh 2009-07-23 19:52:08.000000000 +0200
+++ parted-1.9.0/tests/t4100-msdos-starting-sector.sh 2009-07-30 16:01:58.000000000 +0200
@@ -62,7 +62,7 @@ cat <<EOF > exp || fail=1
BYT;
path:200s:file:512:512:msdos:;
1:32s:96s:65s:free;
-1:97s:195s:99s:::;
+1:97s:195s:99s:::type=83;
EOF
test_expect_success 'create expected output file' 'test $fail = 0'

View File

@ -1,16 +0,0 @@
Index: configure.ac
===================================================================
--- configure.ac.orig 2009-07-23 19:52:08.000000000 +0200
+++ configure.ac 2009-07-30 16:27:26.000000000 +0200
@@ -476,11 +476,6 @@ AC_CHECK_HEADER([execinfo.h], [
AM_CONDITIONAL([COMPILE_FOR_S390], [test "$host_cpu" = s390 || test "$host_cpu" = s390x])
AM_CONDITIONAL([BUILD_LINUX], [test "$OS" = linux])
-dnl check for "check", unit testing library/header
-PKG_CHECK_MODULES([CHECK], [check >= 0.9.3], have_check=yes, have_check=no)
-if test "$have_check" != "yes"; then
- AC_MSG_RESULT([Unable to locate check version 0.9.3 or higher: not building])
-fi
AM_CONDITIONAL([HAVE_CHECK], [test "$have_check" = yes])
dnl Checks for typedefs, structures and compiler characteristics.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:808cbc2394cca1a3df84b0baee781f413d265bf346ef1c052910442ec65ad648
size 1764338

3
parted-2.2.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dfe1251c63939edc3fa1ed858e1a03a2462ec515063ebecd1c3555a86629b23c
size 1952115

View File

@ -1,10 +1,14 @@
---
libparted/labels/gpt.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 107 insertions(+), 2 deletions(-)
Index: libparted/labels/gpt.c
===================================================================
--- libparted/labels/gpt.c.orig 2009-07-23 19:52:08.000000000 +0200
+++ libparted/labels/gpt.c 2009-07-29 14:36:56.000000000 +0200
@@ -47,6 +47,11 @@
--- libparted/labels/gpt.c.orig 2009-12-16 18:01:34.000000000 +0100
+++ libparted/labels/gpt.c 2010-02-02 14:12:46.000000000 +0100
@@ -50,6 +50,11 @@
# define _(String) (String)
#endif /* ENABLE_NLS */
#endif /* ENABLE_NLS */
+/* IA64 always has a properly working EFI implementation */
+#ifndef __ia64__
@ -14,146 +18,143 @@ Index: libparted/labels/gpt.c
#define EFI_PMBR_OSTYPE_EFI 0xEE
#define MSDOS_MBR_SIGNATURE 0xaa55
@@ -968,13 +973,62 @@ error:
return 0;
@@ -1062,11 +1067,60 @@ error:
return 0;
}
+
+#ifdef GPT_SYNC_MBR
+static inline unsigned char
+_part_to_ostype (PedPartition* part)
+{
+ GPTPartitionData* gpt_part_data = part->disk_specific;
+ if (part->fs_type) {
+ if (strncmp (part->fs_type->name, "fat", 3) == 0) return 0xc;
+ if (strncmp (part->fs_type->name, "ntfs", 4) == 0) return 0x7;
+ if (strncmp (part->fs_type->name, "hfs", 3) == 0) return 0xaf;
+ if (strstr (part->fs_type->name, "swap")) return 0x82;
+ }
+ return 0x83; // Everything else is Linux
+ if (part->fs_type) {
+ if (strncmp (part->fs_type->name, "fat", 3) == 0) return 0xc;
+ if (strncmp (part->fs_type->name, "ntfs", 4) == 0) return 0x7;
+ if (strncmp (part->fs_type->name, "hfs", 3) == 0) return 0xaf;
+ if (strstr (part->fs_type->name, "swap")) return 0x82;
+ }
+ return 0x83; // Everything else is Linux
+}
+
+static inline PedPartition*
+_find_first_part (const PedDisk* disk)
+{
+ PedPartition *retval = NULL, *part = NULL;
+ uint64_t lowest_end = 0xffffffffffffffff;
+ while (part = ped_disk_next_partition (disk, part)) {
+ if (part->geom.start == 0 || part->type == PED_PARTITION_METADATA
+ || part->type == PED_PARTITION_FREESPACE)
+ continue;
+ if (part->geom.end < lowest_end) {
+ retval = part;
+ lowest_end = part->geom.end;
+ }
+ }
+ return retval;
+ PedPartition *retval = NULL, *part = NULL;
+ uint64_t lowest_end = 0xffffffffffffffff;
+ while (part = ped_disk_next_partition (disk, part)) {
+ if (part->geom.start == 0 || part->type == PED_PARTITION_METADATA
+ || part->type == PED_PARTITION_FREESPACE)
+ continue;
+ if (part->geom.end < lowest_end) {
+ retval = part;
+ lowest_end = part->geom.end;
+ }
+ }
+ return retval;
+}
+
+static inline uint32_t
+_part_32bitmax (uint64_t in)
+{
+ if (in > 0xFFFFFFFFULL)
+ return 0xFFFFFFFF;
+ else
+ return (uint32_t)in;
+ if (in > 0xFFFFFFFFULL)
+ return 0xFFFFFFFF;
+ else
+ return (uint32_t)in;
+}
+#endif
+
+
+
#ifndef DISCOVER_ONLY
/* Write the protective MBR (to keep DOS happy) */
static int
-_write_pmbr (PedDevice * dev)
+_write_pmbr (const PedDisk * disk)
-_write_pmbr (PedDevice *dev)
+_write_pmbr (const PedDisk *disk)
{
+ PedDevice * dev = disk->dev;
LegacyMBR_t pmbr;
+ PedDevice * dev = disk->dev;
+
+#ifdef GPT_SYNC_MBR
+ int i, pmbr_id, first_entry = 0, last_entry = 3;
+ PedPartition *part = NULL, *esp;
+ int i, pmbr_id, first_entry = 0, last_entry = 3;
+ PedPartition *part = NULL, *esp;
+#endif
+
/* The UEFI spec is not clear about what to do with the following
elements of the Protective MBR (pmbr): BootCode (0-440B),
UniqueMBRSignature (440B-444B) and Unknown (444B-446B).
@@ -982,11 +1036,14 @@ _write_pmbr (PedDevice * dev)
if (ped_device_read (dev, &pmbr, 0, GPT_PMBR_SECTORS) < GPT_PMBR_SECTORS)
memset (&pmbr, 0, sizeof(pmbr));
/* The UEFI spec is not clear about what to do with the following
elements of the Protective MBR (pmbr): BootCode (0-440B),
UniqueMBRSignature (440B-444B) and Unknown (444B-446B).
@@ -1076,10 +1130,13 @@ _write_pmbr (PedDevice *dev)
return 0;
LegacyMBR_t *pmbr = s0;
+#ifndef GPT_SYNC_MBR
/* Zero out all the legacy partitions.
There are 4 PartitionRecords. */
memset (pmbr.PartitionRecord, 0, sizeof pmbr.PartitionRecord);
/* Zero out the legacy partitions. */
memset (pmbr->PartitionRecord, 0, sizeof pmbr->PartitionRecord);
+#endif
pmbr.Signature = PED_CPU_TO_LE16(MSDOS_MBR_SIGNATURE);
pmbr->Signature = PED_CPU_TO_LE16 (MSDOS_MBR_SIGNATURE);
+#ifndef GPT_SYNC_MBR
pmbr.PartitionRecord[0].OSType = EFI_PMBR_OSTYPE_EFI;
pmbr.PartitionRecord[0].StartSector = 1;
pmbr.PartitionRecord[0].EndHead = 0xFE;
@@ -997,6 +1054,54 @@ _write_pmbr (PedDevice * dev)
pmbr.PartitionRecord[0].SizeInLBA = PED_CPU_TO_LE32(0xFFFFFFFF);
else
pmbr.PartitionRecord[0].SizeInLBA = PED_CPU_TO_LE32(dev->length - 1UL);
pmbr->PartitionRecord[0].OSType = EFI_PMBR_OSTYPE_EFI;
pmbr->PartitionRecord[0].StartSector = 1;
pmbr->PartitionRecord[0].EndHead = 0xFE;
@@ -1090,6 +1147,54 @@ _write_pmbr (PedDevice *dev)
pmbr->PartitionRecord[0].SizeInLBA = PED_CPU_TO_LE32 (0xFFFFFFFF);
else
pmbr->PartitionRecord[0].SizeInLBA = PED_CPU_TO_LE32 (dev->length - 1UL);
+#else
+ /* Search for an EFI System Partition */
+ esp = _find_first_part(disk);
+ if (!esp || !esp->fs_type || strncmp (esp->fs_type->name, "fat", 3) != 0)
+ esp = NULL;
+ /* Search for an EFI System Partition */
+ esp = _find_first_part(disk);
+ if (!esp || !esp->fs_type || strncmp (esp->fs_type->name, "fat", 3) != 0)
+ esp = NULL;
+
+ pmbr_id = 3;
+ if (esp) {
+ pmbr_id = 0;
+ first_entry = 1;
+ last_entry = 4;
+ }
+ pmbr_id = 3;
+ if (esp) {
+ pmbr_id = 0;
+ first_entry = 1;
+ last_entry = 4;
+ }
+
+ /* Write a pseudo-PMBR so Linux is happy */
+ pmbr.PartitionRecord[pmbr_id].OSType = EFI_PMBR_OSTYPE_EFI;
+ pmbr.PartitionRecord[pmbr_id].StartSector = 1;
+ pmbr.PartitionRecord[pmbr_id].EndHead = 0xFE;
+ pmbr.PartitionRecord[pmbr_id].EndSector = 0xFF;
+ pmbr.PartitionRecord[pmbr_id].EndTrack = 0xFF;
+ pmbr.PartitionRecord[pmbr_id].StartingLBA = PED_CPU_TO_LE32(1);
+ pmbr.PartitionRecord[pmbr_id].SizeInLBA = 1;
+ if (esp)
+ pmbr.PartitionRecord[pmbr_id].SizeInLBA = esp->geom.end - 1;
+ /* Write a pseudo-PMBR so Linux is happy */
+ pmbr->PartitionRecord[pmbr_id].OSType = EFI_PMBR_OSTYPE_EFI;
+ pmbr->PartitionRecord[pmbr_id].StartSector = 1;
+ pmbr->PartitionRecord[pmbr_id].EndHead = 0xFE;
+ pmbr->PartitionRecord[pmbr_id].EndSector = 0xFF;
+ pmbr->PartitionRecord[pmbr_id].EndTrack = 0xFF;
+ pmbr->PartitionRecord[pmbr_id].StartingLBA = PED_CPU_TO_LE32(1);
+ pmbr->PartitionRecord[pmbr_id].SizeInLBA = 1;
+ if (esp)
+ pmbr->PartitionRecord[pmbr_id].SizeInLBA = esp->geom.end - 1;
+
+ /* sync the first 3 GPT entries to MBR primary partitions */
+ for (i=first_entry; i < last_entry; i++) {
+ part = ped_disk_next_partition (disk, part);
+ if (part == NULL)
+ break;
+ /* we might get a starting garbage partition */
+ if (part->geom.start == 0 || part->type == PED_PARTITION_METADATA || part->type == PED_PARTITION_FREESPACE || part == esp) {
+ i--;
+ continue;
+ }
+ pmbr.PartitionRecord[i].OSType = _part_to_ostype(part);
+ pmbr.PartitionRecord[i].StartSector = 1;
+ pmbr.PartitionRecord[i].StartHead = 0xFE;
+ pmbr.PartitionRecord[i].StartSector = 0xFF;
+ pmbr.PartitionRecord[i].StartTrack = 0xFF;
+ pmbr.PartitionRecord[i].EndHead = 0xFE;
+ pmbr.PartitionRecord[i].EndSector = 0xFF;
+ pmbr.PartitionRecord[i].EndTrack = 0xFF;
+ pmbr.PartitionRecord[i].StartingLBA = _part_32bitmax(part->geom.start);
+ if(((GPTPartitionData*)part->disk_specific)->boot)
+ pmbr.PartitionRecord[i].BootIndicator = 0x80;
+ pmbr.PartitionRecord[i].SizeInLBA = _part_32bitmax(part->geom.end - part->geom.start);
+ }
+ /* sync the first 3 GPT entries to MBR primary partitions */
+ for (i=first_entry; i < last_entry; i++) {
+ part = ped_disk_next_partition (disk, part);
+ if (part == NULL)
+ break;
+ /* we might get a starting garbage partition */
+ if (part->geom.start == 0 || part->type == PED_PARTITION_METADATA || part->type == PED_PARTITION_FREESPACE || part == esp) {
+ i--;
+ continue;
+ }
+ pmbr->PartitionRecord[i].OSType = _part_to_ostype(part);
+ pmbr->PartitionRecord[i].StartSector = 1;
+ pmbr->PartitionRecord[i].StartHead = 0xFE;
+ pmbr->PartitionRecord[i].StartSector = 0xFF;
+ pmbr->PartitionRecord[i].StartTrack = 0xFF;
+ pmbr->PartitionRecord[i].EndHead = 0xFE;
+ pmbr->PartitionRecord[i].EndSector = 0xFF;
+ pmbr->PartitionRecord[i].EndTrack = 0xFF;
+ pmbr->PartitionRecord[i].StartingLBA = _part_32bitmax(part->geom.start);
+ if(((GPTPartitionData*)part->disk_specific)->boot)
+ pmbr->PartitionRecord[i].BootIndicator = 0x80;
+ pmbr->PartitionRecord[i].SizeInLBA = _part_32bitmax(part->geom.end - part->geom.start);
+ }
+#endif
return ped_device_write (dev, &pmbr, GPT_PMBR_LBA, GPT_PMBR_SECTORS);
}
@@ -1100,7 +1205,7 @@ gpt_write(const PedDisk * disk)
ptes_crc = efi_crc32 (ptes, ptes_size);
int write_ok = ped_device_write (dev, pmbr, GPT_PMBR_LBA,
GPT_PMBR_SECTORS);
@@ -1204,7 +1309,7 @@ gpt_write (const PedDisk *disk)
ptes_crc = efi_crc32 (ptes, ptes_size);
/* Write protective MBR */
- if (!_write_pmbr (disk->dev))
+ if (!_write_pmbr (disk))
goto error_free_ptes;
/* Write protective MBR */
- if (!_write_pmbr (disk->dev))
+ if (!_write_pmbr (disk))
goto error_free_ptes;
/* Write PTH and PTEs */
/* Write PTH and PTEs */

View File

@ -1,8 +1,8 @@
Index: parted-1.9.0/libparted/disk.c
Index: parted-2.1/libparted/disk.c
===================================================================
--- parted-1.9.0.orig/libparted/disk.c 2009-07-30 15:22:28.000000000 +0200
+++ parted-1.9.0/libparted/disk.c 2009-07-30 15:22:50.000000000 +0200
@@ -969,6 +969,41 @@ _disk_pop_update_mode (PedDisk* disk)
--- parted-2.1.orig/libparted/disk.c 2010-02-02 11:38:31.000000000 +0100
+++ parted-2.1/libparted/disk.c 2010-02-02 11:39:16.000000000 +0100
@@ -1178,6 +1178,41 @@ _disk_pop_update_mode (PedDisk* disk)
* @{
*/
@ -44,12 +44,12 @@ Index: parted-1.9.0/libparted/disk.c
PedPartition*
_ped_partition_alloc (const PedDisk* disk, PedPartitionType type,
const PedFileSystemType* fs_type,
Index: parted-1.9.0/libparted/labels/mac.c
Index: parted-2.1/libparted/labels/mac.c
===================================================================
--- parted-1.9.0.orig/libparted/labels/mac.c 2009-07-23 19:52:08.000000000 +0200
+++ parted-1.9.0/libparted/labels/mac.c 2009-07-30 15:22:50.000000000 +0200
@@ -1375,6 +1375,36 @@ mac_partition_get_name (const PedPartiti
return mac_data->volume_name;
--- parted-2.1.orig/libparted/labels/mac.c 2009-12-16 18:18:13.000000000 +0100
+++ parted-2.1/libparted/labels/mac.c 2010-02-02 11:43:23.000000000 +0100
@@ -1437,6 +1437,36 @@ mac_get_partition_alignment(const PedDis
return ped_alignment_new(0, sector_size);
}
+/* we do not really want to call this ... yet */
@ -85,16 +85,16 @@ Index: parted-1.9.0/libparted/labels/mac.c
static PedConstraint*
_primary_constraint (PedDisk* disk)
{
@@ -1599,6 +1629,8 @@ static PedDiskOps mac_disk_ops = {
partition_is_flag_available: mac_partition_is_flag_available,
@@ -1640,6 +1670,8 @@ static PedDiskOps mac_disk_ops = {
partition_set_name: mac_partition_set_name,
partition_get_name: mac_partition_get_name,
+ partition_set_system_name: mac_partition_set_system_name,
+ partition_get_system_name: mac_partition_get_system_name,
partition_align: mac_partition_align,
partition_enumerate: mac_partition_enumerate,
+ partition_set_system_name: mac_partition_set_system_name,
+ partition_get_system_name: mac_partition_get_system_name,
@@ -1613,7 +1645,7 @@ static PedDiskType mac_disk_type = {
get_partition_alignment: mac_get_partition_alignment,
@@ -1650,7 +1682,7 @@ static PedDiskType mac_disk_type = {
next: NULL,
name: "mac",
ops: &mac_disk_ops,
@ -103,11 +103,11 @@ Index: parted-1.9.0/libparted/labels/mac.c
};
void
Index: parted-1.9.0/include/parted/disk.h
Index: parted-2.1/include/parted/disk.h
===================================================================
--- parted-1.9.0.orig/include/parted/disk.h 2009-07-30 15:22:28.000000000 +0200
+++ parted-1.9.0/include/parted/disk.h 2009-07-30 15:22:50.000000000 +0200
@@ -61,10 +61,11 @@ enum _PedPartitionFlag {
--- parted-2.1.orig/include/parted/disk.h 2010-02-02 11:38:31.000000000 +0100
+++ parted-2.1/include/parted/disk.h 2010-02-02 11:39:16.000000000 +0100
@@ -76,10 +76,11 @@ enum _PedPartitionFlag {
enum _PedDiskTypeFeature {
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
@ -121,7 +121,7 @@ Index: parted-1.9.0/include/parted/disk.h
struct _PedDisk;
struct _PedPartition;
@@ -212,6 +213,8 @@ struct _PedDiskOps {
@@ -239,6 +240,8 @@ struct _PedDiskOps {
/* other */
int (*alloc_metadata) (PedDisk* disk);
int (*get_max_primary_partition_count) (const PedDisk* disk);
@ -129,8 +129,8 @@ Index: parted-1.9.0/include/parted/disk.h
+ const char* (*partition_get_system_name) (const PedPartition* part);
bool (*get_max_supported_partition_count) (const PedDisk* disk,
int* supported);
};
@@ -288,7 +291,9 @@ extern int ped_partition_is_flag_availab
PedAlignment *(*get_partition_alignment)(const PedDisk *disk);
@@ -325,7 +328,9 @@ extern int ped_partition_is_flag_availab
extern int ped_partition_set_system (PedPartition* part,
const PedFileSystemType* fs_type);
extern int ped_partition_set_name (PedPartition* part, const char* name);
@ -140,11 +140,11 @@ Index: parted-1.9.0/include/parted/disk.h
extern int ped_partition_is_busy (const PedPartition* part);
extern char* ped_partition_get_path (const PedPartition* part);
Index: parted-1.9.0/parted/parted.c
Index: parted-2.1/parted/parted.c
===================================================================
--- parted-1.9.0.orig/parted/parted.c 2009-07-30 15:22:28.000000000 +0200
+++ parted-1.9.0/parted/parted.c 2009-07-30 15:23:47.000000000 +0200
@@ -1165,6 +1165,7 @@ partition_print_flags (PedPartition* par
--- parted-2.1.orig/parted/parted.c 2010-02-02 11:38:31.000000000 +0100
+++ parted-2.1/parted/parted.c 2010-02-02 11:39:16.000000000 +0100
@@ -1235,6 +1235,7 @@ partition_print_flags (PedPartition* par
char* res = ped_malloc(1);
void* _res = res;
int xtype;
@ -152,7 +152,7 @@ Index: parted-1.9.0/parted/parted.c
*res = '\0';
@@ -1201,6 +1202,23 @@ partition_print_flags (PedPartition* par
@@ -1269,6 +1270,23 @@ partition_print_flags (PedPartition* par
}
}

View File

@ -0,0 +1,31 @@
From 2d81422f3caea30d9d65ec343a34bc1f447a4f01 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Thu, 11 Mar 2010 19:01:41 +0100
Subject: [PATCH] libparted: remove "HIGHLY EXPERIMENTAL" warning for >512B-sector devices
* libparted/arch/linux.c (_device_set_sector_size): Remove the
"HIGHLY EXPERIMENTAL" warning, now that support for >512-byte sectors
seems to be usable. Suggested by Colin Watson.
---
Index: parted-2.2/libparted/arch/linux.c
===================================================================
--- parted-2.2.orig/libparted/arch/linux.c 2010-04-02 09:53:02.000000000 +0200
+++ parted-2.2/libparted/arch/linux.c 2010-04-02 09:53:43.000000000 +0200
@@ -688,16 +688,6 @@ _device_set_sector_size (PedDevice* dev)
dev->sector_size = PED_SECTOR_SIZE_DEFAULT;
}
#endif
-
- if (dev->sector_size != PED_SECTOR_SIZE_DEFAULT) {
- ped_exception_throw (
- PED_EXCEPTION_WARNING,
- PED_EXCEPTION_OK,
- _("Device %s has a logical sector size of %lld. Not "
- "all parts of GNU Parted support this at the moment, "
- "and the working code is HIGHLY EXPERIMENTAL.\n"),
- dev->path, dev->sector_size);
- }
}
static int

View File

@ -1,8 +1,16 @@
Index: parted-1.9.0/libparted/disk.c
---
include/parted/disk.h | 9 +++++----
libparted/disk.c | 2 ++
libparted/labels/dos.c | 8 ++++++++
parted/parted.c | 24 +++++++++++++++++++++---
parted/ui.c | 3 +++
5 files changed, 39 insertions(+), 7 deletions(-)
Index: parted-2.1/libparted/disk.c
===================================================================
--- parted-1.9.0.orig/libparted/disk.c 2009-07-30 14:59:14.000000000 +0200
+++ parted-1.9.0/libparted/disk.c 2009-07-30 14:59:21.000000000 +0200
@@ -2240,6 +2240,8 @@ ped_partition_flag_get_name (PedPartitio
--- parted-2.1.orig/libparted/disk.c 2010-02-02 11:57:03.000000000 +0100
+++ parted-2.1/libparted/disk.c 2010-02-02 11:57:14.000000000 +0100
@@ -2429,6 +2429,8 @@ ped_partition_flag_get_name (PedPartitio
return N_("lba");
case PED_PARTITION_HPSERVICE:
return N_("hp-service");
@ -11,11 +19,11 @@ Index: parted-1.9.0/libparted/disk.c
case PED_PARTITION_PALO:
return N_("palo");
case PED_PARTITION_PREP:
Index: parted-1.9.0/libparted/labels/dos.c
Index: parted-2.1/libparted/labels/dos.c
===================================================================
--- parted-1.9.0.orig/libparted/labels/dos.c 2009-07-30 14:59:14.000000000 +0200
+++ parted-1.9.0/libparted/labels/dos.c 2009-07-30 14:59:21.000000000 +0200
@@ -1346,6 +1346,10 @@ msdos_partition_set_flag (PedPartition*
--- parted-2.1.orig/libparted/labels/dos.c 2010-02-02 11:57:03.000000000 +0100
+++ parted-2.1/libparted/labels/dos.c 2010-02-02 11:57:14.000000000 +0100
@@ -1397,6 +1397,10 @@ msdos_partition_set_flag (PedPartition*
disk = part->disk;
switch (flag) {
@ -26,7 +34,7 @@ Index: parted-1.9.0/libparted/labels/dos.c
case PED_PARTITION_HIDDEN:
if (part->type == PED_PARTITION_EXTENDED) {
ped_exception_throw (
@@ -1443,6 +1447,9 @@ msdos_partition_get_flag (const PedParti
@@ -1494,6 +1498,9 @@ msdos_partition_get_flag (const PedParti
case PED_PARTITION_LBA:
return dos_data->lba;
@ -36,7 +44,7 @@ Index: parted-1.9.0/libparted/labels/dos.c
case PED_PARTITION_PALO:
return dos_data->palo;
@@ -1464,6 +1471,7 @@ msdos_partition_is_flag_available (const
@@ -1515,6 +1522,7 @@ msdos_partition_is_flag_available (const
case PED_PARTITION_RAID:
case PED_PARTITION_LVM:
case PED_PARTITION_LBA:
@ -44,43 +52,45 @@ Index: parted-1.9.0/libparted/labels/dos.c
case PED_PARTITION_PALO:
case PED_PARTITION_PREP:
return 1;
Index: parted-1.9.0/parted/ui.c
Index: parted-2.1/parted/ui.c
===================================================================
--- parted-1.9.0.orig/parted/ui.c 2009-07-30 14:59:14.000000000 +0200
+++ parted-1.9.0/parted/ui.c 2009-07-30 14:59:21.000000000 +0200
@@ -908,6 +908,9 @@ command_line_get_integer (const char* pr
--- parted-2.1.orig/parted/ui.c 2010-02-02 11:57:03.000000000 +0100
+++ parted-2.1/parted/ui.c 2010-02-02 12:00:01.000000000 +0100
@@ -918,6 +918,9 @@ command_line_get_integer (const char* pr
NULL, 1);
if (!input)
return 0;
+ if (strstr(input, "0x") == input)
+ valid = sscanf (input, "%x", value);
+ else
+ valid = sscanf (input, "%x", value);
+ else
valid = sscanf (input, "%d", value);
free (input);
return valid;
Index: parted-1.9.0/include/parted/disk.h
Index: parted-2.1/include/parted/disk.h
===================================================================
--- parted-1.9.0.orig/include/parted/disk.h 2009-07-30 14:59:14.000000000 +0200
+++ parted-1.9.0/include/parted/disk.h 2009-07-30 14:59:21.000000000 +0200
@@ -51,9 +51,10 @@ enum _PedPartitionFlag {
--- parted-2.1.orig/include/parted/disk.h 2010-02-02 11:57:03.000000000 +0100
+++ parted-2.1/include/parted/disk.h 2010-02-02 11:58:02.000000000 +0100
@@ -65,10 +65,11 @@ enum _PedPartitionFlag {
PED_PARTITION_LBA=7,
PED_PARTITION_HPSERVICE=8,
PED_PARTITION_PALO=9,
- PED_PARTITION_PREP=10,
- PED_PARTITION_MSFT_RESERVED=11,
- PED_PARTITION_BIOS_GRUB=12
+ PED_PARTITION_TYPE=10,
- PED_PARTITION_BIOS_GRUB=12,
- PED_PARTITION_APPLE_TV_RECOVERY=13
+ PED_PARTITION_TYPE=10,
+ PED_PARTITION_PREP=11,
+ PED_PARTITION_MSFT_RESERVED=12,
+ PED_PARTITION_BIOS_GRUB=13
+ PED_PARTITION_BIOS_GRUB=13,
+ PED_PARTITION_APPLE_TV_RECOVERY=14
};
#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT
#define PED_PARTITION_LAST_FLAG PED_PARTITION_BIOS_GRUB
Index: parted-1.9.0/parted/parted.c
#define PED_PARTITION_LAST_FLAG PED_PARTITION_APPLE_TV_RECOVERY
Index: parted-2.1/parted/parted.c
===================================================================
--- parted-1.9.0.orig/parted/parted.c 2009-07-30 14:59:20.000000000 +0200
+++ parted-1.9.0/parted/parted.c 2009-07-30 15:13:40.000000000 +0200
@@ -1164,13 +1164,14 @@ partition_print_flags (PedPartition* par
--- parted-2.1.orig/parted/parted.c 2010-02-02 11:57:03.000000000 +0100
+++ parted-2.1/parted/parted.c 2010-02-02 11:57:14.000000000 +0100
@@ -1234,13 +1234,14 @@ partition_print_flags (PedPartition* par
const char* name;
char* res = ped_malloc(1);
void* _res = res;
@ -96,7 +106,7 @@ Index: parted-1.9.0/parted/parted.c
if (first_flag)
first_flag = 0;
else {
@@ -1180,7 +1181,16 @@ partition_print_flags (PedPartition* par
@@ -1249,7 +1250,16 @@ partition_print_flags (PedPartition* par
res = _res;
strncat (res, ", ", 2);
}
@ -113,16 +123,16 @@ Index: parted-1.9.0/parted/parted.c
+ else {
name = _(ped_partition_flag_get_name (flag));
_res = res;
ped_realloc (&_res, strlen (res) + 1
@@ -1189,6 +1199,7 @@ partition_print_flags (PedPartition* par
strncat (res, name, 21);
ped_realloc (&_res, strlen (res) + 1 + strlen (name));
@@ -1257,6 +1267,7 @@ partition_print_flags (PedPartition* par
strcat(res, name);
}
}
+ }
return res;
}
@@ -1940,12 +1951,19 @@ do_set (PedDevice** dev)
@@ -2057,12 +2068,19 @@ do_set (PedDevice** dev)
goto error_destroy_disk;
if (!command_line_get_part_flag (_("Flag to Invert?"), part, &flag))
goto error_destroy_disk;

View File

@ -1,36 +1,19 @@
Index: parted-1.9.0/libparted/labels/dos.c
Index: parted-2.1/libparted/labels/dos.c
===================================================================
--- parted-1.9.0.orig/libparted/labels/dos.c 2009-07-29 11:31:18.000000000 +0200
+++ parted-1.9.0/libparted/labels/dos.c 2009-07-29 11:36:43.000000000 +0200
@@ -54,6 +54,8 @@ static const char MBR_BOOT_CODE[] = {
#define MSDOS_MAGIC 0xAA55
#define PARTITION_MAGIC_MAGIC 0xf6f6
--- parted-2.1.orig/libparted/labels/dos.c 2010-02-02 13:26:28.000000000 +0100
+++ parted-2.1/libparted/labels/dos.c 2010-02-02 13:28:15.000000000 +0100
@@ -1187,7 +1187,13 @@ msdos_write (const PedDisk* disk)
return 0;
DosRawTable *table = (DosRawTable *) s0;
+#define AIXIPLRECID 0xc9c2d4c1 /* Value is EBCIDIC 'IBMA' */
+
#define PARTITION_EMPTY 0x00
#define PARTITION_FAT12 0x01
#define PARTITION_FAT16_SM 0x04
@@ -193,6 +195,10 @@ msdos_probe (const PedDevice *dev)
if (PED_LE16_TO_CPU (part_table->magic) != MSDOS_MAGIC)
goto probe_fail;
+ /* Is this an AIX IPL label? Then just go away. */
+ if (PED_BE32_TO_CPU (*(unsigned int*)(part_table->boot_code)) == AIXIPLRECID)
+ goto probe_fail;
+
/* If this is a FAT fs, fail here. Checking for the FAT signature
* has some false positives; instead, do what the Linux kernel does
* and ensure that each partition has a boot indicator that is
@@ -1142,7 +1148,10 @@ msdos_write (const PedDisk* disk)
ped_device_read (disk->dev, &table, 0, 1);
- if (!table.boot_code[0]) {
- if (!table->boot_code[0]) {
+ /* either no bootrecord at all, or AIX IPL signature ... */
+ if ((!table.boot_code[0]) ||
+ (PED_BE32_TO_CPU (*(unsigned int*)(table.boot_code)) == AIXIPLRECID)
+ ) {
memset (table.boot_code, 0, 512);
memcpy (table.boot_code, MBR_BOOT_CODE, sizeof (MBR_BOOT_CODE));
+ if ( (!table->boot_code[0]) ||
+ ( table->boot_code[0] == (char) 0xc9 &&
+ table->boot_code[1] == (char) 0xc2 &&
+ table->boot_code[2] == (char) 0xd4 &&
+ table->boot_code[3] == (char) 0xc1)
+ ) {
memset (table->boot_code, 0, 512);
memcpy (table->boot_code, MBR_BOOT_CODE, sizeof (MBR_BOOT_CODE));
}

View File

@ -1,3 +1,133 @@
-------------------------------------------------------------------
Fri Apr 2 08:41:02 UTC 2010 - puzel@novell.com
- add parted-remove-experimental-warning.patch
- refresh always_print_geom.diff to apply at correct function
-------------------------------------------------------------------
Fri Feb 26 17:56:05 UTC 2010 - puzel@novell.com
- update to parted-2.2
- Changes in behavior
- The default alignment (--align option) for newly created
partitions has been changed to optimal.
- New features
- The ped_device_get_*_alignment() functions now return a sane
default value instead of NULL when the so called topology
information is incomplete. The default minimum alignment aligns
to physical sector size, the default optimal alignment is 1MiB,
which is what vista and windows 7 do.
- Bug fixes
- Parted no longer uses a physical sector size of 0 or of any
other value smaller than the logical sector size.
- dos: creating an HFS or HFS+ partition in an msdos partition
table used to set the partition type to 0x83. That is wrong.
The required number is 0xaf, and that is what is used now.
- gpt: read-only operation could clobber MBR part of hybrid
GPT+MBR table [bug introduced in parted-2.1]
- gpt: a read-only operation like "parted $dev print" would
overwrite $dev's protective MBR when exactly one of the primary
and backup GPT tables was found to be corrupt. [bug introduced
prior to parted-1.8.0]
- sun: the version, sanity and nparts VTOC fields were ignored by
libparted. Those fields are properly initialized now. The
nparts (number of partitions) field is initialized to 8 (max.
number of sun partitions) rather that to a real number of
partitions. This solution is compatible with Linux kernel and
Linux fdisk.
- libparted: try harder to inform kernel of partition changes.
Previously when editing partitions, occasionally the kernel
would fail to be informed of partition changes. When this
happened future problems would occur because the kernel had
incorrect information. For example, if this problem arose when
resizing or creating a new partition, then an incorrect
partition size might be displayed or a user might encounter a
failure to format or delete a newly created partition,
respectively.
- libparted: committing a disk that was returned by
ped_disk_duplicate would always result in ped_disk_clobber being
called (and thus the first and last 9KiB of the disk being
zeroed), even if the duplicated disk, was not returned by
ped_disk_fresh().
- drop do-not-install-test-programs.patch (fixed in upstream)
-------------------------------------------------------------------
Wed Feb 17 16:33:01 UTC 2010 - puzel@novell.com
- add do-not-install-test-programs.patch
- avoid deleting this in specfile
-------------------------------------------------------------------
Mon Feb 1 13:34:10 UTC 2010 - puzel@novell.com
- update to parted-2.1 (noteworthy changes)
* New features
- new --align=<align> commandline option which can have the
following values:
- none: Use the minimum alignment allowed by the disk type
- cylinder: Align partitions to cylinders (the default)
- minimal: Use minimum alignment as given by the disk
topology information
- optimal: Use optimum alignment as given by the disk
topology information
The minimal and optimal values will use layout information
provided by the disk to align the logical partition table
addresses to actual physical blocks on the disks. The minimal
value uses the minimum alignment needed to align the partition
properly to physical blocks, which avoids performance
degradation. Where as the optimal value uses a multiple of the
physical block size in a way that guarantees optimal
performance. The min and opt values will only work when
compiled with libblkid >= 2.17 and running on a kernel >=
2.6.31, otherwise they will behave as the none --align value.
- Parted now supports disks with sector size larger than 512 bytes.
Before this release, parted could operate only on disks with a
sector size of 512 bytes. However, disk manufacturers are
already making disks with an exposed hardware sector size of
4096 bytes. Prior versions of parted cannot even read a
partition table on such a device, not to mention create or
manipulate existing partition tables. Due to internal design
and time constraints, the following less-common partition
table types are currently disabled:
- amiga, bsd, aix, pc98
- new command "align-check TYPE N" to determine whether the
starting sector of partition N is
TYPE(minimal|optimal)-aligned for the disk. The same
libblkid and kernel version requirements apply as for --align
* Bug fixes
- parted can once again create partition tables on loop devices.
- improved >512-byte sector support
- gpt tables are more rigorously checked
- improved dasd disk support
- handle device nodes created by lvm built with udev
synchronisation enabled properly.
- when printing tables, parted no longer truncates flag names
- Partitions in a GPT table are no longer assigned the
"microsoft reserved partition" type. Before this change,
each partition would be listed with a type of "msftres" by
default.
* Notice
- Parted stopped using BLKPG_* ioctls to inform the kernel
about changes of the partition table. The consequence of this
change is that parted alone can no longer inform the kernel
about changes to partition table on a disk where some of the
partitions are mounted.
- build requires check-devel and pkg-config
- drop parted-1.8.3.dif - fixed by adding pkg-config and check-devel
to BuildRequires
- drop parted.tty.patch, parted.no-O_DIRECT.patch,
do-not-discard-bootcode-in-extended-partition.patch,
avoid-unnecessary-open-close.patch,
do-not-unnecessarily-open-part-dev.patch
- fixed upstream
- drop fix-tests.sh - make check disabled in specfile
- drop fix-error-informing-the-kernel.patch,
fix-race-call-udevadm-settle.patch,
retry-blkpg-ioctl.patch, use-ext-range.patch
- affected code removed as part of the BLKPG to BLKRRPART
switch
- clean up specfile
-------------------------------------------------------------------
Mon Feb 1 12:22:54 UTC 2010 - jengelh@medozas.de

View File

@ -1,40 +0,0 @@
---
libparted/arch/linux.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
Index: parted-1.9.0/libparted/arch/linux.c
===================================================================
--- parted-1.9.0.orig/libparted/arch/linux.c 2009-07-29 14:01:00.000000000 +0200
+++ parted-1.9.0/libparted/arch/linux.c 2009-07-29 14:07:44.000000000 +0200
@@ -66,15 +66,9 @@
#define HDIO_GETGEO 0x0301 /* get device geometry */
#define HDIO_GET_IDENTITY 0x030d /* get IDE identification info */
-#if defined(O_DIRECT) && !(defined(__s390__) || defined(__s390x__))
-#define RD_MODE (O_RDONLY | O_DIRECT)
-#define WR_MODE (O_WRONLY | O_DIRECT)
-#define RW_MODE (O_RDWR | O_DIRECT)
-#else
#define RD_MODE (O_RDONLY)
#define WR_MODE (O_WRONLY)
#define RW_MODE (O_RDWR)
-#endif
struct hd_geometry {
unsigned char heads;
@@ -1409,6 +1403,7 @@ _flush_cache (PedDevice* dev)
fd = open (name, WR_MODE, 0);
if (fd > 0) {
ioctl (fd, BLKFLSBUF);
+ fsync (fd);
close (fd);
}
}
@@ -1471,6 +1466,7 @@ linux_close (PedDevice* dev)
if (dev->dirty)
_flush_cache (dev);
+ fsync (arch_specific->fd);
close (arch_specific->fd);
return 1;
}

View File

@ -1,5 +1,5 @@
#
# spec file for package parted (Version 1.9.0)
# spec file for package parted (Version 2.2)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@ -15,59 +15,43 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# norootforbuild
Name: parted
BuildRequires: device-mapper-devel
BuildRequires: e2fsprogs-devel
BuildRequires: libreiserfs-devel
BuildRequires: readline-devel
BuildRequires: libsepol-devel
BuildRequires: libselinux-devel
%define aclocaldir /usr/share/aclocal
License: GPLv3+
Group: System/Filesystems
Requires: /sbin/udevadm
Version: 2.2
Release: 4
License: GPL v3 or later
Summary: GNU partitioner
Version: 1.9.0
Release: 5
Url: http://www.gnu.org/software/parted/
Group: System/Filesystems
Source0: %{name}-%{version}.tar.bz2
Source1: baselibs.conf
Patch0: always-resize-part.dif
Patch1: parted-type.patch
Patch2: parted-mac.patch
Patch2: parted-mac.patch
Patch3: parted-wipeaix.patch
Patch4: etherd_support.diff
Patch5: parted-1.8.3.dif
Patch6: hfs_fix.dif
Patch7: always_print_geom.diff
Patch8: fix-function-def.patch
Patch9: parted.tty.patch
Patch10: parted.no-O_DIRECT.patch
Patch11: parted-gpt-mbr-sync.patch
Patch12: parted-no-inttypes-include
Patch13: fix-error-informing-the-kernel.patch
Patch14: do-not-discard-bootcode-in-extended-partition.patch
Patch5: hfs_fix.dif
Patch6: always_print_geom.diff
Patch7: fix-function-def.patch
Patch8: parted-gpt-mbr-sync.patch
Patch9: parted-no-inttypes-include
#PATCH-FEATURE-OPENSUSE fix-dm-partition-name.patch bnc471440,447591 petr.uzel@suse.cz
Patch15: fix-dm-partition-name.patch
#PATCH-FEATURE-OPENSUSE fix-tests.sh petr.uzel@suse.cz
Patch16: fix-tests.sh
Patch10: fix-dm-partition-name.patch
#PATCH-FEATURE-OPENSUSE do-not-create-dm-nodes.patch bnc#501773 petr.uzel@suse.cz
Patch17: do-not-create-dm-nodes.patch
#PATCH-FIX-UPSTREAM avoid-unnecessary-open-close.patch bnc#539521 petr.uzel@suse.cz
Patch18: avoid-unnecessary-open-close.patch
#PATCH-FIX-UPSTREAM do-not-unnecessarily-open-part-dev.patch bnc#539521 petr.uzel@suse.cz
Patch19: do-not-unnecessarily-open-part-dev.patch
#PATCH-FIX-UPSTREAM fix-race-call-udevadm-settle.patch bnc#539521 petr.uzel@suse.cz
Patch20: fix-race-call-udevadm-settle.patch
#PATCH-FIX-UPSTREAM retry-blkpg-ioctl.patch bnc#539521 petr.uzel@suse.cz
Patch21: retry-blkpg-ioctl.patch
#PATCH-FIX-UPSTREAM use-ext-range.patch bnc#567652 petr.uzel@suse.cz
Patch22: use-ext-range.patch
Patch11: do-not-create-dm-nodes.patch
#PATCH-FIX-UPSTREAM parted-remove-experimental-warning.patch
Patch12: parted-remove-experimental-warning.patch
Requires: /sbin/udevadm
BuildRequires: check-devel
BuildRequires: device-mapper-devel >= 1.02.33
BuildRequires: e2fsprogs-devel
BuildRequires: libreiserfs-devel
BuildRequires: libselinux-devel
BuildRequires: libsepol-devel
BuildRequires: pkg-config
BuildRequires: readline-devel
Requires: %install_info_prereq
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Url: http://www.gnu.org/software/parted/
PreReq: %install_info_prereq
# bug437293
%ifarch ppc64
Obsoletes: parted-64bit
@ -77,15 +61,14 @@ Obsoletes: parted-64bit
GNU Parted is a program for creating, destroying, resizing, checking,
and copying partitions, and the file systems on them.
Authors:
--------
Andrew Clausen <clausen@gnu.org>
%package devel
License: GPLv2+
License: GPL v3 or later
Summary: Parted Include Files and Libraries necessary for Development
Group: Development/Libraries/C and C++
Requires: e2fsprogs-devel parted = %version device-mapper-devel libreiserfs-devel
Requires: device-mapper-devel >= 1.02.33
Requires: e2fsprogs-devel
Requires: libreiserfs-devel
Requires: parted = %version
# bug437293
%ifarch ppc64
Obsoletes: parted-devel-64bit
@ -95,15 +78,6 @@ Obsoletes: parted-devel-64bit
This package contains all necessary include files and libraries needed
to develop applications that require these.
Authors:
--------
Andrew Clausen <clausen@gnu.org>
Lennert Buytenhek <buytenh@gnu.org>
Matthew Wilson <msw@redhat.com>
Masahiro Sakai <ZVM01052@nifty.ne.jp>
Ben Collins <vincent.stelhe@free.fr>
Matt Domsch <Matt_Domsch@dell.com>
%lang_package
%prep
%setup -q
@ -112,24 +86,14 @@ Authors:
%patch2 -p1
%patch3 -p1
%patch4 -p0
%patch5
%patch6 -p1
%patch5 -p1
%patch6
%patch7
%patch8
%patch9 -p1
%patch10 -p1
%patch11
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%build
AUTOPOINT=true autoreconf --force --install
@ -142,12 +106,12 @@ AUTOPOINT=true autoreconf --force --install
make %{?jobs:-j%jobs}
%install
make DESTDIR="$RPM_BUILD_ROOT" install
rm $RPM_BUILD_ROOT%{_libdir}/*.la
%makeinstall
rm %{buildroot}%{_libdir}/*.la
%find_lang %{name}
%clean
rm -rf "$RPM_BUILD_ROOT"
rm -rf %{buildroot}
%post
/sbin/ldconfig
@ -168,7 +132,7 @@ rm -rf "$RPM_BUILD_ROOT"
%files devel
%defattr(-,root,root)
%doc doc/API doc/FAT
%{_prefix}/include/*
%{_includedir}/*
%{_libdir}/pkgconfig/libparted.pc
%{_libdir}/*.so

View File

@ -1,18 +0,0 @@
Index: parted-1.9.0/parted/ui.c
===================================================================
--- parted-1.9.0.orig/parted/ui.c 2009-07-30 16:28:35.000000000 +0200
+++ parted-1.9.0/parted/ui.c 2009-07-30 16:28:38.000000000 +0200
@@ -1402,9 +1402,13 @@ init_ui ()
ped_exception_set_handler (exception_handler);
#ifdef HAVE_LIBREADLINE
+ /* check for tty is favorable here because readline might try to set some
+ * terminal stuff that messes up parsing in non-interactive mode */
+ if( isatty(fileno(stdout)) ) {
rl_initialize ();
rl_attempted_completion_function = (CPPFunction*) complete_function;
readline_state.in_readline = 0;
+ }
#endif
#ifdef SA_SIGINFO

View File

@ -1,22 +0,0 @@
Index: parted-1.9.0/libparted/arch/linux.c
===================================================================
--- parted-1.9.0.orig/libparted/arch/linux.c 2010-01-25 16:24:54.000000000 +0100
+++ parted-1.9.0/libparted/arch/linux.c 2010-01-25 16:26:35.000000000 +0100
@@ -2360,8 +2360,17 @@ _disk_sync_part_table (PedDisk* disk)
int i;
for (i = 1; i <= lpn; i++) {
+ /* try to BLKPG_REMOVE the partition
+ * retry once more after short sleep if EBUSY
+ */
rets[i - 1] = _blkpg_remove_partition (disk, i);
errnums[i - 1] = errno;
+
+ if ( !rets[i - 1] && errnums[i - 1] == EBUSY ) {
+ sleep(1);
+ rets[i - 1] = _blkpg_remove_partition (disk, i);
+ errnums[i - 1] = errno;
+ }
}
for (i = 1; i <= lpn; i++) {

View File

@ -1,22 +0,0 @@
Index: parted-1.9.0/libparted/arch/linux.c
===================================================================
--- parted-1.9.0.orig/libparted/arch/linux.c 2010-01-25 16:32:09.000000000 +0100
+++ parted-1.9.0/libparted/arch/linux.c 2010-01-25 16:33:18.000000000 +0100
@@ -2296,7 +2296,7 @@ _blkpg_remove_partition (PedDisk* disk,
/*
* The number of partitions that a device can have depends on the kernel.
- * If we don't find this value in /sys/block/DEV/range, we will use our own
+ * If we don't find this value in /sys/block/DEV/ext_range, we will use our own
* value.
*/
static unsigned int
@@ -2307,7 +2307,7 @@ _device_get_partition_range(PedDevice* d
FILE* fp;
bool ok;
- r = snprintf(path, sizeof(path), "/sys/block/%s/range",
+ r = snprintf(path, sizeof(path), "/sys/block/%s/ext_range",
last_component(dev->path));
if(r < 0 || r >= sizeof(path))
return MAX_NUM_PARTS;