- New upstream release 2.1
- Drop all our patches (all merged upstream)
This commit is contained in:
parent
c11ab73298
commit
33fde2056a
@ -1 +1 @@
|
||||
parted-1.9.0.tar.xz
|
||||
parted-2.1.tar.xz
|
||||
|
@ -1,198 +0,0 @@
|
||||
From fc419e55f358fae46ca24f15f5ce2bc7ff1b9e4a Mon Sep 17 00:00:00 2001
|
||||
From: Joel Granados Moreno <jgranado@redhat.com>
|
||||
Date: Thu, 11 Jun 2009 16:06:43 +0200
|
||||
Subject: [PATCH] Add support for appletv partitions.
|
||||
|
||||
---
|
||||
include/parted/disk.h | 5 ++-
|
||||
libparted/disk.c | 2 +
|
||||
libparted/labels/gpt.c | 50 ++++++++++++++++++++++++++++++++++++++---------
|
||||
3 files changed, 45 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/include/parted/disk.h b/include/parted/disk.h
|
||||
index 691f413..5207e0b 100644
|
||||
--- a/include/parted/disk.h
|
||||
+++ b/include/parted/disk.h
|
||||
@@ -53,10 +53,11 @@ enum _PedPartitionFlag {
|
||||
PED_PARTITION_PALO=9,
|
||||
PED_PARTITION_PREP=10,
|
||||
PED_PARTITION_MSFT_RESERVED=11,
|
||||
- PED_PARTITION_BIOS_GRUB=12
|
||||
+ PED_PARTITION_BIOS_GRUB=12,
|
||||
+ PED_PARTITION_APPLE_TV_RECOVERY=13
|
||||
};
|
||||
#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT
|
||||
-#define PED_PARTITION_LAST_FLAG PED_PARTITION_BIOS_GRUB
|
||||
+#define PED_PARTITION_LAST_FLAG PED_PARTITION_APPLE_TV_RECOVERY
|
||||
|
||||
enum _PedDiskTypeFeature {
|
||||
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
|
||||
diff --git a/libparted/disk.c b/libparted/disk.c
|
||||
index 5fb8060..3269b9d 100644
|
||||
--- a/libparted/disk.c
|
||||
+++ b/libparted/disk.c
|
||||
@@ -2246,6 +2246,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
|
||||
return N_("prep");
|
||||
case PED_PARTITION_MSFT_RESERVED:
|
||||
return N_("msftres");
|
||||
+ case PED_PARTITION_APPLE_TV_RECOVERY:
|
||||
+ return N_("atvrecv");
|
||||
|
||||
default:
|
||||
ped_exception_throw (
|
||||
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
|
||||
index 536e06a..73bdbb2 100644
|
||||
--- a/libparted/labels/gpt.c
|
||||
+++ b/libparted/labels/gpt.c
|
||||
@@ -127,6 +127,10 @@ typedef struct {
|
||||
((efi_guid_t) { PED_CPU_TO_LE32 (0x48465300), PED_CPU_TO_LE16 (0x0000), \
|
||||
PED_CPU_TO_LE16 (0x11AA), 0xaa, 0x11, \
|
||||
{ 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC }})
|
||||
+#define PARTITION_APPLE_TV_RECOVERY_GUID \
|
||||
+ ((efi_guid_t) { PED_CPU_TO_LE32 (0x5265636F), PED_CPU_TO_LE16 (0x7665), \
|
||||
+ PED_CPU_TO_LE16 (0x11AA), 0xaa, 0x11, \
|
||||
+ { 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC }})
|
||||
|
||||
struct __attribute__ ((packed)) _GuidPartitionTableHeader_t {
|
||||
uint64_t Signature;
|
||||
@@ -254,6 +258,7 @@ typedef struct _GPTPartitionData {
|
||||
int hp_service;
|
||||
int hidden;
|
||||
int msftres;
|
||||
+ int atvrecv;
|
||||
} GPTPartitionData;
|
||||
|
||||
static PedDiskType gpt_disk_type;
|
||||
@@ -768,7 +773,7 @@ _parse_part_entry (PedDisk* disk, GuidPartitionEntry_t* pte)
|
||||
gpt_part_data->lvm = gpt_part_data->raid
|
||||
= gpt_part_data->boot = gpt_part_data->hp_service
|
||||
= gpt_part_data->hidden = gpt_part_data->msftres
|
||||
- = gpt_part_data->bios_grub = 0;
|
||||
+ = gpt_part_data->bios_grub = gpt_part_data->atvrecv = 0;
|
||||
|
||||
if (pte->Attributes.RequiredToFunction & 0x1)
|
||||
gpt_part_data->hidden = 1;
|
||||
@@ -783,9 +788,11 @@ _parse_part_entry (PedDisk* disk, GuidPartitionEntry_t* pte)
|
||||
gpt_part_data->lvm = 1;
|
||||
else if (!guid_cmp (gpt_part_data->type, PARTITION_HPSERVICE_GUID))
|
||||
gpt_part_data->hp_service = 1;
|
||||
- else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RESERVED_GUID))
|
||||
- gpt_part_data->msftres = 1;
|
||||
-
|
||||
+ else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RESERVED_GUID))
|
||||
+ gpt_part_data->msftres = 1;
|
||||
+ else if (!guid_cmp (gpt_part_data->type, PARTITION_APPLE_TV_RECOVERY_GUID))
|
||||
+ gpt_part_data->atvrecv = 1;
|
||||
+
|
||||
return part;
|
||||
}
|
||||
|
||||
@@ -1182,6 +1189,7 @@ gpt_partition_new (const PedDisk* disk,
|
||||
gpt_part_data->hp_service = 0;
|
||||
gpt_part_data->hidden = 0;
|
||||
gpt_part_data->msftres = 0;
|
||||
+ gpt_part_data->atvrecv = 0;
|
||||
uuid_generate ((unsigned char*) &gpt_part_data->uuid);
|
||||
swap_uuid_and_efi_guid((unsigned char*)(&gpt_part_data->uuid));
|
||||
memset (gpt_part_data->name, 0, sizeof gpt_part_data->name);
|
||||
@@ -1269,6 +1277,11 @@ gpt_partition_set_system (PedPartition* part, const PedFileSystemType* fs_type)
|
||||
gpt_part_data->type = PARTITION_MSFT_RESERVED_GUID;
|
||||
return 1;
|
||||
}
|
||||
+ if (gpt_part_data->atvrecv) {
|
||||
+ gpt_part_data->type = PARTITION_APPLE_TV_RECOVERY_GUID;
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
|
||||
if (fs_type) {
|
||||
if (strncmp (fs_type->name, "fat", 3) == 0
|
||||
@@ -1361,7 +1374,8 @@ gpt_partition_set_flag(PedPartition *part,
|
||||
= gpt_part_data->lvm
|
||||
= gpt_part_data->bios_grub
|
||||
= gpt_part_data->hp_service
|
||||
- = gpt_part_data->msftres = 0;
|
||||
+ = gpt_part_data->msftres
|
||||
+ = gpt_part_data->atvrecv = 0;
|
||||
return gpt_partition_set_system (part, part->fs_type);
|
||||
case PED_PARTITION_BIOS_GRUB:
|
||||
gpt_part_data->bios_grub = state;
|
||||
@@ -1370,7 +1384,8 @@ gpt_partition_set_flag(PedPartition *part,
|
||||
= gpt_part_data->lvm
|
||||
= gpt_part_data->boot
|
||||
= gpt_part_data->hp_service
|
||||
- = gpt_part_data->msftres = 0;
|
||||
+ = gpt_part_data->msftres
|
||||
+ = gpt_part_data->atvrecv = 0;
|
||||
return gpt_partition_set_system (part, part->fs_type);
|
||||
case PED_PARTITION_RAID:
|
||||
gpt_part_data->raid = state;
|
||||
@@ -1379,7 +1394,8 @@ gpt_partition_set_flag(PedPartition *part,
|
||||
= gpt_part_data->lvm
|
||||
= gpt_part_data->bios_grub
|
||||
= gpt_part_data->hp_service
|
||||
- = gpt_part_data->msftres = 0;
|
||||
+ = gpt_part_data->msftres
|
||||
+ = gpt_part_data->atvrecv = 0;
|
||||
return gpt_partition_set_system (part, part->fs_type);
|
||||
case PED_PARTITION_LVM:
|
||||
gpt_part_data->lvm = state;
|
||||
@@ -1388,7 +1404,8 @@ gpt_partition_set_flag(PedPartition *part,
|
||||
= gpt_part_data->raid
|
||||
= gpt_part_data->bios_grub
|
||||
= gpt_part_data->hp_service
|
||||
- = gpt_part_data->msftres = 0;
|
||||
+ = gpt_part_data->msftres
|
||||
+ = gpt_part_data->atvrecv = 0;
|
||||
return gpt_partition_set_system (part, part->fs_type);
|
||||
case PED_PARTITION_HPSERVICE:
|
||||
gpt_part_data->hp_service = state;
|
||||
@@ -1397,7 +1414,8 @@ gpt_partition_set_flag(PedPartition *part,
|
||||
= gpt_part_data->raid
|
||||
= gpt_part_data->lvm
|
||||
= gpt_part_data->bios_grub
|
||||
- = gpt_part_data->msftres = 0;
|
||||
+ = gpt_part_data->msftres
|
||||
+ = gpt_part_data->atvrecv = 0;
|
||||
return gpt_partition_set_system (part, part->fs_type);
|
||||
case PED_PARTITION_MSFT_RESERVED:
|
||||
gpt_part_data->msftres = state;
|
||||
@@ -1406,8 +1424,17 @@ gpt_partition_set_flag(PedPartition *part,
|
||||
= gpt_part_data->raid
|
||||
= gpt_part_data->lvm
|
||||
= gpt_part_data->bios_grub
|
||||
- = gpt_part_data->hp_service = 0;
|
||||
+ = gpt_part_data->hp_service
|
||||
+ = gpt_part_data->atvrecv = 0;
|
||||
return gpt_partition_set_system (part, part->fs_type);
|
||||
+ case PED_PARTITION_APPLE_TV_RECOVERY:
|
||||
+ gpt_part_data->atvrecv = state;
|
||||
+ if (state)
|
||||
+ gpt_part_data->boot
|
||||
+ = gpt_part_data->raid
|
||||
+ = gpt_part_data->lvm
|
||||
+ = gpt_part_data->hp_service
|
||||
+ = gpt_part_data->msftres = 0;
|
||||
case PED_PARTITION_HIDDEN:
|
||||
gpt_part_data->hidden = state;
|
||||
return 1;
|
||||
@@ -1440,6 +1467,8 @@ gpt_partition_get_flag(const PedPartition *part, PedPartitionFlag flag)
|
||||
return gpt_part_data->hp_service;
|
||||
case PED_PARTITION_MSFT_RESERVED:
|
||||
return gpt_part_data->msftres;
|
||||
+ case PED_PARTITION_APPLE_TV_RECOVERY:
|
||||
+ return gpt_part_data->atvrecv;
|
||||
case PED_PARTITION_HIDDEN:
|
||||
return gpt_part_data->hidden;
|
||||
case PED_PARTITION_SWAP:
|
||||
@@ -1462,6 +1491,7 @@ gpt_partition_is_flag_available(const PedPartition * part,
|
||||
case PED_PARTITION_BIOS_GRUB:
|
||||
case PED_PARTITION_HPSERVICE:
|
||||
case PED_PARTITION_MSFT_RESERVED:
|
||||
+ case PED_PARTITION_APPLE_TV_RECOVERY:
|
||||
case PED_PARTITION_HIDDEN:
|
||||
return 1;
|
||||
case PED_PARTITION_SWAP:
|
||||
--
|
||||
1.6.0.6
|
||||
|
@ -1,44 +0,0 @@
|
||||
From 50898ea17a25c92c3b0ab3c0f12ea867a6ff1ff9 Mon Sep 17 00:00:00 2001
|
||||
From: Joel Granados Moreno <jgranado@redhat.com>
|
||||
Date: Mon, 31 Aug 2009 13:42:47 +0200
|
||||
Subject: [PATCH 2/3] Commit without close
|
||||
|
||||
---
|
||||
libparted/disk.c | 20 ++++++++++++++++++--
|
||||
1 files changed, 18 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/libparted/disk.c b/libparted/disk.c
|
||||
index 27611eb..b01ac70 100644
|
||||
--- a/libparted/disk.c
|
||||
+++ b/libparted/disk.c
|
||||
@@ -513,9 +513,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 send under Linux). */
|
||||
+ if (!ped_device_open (disk->dev))
|
||||
+ goto error;
|
||||
+
|
||||
if (!ped_disk_commit_to_dev (disk))
|
||||
- return 0;
|
||||
- return ped_disk_commit_to_os (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;
|
||||
}
|
||||
|
||||
/**
|
||||
--
|
||||
1.6.4
|
||||
|
@ -1,113 +0,0 @@
|
||||
diff -up parted-1.9.0/libparted/arch/linux.c.dasd2 parted-1.9.0/libparted/arch/linux.c
|
||||
--- parted-1.9.0/libparted/arch/linux.c.dasd2 2009-11-09 18:41:58.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/arch/linux.c 2009-11-09 18:41:58.000000000 +0100
|
||||
@@ -22,6 +22,9 @@
|
||||
|
||||
#include <parted/parted.h>
|
||||
#include <parted/debug.h>
|
||||
+#if defined __s390__ || defined __s390x__
|
||||
+#include <parted/fdasd.h>
|
||||
+#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
@@ -1079,7 +1082,7 @@ init_dasd (PedDevice* dev, const char* m
|
||||
{
|
||||
struct stat dev_stat;
|
||||
struct hd_geometry geo;
|
||||
- char *errstr = 0;
|
||||
+ dasd_information_t dasd_info;
|
||||
|
||||
if (!_device_stat (dev, &dev_stat))
|
||||
goto error;
|
||||
@@ -1115,15 +1118,17 @@ init_dasd (PedDevice* dev, const char* m
|
||||
dev->hw_geom = dev->bios_geom;
|
||||
}
|
||||
|
||||
+ if (!ioctl(arch_specific->fd, BIODASDINFO, &dasd_info)) {
|
||||
+ arch_specific->devno = dasd_info.devno;
|
||||
+ } else {
|
||||
+ arch_specific->devno = -1;
|
||||
+ }
|
||||
+
|
||||
dev->model = strdup (model_name);
|
||||
|
||||
ped_device_close (dev);
|
||||
return 1;
|
||||
|
||||
- ped_exception_throw ( PED_EXCEPTION_ERROR,
|
||||
- PED_EXCEPTION_IGNORE_CANCEL,
|
||||
- errstr );
|
||||
-
|
||||
error_close_dev:
|
||||
ped_device_close (dev);
|
||||
error:
|
||||
diff -up parted-1.9.0/libparted/arch/linux.h.dasd2 parted-1.9.0/libparted/arch/linux.h
|
||||
--- parted-1.9.0/libparted/arch/linux.h.dasd2 2009-11-09 18:41:58.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/arch/linux.h 2009-11-09 18:42:36.000000000 +0100
|
||||
@@ -31,6 +31,7 @@ struct _LinuxSpecific {
|
||||
char* dmtype; /**< device map target type */
|
||||
#if defined(__s390__) || defined(__s390x__)
|
||||
unsigned int real_sector_size;
|
||||
+ unsigned int devno;
|
||||
#endif
|
||||
#if HAVE_BLKID_BLKID_H
|
||||
blkid_probe probe;
|
||||
diff -up parted-1.9.0/libparted/labels/dasd.c.dasd2 parted-1.9.0/libparted/labels/dasd.c
|
||||
--- parted-1.9.0/libparted/labels/dasd.c.dasd2 2009-11-09 18:41:58.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/labels/dasd.c 2009-11-09 18:42:59.000000000 +0100
|
||||
@@ -70,6 +70,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
unsigned int format_type;
|
||||
+ volume_label_t vlabel;
|
||||
} DasdDiskSpecific;
|
||||
|
||||
static PedDiskType dasd_disk_type;
|
||||
@@ -80,6 +81,7 @@ dasd_alloc (const PedDevice* dev)
|
||||
PedDisk* disk;
|
||||
LinuxSpecific* arch_specific;
|
||||
DasdDiskSpecific *disk_specific;
|
||||
+ char volser[7];
|
||||
|
||||
PED_ASSERT (dev != NULL, return NULL);
|
||||
|
||||
@@ -97,6 +99,15 @@ dasd_alloc (const PedDevice* dev)
|
||||
/* CDL format, newer */
|
||||
disk_specific->format_type = 2;
|
||||
|
||||
+ /* Setup volume label (for fresh disks) */
|
||||
+ snprintf(volser, sizeof(volser), "0X%04X", arch_specific->devno);
|
||||
+ vtoc_volume_label_init(&disk_specific->vlabel);
|
||||
+ vtoc_volume_label_set_key(&disk_specific->vlabel, "VOL1");
|
||||
+ vtoc_volume_label_set_label(&disk_specific->vlabel, "VOL1");
|
||||
+ vtoc_volume_label_set_volser(&disk_specific->vlabel, volser);
|
||||
+ vtoc_set_cchhb(&disk_specific->vlabel.vtoc,
|
||||
+ VTOC_START_CC, VTOC_START_HH, 0x01);
|
||||
+
|
||||
return disk;
|
||||
}
|
||||
|
||||
@@ -217,6 +228,9 @@ dasd_read (PedDisk* disk)
|
||||
if (fdasd_check_volume(&anchor, arch_specific->fd))
|
||||
goto error_close_dev;
|
||||
|
||||
+ /* Save volume label (read by fdasd_check_volume) for writing */
|
||||
+ memcpy(&disk_specific->vlabel, anchor.vlabel, sizeof(volume_label_t));
|
||||
+
|
||||
if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE)
|
||||
anchor.big_disk++;
|
||||
|
||||
@@ -477,10 +491,8 @@ dasd_write (const PedDisk* disk)
|
||||
/* initialize the anchor */
|
||||
fdasd_initialize_anchor(&anchor);
|
||||
fdasd_get_geometry(&anchor, arch_specific->fd);
|
||||
-
|
||||
- /* check dasd for labels and vtoc */
|
||||
- if (fdasd_check_volume(&anchor, arch_specific->fd))
|
||||
- goto error;
|
||||
+ memcpy(anchor.vlabel, &disk_specific->vlabel, sizeof(volume_label_t));
|
||||
+ anchor.vlabel_changed++;
|
||||
|
||||
if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE)
|
||||
anchor.big_disk++;
|
@ -1,486 +0,0 @@
|
||||
diff -ur parted-1.9.0.orig/libparted/arch/linux.c parted-1.9.0/libparted/arch/linux.c
|
||||
--- parted-1.9.0.orig/libparted/arch/linux.c 2009-11-03 11:35:00.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/arch/linux.c 2009-11-03 11:45:48.000000000 +0100
|
||||
@@ -646,10 +646,14 @@
|
||||
#if USE_BLKID
|
||||
get_blkid_topology(arch_specific);
|
||||
#endif
|
||||
+
|
||||
+#if defined __s390__ || defined __s390x__
|
||||
/* Return PED_SECTOR_SIZE_DEFAULT for DASDs. */
|
||||
if (dev->type == PED_DEVICE_DASD) {
|
||||
+ arch_specific->real_sector_size = dev->sector_size;
|
||||
dev->sector_size = PED_SECTOR_SIZE_DEFAULT;
|
||||
}
|
||||
+#endif
|
||||
|
||||
if (dev->sector_size != PED_SECTOR_SIZE_DEFAULT) {
|
||||
ped_exception_throw (
|
||||
@@ -1069,6 +1073,7 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
+#if defined __s390__ || defined __s390x__
|
||||
static int
|
||||
init_dasd (PedDevice* dev, const char* model_name)
|
||||
{
|
||||
@@ -1124,6 +1129,7 @@
|
||||
error:
|
||||
return 0;
|
||||
}
|
||||
+#endif
|
||||
|
||||
static int
|
||||
init_generic (PedDevice* dev, const char* model_name)
|
||||
@@ -1270,10 +1276,12 @@
|
||||
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;
|
||||
break;
|
||||
+#endif
|
||||
|
||||
case PED_DEVICE_VIODASD:
|
||||
if (!init_generic (dev, _("IBM iSeries Virtual DASD")))
|
||||
Only in parted-1.9.0/libparted/arch: linux.c.orig
|
||||
Only in parted-1.9.0/libparted/arch: linux.c.rej
|
||||
Only in parted-1.9.0/libparted/arch: linux.c~
|
||||
diff -ur parted-1.9.0.orig/libparted/arch/linux.h parted-1.9.0/libparted/arch/linux.h
|
||||
--- parted-1.9.0.orig/libparted/arch/linux.h 2009-11-03 11:35:00.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/arch/linux.h 2009-11-03 11:44:40.000000000 +0100
|
||||
@@ -18,10 +18,6 @@
|
||||
#ifndef PED_ARCH_LINUX_H_INCLUDED
|
||||
#define PED_ARCH_LINUX_H_INCLUDED
|
||||
|
||||
-#if defined(__s390__) || defined(__s390x__)
|
||||
-# include <parted/fdasd.h>
|
||||
-#endif
|
||||
-
|
||||
#if HAVE_BLKID_BLKID_H
|
||||
# include <blkid/blkid.h>
|
||||
#endif
|
||||
@@ -35,8 +31,6 @@
|
||||
char* dmtype; /**< device map target type */
|
||||
#if defined(__s390__) || defined(__s390x__)
|
||||
unsigned int real_sector_size;
|
||||
- /* IBM internal dasd structure (i guess ;), required. */
|
||||
- struct fdasd_anchor *anchor;
|
||||
#endif
|
||||
#if HAVE_BLKID_BLKID_H
|
||||
blkid_probe probe;
|
||||
Only in parted-1.9.0/libparted/arch: linux.h.orig
|
||||
Only in parted-1.9.0/libparted/arch: linux.h.rej
|
||||
Only in parted-1.9.0/libparted/arch: linux.h~
|
||||
diff -ur parted-1.9.0.orig/libparted/labels/dasd.c parted-1.9.0/libparted/labels/dasd.c
|
||||
--- parted-1.9.0.orig/libparted/labels/dasd.c 2009-11-03 11:35:00.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/labels/dasd.c 2009-11-03 11:48:17.000000000 +0100
|
||||
@@ -66,14 +66,10 @@
|
||||
int system;
|
||||
int raid;
|
||||
int lvm;
|
||||
- void *part_info;
|
||||
} DasdPartitionData;
|
||||
|
||||
typedef struct {
|
||||
- unsigned int real_sector_size;
|
||||
unsigned int format_type;
|
||||
- /* IBM internal dasd structure (i guess ;), required. */
|
||||
- struct fdasd_anchor *anchor;
|
||||
} DasdDiskSpecific;
|
||||
|
||||
static PedDiskType dasd_disk_type;
|
||||
@@ -98,17 +94,8 @@
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- /* because we lie to parted we have to compensate with the
|
||||
- real sector size. Record that now. */
|
||||
- if (ioctl(arch_specific->fd, BLKSSZGET,
|
||||
- &disk_specific->real_sector_size) == -1) {
|
||||
- ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
|
||||
- _("Unable to determine the block "
|
||||
- "size of this dasd"));
|
||||
- free(disk_specific);
|
||||
- free(disk);
|
||||
- return NULL;
|
||||
- }
|
||||
+ /* CDL format, newer */
|
||||
+ disk_specific->format_type = 2;
|
||||
|
||||
return disk;
|
||||
}
|
||||
@@ -123,7 +110,8 @@
|
||||
if (!new_disk)
|
||||
return NULL;
|
||||
|
||||
- new_disk->disk_specific = NULL;
|
||||
+ memcpy(new_disk->disk_specific, disk->disk_specific,
|
||||
+ sizeof(DasdDiskSpecific));
|
||||
|
||||
return new_disk;
|
||||
}
|
||||
@@ -187,6 +175,8 @@
|
||||
fdasd_recreate_vtoc(&anchor);
|
||||
fdasd_write_labels(&anchor, arch_specific->fd);
|
||||
|
||||
+ fdasd_cleanup(&anchor);
|
||||
+
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -203,6 +193,7 @@
|
||||
partition_info_t *p;
|
||||
LinuxSpecific* arch_specific;
|
||||
DasdDiskSpecific* disk_specific;
|
||||
+ struct fdasd_anchor anchor;
|
||||
|
||||
PDEBUG;
|
||||
|
||||
@@ -216,35 +207,32 @@
|
||||
arch_specific = LINUX_SPECIFIC(dev);
|
||||
disk_specific = disk->disk_specific;
|
||||
|
||||
- disk_specific->anchor = ped_malloc(sizeof(fdasd_anchor_t));
|
||||
-
|
||||
PDEBUG;
|
||||
|
||||
- fdasd_initialize_anchor(disk_specific->anchor);
|
||||
+ fdasd_initialize_anchor(&anchor);
|
||||
|
||||
- fdasd_get_geometry(disk_specific->anchor, arch_specific->fd);
|
||||
+ fdasd_get_geometry(&anchor, arch_specific->fd);
|
||||
|
||||
/* check dasd for labels and vtoc */
|
||||
- if (fdasd_check_volume(disk_specific->anchor, arch_specific->fd))
|
||||
+ if (fdasd_check_volume(&anchor, arch_specific->fd))
|
||||
goto error_close_dev;
|
||||
|
||||
- if ((disk_specific->anchor->geo.cylinders
|
||||
- * disk_specific->anchor->geo.heads) > BIG_DISK_SIZE)
|
||||
- disk_specific->anchor->big_disk++;
|
||||
+ if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE)
|
||||
+ anchor.big_disk++;
|
||||
|
||||
ped_disk_delete_all (disk);
|
||||
|
||||
- if (strncmp(disk_specific->anchor->vlabel->volkey,
|
||||
+ if (strncmp(anchor.vlabel->volkey,
|
||||
vtoc_ebcdic_enc ("LNX1", str, 4), 4) == 0) {
|
||||
DasdPartitionData* dasd_data;
|
||||
|
||||
/* LDL format, old one */
|
||||
disk_specific->format_type = 1;
|
||||
start = 24;
|
||||
- end = (long long)(long long) disk_specific->anchor->geo.cylinders
|
||||
- * (long long)disk_specific->anchor->geo.heads
|
||||
+ end = (long long)(long long) anchor.geo.cylinders
|
||||
+ * (long long)anchor.geo.heads
|
||||
* (long long)disk->dev->hw_geom.sectors
|
||||
- * (long long)disk_specific->real_sector_size
|
||||
+ * (long long)arch_specific->real_sector_size
|
||||
/ (long long)disk->dev->sector_size - 1;
|
||||
part = ped_partition_new (disk, PED_PARTITION_PROTECTED, NULL, start, end);
|
||||
if (!part)
|
||||
@@ -260,13 +248,15 @@
|
||||
if (!ped_disk_add_partition (disk, part, NULL))
|
||||
goto error_close_dev;
|
||||
|
||||
+ fdasd_cleanup(&anchor);
|
||||
+
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* CDL format, newer */
|
||||
disk_specific->format_type = 2;
|
||||
|
||||
- p = disk_specific->anchor->first;
|
||||
+ p = anchor.first;
|
||||
PDEBUG;
|
||||
|
||||
for (i = 1 ; i <= USABLE_PARTITIONS; i++) {
|
||||
@@ -281,11 +271,11 @@
|
||||
|
||||
start = (long long)(long long) p->start_trk
|
||||
* (long long) disk->dev->hw_geom.sectors
|
||||
- * (long long) disk_specific->real_sector_size
|
||||
+ * (long long) arch_specific->real_sector_size
|
||||
/ (long long) disk->dev->sector_size;
|
||||
end = (long long)((long long) p->end_trk + 1)
|
||||
* (long long) disk->dev->hw_geom.sectors
|
||||
- * (long long) disk_specific->real_sector_size
|
||||
+ * (long long) arch_specific->real_sector_size
|
||||
/ (long long) disk->dev->sector_size - 1;
|
||||
part = ped_partition_new(disk, PED_PARTITION_NORMAL, NULL,
|
||||
start, end);
|
||||
@@ -331,24 +321,25 @@
|
||||
|
||||
vtoc_ebcdic_enc(p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44);
|
||||
|
||||
- dasd_data->part_info = (void *) p;
|
||||
dasd_data->type = 0;
|
||||
|
||||
constraint_exact = ped_constraint_exact (&part->geom);
|
||||
if (!constraint_exact)
|
||||
goto error_close_dev;
|
||||
- if (!ped_disk_add_partition(disk, part, constraint_exact))
|
||||
+ if (!ped_disk_add_partition(disk, part, constraint_exact)) {
|
||||
+ ped_constraint_destroy(constraint_exact);
|
||||
goto error_close_dev;
|
||||
+ }
|
||||
ped_constraint_destroy(constraint_exact);
|
||||
|
||||
if (p->fspace_trk > 0) {
|
||||
start = (long long)((long long) p->end_trk + 1)
|
||||
* (long long) disk->dev->hw_geom.sectors
|
||||
- * (long long) disk_specific->real_sector_size
|
||||
+ * (long long) arch_specific->real_sector_size
|
||||
/ (long long) disk->dev->sector_size;
|
||||
end = (long long)((long long) p->end_trk + 1 + p->fspace_trk)
|
||||
* (long long) disk->dev->hw_geom.sectors
|
||||
- * (long long) disk_specific->real_sector_size
|
||||
+ * (long long) arch_specific->real_sector_size
|
||||
/ (long long) disk->dev->sector_size - 1;
|
||||
part = ped_partition_new (disk, PED_PARTITION_NORMAL,
|
||||
NULL, start, end);
|
||||
@@ -361,8 +352,10 @@
|
||||
|
||||
if (!constraint_exact)
|
||||
goto error_close_dev;
|
||||
- if (!ped_disk_add_partition(disk, part, constraint_exact))
|
||||
+ if (!ped_disk_add_partition(disk, part, constraint_exact)) {
|
||||
+ ped_constraint_destroy(constraint_exact);
|
||||
goto error_close_dev;
|
||||
+ }
|
||||
|
||||
ped_constraint_destroy (constraint_exact);
|
||||
}
|
||||
@@ -371,16 +364,20 @@
|
||||
}
|
||||
|
||||
PDEBUG;
|
||||
+ fdasd_cleanup(&anchor);
|
||||
return 1;
|
||||
|
||||
error_close_dev:
|
||||
PDEBUG;
|
||||
+ fdasd_cleanup(&anchor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
-dasd_update_type (const PedDisk* disk)
|
||||
+dasd_update_type (const PedDisk* disk, struct fdasd_anchor *anchor,
|
||||
+ partition_info_t *part_info[USABLE_PARTITIONS])
|
||||
{
|
||||
+ int i;
|
||||
PedPartition* part;
|
||||
LinuxSpecific* arch_specific;
|
||||
DasdDiskSpecific* disk_specific;
|
||||
@@ -390,22 +387,21 @@
|
||||
|
||||
PDEBUG;
|
||||
|
||||
- for (part = ped_disk_next_partition(disk, NULL); part;
|
||||
- part = ped_disk_next_partition(disk, part)) {
|
||||
+ for (i = 1; i <= USABLE_PARTITIONS; i++) {
|
||||
partition_info_t *p;
|
||||
char *ch = NULL;
|
||||
DasdPartitionData* dasd_data;
|
||||
|
||||
PDEBUG;
|
||||
|
||||
- if (part->type & PED_PARTITION_FREESPACE
|
||||
- || part->type & PED_PARTITION_METADATA)
|
||||
+ part = ped_disk_get_partition(disk, i);
|
||||
+ if (!part)
|
||||
continue;
|
||||
|
||||
PDEBUG;
|
||||
|
||||
dasd_data = part->disk_specific;
|
||||
- p = dasd_data->part_info;
|
||||
+ p = part_info[i - 1];
|
||||
|
||||
if (!p ) {
|
||||
PDEBUG;
|
||||
@@ -447,7 +443,7 @@
|
||||
break;
|
||||
}
|
||||
|
||||
- disk_specific->anchor->vtoc_changed++;
|
||||
+ anchor->vtoc_changed++;
|
||||
vtoc_ebcdic_enc(p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44);
|
||||
}
|
||||
|
||||
@@ -463,6 +459,9 @@
|
||||
partition_info_t *p;
|
||||
LinuxSpecific* arch_specific;
|
||||
DasdDiskSpecific* disk_specific;
|
||||
+ struct fdasd_anchor anchor;
|
||||
+ partition_info_t *part_info[USABLE_PARTITIONS];
|
||||
+
|
||||
PED_ASSERT(disk != NULL, return 0);
|
||||
PED_ASSERT(disk->dev != NULL, return 0);
|
||||
|
||||
@@ -475,23 +474,21 @@
|
||||
if (disk_specific->format_type == 1)
|
||||
return 1;
|
||||
|
||||
- /* XXX re-initialize anchor? */
|
||||
- fdasd_initialize_anchor(disk_specific->anchor);
|
||||
- fdasd_get_geometry(disk_specific->anchor, arch_specific->fd);
|
||||
+ /* initialize the anchor */
|
||||
+ fdasd_initialize_anchor(&anchor);
|
||||
+ fdasd_get_geometry(&anchor, arch_specific->fd);
|
||||
|
||||
/* check dasd for labels and vtoc */
|
||||
- if (fdasd_check_volume(disk_specific->anchor, arch_specific->fd))
|
||||
+ if (fdasd_check_volume(&anchor, arch_specific->fd))
|
||||
goto error;
|
||||
|
||||
- if ((disk_specific->anchor->geo.cylinders
|
||||
- * disk_specific->anchor->geo.heads) > BIG_DISK_SIZE)
|
||||
- disk_specific->anchor->big_disk++;
|
||||
+ if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE)
|
||||
+ anchor.big_disk++;
|
||||
|
||||
- fdasd_recreate_vtoc(disk_specific->anchor);
|
||||
+ fdasd_recreate_vtoc(&anchor);
|
||||
|
||||
for (i = 1; i <= USABLE_PARTITIONS; i++) {
|
||||
unsigned int start, stop;
|
||||
- int type;
|
||||
|
||||
PDEBUG;
|
||||
part = ped_disk_get_partition(disk, i);
|
||||
@@ -501,41 +498,40 @@
|
||||
PDEBUG;
|
||||
|
||||
start = part->geom.start * disk->dev->sector_size
|
||||
- / disk_specific->real_sector_size / disk->dev->hw_geom.sectors;
|
||||
+ / arch_specific->real_sector_size / disk->dev->hw_geom.sectors;
|
||||
stop = (part->geom.end + 1)
|
||||
- * disk->dev->sector_size / disk_specific->real_sector_size
|
||||
+ * disk->dev->sector_size / arch_specific->real_sector_size
|
||||
/ disk->dev->hw_geom.sectors - 1;
|
||||
|
||||
PDEBUG;
|
||||
dasd_data = part->disk_specific;
|
||||
|
||||
- type = dasd_data->type;
|
||||
- PDEBUG;
|
||||
-
|
||||
- p = fdasd_add_partition(disk_specific->anchor, start, stop);
|
||||
+ p = fdasd_add_partition(&anchor, start, stop);
|
||||
if (!p) {
|
||||
PDEBUG;
|
||||
- return 0;
|
||||
+ goto error;
|
||||
}
|
||||
- dasd_data->part_info = (void *) p;
|
||||
+ part_info[i - 1] = p;
|
||||
p->type = dasd_data->system;
|
||||
}
|
||||
|
||||
PDEBUG;
|
||||
|
||||
- if (!fdasd_prepare_labels(disk_specific->anchor, arch_specific->fd))
|
||||
- return 0;
|
||||
+ if (!fdasd_prepare_labels(&anchor, arch_specific->fd))
|
||||
+ goto error;
|
||||
|
||||
- dasd_update_type(disk);
|
||||
+ dasd_update_type(disk, &anchor, part_info);
|
||||
PDEBUG;
|
||||
|
||||
- if (!fdasd_write_labels(disk_specific->anchor, arch_specific->fd))
|
||||
- return 0;
|
||||
+ if (!fdasd_write_labels(&anchor, arch_specific->fd))
|
||||
+ goto error;
|
||||
|
||||
+ fdasd_cleanup(&anchor);
|
||||
return 1;
|
||||
|
||||
error:
|
||||
PDEBUG;
|
||||
+ fdasd_cleanup(&anchor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -557,6 +553,23 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static PedPartition*
|
||||
+dasd_partition_duplicate (const PedPartition *part)
|
||||
+{
|
||||
+ PedPartition *new_part;
|
||||
+
|
||||
+ new_part = ped_partition_new (part->disk, part->type, part->fs_type,
|
||||
+ part->geom.start, part->geom.end);
|
||||
+ if (!new_part)
|
||||
+ return NULL;
|
||||
+ new_part->num = part->num;
|
||||
+
|
||||
+ memcpy(new_part->disk_specific, part->disk_specific,
|
||||
+ sizeof(DasdPartitionData));
|
||||
+
|
||||
+ return new_part;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
dasd_partition_destroy (PedPartition* part)
|
||||
{
|
||||
@@ -650,9 +662,9 @@
|
||||
static PedAlignment*
|
||||
dasd_get_partition_alignment(const PedDisk *disk)
|
||||
{
|
||||
- DasdDiskSpecific* disk_specific = disk->disk_specific;
|
||||
+ LinuxSpecific *arch_specific = LINUX_SPECIFIC(disk->dev);
|
||||
PedSector sector_size =
|
||||
- disk_specific->real_sector_size / disk->dev->sector_size;
|
||||
+ arch_specific->real_sector_size / disk->dev->sector_size;
|
||||
|
||||
return ped_alignment_new(0, disk->dev->hw_geom.sectors * sector_size);
|
||||
}
|
||||
@@ -670,7 +683,7 @@
|
||||
|
||||
arch_specific = LINUX_SPECIFIC (disk->dev);
|
||||
disk_specific = disk->disk_specific;
|
||||
- sector_size = disk_specific->real_sector_size / disk->dev->sector_size;
|
||||
+ sector_size = arch_specific->real_sector_size / disk->dev->sector_size;
|
||||
|
||||
if (!ped_alignment_init (&start_align, 0,
|
||||
disk->dev->hw_geom.sectors * sector_size))
|
||||
@@ -796,7 +809,7 @@
|
||||
else
|
||||
/* Mark the start of the disk as metadata. */
|
||||
vtoc_end = (FIRST_USABLE_TRK * (long long) disk->dev->hw_geom.sectors
|
||||
- * (long long) disk_specific->real_sector_size
|
||||
+ * (long long) arch_specific->real_sector_size
|
||||
/ (long long) disk->dev->sector_size) - 1;
|
||||
|
||||
new_part = ped_partition_new (disk,PED_PARTITION_METADATA,NULL,0,vtoc_end);
|
||||
@@ -828,6 +841,7 @@
|
||||
partition_set_system: dasd_partition_set_system,
|
||||
|
||||
partition_new: dasd_partition_new,
|
||||
+ partition_duplicate: dasd_partition_duplicate,
|
||||
partition_destroy: dasd_partition_destroy,
|
||||
partition_set_flag: dasd_partition_set_flag,
|
||||
partition_get_flag: dasd_partition_get_flag,
|
||||
@@ -841,8 +855,6 @@
|
||||
get_max_primary_partition_count: dasd_get_max_primary_partition_count,
|
||||
get_max_supported_partition_count: dasd_get_max_supported_partition_count,
|
||||
get_partition_alignment: dasd_get_partition_alignment,
|
||||
-
|
||||
- partition_duplicate: NULL
|
||||
};
|
||||
|
||||
static PedDiskType dasd_disk_type = {
|
||||
Only in parted-1.9.0/libparted/labels: dasd.c.orig
|
||||
Only in parted-1.9.0/libparted/labels: dasd.c.rej
|
||||
Only in parted-1.9.0/libparted/labels: dasd.c~
|
@ -1,409 +0,0 @@
|
||||
diff -up parted-1.9.0/include/parted/disk.h.diskflags parted-1.9.0/include/parted/disk.h
|
||||
--- parted-1.9.0/include/parted/disk.h.diskflags 2009-12-15 11:07:11.000000000 +0100
|
||||
+++ parted-1.9.0/include/parted/disk.h 2009-12-15 11:08:29.000000000 +0100
|
||||
@@ -27,6 +27,20 @@
|
||||
#define PED_DISK_H_INCLUDED
|
||||
|
||||
/**
|
||||
+ * Disk flags
|
||||
+ */
|
||||
+enum _PedDiskFlag {
|
||||
+ /* This flag (which defaults to true) controls if disk types for
|
||||
+ which cylinder alignment is optional do cylinder alignment when a
|
||||
+ new partition gets added.
|
||||
+ This flag is available for msdos and sun disklabels (for sun labels
|
||||
+ it only controls the aligning of the end of the partition) */
|
||||
+ PED_DISK_CYLINDER_ALIGNMENT=1,
|
||||
+};
|
||||
+#define PED_DISK_FIRST_FLAG PED_DISK_CYLINDER_ALIGNMENT
|
||||
+#define PED_DISK_LAST_FLAG PED_DISK_CYLINDER_ALIGNMENT
|
||||
+
|
||||
+/**
|
||||
* Partition types
|
||||
*/
|
||||
enum _PedPartitionType {
|
||||
@@ -72,6 +86,7 @@ struct _PedDiskOps;
|
||||
struct _PedDiskType;
|
||||
struct _PedDiskArchOps;
|
||||
|
||||
+typedef enum _PedDiskFlag PedDiskFlag;
|
||||
typedef enum _PedPartitionType PedPartitionType;
|
||||
typedef enum _PedPartitionFlag PedPartitionFlag;
|
||||
typedef enum _PedDiskTypeFeature PedDiskTypeFeature;
|
||||
@@ -180,6 +195,16 @@ struct _PedDiskOps {
|
||||
void (*free) (PedDisk* disk);
|
||||
int (*read) (PedDisk* disk);
|
||||
int (*write) (const PedDisk* disk);
|
||||
+ int (*disk_set_flag) (
|
||||
+ PedDisk *disk,
|
||||
+ PedDiskFlag flag,
|
||||
+ int state);
|
||||
+ int (*disk_get_flag) (
|
||||
+ const PedDisk *disk,
|
||||
+ PedDiskFlag flag);
|
||||
+ int (*disk_is_flag_available) (
|
||||
+ const PedDisk *disk,
|
||||
+ PedDiskFlag flag);
|
||||
/** \todo add label guessing op here */
|
||||
|
||||
/* partition operations */
|
||||
@@ -304,6 +329,14 @@ extern const char* ped_partition_flag_ge
|
||||
extern PedPartitionFlag ped_partition_flag_get_by_name (const char* name);
|
||||
extern PedPartitionFlag ped_partition_flag_next (PedPartitionFlag flag);
|
||||
|
||||
+extern int ped_disk_set_flag(PedDisk *disk, PedDiskFlag flag, int state);
|
||||
+extern int ped_disk_get_flag(const PedDisk *disk, PedDiskFlag flag);
|
||||
+extern int ped_disk_is_flag_available(const PedDisk *disk, PedDiskFlag flag);
|
||||
+
|
||||
+extern const char *ped_disk_flag_get_name(PedDiskFlag flag);
|
||||
+extern PedDiskFlag ped_disk_flag_get_by_name(const char *name);
|
||||
+extern PedDiskFlag ped_disk_flag_next(PedDiskFlag flag);
|
||||
+
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
diff -up parted-1.9.0/libparted/disk.c.diskflags parted-1.9.0/libparted/disk.c
|
||||
--- parted-1.9.0/libparted/disk.c.diskflags 2009-12-15 11:07:11.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/disk.c 2009-12-15 11:08:29.000000000 +0100
|
||||
@@ -773,6 +773,130 @@ ped_disk_max_partition_start_sector (con
|
||||
}
|
||||
|
||||
/**
|
||||
+ * Set the state (\c 1 or \c 0) of a flag on a disk.
|
||||
+ *
|
||||
+ * \note It is an error to call this on an unavailable flag -- use
|
||||
+ * ped_disk_is_flag_available() to determine which flags are available
|
||||
+ * for a given disk label.
|
||||
+ *
|
||||
+ * \throws PED_EXCEPTION_ERROR if the requested flag is not available for this
|
||||
+ * label.
|
||||
+ */
|
||||
+int
|
||||
+ped_disk_set_flag(PedDisk *disk, PedDiskFlag flag, int state)
|
||||
+{
|
||||
+ PED_ASSERT (disk != NULL, return 0);
|
||||
+
|
||||
+ PedDiskOps *ops = disk->type->ops;
|
||||
+
|
||||
+ if (!ped_disk_is_flag_available(disk, flag)) {
|
||||
+ ped_exception_throw (
|
||||
+ PED_EXCEPTION_ERROR,
|
||||
+ PED_EXCEPTION_CANCEL,
|
||||
+ "The flag '%s' is not available for %s disk labels.",
|
||||
+ ped_disk_flag_get_name(flag),
|
||||
+ disk->type->name);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ return ops->disk_set_flag(disk, flag, state);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * Get the state (\c 1 or \c 0) of a flag on a disk.
|
||||
+ */
|
||||
+int
|
||||
+ped_disk_get_flag(const PedDisk *disk, PedDiskFlag flag)
|
||||
+{
|
||||
+ PED_ASSERT (disk != NULL, return 0);
|
||||
+
|
||||
+ PedDiskOps *ops = disk->type->ops;
|
||||
+
|
||||
+ if (!ped_disk_is_flag_available(disk, flag))
|
||||
+ return 0;
|
||||
+
|
||||
+ return ops->disk_get_flag(disk, flag);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * Check whether a given flag is available on a disk.
|
||||
+ *
|
||||
+ * \return \c 1 if the flag is available.
|
||||
+ */
|
||||
+int
|
||||
+ped_disk_is_flag_available(const PedDisk *disk, PedDiskFlag flag)
|
||||
+{
|
||||
+ PED_ASSERT (disk != NULL, return 0);
|
||||
+
|
||||
+ PedDiskOps *ops = disk->type->ops;
|
||||
+
|
||||
+ if (!ops->disk_is_flag_available)
|
||||
+ return 0;
|
||||
+
|
||||
+ return ops->disk_is_flag_available(disk, flag);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * Returns a name for a \p flag, e.g. PED_DISK_CYLINDER_ALIGNMENT will return
|
||||
+ * "cylinder_alignment".
|
||||
+ *
|
||||
+ * \note The returned string will be in English. However,
|
||||
+ * translations are provided, so the caller can call
|
||||
+ * dgettext("parted", RESULT) on the result.
|
||||
+ */
|
||||
+const char *
|
||||
+ped_disk_flag_get_name(PedDiskFlag flag)
|
||||
+{
|
||||
+ switch (flag) {
|
||||
+ case PED_DISK_CYLINDER_ALIGNMENT:
|
||||
+ return N_("cylinder_alignment");
|
||||
+
|
||||
+ default:
|
||||
+ ped_exception_throw (
|
||||
+ PED_EXCEPTION_BUG,
|
||||
+ PED_EXCEPTION_CANCEL,
|
||||
+ _("Unknown disk flag, %d."),
|
||||
+ flag);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * Returns the flag associated with \p name.
|
||||
+ *
|
||||
+ * \p name can be the English
|
||||
+ * string, or the translation for the native language.
|
||||
+ */
|
||||
+PedDiskFlag
|
||||
+ped_disk_flag_get_by_name(const char *name)
|
||||
+{
|
||||
+ PedDiskFlag flag;
|
||||
+
|
||||
+ for (flag = ped_disk_flag_next(0); flag;
|
||||
+ flag = ped_disk_flag_next(flag)) {
|
||||
+ const char *flag_name = ped_disk_flag_get_name(flag);
|
||||
+ if (strcasecmp(name, flag_name) == 0
|
||||
+ || strcasecmp(name, _(flag_name)) == 0)
|
||||
+ return flag;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * Iterates through all disk flags.
|
||||
+ *
|
||||
+ * ped_disk_flag_next(0) returns the first flag
|
||||
+ *
|
||||
+ * \return the next flag, or 0 if there are no more flags
|
||||
+ */
|
||||
+PedDiskFlag
|
||||
+ped_disk_flag_next(PedDiskFlag flag)
|
||||
+{
|
||||
+ return (flag + 1) % (PED_DISK_LAST_FLAG + 1);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
* \internal We turned a really nasty bureaucracy problem into an elegant maths
|
||||
* problem :-) Basically, there are some constraints to a partition's
|
||||
* geometry:
|
||||
diff -up parted-1.9.0/libparted/labels/dos.c.diskflags parted-1.9.0/libparted/labels/dos.c
|
||||
--- parted-1.9.0/libparted/labels/dos.c.diskflags 2009-12-15 11:07:11.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/labels/dos.c 2009-12-15 11:12:46.000000000 +0100
|
||||
@@ -140,6 +140,10 @@ typedef struct {
|
||||
} OrigState;
|
||||
|
||||
typedef struct {
|
||||
+ int cylinder_alignment;
|
||||
+} DosDiskData;
|
||||
+
|
||||
+typedef struct {
|
||||
unsigned char system;
|
||||
int boot;
|
||||
int hidden;
|
||||
@@ -243,8 +247,16 @@ msdos_alloc (const PedDevice* dev)
|
||||
PED_ASSERT (dev != NULL, return NULL);
|
||||
|
||||
disk = _ped_disk_alloc ((PedDevice*)dev, &msdos_disk_type);
|
||||
- if (disk)
|
||||
- disk->disk_specific = NULL;
|
||||
+ if (disk) {
|
||||
+ DosDiskData *disk_specific = ped_malloc(sizeof *disk_specific);
|
||||
+ if (!disk_specific) {
|
||||
+ free (disk);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ disk_specific->cylinder_alignment = 1;
|
||||
+ disk->disk_specific = disk_specific;
|
||||
+ }
|
||||
+
|
||||
return disk;
|
||||
}
|
||||
|
||||
@@ -256,7 +268,10 @@ msdos_duplicate (const PedDisk* disk)
|
||||
new_disk = ped_disk_new_fresh (disk->dev, &msdos_disk_type);
|
||||
if (!new_disk)
|
||||
return NULL;
|
||||
- new_disk->disk_specific = NULL;
|
||||
+
|
||||
+ memcpy(new_disk->disk_specific, disk->disk_specific,
|
||||
+ sizeof(DosDiskData));
|
||||
+
|
||||
return new_disk;
|
||||
}
|
||||
|
||||
@@ -265,7 +280,45 @@ msdos_free (PedDisk* disk)
|
||||
{
|
||||
PED_ASSERT (disk != NULL, return);
|
||||
|
||||
+ DosDiskData *disk_specific = disk->disk_specific;
|
||||
_ped_disk_free (disk);
|
||||
+ free(disk_specific);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+msdos_disk_set_flag (PedDisk *disk, PedDiskFlag flag, int state)
|
||||
+{
|
||||
+ DosDiskData *disk_specific = disk->disk_specific;
|
||||
+ switch (flag) {
|
||||
+ case PED_DISK_CYLINDER_ALIGNMENT:
|
||||
+ disk_specific->cylinder_alignment = !!state;
|
||||
+ return 1;
|
||||
+ default:
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+msdos_disk_get_flag (const PedDisk *disk, PedDiskFlag flag)
|
||||
+{
|
||||
+ DosDiskData *disk_specific = disk->disk_specific;
|
||||
+ switch (flag) {
|
||||
+ case PED_DISK_CYLINDER_ALIGNMENT:
|
||||
+ return disk_specific->cylinder_alignment;
|
||||
+ default:
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+msdos_disk_is_flag_available (const PedDisk *disk, PedDiskFlag flag)
|
||||
+{
|
||||
+ switch (flag) {
|
||||
+ case PED_DISK_CYLINDER_ALIGNMENT:
|
||||
+ return 1;
|
||||
+ default:
|
||||
+ return 0;
|
||||
+ }
|
||||
}
|
||||
|
||||
#ifndef DISCOVER_ONLY
|
||||
@@ -2029,8 +2082,11 @@ msdos_partition_align (PedPartition* par
|
||||
|
||||
partition_probe_bios_geometry (part, &bios_geom);
|
||||
|
||||
- if (_align (part, &bios_geom, constraint))
|
||||
- return 1;
|
||||
+ DosDiskData *disk_specific = part->disk->disk_specific;
|
||||
+ if (disk_specific->cylinder_alignment)
|
||||
+ if (_align (part, &bios_geom, constraint))
|
||||
+ return 1;
|
||||
+
|
||||
if (_align_no_geom (part, constraint))
|
||||
return 1;
|
||||
|
||||
@@ -2324,6 +2380,10 @@ static PedDiskOps msdos_disk_ops = {
|
||||
write: NULL,
|
||||
#endif
|
||||
|
||||
+ disk_set_flag: msdos_disk_set_flag,
|
||||
+ disk_get_flag: msdos_disk_get_flag,
|
||||
+ disk_is_flag_available: msdos_disk_is_flag_available,
|
||||
+
|
||||
partition_new: msdos_partition_new,
|
||||
partition_duplicate: msdos_partition_duplicate,
|
||||
partition_destroy: msdos_partition_destroy,
|
||||
diff -up parted-1.9.0/libparted/labels/sun.c.diskflags parted-1.9.0/libparted/labels/sun.c
|
||||
--- parted-1.9.0/libparted/labels/sun.c.diskflags 2009-12-15 11:07:11.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/labels/sun.c 2009-12-15 11:13:44.000000000 +0100
|
||||
@@ -94,6 +94,7 @@ struct _SunPartitionData {
|
||||
struct _SunDiskData {
|
||||
PedSector length; /* This is based on cyl - alt-cyl */
|
||||
SunRawLabel raw_label;
|
||||
+ int cylinder_alignment;
|
||||
};
|
||||
|
||||
static PedDiskType sun_disk_type;
|
||||
@@ -190,6 +191,7 @@ sun_alloc (const PedDevice* dev)
|
||||
|
||||
bios_geom->cylinders = dev->length / cyl_size;
|
||||
sun_specific->length = bios_geom->cylinders * cyl_size;
|
||||
+ sun_specific->cylinder_alignment = 1;
|
||||
|
||||
label = &sun_specific->raw_label;
|
||||
memset(label, 0, sizeof(SunRawLabel));
|
||||
@@ -252,6 +254,42 @@ sun_free (PedDisk *disk)
|
||||
}
|
||||
|
||||
static int
|
||||
+sun_disk_set_flag (PedDisk *disk, PedDiskFlag flag, int state)
|
||||
+{
|
||||
+ SunDiskData *disk_specific = disk->disk_specific;
|
||||
+ switch (flag) {
|
||||
+ case PED_DISK_CYLINDER_ALIGNMENT:
|
||||
+ disk_specific->cylinder_alignment = !!state;
|
||||
+ return 1;
|
||||
+ default:
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+sun_disk_get_flag (const PedDisk *disk, PedDiskFlag flag)
|
||||
+{
|
||||
+ SunDiskData *disk_specific = disk->disk_specific;
|
||||
+ switch (flag) {
|
||||
+ case PED_DISK_CYLINDER_ALIGNMENT:
|
||||
+ return disk_specific->cylinder_alignment;
|
||||
+ default:
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+sun_disk_is_flag_available (const PedDisk *disk, PedDiskFlag flag)
|
||||
+{
|
||||
+ switch (flag) {
|
||||
+ case PED_DISK_CYLINDER_ALIGNMENT:
|
||||
+ return 1;
|
||||
+ default:
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
_check_geometry_sanity (PedDisk* disk, SunRawLabel* label)
|
||||
{
|
||||
PedDevice* dev = disk->dev;
|
||||
@@ -738,12 +776,15 @@ sun_partition_align (PedPartition* part,
|
||||
{
|
||||
PED_ASSERT (part != NULL, return 0);
|
||||
|
||||
- if (_ped_partition_attempt_align (part, constraint,
|
||||
- _get_strict_constraint (part->disk)))
|
||||
- return 1;
|
||||
- if (_ped_partition_attempt_align (part, constraint,
|
||||
- _get_lax_constraint (part->disk)))
|
||||
- return 1;
|
||||
+ SunDiskData *disk_specific = part->disk->disk_specific;
|
||||
+
|
||||
+ if (disk_specific->cylinder_alignment &&
|
||||
+ _ped_partition_attempt_align (part, constraint,
|
||||
+ _get_strict_constraint (part->disk)))
|
||||
+ return 1;
|
||||
+ if (_ped_partition_attempt_align (part, constraint,
|
||||
+ _get_lax_constraint (part->disk)))
|
||||
+ return 1;
|
||||
|
||||
#ifndef DISCOVER_ONLY
|
||||
ped_exception_throw (
|
||||
@@ -862,6 +903,10 @@ static PedDiskOps sun_disk_ops = {
|
||||
write: NULL,
|
||||
#endif
|
||||
|
||||
+ disk_set_flag: sun_disk_set_flag,
|
||||
+ disk_get_flag: sun_disk_get_flag,
|
||||
+ disk_is_flag_available: sun_disk_is_flag_available,
|
||||
+
|
||||
partition_new: sun_partition_new,
|
||||
partition_duplicate: sun_partition_duplicate,
|
||||
partition_destroy: sun_partition_destroy,
|
@ -1,94 +0,0 @@
|
||||
From a8dc525bdab612551a5859b8a8bd2b944a259766 Mon Sep 17 00:00:00 2001
|
||||
From: Joel Granados Moreno <jgranado@redhat.com>
|
||||
Date: Mon, 31 Aug 2009 13:44:02 +0200
|
||||
Subject: [PATCH 3/3] Dont touch part nodes
|
||||
|
||||
---
|
||||
libparted/arch/linux.c | 47 ++++++++++++++++++++++++++++++++---------------
|
||||
1 files changed, 32 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
|
||||
index e47030f..1d4fc7e 100644
|
||||
--- a/libparted/arch/linux.c
|
||||
+++ b/libparted/arch/linux.c
|
||||
@@ -586,6 +586,19 @@ _get_linux_version ()
|
||||
return kver = KERNEL_VERSION (major, minor, teeny);
|
||||
}
|
||||
|
||||
+static int
|
||||
+_have_kern26 ()
|
||||
+{
|
||||
+ static int have_kern26 = -1;
|
||||
+ int kver;
|
||||
+
|
||||
+ if (have_kern26 != -1)
|
||||
+ return have_kern26;
|
||||
+
|
||||
+ kver = _get_linux_version();
|
||||
+ return have_kern26 = kver >= KERNEL_VERSION (2,6,0) ? 1 : 0;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
_device_set_sector_size (PedDevice* dev)
|
||||
{
|
||||
@@ -1354,8 +1367,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
|
||||
@@ -1373,21 +1386,23 @@ _flush_cache (PedDevice* dev)
|
||||
|
||||
ioctl (arch_specific->fd, BLKFLSBUF);
|
||||
|
||||
- for (i = 1; i < 16; i++) {
|
||||
- char* name;
|
||||
- int fd;
|
||||
+ if (!_have_kern26()) {
|
||||
+ for (i = 1; i < 16; i++) {
|
||||
+ char* name;
|
||||
+ int fd;
|
||||
|
||||
- name = _device_get_part_path (dev, i);
|
||||
- if (!name)
|
||||
- break;
|
||||
- if (!_partition_is_mounted_by_path (name)) {
|
||||
- fd = open (name, WR_MODE, 0);
|
||||
- if (fd > 0) {
|
||||
- ioctl (fd, BLKFLSBUF);
|
||||
- close (fd);
|
||||
+ name = _device_get_part_path (dev, i);
|
||||
+ if (!name)
|
||||
+ break;
|
||||
+ if (!_partition_is_mounted_by_path (name)) {
|
||||
+ fd = open (name, WR_MODE, 0);
|
||||
+ if (fd > 0) {
|
||||
+ ioctl (fd, BLKFLSBUF);
|
||||
+ close (fd);
|
||||
+ }
|
||||
}
|
||||
+ free (name);
|
||||
}
|
||||
- free (name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1428,7 +1443,9 @@ retry:
|
||||
dev->read_only = 0;
|
||||
}
|
||||
|
||||
- _flush_cache (dev);
|
||||
+ /* With kernels < 2.6 flush cache for cache coherence issues */
|
||||
+ if (!_have_kern26())
|
||||
+ _flush_cache (dev);
|
||||
|
||||
return 1;
|
||||
}
|
||||
--
|
||||
1.6.4
|
||||
|
@ -1,52 +0,0 @@
|
||||
diff -up parted-1.9.0/libparted/disk.c.entiredisk parted-1.9.0/libparted/disk.c
|
||||
--- parted-1.9.0/libparted/disk.c.entiredisk 2009-12-15 19:22:01.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/disk.c 2009-12-15 20:19:30.000000000 +0100
|
||||
@@ -785,10 +785,15 @@ ped_disk_max_partition_start_sector (con
|
||||
int
|
||||
ped_disk_set_flag(PedDisk *disk, PedDiskFlag flag, int state)
|
||||
{
|
||||
+ int ret;
|
||||
+
|
||||
PED_ASSERT (disk != NULL, return 0);
|
||||
|
||||
PedDiskOps *ops = disk->type->ops;
|
||||
|
||||
+ if (!_disk_push_update_mode(disk))
|
||||
+ return 0;
|
||||
+
|
||||
if (!ped_disk_is_flag_available(disk, flag)) {
|
||||
ped_exception_throw (
|
||||
PED_EXCEPTION_ERROR,
|
||||
@@ -796,10 +801,16 @@ ped_disk_set_flag(PedDisk *disk, PedDisk
|
||||
"The flag '%s' is not available for %s disk labels.",
|
||||
ped_disk_flag_get_name(flag),
|
||||
disk->type->name);
|
||||
+ _disk_pop_update_mode(disk);
|
||||
return 0;
|
||||
}
|
||||
|
||||
- return ops->disk_set_flag(disk, flag, state);
|
||||
+ ret = ops->disk_set_flag(disk, flag, state);
|
||||
+
|
||||
+ if (!_disk_pop_update_mode (disk))
|
||||
+ return 0;
|
||||
+
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
diff -up parted-1.9.0/libparted/labels/dos.c.entiredisk parted-1.9.0/libparted/labels/dos.c
|
||||
--- parted-1.9.0/libparted/labels/dos.c.entiredisk 2009-12-15 19:22:01.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/labels/dos.c 2009-12-15 20:19:38.000000000 +0100
|
||||
@@ -2242,7 +2242,10 @@ add_startend_metadata (PedDisk* disk)
|
||||
else
|
||||
init_end = PED_MIN (dev->bios_geom.sectors - 1, init_end - 1);
|
||||
|
||||
- if (!get_end_last_nonfree_part(disk, &final_start))
|
||||
+ DosDiskData *disk_specific = disk->disk_specific;
|
||||
+ if (!disk_specific->cylinder_alignment)
|
||||
+ final_start = dev->length - 1;
|
||||
+ else if (!get_end_last_nonfree_part(disk, &final_start))
|
||||
final_start = ped_round_down_to (dev->length, cyl_size);
|
||||
else
|
||||
final_start = PED_MAX (final_start + 1,
|
@ -1,569 +0,0 @@
|
||||
diff -up parted-1.9.0/configure.ac.export-align parted-1.9.0/configure.ac
|
||||
--- parted-1.9.0/configure.ac.export-align 2009-07-23 19:52:08.000000000 +0200
|
||||
+++ parted-1.9.0/configure.ac 2009-11-03 11:30:46.000000000 +0100
|
||||
@@ -519,6 +519,18 @@ HOST=$(hostname)
|
||||
BUILDINFO="$USER@$HOST, $DATE"
|
||||
AC_SUBST([BUILDINFO])
|
||||
|
||||
+LIB_BLKID=
|
||||
+AC_SUBST([LIB_BLKID])
|
||||
+pe_saved_libs=$LIBS
|
||||
+ AC_SEARCH_LIBS([blkid_probe_get_topology], [blkid],
|
||||
+ [test "$ac_cv_search_blkid_probe_get_topology" = "none required" \
|
||||
+ || LIB_BLKID=$ac_cv_search_blkid_probe_get_topology])
|
||||
+ AC_CHECK_FUNC([blkid_probe_get_topology], [use_blkid=1], [use_blkid=0])
|
||||
+LIBS=$pe_saved_libs
|
||||
+AC_DEFINE_UNQUOTED([USE_BLKID], [$use_blkid],
|
||||
+ [Define if you have sufficient blkid support.])
|
||||
+AC_CHECK_HEADERS_ONCE([blkid/blkid.h])
|
||||
+
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
lib/Makefile
|
||||
diff -up parted-1.9.0/include/parted/device.h.export-align parted-1.9.0/include/parted/device.h
|
||||
--- parted-1.9.0/include/parted/device.h.export-align 2009-07-23 19:52:08.000000000 +0200
|
||||
+++ parted-1.9.0/include/parted/device.h 2009-11-03 11:30:46.000000000 +0100
|
||||
@@ -92,6 +92,8 @@ struct _PedDevice {
|
||||
void* arch_specific;
|
||||
};
|
||||
|
||||
+#include <parted/natmath.h>
|
||||
+
|
||||
/**
|
||||
* List of functions implementing architecture-specific operations.
|
||||
*/
|
||||
@@ -112,6 +114,9 @@ struct _PedDeviceArchOps {
|
||||
PedSector (*check) (PedDevice* dev, void* buffer,
|
||||
PedSector start, PedSector count);
|
||||
void (*probe_all) ();
|
||||
+ /* These functions are optional */
|
||||
+ PedAlignment *(*get_minimum_alignment)(const PedDevice *dev);
|
||||
+ PedAlignment *(*get_optimum_alignment)(const PedDevice *dev);
|
||||
};
|
||||
|
||||
#include <parted/constraint.h>
|
||||
@@ -141,6 +146,14 @@ extern PedSector ped_device_check (PedDe
|
||||
PedSector start, PedSector count);
|
||||
extern PedConstraint* ped_device_get_constraint (PedDevice* dev);
|
||||
|
||||
+extern PedConstraint *ped_device_get_minimal_aligned_constraint(
|
||||
+ const PedDevice *dev);
|
||||
+extern PedConstraint *ped_device_get_optimal_aligned_constraint(
|
||||
+ const PedDevice *dev);
|
||||
+
|
||||
+extern PedAlignment *ped_device_get_minimum_alignment(const PedDevice *dev);
|
||||
+extern PedAlignment *ped_device_get_optimum_alignment(const PedDevice *dev);
|
||||
+
|
||||
/* private stuff ;-) */
|
||||
|
||||
extern void _ped_device_probe (const char* path);
|
||||
diff -up parted-1.9.0/include/parted/disk.h.export-align parted-1.9.0/include/parted/disk.h
|
||||
--- parted-1.9.0/include/parted/disk.h.export-align 2009-11-03 11:30:46.000000000 +0100
|
||||
+++ parted-1.9.0/include/parted/disk.h 2009-11-03 11:30:46.000000000 +0100
|
||||
@@ -214,6 +214,7 @@ struct _PedDiskOps {
|
||||
int (*get_max_primary_partition_count) (const PedDisk* disk);
|
||||
bool (*get_max_supported_partition_count) (const PedDisk* disk,
|
||||
int* supported);
|
||||
+ PedAlignment *(*get_partition_alignment)(const PedDisk *disk);
|
||||
};
|
||||
|
||||
struct _PedDiskType {
|
||||
@@ -263,6 +264,7 @@ extern int ped_disk_get_last_partition_n
|
||||
extern int ped_disk_get_max_primary_partition_count (const PedDisk* disk);
|
||||
extern bool ped_disk_get_max_supported_partition_count(const PedDisk* disk,
|
||||
int* supported);
|
||||
+extern PedAlignment *ped_disk_get_partition_alignment(const PedDisk *disk);
|
||||
|
||||
/** @} */
|
||||
|
||||
diff -up parted-1.9.0/include/parted/natmath.h.export-align parted-1.9.0/include/parted/natmath.h
|
||||
--- parted-1.9.0/include/parted/natmath.h.export-align 2009-07-23 19:52:08.000000000 +0200
|
||||
+++ parted-1.9.0/include/parted/natmath.h 2009-11-03 11:30:46.000000000 +0100
|
||||
@@ -31,6 +31,7 @@ typedef struct _PedAlignment PedAlignmen
|
||||
|
||||
#include <parted/disk.h>
|
||||
#include <parted/device.h>
|
||||
+#include <parted/geom.h>
|
||||
|
||||
#define PED_MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
|
||||
#define PED_MAX(a, b) ( ((a)>(b)) ? (a) : (b) )
|
||||
diff -up parted-1.9.0/libparted/Makefile.am.export-align parted-1.9.0/libparted/Makefile.am
|
||||
--- parted-1.9.0/libparted/Makefile.am.export-align 2009-07-23 19:52:08.000000000 +0200
|
||||
+++ parted-1.9.0/libparted/Makefile.am 2009-11-03 11:30:46.000000000 +0100
|
||||
@@ -50,6 +50,7 @@ libparted_la_LIBADD = \
|
||||
$(DL_LIBS) \
|
||||
$(DM_LIBS) \
|
||||
$(SELINUX_LIBS) \
|
||||
+ $(LIB_BLKID) \
|
||||
$(INTLLIBS)
|
||||
|
||||
EXTRA_DIST = mbr.s
|
||||
diff -up parted-1.9.0/libparted/arch/linux.c.export-align parted-1.9.0/libparted/arch/linux.c
|
||||
--- parted-1.9.0/libparted/arch/linux.c.export-align 2009-11-03 11:30:46.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/arch/linux.c 2009-11-03 11:30:46.000000000 +0100
|
||||
@@ -598,7 +598,24 @@ _have_kern26 ()
|
||||
kver = _get_linux_version();
|
||||
return have_kern26 = kver >= KERNEL_VERSION (2,6,0) ? 1 : 0;
|
||||
}
|
||||
-
|
||||
+
|
||||
+#if USE_BLKID
|
||||
+static void
|
||||
+get_blkid_topology (LinuxSpecific *arch_specific)
|
||||
+{
|
||||
+ arch_specific->probe = blkid_new_probe ();
|
||||
+ if (!arch_specific->probe)
|
||||
+ return;
|
||||
+
|
||||
+ if (blkid_probe_set_device(arch_specific->probe,
|
||||
+ arch_specific->fd, 0, 0))
|
||||
+ return;
|
||||
+
|
||||
+ arch_specific->topology =
|
||||
+ blkid_probe_get_topology(arch_specific->probe);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
static void
|
||||
_device_set_sector_size (PedDevice* dev)
|
||||
{
|
||||
@@ -626,6 +643,9 @@ _device_set_sector_size (PedDevice* dev)
|
||||
dev->sector_size = (long long)sector_size;
|
||||
}
|
||||
|
||||
+#if USE_BLKID
|
||||
+ get_blkid_topology(arch_specific);
|
||||
+#endif
|
||||
/* Return PED_SECTOR_SIZE_DEFAULT for DASDs. */
|
||||
if (dev->type == PED_DEVICE_DASD) {
|
||||
dev->sector_size = PED_SECTOR_SIZE_DEFAULT;
|
||||
@@ -1215,6 +1235,10 @@ linux_new (const char* path)
|
||||
goto error_free_path;
|
||||
arch_specific = LINUX_SPECIFIC (dev);
|
||||
arch_specific->dmtype = NULL;
|
||||
+#if USE_BLKID
|
||||
+ arch_specific->probe = NULL;
|
||||
+ arch_specific->topology = NULL;
|
||||
+#endif
|
||||
|
||||
dev->open_count = 0;
|
||||
dev->read_only = 0;
|
||||
@@ -1335,7 +1359,12 @@ error:
|
||||
static void
|
||||
linux_destroy (PedDevice* dev)
|
||||
{
|
||||
- free (((LinuxSpecific*)dev->arch_specific)->dmtype);
|
||||
+ LinuxSpecific *arch_specific = LINUX_SPECIFIC(dev);
|
||||
+#if USE_BLKID
|
||||
+ if (arch_specific->probe)
|
||||
+ blkid_free_probe(arch_specific->probe);
|
||||
+#endif
|
||||
+ free (arch_specific->dmtype);
|
||||
free (dev->arch_specific);
|
||||
free (dev->path);
|
||||
free (dev->model);
|
||||
@@ -2446,6 +2475,34 @@ linux_disk_commit (PedDisk* disk)
|
||||
return 1;
|
||||
}
|
||||
|
||||
+#if HAVE_BLKID_BLKID_H
|
||||
+PedAlignment*
|
||||
+linux_get_minimum_alignment(const PedDevice *dev)
|
||||
+{
|
||||
+ blkid_topology tp = LINUX_SPECIFIC(dev)->topology;
|
||||
+
|
||||
+ if (!tp || blkid_topology_get_minimum_io_size(tp) == 0)
|
||||
+ return NULL; /* ped_alignment_none */
|
||||
+
|
||||
+ return ped_alignment_new(
|
||||
+ blkid_topology_get_alignment_offset(tp) / dev->sector_size,
|
||||
+ blkid_topology_get_minimum_io_size(tp) / dev->sector_size);
|
||||
+}
|
||||
+
|
||||
+PedAlignment*
|
||||
+linux_get_optimum_alignment(const PedDevice *dev)
|
||||
+{
|
||||
+ blkid_topology tp = LINUX_SPECIFIC(dev)->topology;
|
||||
+
|
||||
+ if (!tp || blkid_topology_get_optimal_io_size(tp) == 0)
|
||||
+ return NULL; /* ped_alignment_none */
|
||||
+
|
||||
+ return ped_alignment_new(
|
||||
+ blkid_topology_get_alignment_offset(tp) / dev->sector_size,
|
||||
+ blkid_topology_get_optimal_io_size(tp) / dev->sector_size);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
static PedDeviceArchOps linux_dev_ops = {
|
||||
_new: linux_new,
|
||||
destroy: linux_destroy,
|
||||
@@ -2459,7 +2516,11 @@ static PedDeviceArchOps linux_dev_ops =
|
||||
check: linux_check,
|
||||
sync: linux_sync,
|
||||
sync_fast: linux_sync_fast,
|
||||
- probe_all: linux_probe_all
|
||||
+ probe_all: linux_probe_all,
|
||||
+#if HAVE_BLKID_BLKID_H
|
||||
+ get_minimum_alignment: linux_get_minimum_alignment,
|
||||
+ get_optimum_alignment: linux_get_optimum_alignment,
|
||||
+#endif
|
||||
};
|
||||
|
||||
PedDiskArchOps linux_disk_ops = {
|
||||
diff -up parted-1.9.0/libparted/arch/linux.h.export-align parted-1.9.0/libparted/arch/linux.h
|
||||
--- parted-1.9.0/libparted/arch/linux.h.export-align 2009-07-23 19:52:08.000000000 +0200
|
||||
+++ parted-1.9.0/libparted/arch/linux.h 2009-11-03 11:30:46.000000000 +0100
|
||||
@@ -22,6 +22,10 @@
|
||||
# include <parted/fdasd.h>
|
||||
#endif
|
||||
|
||||
+#if HAVE_BLKID_BLKID_H
|
||||
+# include <blkid/blkid.h>
|
||||
+#endif
|
||||
+
|
||||
#define LINUX_SPECIFIC(dev) ((LinuxSpecific*) (dev)->arch_specific)
|
||||
|
||||
typedef struct _LinuxSpecific LinuxSpecific;
|
||||
@@ -34,6 +38,10 @@ struct _LinuxSpecific {
|
||||
/* IBM internal dasd structure (i guess ;), required. */
|
||||
struct fdasd_anchor *anchor;
|
||||
#endif
|
||||
+#if HAVE_BLKID_BLKID_H
|
||||
+ blkid_probe probe;
|
||||
+ blkid_topology topology;
|
||||
+#endif
|
||||
};
|
||||
|
||||
#endif /* PED_ARCH_LINUX_H_INCLUDED */
|
||||
diff -up parted-1.9.0/libparted/device.c.export-align parted-1.9.0/libparted/device.c
|
||||
--- parted-1.9.0/libparted/device.c.export-align 2009-07-23 19:52:08.000000000 +0200
|
||||
+++ parted-1.9.0/libparted/device.c 2009-11-03 11:30:46.000000000 +0100
|
||||
@@ -416,33 +416,146 @@ ped_device_sync_fast (PedDevice* dev)
|
||||
}
|
||||
|
||||
/**
|
||||
- * Get a constraint that represents hardware requirements on alignment and
|
||||
- * geometry.
|
||||
- * This is, for example, important for media that have a physical sector
|
||||
- * size that is a multiple of the logical sector size.
|
||||
+ * Get a constraint that represents hardware requirements on geometry.
|
||||
+ * This function will return a constraint representing the limits imposed
|
||||
+ * by the size of the disk, it will *not* provide any alignment constraints.
|
||||
*
|
||||
- * \warning This function is experimental for physical sector sizes not equal to
|
||||
- * 2^9.
|
||||
+ * Alignment constraints may be desirable when using media that have a physical
|
||||
+ * sector size that is a multiple of the logical sector size, as in this case
|
||||
+ * proper partition alignment can benefit disk performance signigicantly.
|
||||
+ * When you want a constraint with alignment info, use
|
||||
+ * ped_device_get_minimal_aligned_constraint() or
|
||||
+ * ped_device_get_optimal_aligned_constraint().
|
||||
+ *
|
||||
+ * \return NULL on error, otherwise a pointer to a dynamically allocated
|
||||
+ * constraint.
|
||||
*/
|
||||
PedConstraint*
|
||||
ped_device_get_constraint (PedDevice* dev)
|
||||
{
|
||||
- int multiplier = dev->phys_sector_size / dev->sector_size;
|
||||
-
|
||||
- PedAlignment* start_align = ped_alignment_new (multiplier, multiplier);
|
||||
-
|
||||
PedGeometry *s, *e;
|
||||
PedConstraint* c = ped_constraint_new (
|
||||
- start_align, ped_alignment_any,
|
||||
+ ped_alignment_any, ped_alignment_any,
|
||||
s = ped_geometry_new (dev, 0, dev->length),
|
||||
e = ped_geometry_new (dev, 0, dev->length),
|
||||
1, dev->length);
|
||||
|
||||
free (s);
|
||||
free (e);
|
||||
+ return c;
|
||||
+}
|
||||
+
|
||||
+static PedConstraint*
|
||||
+_ped_device_get_aligned_constraint(const PedDevice *dev,
|
||||
+ PedAlignment* start_align)
|
||||
+{
|
||||
+ PedAlignment *end_align = NULL;
|
||||
+ PedGeometry *whole_dev_geom = NULL;
|
||||
+ PedConstraint *c = NULL;
|
||||
+
|
||||
+ if (start_align) {
|
||||
+ end_align = ped_alignment_new(start_align->offset - 1,
|
||||
+ start_align->grain_size);
|
||||
+ if (!end_align)
|
||||
+ goto free_start_align;
|
||||
+ }
|
||||
+
|
||||
+ whole_dev_geom = ped_geometry_new (dev, 0, dev->length);
|
||||
+
|
||||
+ if (start_align)
|
||||
+ c = ped_constraint_new (start_align, end_align,
|
||||
+ whole_dev_geom, whole_dev_geom,
|
||||
+ 1, dev->length);
|
||||
+ else
|
||||
+ c = ped_constraint_new (ped_alignment_any, ped_alignment_any,
|
||||
+ whole_dev_geom, whole_dev_geom,
|
||||
+ 1, dev->length);
|
||||
+
|
||||
+ free (whole_dev_geom);
|
||||
+ free (end_align);
|
||||
+free_start_align:
|
||||
free (start_align);
|
||||
return c;
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * Get a constraint that represents hardware requirements on geometry and
|
||||
+ * alignment.
|
||||
+ *
|
||||
+ * This function will return a constraint representing the limits imposed
|
||||
+ * by the size of the disk and the minimal alignment requirements for proper
|
||||
+ * performance of the disk.
|
||||
+ *
|
||||
+ * \return NULL on error, otherwise a pointer to a dynamically allocated
|
||||
+ * constraint.
|
||||
+ */
|
||||
+PedConstraint*
|
||||
+ped_device_get_minimal_aligned_constraint(const PedDevice *dev)
|
||||
+{
|
||||
+ return _ped_device_get_aligned_constraint(dev,
|
||||
+ ped_device_get_minimum_alignment(dev));
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * Get a constraint that represents hardware requirements on geometry and
|
||||
+ * alignment.
|
||||
+ *
|
||||
+ * This function will return a constraint representing the limits imposed
|
||||
+ * by the size of the disk and the alignment requirements for optimal
|
||||
+ * performance of the disk.
|
||||
+ *
|
||||
+ * \return NULL on error, otherwise a pointer to a dynamically allocated
|
||||
+ * constraint.
|
||||
+ */
|
||||
+PedConstraint*
|
||||
+ped_device_get_optimal_aligned_constraint(const PedDevice *dev)
|
||||
+{
|
||||
+ return _ped_device_get_aligned_constraint(dev,
|
||||
+ ped_device_get_optimum_alignment(dev));
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * Get an alignment that represents minimum hardware requirements on alignment.
|
||||
+ * When for example using media that has a physical sector size that is a
|
||||
+ * multiple of the logical sector size, it is desirable to have disk accesses
|
||||
+ * (and thus partitions) properly aligned. Having partitions not aligned to
|
||||
+ * the minimum hardware requirements may lead to a performance penalty.
|
||||
+ *
|
||||
+ * The returned alignment describes the alignment for the start sector of the
|
||||
+ * partition, the end sector should be aligned too, to get the end sector
|
||||
+ * alignment decrease the returned alignment's offset by 1.
|
||||
+ *
|
||||
+ * \return the minimum alignment of partition start sectors, or NULL if this
|
||||
+ * information is not available.
|
||||
+ */
|
||||
+PedAlignment*
|
||||
+ped_device_get_minimum_alignment(const PedDevice *dev)
|
||||
+{
|
||||
+ if (ped_architecture->dev_ops->get_minimum_alignment)
|
||||
+ return ped_architecture->dev_ops->get_minimum_alignment(dev);
|
||||
+
|
||||
+ return NULL; /* ped_alignment_none */
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * Get an alignment that represents the hardware requirements for optimal
|
||||
+ * performance.
|
||||
+ *
|
||||
+ * The returned alignment describes the alignment for the start sector of the
|
||||
+ * partition, the end sector should be aligned too, to get the end sector
|
||||
+ * alignment decrease the returned alignment's offset by 1.
|
||||
+ *
|
||||
+ * \return the optimal alignment of partition start sectors, or NULL if this
|
||||
+ * information is not available.
|
||||
+ */
|
||||
+PedAlignment*
|
||||
+ped_device_get_optimum_alignment(const PedDevice *dev)
|
||||
+{
|
||||
+ if (ped_architecture->dev_ops->get_optimum_alignment)
|
||||
+ return ped_architecture->dev_ops->get_optimum_alignment(dev);
|
||||
+
|
||||
+ return NULL; /* ped_alignment_none */
|
||||
+}
|
||||
+
|
||||
/** @} */
|
||||
|
||||
diff -up parted-1.9.0/libparted/disk.c.export-align parted-1.9.0/libparted/disk.c
|
||||
--- parted-1.9.0/libparted/disk.c.export-align 2009-11-03 11:30:46.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/disk.c 2009-11-03 11:30:46.000000000 +0100
|
||||
@@ -703,6 +703,26 @@ ped_disk_get_max_supported_partition_cou
|
||||
}
|
||||
|
||||
/**
|
||||
+ * Get the alignment needed for partition boundaries on this disk.
|
||||
+ * The returned alignment describes the alignment for the start sector of the
|
||||
+ * partition, for all disklabel types which require alignment, except Sun
|
||||
+ * disklabels, the end sector must be aligned too. To get the end sector
|
||||
+ * alignment decrease the PedAlignment offset by 1.
|
||||
+ *
|
||||
+ * \return NULL on error, otherwise a pointer to a dynamically allocated
|
||||
+ * alignment.
|
||||
+ */
|
||||
+PedAlignment*
|
||||
+ped_disk_get_partition_alignment(const PedDisk *disk)
|
||||
+{
|
||||
+ /* disklabel handlers which don't need alignment don't define this */
|
||||
+ if (!disk->type->ops->get_partition_alignment)
|
||||
+ return ped_alignment_duplicate(ped_alignment_any);
|
||||
+
|
||||
+ return disk->type->ops->get_partition_alignment(disk);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
* Get the maximum number of (primary) partitions the disk label supports.
|
||||
*
|
||||
* For example, MacIntosh partition maps can have different sizes,
|
||||
diff -up parted-1.9.0/libparted/labels/dasd.c.export-align parted-1.9.0/libparted/labels/dasd.c
|
||||
--- parted-1.9.0/libparted/labels/dasd.c.export-align 2009-11-03 11:30:46.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/labels/dasd.c 2009-11-03 11:32:19.000000000 +0100
|
||||
@@ -646,6 +646,16 @@ dasd_get_max_supported_partition_count (
|
||||
return true;
|
||||
}
|
||||
|
||||
+static PedAlignment*
|
||||
+dasd_get_partition_alignment(const PedDisk *disk)
|
||||
+{
|
||||
+ DasdDiskSpecific* disk_specific = disk->disk_specific;
|
||||
+ PedSector sector_size =
|
||||
+ disk_specific->real_sector_size / disk->dev->sector_size;
|
||||
+
|
||||
+ return ped_alignment_new(0, disk->dev->hw_geom.sectors * sector_size);
|
||||
+}
|
||||
+
|
||||
static PedConstraint*
|
||||
_primary_constraint (PedDisk* disk)
|
||||
{
|
||||
@@ -830,6 +840,7 @@ static PedDiskOps dasd_disk_ops = {
|
||||
alloc_metadata: dasd_alloc_metadata,
|
||||
get_max_primary_partition_count: dasd_get_max_primary_partition_count,
|
||||
get_max_supported_partition_count: dasd_get_max_supported_partition_count,
|
||||
+ get_partition_alignment: dasd_get_partition_alignment,
|
||||
|
||||
partition_duplicate: NULL
|
||||
};
|
||||
diff -up parted-1.9.0/libparted/labels/mac.c.export-align parted-1.9.0/libparted/labels/mac.c
|
||||
--- parted-1.9.0/libparted/labels/mac.c.export-align 2009-07-23 19:52:08.000000000 +0200
|
||||
+++ parted-1.9.0/libparted/labels/mac.c 2009-11-03 11:30:46.000000000 +0100
|
||||
@@ -1375,6 +1375,14 @@ mac_partition_get_name (const PedPartiti
|
||||
return mac_data->volume_name;
|
||||
}
|
||||
|
||||
+static PedAlignment*
|
||||
+mac_get_partition_alignment(const PedDisk *disk)
|
||||
+{
|
||||
+ PedSector sector_size = disk->dev->sector_size / 512;
|
||||
+
|
||||
+ return ped_alignment_new(0, sector_size);
|
||||
+}
|
||||
+
|
||||
static PedConstraint*
|
||||
_primary_constraint (PedDisk* disk)
|
||||
{
|
||||
@@ -1606,7 +1614,8 @@ static PedDiskOps mac_disk_ops = {
|
||||
get_max_primary_partition_count:
|
||||
mac_get_max_primary_partition_count,
|
||||
get_max_supported_partition_count:
|
||||
- mac_get_max_supported_partition_count
|
||||
+ mac_get_max_supported_partition_count,
|
||||
+ get_partition_alignment: mac_get_partition_alignment,
|
||||
};
|
||||
|
||||
static PedDiskType mac_disk_type = {
|
||||
diff -up parted-1.9.0/libparted/labels/pc98.c.export-align parted-1.9.0/libparted/labels/pc98.c
|
||||
--- parted-1.9.0/libparted/labels/pc98.c.export-align 2009-07-23 19:52:08.000000000 +0200
|
||||
+++ parted-1.9.0/libparted/labels/pc98.c 2009-11-03 11:30:46.000000000 +0100
|
||||
@@ -720,6 +720,15 @@ pc98_partition_get_name (const PedPartit
|
||||
return pc98_data->name;
|
||||
}
|
||||
|
||||
+static PedAlignment*
|
||||
+pc98_get_partition_alignment(const PedDisk *disk)
|
||||
+{
|
||||
+ PedSector cylinder_size =
|
||||
+ disk->dev->hw_geom.sectors * disk->dev->hw_geom.heads;
|
||||
+
|
||||
+ return ped_alignment_new(0, cylinder_size);
|
||||
+}
|
||||
+
|
||||
static PedConstraint*
|
||||
_primary_constraint (PedDisk* disk)
|
||||
{
|
||||
@@ -872,7 +881,8 @@ static PedDiskOps pc98_disk_ops = {
|
||||
get_max_primary_partition_count:
|
||||
pc98_get_max_primary_partition_count,
|
||||
get_max_supported_partition_count:
|
||||
- pc98_get_max_supported_partition_count
|
||||
+ pc98_get_max_supported_partition_count,
|
||||
+ get_partition_alignment: pc98_get_partition_alignment,
|
||||
};
|
||||
|
||||
static PedDiskType pc98_disk_type = {
|
||||
diff -up parted-1.9.0/libparted/labels/rdb.c.export-align parted-1.9.0/libparted/labels/rdb.c
|
||||
--- parted-1.9.0/libparted/labels/rdb.c.export-align 2009-07-23 19:52:08.000000000 +0200
|
||||
+++ parted-1.9.0/libparted/labels/rdb.c 2009-11-03 11:30:46.000000000 +0100
|
||||
@@ -1024,6 +1024,15 @@ amiga_partition_get_name (const PedParti
|
||||
return _amiga_get_bstr(partition->pb_DriveName);
|
||||
}
|
||||
|
||||
+static PedAlignment*
|
||||
+amiga_get_partition_alignment(const PedDisk *disk)
|
||||
+{
|
||||
+ PedSector cylinder_size =
|
||||
+ disk->dev->hw_geom.sectors * disk->dev->hw_geom.heads;
|
||||
+
|
||||
+ return ped_alignment_new(0, cylinder_size);
|
||||
+}
|
||||
+
|
||||
static PedConstraint*
|
||||
_amiga_get_constraint (const PedDisk *disk)
|
||||
{
|
||||
@@ -1166,7 +1175,8 @@ static PedDiskOps amiga_disk_ops = {
|
||||
get_max_primary_partition_count:
|
||||
amiga_get_max_primary_partition_count,
|
||||
get_max_supported_partition_count:
|
||||
- amiga_get_max_supported_partition_count
|
||||
+ amiga_get_max_supported_partition_count,
|
||||
+ get_partition_alignment: amiga_get_partition_alignment,
|
||||
};
|
||||
|
||||
static PedDiskType amiga_disk_type = {
|
||||
diff -up parted-1.9.0/libparted/labels/sun.c.export-align parted-1.9.0/libparted/labels/sun.c
|
||||
--- parted-1.9.0/libparted/labels/sun.c.export-align 2009-07-23 19:52:08.000000000 +0200
|
||||
+++ parted-1.9.0/libparted/labels/sun.c 2009-11-03 11:30:46.000000000 +0100
|
||||
@@ -677,6 +677,15 @@ sun_get_max_primary_partition_count (con
|
||||
return SUN_DISK_MAXPARTITIONS;
|
||||
}
|
||||
|
||||
+static PedAlignment*
|
||||
+sun_get_partition_alignment(const PedDisk *disk)
|
||||
+{
|
||||
+ PedSector block =
|
||||
+ disk->dev->hw_geom.sectors * disk->dev->hw_geom.heads;
|
||||
+
|
||||
+ return ped_alignment_new(0, block);
|
||||
+}
|
||||
+
|
||||
static PedConstraint*
|
||||
_get_strict_constraint (PedDisk* disk)
|
||||
{
|
||||
@@ -867,6 +876,7 @@ static PedDiskOps sun_disk_ops = {
|
||||
sun_get_max_primary_partition_count,
|
||||
get_max_supported_partition_count:
|
||||
sun_get_max_supported_partition_count,
|
||||
+ get_partition_alignment: sun_get_partition_alignment,
|
||||
|
||||
partition_set_name: NULL,
|
||||
partition_get_name: NULL,
|
@ -1,41 +0,0 @@
|
||||
From f515b5a54a929896c9ad1482f05c060f4a1b9893 Mon Sep 17 00:00:00 2001
|
||||
From: Petr Uzel <petr.uzel@suse.cz>
|
||||
Date: Fri, 5 Jun 2009 14:14:11 +0200
|
||||
Subject: [PATCH] do not discard bootcode from extended partition
|
||||
|
||||
* libparted/labels/dos.c (write_ext_table): Do not discard
|
||||
bootcode from extended partition on msdos label when some of
|
||||
the logical partitions are changed.
|
||||
|
||||
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
|
||||
---
|
||||
libparted/labels/dos.c | 6 ++++--
|
||||
1 files changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
|
||||
index b4cd23a..fc54339 100644
|
||||
--- a/libparted/labels/dos.c
|
||||
+++ b/libparted/labels/dos.c
|
||||
@@ -1060,7 +1060,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))
|
||||
@@ -1094,7 +1095,8 @@ write_empty_table (const PedDisk* disk, PedSector sector)
|
||||
|
||||
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);
|
||||
--
|
||||
1.6.0.6
|
||||
|
@ -1,60 +0,0 @@
|
||||
From d6e9b3bbda5eb565b6031b5620e38cba871c6748 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Meyering <meyering@redhat.com>
|
||||
Date: Tue, 6 Oct 2009 20:10:00 +0200
|
||||
Subject: [PATCH parted 1/3] gpt: don't malfunction on big-endian systems
|
||||
|
||||
Numerous GPT tests would fail when run on e.g., big-endian PPC.
|
||||
* libparted/labels/gpt.c (gpt_read): Now that we use the
|
||||
SizeOfPartitionEntry member, be sure to convert from GPT's
|
||||
little-endian on-disk format to to CPU endianness.
|
||||
This bug was introduced via commit 14cce9b2, 2009-06-10, "gpt:
|
||||
fix gpt_read to read all of the partition entries correctly".
|
||||
* libparted/labels/gpt.c (_header_is_valid): Also convert it here.
|
||||
Add a test to ensure that the partition entry size is no larger
|
||||
than the slightly arbitrary UINT32_MAX/16.
|
||||
* NEWS (Bug fixes): Mention it.
|
||||
---
|
||||
NEWS | 3 +++
|
||||
libparted/labels/gpt.c | 12 +++++++-----
|
||||
2 files changed, 10 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
|
||||
index cc9bcdc..b4549ef 100644
|
||||
--- a/libparted/labels/gpt.c
|
||||
+++ b/libparted/labels/gpt.c
|
||||
@@ -608,8 +608,10 @@ _header_is_valid (const PedDevice* dev, GuidPartitionTableHeader_t* gpt)
|
||||
* the SizeOfPartitionEntry must be a multiple of 8 and
|
||||
* no smaller than the size of the PartitionEntry structure.
|
||||
*/
|
||||
- uint32_t sope = gpt->SizeOfPartitionEntry;
|
||||
- if (sope % 8 != 0 || sope < sizeof(GuidPartitionEntry_t) )
|
||||
+ uint32_t sope = PED_LE32_TO_CPU (gpt->SizeOfPartitionEntry);
|
||||
+ if (sope % 8 != 0
|
||||
+ || sope < sizeof (GuidPartitionEntry_t)
|
||||
+ || (UINT32_MAX >> 4) < sope)
|
||||
return 0;
|
||||
|
||||
origcrc = gpt->HeaderCRC32;
|
||||
@@ -911,7 +913,8 @@ gpt_read (PedDisk * disk)
|
||||
if (!_parse_header (disk, gpt, &write_back))
|
||||
goto error_free_gpt;
|
||||
|
||||
- ptes_sectors = ped_div_round_up (gpt->SizeOfPartitionEntry
|
||||
+ uint32_t p_ent_size = PED_LE32_TO_CPU (gpt->SizeOfPartitionEntry);
|
||||
+ ptes_sectors = ped_div_round_up (p_ent_size
|
||||
* gpt_disk_data->entry_count,
|
||||
disk->dev->sector_size);
|
||||
|
||||
@@ -926,8 +929,7 @@ gpt_read (PedDisk * disk)
|
||||
|
||||
for (i = 0; i < gpt_disk_data->entry_count; i++) {
|
||||
GuidPartitionEntry_t* pte
|
||||
- = (GuidPartitionEntry_t*) ((char *)ptes + i
|
||||
- * gpt->SizeOfPartitionEntry);
|
||||
+ = (GuidPartitionEntry_t*) ((char *)ptes + i * p_ent_size);
|
||||
PedPartition* part;
|
||||
PedConstraint* constraint_exact;
|
||||
|
||||
--
|
||||
1.6.5.rc2
|
||||
|
@ -1,28 +0,0 @@
|
||||
From 4f14bec7eb887aba8b8e38b987bc01e8456a79fc Mon Sep 17 00:00:00 2001
|
||||
From: Joel Granados Moreno <jgranado@redhat.com>
|
||||
Date: Wed, 22 Jul 2009 12:08:34 +0200
|
||||
Subject: [PATCH] Try to handle the duplicate error a little better.
|
||||
|
||||
---
|
||||
libparted/disk.c | 4 +++-
|
||||
1 files changed, 3 insertions(+), 1 deletions(-)
|
||||
|
||||
diff --git a/libparted/disk.c b/libparted/disk.c
|
||||
index 3656d22..27611eb 100644
|
||||
--- a/libparted/disk.c
|
||||
+++ b/libparted/disk.c
|
||||
@@ -277,8 +277,10 @@ ped_disk_duplicate (const PedDisk* old_disk)
|
||||
for (old_part = ped_disk_next_partition (old_disk, NULL); old_part;
|
||||
old_part = ped_disk_next_partition (old_disk, old_part)) {
|
||||
if (ped_partition_is_active (old_part)) {
|
||||
- if (!_add_duplicate_part (new_disk, old_part))
|
||||
+ if (!_add_duplicate_part (new_disk, old_part)){
|
||||
+ _disk_pop_update_mode (new_disk);
|
||||
goto error_destroy_new_disk;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
if (!_disk_pop_update_mode (new_disk))
|
||||
--
|
||||
1.6.0.6
|
||||
|
@ -1,36 +0,0 @@
|
||||
diff -up parted-1.9.0/libparted/arch/linux.c.orig parted-1.9.0/libparted/arch/linux.c
|
||||
--- parted-1.9.0/libparted/arch/linux.c.orig 2009-12-14 22:44:18.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/arch/linux.c 2009-12-15 10:25:38.000000000 +0100
|
||||
@@ -259,6 +259,7 @@ struct blkdev_ioctl_param {
|
||||
#define SX8_MAJOR2 161
|
||||
#define XVD_MAJOR 202
|
||||
#define SDMMC_MAJOR 179
|
||||
+#define LOOP_MAJOR 7
|
||||
|
||||
#define SCSI_BLK_MAJOR(M) ( \
|
||||
(M) == SCSI_DISK0_MAJOR \
|
||||
@@ -561,6 +562,8 @@ _device_probe_type (PedDevice* dev)
|
||||
dev->type = PED_DEVICE_SDMMC;
|
||||
} else if (_is_virtblk_major(dev_major)) {
|
||||
dev->type = PED_DEVICE_VIRTBLK;
|
||||
+ } else if (dev_major == LOOP_MAJOR) {
|
||||
+ dev->type = PED_DEVICE_FILE;
|
||||
} else {
|
||||
dev->type = PED_DEVICE_UNKNOWN;
|
||||
}
|
||||
@@ -1048,6 +1048,15 @@ init_file (PedDevice* dev)
|
||||
if (!ped_device_open (dev))
|
||||
goto error;
|
||||
|
||||
+ dev->sector_size = PED_SECTOR_SIZE_DEFAULT;
|
||||
+ char *p = getenv ("PARTED_SECTOR_SIZE");
|
||||
+ if (p) {
|
||||
+ int s = atoi (p);
|
||||
+ if (0 < s && s % 512 == 0)
|
||||
+ dev->sector_size = s;
|
||||
+ }
|
||||
+ dev->phys_sector_size = dev->sector_size;
|
||||
+
|
||||
if (S_ISBLK(dev_stat.st_mode))
|
||||
dev->length = _device_get_length (dev);
|
||||
else
|
@ -1,166 +0,0 @@
|
||||
From cd5dd183b4810de2160c433544541c852ca1877d Mon Sep 17 00:00:00 2001
|
||||
From: Joel Granados Moreno <jgranado@redhat.com>
|
||||
Date: Mon, 29 Jun 2009 13:44:10 +0200
|
||||
Subject: [PATCH] Put the dasd function definitions at the end of the file.
|
||||
|
||||
All label types define the label functions at the end of the file. Be
|
||||
consistent with this characteristic. The function declarations are no
|
||||
longer needed.
|
||||
|
||||
* libparted/labels/dasd.c (dasd_disk_ops, dasd_disk_type)
|
||||
(ped_disk_dasd_init, ped_disk_dasd_done): Move the specifications of the
|
||||
functions the end of the file. Remove function declarations.
|
||||
---
|
||||
libparted/labels/dasd.c | 125 ++++++++++++++++++-----------------------------
|
||||
1 files changed, 48 insertions(+), 77 deletions(-)
|
||||
|
||||
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
|
||||
index 3a0bb32..e3e5d1b 100644
|
||||
--- a/libparted/labels/dasd.c
|
||||
+++ b/libparted/labels/dasd.c
|
||||
@@ -76,70 +76,7 @@ typedef struct {
|
||||
struct fdasd_anchor *anchor;
|
||||
} DasdDiskSpecific;
|
||||
|
||||
-static int dasd_probe (const PedDevice *dev);
|
||||
-static int dasd_clobber (PedDevice* dev);
|
||||
-static int dasd_read (PedDisk* disk);
|
||||
-static int dasd_write (const PedDisk* disk);
|
||||
-
|
||||
-static PedPartition* dasd_partition_new (const PedDisk* disk,
|
||||
- PedPartitionType part_type,
|
||||
- const PedFileSystemType* fs_type,
|
||||
- PedSector start,
|
||||
- PedSector end);
|
||||
-static void dasd_partition_destroy (PedPartition* part);
|
||||
-static int dasd_partition_set_flag (PedPartition* part,
|
||||
- PedPartitionFlag flag,
|
||||
- int state);
|
||||
-static int dasd_partition_get_flag (const PedPartition* part,
|
||||
- PedPartitionFlag flag);
|
||||
-static int dasd_partition_is_flag_available (const PedPartition* part,
|
||||
- PedPartitionFlag flag);
|
||||
-static int dasd_partition_align (PedPartition* part,
|
||||
- const PedConstraint* constraint);
|
||||
-static int dasd_partition_enumerate (PedPartition* part);
|
||||
-static int dasd_get_max_primary_partition_count (const PedDisk* disk);
|
||||
-
|
||||
-static PedDisk* dasd_alloc (const PedDevice* dev);
|
||||
-static PedDisk* dasd_duplicate (const PedDisk* disk);
|
||||
-static void dasd_free (PedDisk* disk);
|
||||
-static int dasd_partition_set_system (PedPartition* part,
|
||||
- const PedFileSystemType* fs_type);
|
||||
-static int dasd_alloc_metadata (PedDisk* disk);
|
||||
-
|
||||
-static PedDiskOps dasd_disk_ops = {
|
||||
- probe: dasd_probe,
|
||||
- clobber: dasd_clobber,
|
||||
- read: dasd_read,
|
||||
- write: dasd_write,
|
||||
-
|
||||
- alloc: dasd_alloc,
|
||||
- duplicate: dasd_duplicate,
|
||||
- free: dasd_free,
|
||||
- partition_set_system: dasd_partition_set_system,
|
||||
-
|
||||
- partition_new: dasd_partition_new,
|
||||
- partition_destroy: dasd_partition_destroy,
|
||||
- partition_set_flag: dasd_partition_set_flag,
|
||||
- partition_get_flag: dasd_partition_get_flag,
|
||||
- partition_is_flag_available: dasd_partition_is_flag_available,
|
||||
- partition_set_name: NULL,
|
||||
- partition_get_name: NULL,
|
||||
- partition_align: dasd_partition_align,
|
||||
- partition_enumerate: dasd_partition_enumerate,
|
||||
-
|
||||
- alloc_metadata: dasd_alloc_metadata,
|
||||
- get_max_primary_partition_count: dasd_get_max_primary_partition_count,
|
||||
- get_max_supported_partition_count: dasd_get_max_supported_partition_count,
|
||||
-
|
||||
- partition_duplicate: NULL
|
||||
-};
|
||||
-
|
||||
-static PedDiskType dasd_disk_type = {
|
||||
- next: NULL,
|
||||
- name: "dasd",
|
||||
- ops: &dasd_disk_ops,
|
||||
- features: 0
|
||||
-};
|
||||
+static PedDiskType dasd_disk_type;
|
||||
|
||||
static PedDisk*
|
||||
dasd_alloc (const PedDevice* dev)
|
||||
@@ -199,19 +136,6 @@ dasd_free (PedDisk* disk)
|
||||
_ped_disk_free(disk);
|
||||
}
|
||||
|
||||
-
|
||||
-void
|
||||
-ped_disk_dasd_init ()
|
||||
-{
|
||||
- ped_disk_type_register(&dasd_disk_type);
|
||||
-}
|
||||
-
|
||||
-void
|
||||
-ped_disk_dasd_done ()
|
||||
-{
|
||||
- ped_disk_type_unregister(&dasd_disk_type);
|
||||
-}
|
||||
-
|
||||
static int
|
||||
dasd_probe (const PedDevice *dev)
|
||||
{
|
||||
@@ -881,3 +805,50 @@ error:
|
||||
ped_constraint_destroy (constraint_any);
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+static PedDiskOps dasd_disk_ops = {
|
||||
+ probe: dasd_probe,
|
||||
+ clobber: dasd_clobber,
|
||||
+ read: dasd_read,
|
||||
+ write: dasd_write,
|
||||
+
|
||||
+ alloc: dasd_alloc,
|
||||
+ duplicate: dasd_duplicate,
|
||||
+ free: dasd_free,
|
||||
+ partition_set_system: dasd_partition_set_system,
|
||||
+
|
||||
+ partition_new: dasd_partition_new,
|
||||
+ partition_destroy: dasd_partition_destroy,
|
||||
+ partition_set_flag: dasd_partition_set_flag,
|
||||
+ partition_get_flag: dasd_partition_get_flag,
|
||||
+ partition_is_flag_available: dasd_partition_is_flag_available,
|
||||
+ partition_set_name: NULL,
|
||||
+ partition_get_name: NULL,
|
||||
+ partition_align: dasd_partition_align,
|
||||
+ partition_enumerate: dasd_partition_enumerate,
|
||||
+
|
||||
+ alloc_metadata: dasd_alloc_metadata,
|
||||
+ get_max_primary_partition_count: dasd_get_max_primary_partition_count,
|
||||
+ get_max_supported_partition_count: dasd_get_max_supported_partition_count,
|
||||
+
|
||||
+ partition_duplicate: NULL
|
||||
+};
|
||||
+
|
||||
+static PedDiskType dasd_disk_type = {
|
||||
+ next: NULL,
|
||||
+ name: "dasd",
|
||||
+ ops: &dasd_disk_ops,
|
||||
+ features: 0
|
||||
+};
|
||||
+
|
||||
+void
|
||||
+ped_disk_dasd_init ()
|
||||
+{
|
||||
+ ped_disk_type_register(&dasd_disk_type);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+ped_disk_dasd_done ()
|
||||
+{
|
||||
+ ped_disk_type_unregister(&dasd_disk_type);
|
||||
+}
|
||||
--
|
||||
1.6.0.6
|
||||
|
@ -1,122 +0,0 @@
|
||||
--- parted-1.9.0.orig/libparted/arch/linux.c 2009-12-18 09:35:22.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/arch/linux.c 2009-12-18 09:57:37.000000000 +0100
|
||||
@@ -430,7 +430,8 @@
|
||||
if (!(dmt = dm_task_create(DM_DEVICE_TABLE)))
|
||||
return r;
|
||||
|
||||
- if (!dm_task_set_name(dmt, dev->path))
|
||||
+ if (!dm_task_set_major_minor(dmt, arch_specific->major,
|
||||
+ arch_specific->minor, 0))
|
||||
goto bad;
|
||||
|
||||
dm_task_no_open_count(dmt);
|
||||
@@ -513,6 +514,7 @@
|
||||
struct stat dev_stat;
|
||||
int dev_major;
|
||||
int dev_minor;
|
||||
+ LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
|
||||
|
||||
if (!_device_stat (dev, &dev_stat))
|
||||
return 0;
|
||||
@@ -522,8 +524,8 @@
|
||||
return 1;
|
||||
}
|
||||
|
||||
- dev_major = major (dev_stat.st_rdev);
|
||||
- dev_minor = minor (dev_stat.st_rdev);
|
||||
+ arch_specific->major = dev_major = major (dev_stat.st_rdev);
|
||||
+ arch_specific->minor = dev_minor = minor (dev_stat.st_rdev);
|
||||
|
||||
if (SCSI_BLK_MAJOR (dev_major) && (dev_minor % 0x10 == 0)) {
|
||||
dev->type = PED_DEVICE_SCSI;
|
||||
@@ -2305,22 +2307,20 @@
|
||||
static int
|
||||
_dm_remove_parts (PedDevice* dev)
|
||||
{
|
||||
- struct stat dev_stat;
|
||||
struct dm_task* task = NULL;
|
||||
struct dm_info* info = alloca(sizeof *info);
|
||||
struct dm_names* names = NULL;
|
||||
unsigned int next = 0;
|
||||
int rc;
|
||||
-
|
||||
- if (!_device_stat (dev, &dev_stat))
|
||||
- goto err;
|
||||
+ LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
|
||||
|
||||
task = dm_task_create(DM_DEVICE_LIST);
|
||||
if (!task)
|
||||
goto err;
|
||||
|
||||
- dm_task_set_major (task, major (dev_stat.st_rdev));
|
||||
- dm_task_set_minor (task, minor (dev_stat.st_rdev));
|
||||
+ if (!dm_task_set_major_minor (task, arch_specific->major,
|
||||
+ arch_specific->minor, 0))
|
||||
+ goto err;
|
||||
|
||||
rc = dm_task_run(task);
|
||||
if (rc < 0)
|
||||
@@ -2365,33 +2365,36 @@
|
||||
static int
|
||||
_dm_add_partition (PedDisk* disk, PedPartition* part)
|
||||
{
|
||||
- struct stat dev_stat;
|
||||
struct dm_task* task = NULL;
|
||||
int rc;
|
||||
char* vol_name = NULL;
|
||||
- char* dev_name = NULL;
|
||||
+ const char *dev_name = NULL;
|
||||
char* params = NULL;
|
||||
+ LinuxSpecific* arch_specific = LINUX_SPECIFIC (disk->dev);
|
||||
|
||||
- dev_name = _device_get_part_path (disk->dev, part->num);
|
||||
- if (!dev_name)
|
||||
- return 0;
|
||||
+ /* Get map name from devicemapper */
|
||||
+ task = dm_task_create (DM_DEVICE_INFO);
|
||||
+ if (!task)
|
||||
+ goto err;
|
||||
|
||||
- vol_name = strrchr (dev_name, '/');
|
||||
- if (vol_name && *vol_name && *(++vol_name))
|
||||
- vol_name = strdup (vol_name);
|
||||
- else
|
||||
- vol_name = strdup (dev_name);
|
||||
- if (!vol_name)
|
||||
- return 0;
|
||||
+ if (!dm_task_set_major_minor (task, arch_specific->major,
|
||||
+ arch_specific->minor, 0))
|
||||
+ goto err;
|
||||
|
||||
- if (!_device_stat (disk->dev, &dev_stat))
|
||||
+ rc = dm_task_run(task);
|
||||
+ if (rc < 0)
|
||||
goto err;
|
||||
|
||||
- if (asprintf (¶ms, "%d:%d %lld", major (dev_stat.st_rdev),
|
||||
- minor (dev_stat.st_rdev), part->geom.start) == -1)
|
||||
+ dev_name = dm_task_get_name (task);
|
||||
+
|
||||
+ if (asprintf (&vol_name, "%sp%d", dev_name, part->num) == -1)
|
||||
goto err;
|
||||
|
||||
- if (!params)
|
||||
+ dm_task_destroy (task);
|
||||
+ task = NULL;
|
||||
+
|
||||
+ if (asprintf (¶ms, "%d:%d %lld", arch_specific->major,
|
||||
+ arch_specific->minor, part->geom.start) == -1)
|
||||
goto err;
|
||||
|
||||
task = dm_task_create (DM_DEVICE_CREATE);
|
||||
--- parted-1.9.0.orig/libparted/arch/linux.h 2009-12-18 09:35:22.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/arch/linux.h 2009-12-18 09:44:26.000000000 +0100
|
||||
@@ -28,6 +28,8 @@
|
||||
|
||||
struct _LinuxSpecific {
|
||||
int fd;
|
||||
+ int major;
|
||||
+ int minor;
|
||||
char* dmtype; /**< device map target type */
|
||||
#if defined(__s390__) || defined(__s390x__)
|
||||
unsigned int real_sector_size;
|
@ -1,264 +0,0 @@
|
||||
From ead3330dfadfcb2bd53a136916d4087cc725ef42 Mon Sep 17 00:00:00 2001
|
||||
From: Joel Granados Moreno <jgranado@redhat.com>
|
||||
Date: Mon, 31 Aug 2009 13:41:06 +0200
|
||||
Subject: [PATCH 1/3] No BLKPG
|
||||
|
||||
---
|
||||
libparted/arch/linux.c | 213 ------------------------------------------------
|
||||
1 files changed, 0 insertions(+), 213 deletions(-)
|
||||
|
||||
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
|
||||
index 8f220e0..e47030f 100644
|
||||
--- a/libparted/arch/linux.c
|
||||
+++ b/libparted/arch/linux.c
|
||||
@@ -41,7 +41,6 @@
|
||||
#include <libdevmapper.h>
|
||||
#endif
|
||||
|
||||
-#include "blkpg.h"
|
||||
#include "../architecture.h"
|
||||
#include "dirname.h"
|
||||
|
||||
@@ -587,22 +586,6 @@ _get_linux_version ()
|
||||
return kver = KERNEL_VERSION (major, minor, teeny);
|
||||
}
|
||||
|
||||
-static int
|
||||
-_have_devfs ()
|
||||
-{
|
||||
- static int have_devfs = -1;
|
||||
- struct stat sb;
|
||||
-
|
||||
- if (have_devfs != -1)
|
||||
- return have_devfs;
|
||||
-
|
||||
- /* the presence of /dev/.devfsd implies that DevFS is active */
|
||||
- if (stat("/dev/.devfsd", &sb) < 0)
|
||||
- return have_devfs = 0;
|
||||
-
|
||||
- return have_devfs = S_ISCHR(sb.st_mode) ? 1 : 0;
|
||||
-}
|
||||
-
|
||||
static void
|
||||
_device_set_sector_size (PedDevice* dev)
|
||||
{
|
||||
@@ -2189,176 +2172,6 @@ linux_partition_is_busy (const PedPartition* part)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int
|
||||
-_blkpg_part_command (PedDevice* dev, struct blkpg_partition* part, int op)
|
||||
-{
|
||||
- LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
|
||||
- struct blkpg_ioctl_arg ioctl_arg;
|
||||
-
|
||||
- ioctl_arg.op = op;
|
||||
- ioctl_arg.flags = 0;
|
||||
- ioctl_arg.datalen = sizeof (struct blkpg_partition);
|
||||
- ioctl_arg.data = (void*) part;
|
||||
-
|
||||
- return ioctl (arch_specific->fd, BLKPG, &ioctl_arg) == 0;
|
||||
-}
|
||||
-
|
||||
-static int
|
||||
-_blkpg_add_partition (PedDisk* disk, const PedPartition *part)
|
||||
-{
|
||||
- struct blkpg_partition linux_part;
|
||||
- const char* vol_name;
|
||||
- char* dev_name;
|
||||
-
|
||||
- PED_ASSERT(disk != NULL, return 0);
|
||||
- PED_ASSERT(disk->dev->sector_size % PED_SECTOR_SIZE_DEFAULT == 0,
|
||||
- return 0);
|
||||
-
|
||||
- if (ped_disk_type_check_feature (disk->type,
|
||||
- PED_DISK_TYPE_PARTITION_NAME))
|
||||
- vol_name = ped_partition_get_name (part);
|
||||
- else
|
||||
- vol_name = NULL;
|
||||
-
|
||||
- dev_name = _device_get_part_path (disk->dev, part->num);
|
||||
- if (!dev_name)
|
||||
- return 0;
|
||||
-
|
||||
- memset (&linux_part, 0, sizeof (linux_part));
|
||||
- linux_part.start = part->geom.start * disk->dev->sector_size;
|
||||
- /* see fs/partitions/msdos.c:msdos_partition(): "leave room for LILO" */
|
||||
- if (part->type & PED_PARTITION_EXTENDED)
|
||||
- linux_part.length = part->geom.length == 1 ? 512 : 1024;
|
||||
- else
|
||||
- linux_part.length = part->geom.length * disk->dev->sector_size;
|
||||
- linux_part.pno = part->num;
|
||||
- strncpy (linux_part.devname, dev_name, BLKPG_DEVNAMELTH);
|
||||
- if (vol_name)
|
||||
- strncpy (linux_part.volname, vol_name, BLKPG_VOLNAMELTH);
|
||||
-
|
||||
- free (dev_name);
|
||||
-
|
||||
- if (!_blkpg_part_command (disk->dev, &linux_part,
|
||||
- BLKPG_ADD_PARTITION)) {
|
||||
- return ped_exception_throw (
|
||||
- PED_EXCEPTION_ERROR,
|
||||
- PED_EXCEPTION_IGNORE_CANCEL,
|
||||
- _("Error informing the kernel about modifications to "
|
||||
- "partition %s -- %s. This means Linux won't know "
|
||||
- "about any changes you made to %s until you reboot "
|
||||
- "-- so you shouldn't mount it or use it in any way "
|
||||
- "before rebooting."),
|
||||
- linux_part.devname,
|
||||
- strerror (errno),
|
||||
- linux_part.devname)
|
||||
- == PED_EXCEPTION_IGNORE;
|
||||
- }
|
||||
-
|
||||
- return 1;
|
||||
-}
|
||||
-
|
||||
-static int
|
||||
-_blkpg_remove_partition (PedDisk* disk, int n)
|
||||
-{
|
||||
- struct blkpg_partition linux_part;
|
||||
-
|
||||
- memset (&linux_part, 0, sizeof (linux_part));
|
||||
- linux_part.pno = n;
|
||||
- return _blkpg_part_command (disk->dev, &linux_part,
|
||||
- BLKPG_DEL_PARTITION);
|
||||
-}
|
||||
-
|
||||
-/*
|
||||
- * 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
|
||||
- * value.
|
||||
- */
|
||||
-static unsigned int
|
||||
-_device_get_partition_range(PedDevice* dev)
|
||||
-{
|
||||
- int range, r;
|
||||
- char path[128];
|
||||
- FILE* fp;
|
||||
- bool ok;
|
||||
-
|
||||
- r = snprintf(path, sizeof(path), "/sys/block/%s/range",
|
||||
- last_component(dev->path));
|
||||
- if(r < 0 || r >= sizeof(path))
|
||||
- return MAX_NUM_PARTS;
|
||||
-
|
||||
- fp = fopen(path, "r");
|
||||
- if(!fp)
|
||||
- return MAX_NUM_PARTS;
|
||||
-
|
||||
- ok = fscanf(fp, "%d", &range) == 1;
|
||||
- fclose(fp);
|
||||
-
|
||||
- /* (range <= 0) is none sense.*/
|
||||
- return ok && range > 0 ? range : MAX_NUM_PARTS;
|
||||
-}
|
||||
-
|
||||
-/*
|
||||
- * Sync the partition table in two step process:
|
||||
- * 1. Remove all of the partitions from the kernel's tables, but do not attempt
|
||||
- * removal of any partition for which the corresponding ioctl call fails.
|
||||
- * 2. Add all the partitions that we hold in disk.
|
||||
- *
|
||||
- * To achieve this two step process we must calculate the minimum number of
|
||||
- * maximum possible partitions between what linux supports and what the label
|
||||
- * type supports. EX:
|
||||
- *
|
||||
- * number=MIN(max_parts_supported_in_linux,max_parts_supported_in_msdos_tables)
|
||||
- */
|
||||
-static int
|
||||
-_disk_sync_part_table (PedDisk* disk)
|
||||
-{
|
||||
- PED_ASSERT(disk != NULL, return 0);
|
||||
- PED_ASSERT(disk->dev != NULL, return 0);
|
||||
- int lpn;
|
||||
-
|
||||
- /* lpn = largest partition number. */
|
||||
- if(ped_disk_get_max_supported_partition_count(disk, &lpn))
|
||||
- lpn = PED_MIN(lpn, _device_get_partition_range(disk->dev));
|
||||
- else
|
||||
- lpn = _device_get_partition_range(disk->dev);
|
||||
-
|
||||
- /* Its not possible to support largest_partnum < 0.
|
||||
- * largest_partnum == 0 would mean does not support partitions.
|
||||
- * */
|
||||
- if(lpn < 0)
|
||||
- return 0;
|
||||
-
|
||||
- int *rets = ped_malloc(sizeof(int) * lpn);
|
||||
- int *errnums = ped_malloc(sizeof(int) * lpn);
|
||||
- int ret = 1;
|
||||
- int i;
|
||||
-
|
||||
- for (i = 1; i <= lpn; i++) {
|
||||
- rets[i - 1] = _blkpg_remove_partition (disk, i);
|
||||
- errnums[i - 1] = errno;
|
||||
- }
|
||||
-
|
||||
- for (i = 1; i <= lpn; i++) {
|
||||
- const PedPartition *part = ped_disk_get_partition (disk, i);
|
||||
- if (part) {
|
||||
- /* busy... so we won't (can't!) disturb ;) Prolly
|
||||
- * doesn't matter anyway, because users shouldn't be
|
||||
- * changing mounted partitions anyway...
|
||||
- */
|
||||
- if (!rets[i - 1] && errnums[i - 1] == EBUSY)
|
||||
- continue;
|
||||
-
|
||||
- /* add the (possibly modified or new) partition */
|
||||
- if (!_blkpg_add_partition (disk, part))
|
||||
- ret = 0;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- free (rets);
|
||||
- free (errnums);
|
||||
- return ret;
|
||||
-}
|
||||
-
|
||||
#ifdef ENABLE_DEVICE_MAPPER
|
||||
static int
|
||||
_dm_remove_map_name(char *name)
|
||||
@@ -2601,19 +2414,6 @@ _kernel_reread_part_table (PedDevice* dev)
|
||||
}
|
||||
|
||||
static int
|
||||
-_have_blkpg ()
|
||||
-{
|
||||
- static int have_blkpg = -1;
|
||||
- int kver;
|
||||
-
|
||||
- if (have_blkpg != -1)
|
||||
- return have_blkpg;
|
||||
-
|
||||
- kver = _get_linux_version();
|
||||
- return have_blkpg = kver >= KERNEL_VERSION (2,4,0) ? 1 : 0;
|
||||
-}
|
||||
-
|
||||
-static int
|
||||
linux_disk_commit (PedDisk* disk)
|
||||
{
|
||||
#ifdef ENABLE_DEVICE_MAPPER
|
||||
@@ -2621,19 +2421,6 @@ linux_disk_commit (PedDisk* disk)
|
||||
return _dm_reread_part_table (disk);
|
||||
#endif
|
||||
if (disk->dev->type != PED_DEVICE_FILE) {
|
||||
- /* The ioctl() command BLKPG_ADD_PARTITION does not notify
|
||||
- * the devfs system; consequently, /proc/partitions will not
|
||||
- * be up to date, and the proper links in /dev are not
|
||||
- * created. Therefore, if using DevFS, we must get the kernel
|
||||
- * to re-read and grok the partition table.
|
||||
- */
|
||||
- /* Work around kernel dasd problem so we really do BLKRRPART */
|
||||
- if (disk->dev->type != PED_DEVICE_DASD &&
|
||||
- _have_blkpg () && !_have_devfs ()) {
|
||||
- if (_disk_sync_part_table (disk))
|
||||
- return 1;
|
||||
- }
|
||||
-
|
||||
return _kernel_reread_part_table (disk->dev);
|
||||
}
|
||||
|
||||
--
|
||||
1.6.4
|
||||
|
@ -1,64 +0,0 @@
|
||||
commit 0098e7bdb80fb7ffe55b8bc9086a16d0a65898e5
|
||||
Author: Joel Granados Moreno <jgranado@redhat.com>
|
||||
Date: Mon Jun 22 11:37:26 2009 +0200
|
||||
|
||||
Add mechanism to avoid cylinder alignments.
|
||||
|
||||
diff --git a/include/parted/disk.h b/include/parted/disk.h
|
||||
index 172fbee..664c388 100644
|
||||
--- a/include/parted/disk.h
|
||||
+++ b/include/parted/disk.h
|
||||
@@ -263,7 +263,8 @@ extern int ped_disk_get_last_partition_num (const PedDisk* disk);
|
||||
extern int ped_disk_get_max_primary_partition_count (const PedDisk* disk);
|
||||
extern bool ped_disk_get_max_supported_partition_count(const PedDisk* disk,
|
||||
int* supported);
|
||||
-
|
||||
+extern int ped_disk_align_to_cylinders_on();
|
||||
+extern int ped_disk_align_to_cylinders_toggle();
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
diff --git a/libparted/disk.c b/libparted/disk.c
|
||||
index 6884c83..44a2f2f 100644
|
||||
--- a/libparted/disk.c
|
||||
+++ b/libparted/disk.c
|
||||
@@ -65,6 +65,23 @@ static int _disk_raw_add (PedDisk* disk, PedPartition* part);
|
||||
|
||||
static PedDiskType* disk_types = NULL;
|
||||
|
||||
+int ped_disk_align_to_cylinders = 1;
|
||||
+
|
||||
+int
|
||||
+ped_disk_align_to_cylinders_toggle ()
|
||||
+{
|
||||
+ if (ped_disk_align_to_cylinders == 1)
|
||||
+ return ped_disk_align_to_cylinders = 0;
|
||||
+ else
|
||||
+ return ped_disk_align_to_cylinders = 1;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+ped_disk_align_to_cylinders_on ()
|
||||
+{
|
||||
+ return ped_disk_align_to_cylinders;
|
||||
+}
|
||||
+
|
||||
void
|
||||
ped_disk_type_register (PedDiskType* disk_type)
|
||||
{
|
||||
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
|
||||
index fc54339..e7d416d 100644
|
||||
--- a/libparted/labels/dos.c
|
||||
+++ b/libparted/labels/dos.c
|
||||
@@ -2005,8 +2005,9 @@ msdos_partition_align (PedPartition* part, const PedConstraint* constraint)
|
||||
|
||||
partition_probe_bios_geometry (part, &bios_geom);
|
||||
|
||||
- if (_align (part, &bios_geom, constraint))
|
||||
- return 1;
|
||||
+ if (ped_disk_align_to_cylinders_on())
|
||||
+ if (_align (part, &bios_geom, constraint))
|
||||
+ return 1;
|
||||
if (_align_no_geom (part, constraint))
|
||||
return 1;
|
||||
|
@ -1,30 +0,0 @@
|
||||
From 1dd152a33813406e91261db1f59a9a9dacf4bff6 Mon Sep 17 00:00:00 2001
|
||||
From: Joel Granados Moreno <jgranado@redhat.com>
|
||||
Date: Thu, 11 Jun 2009 16:20:45 +0200
|
||||
Subject: [PATCH] No include headers.
|
||||
|
||||
---
|
||||
include/parted/Makefile.am | 6 +++---
|
||||
1 files changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/include/parted/Makefile.am b/include/parted/Makefile.am
|
||||
index a1ba960..022373f 100644
|
||||
--- a/include/parted/Makefile.am
|
||||
+++ b/include/parted/Makefile.am
|
||||
@@ -16,10 +16,10 @@ partedinclude_HEADERS = constraint.h \
|
||||
natmath.h \
|
||||
timer.h \
|
||||
unit.h \
|
||||
- parted.h \
|
||||
- $(S390_HDRS)
|
||||
+ parted.h
|
||||
|
||||
noinst_HEADERS = crc32.h \
|
||||
- endian.h
|
||||
+ endian.h \
|
||||
+ $(S390_HDRS)
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
--
|
||||
1.6.0.6
|
||||
|
@ -1,250 +0,0 @@
|
||||
--- parted-1.9.0.orig/include/parted/disk.h 2009-12-15 10:32:24.000000000 +0100
|
||||
+++ parted-1.9.0/include/parted/disk.h 2009-12-15 10:59:26.000000000 +0100
|
||||
@@ -265,6 +265,8 @@ extern int ped_disk_get_max_primary_part
|
||||
extern bool ped_disk_get_max_supported_partition_count(const PedDisk* disk,
|
||||
int* supported);
|
||||
extern PedAlignment *ped_disk_get_partition_alignment(const PedDisk *disk);
|
||||
+extern PedSector ped_disk_max_partition_length (const PedDisk *disk);
|
||||
+extern PedSector ped_disk_max_partition_start_sector (const PedDisk *disk);
|
||||
|
||||
/** @} */
|
||||
|
||||
--- parted-1.9.0.orig/libparted/disk.c 2009-12-15 10:32:24.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/disk.c 2009-12-15 10:55:16.000000000 +0100
|
||||
@@ -738,6 +738,40 @@
|
||||
return disk->type->ops->get_max_primary_partition_count (disk);
|
||||
}
|
||||
|
||||
+#include "labels/pt-limit.c"
|
||||
+
|
||||
+/**
|
||||
+ * Return the maximum representable length (in sectors) of a
|
||||
+ * partition on disk \disk.
|
||||
+ */
|
||||
+PedSector
|
||||
+ped_disk_max_partition_length (const PedDisk* disk)
|
||||
+{
|
||||
+ const char *pt_type = disk->type->name;
|
||||
+ struct partition_limit const *pt_lim
|
||||
+ = pt_limit_lookup (pt_type, strlen (pt_type));
|
||||
+ if (pt_lim == NULL)
|
||||
+ return 0;
|
||||
+
|
||||
+ return pt_lim->max_length;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * Return the maximum representable start sector of a
|
||||
+ * partition on disk \disk.
|
||||
+ */
|
||||
+PedSector
|
||||
+ped_disk_max_partition_start_sector (const PedDisk* disk)
|
||||
+{
|
||||
+ const char *pt_type = disk->type->name;
|
||||
+ struct partition_limit const *pt_lim
|
||||
+ = pt_limit_lookup (pt_type, strlen (pt_type));
|
||||
+ if (pt_lim == NULL)
|
||||
+ return 0;
|
||||
+
|
||||
+ return pt_lim->max_start_sector;
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* \internal We turned a really nasty bureaucracy problem into an elegant maths
|
||||
* problem :-) Basically, there are some constraints to a partition's
|
||||
--- parted-1.9.0.orig/libparted/labels/pt-limit.c 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/labels/pt-limit.c 2009-12-15 10:40:46.000000000 +0100
|
||||
@@ -0,0 +1,164 @@
|
||||
+/* ANSI-C code produced by gperf version 3.0.3 */
|
||||
+/* Command-line: gperf -C -N pt_limit_lookup -n -t -s 6 -k '*' --language=ANSI-C pt-limit.gperf */
|
||||
+
|
||||
+#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
|
||||
+ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
|
||||
+ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
|
||||
+ && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
|
||||
+ && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
|
||||
+ && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
|
||||
+ && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
|
||||
+ && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
|
||||
+ && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
|
||||
+ && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
|
||||
+ && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
|
||||
+ && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
|
||||
+ && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
|
||||
+ && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
|
||||
+ && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
|
||||
+ && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
|
||||
+ && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
|
||||
+ && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
|
||||
+ && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
|
||||
+ && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
|
||||
+ && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
|
||||
+ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
|
||||
+ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
|
||||
+/* The character set is not based on ISO-646. */
|
||||
+#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
|
||||
+#endif
|
||||
+
|
||||
+#line 1 "pt-limit.gperf"
|
||||
+struct partition_limit
|
||||
+{
|
||||
+ char const *name;
|
||||
+ uint64_t max_start_sector;
|
||||
+ uint64_t max_length;
|
||||
+};
|
||||
+
|
||||
+#define TOTAL_KEYWORDS 10
|
||||
+#define MIN_WORD_LENGTH 3
|
||||
+#define MAX_WORD_LENGTH 5
|
||||
+#define MIN_HASH_VALUE 0
|
||||
+#define MAX_HASH_VALUE 45
|
||||
+/* maximum key range = 46, duplicates = 0 */
|
||||
+
|
||||
+#ifdef __GNUC__
|
||||
+__inline
|
||||
+#else
|
||||
+#ifdef __cplusplus
|
||||
+inline
|
||||
+#endif
|
||||
+#endif
|
||||
+static unsigned int
|
||||
+hash (register const char *str, register unsigned int len)
|
||||
+{
|
||||
+ static const unsigned char asso_values[] =
|
||||
+ {
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 10, 5, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 0, 30, 30,
|
||||
+ 10, 46, 46, 5, 10, 15, 46, 46, 5, 5,
|
||||
+ 0, 0, 0, 46, 46, 0, 5, 0, 10, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
|
||||
+ 46, 46, 46, 46, 46, 46
|
||||
+ };
|
||||
+ register int hval = 0;
|
||||
+
|
||||
+ switch (len)
|
||||
+ {
|
||||
+ default:
|
||||
+ hval += asso_values[(unsigned char)str[4]];
|
||||
+ /*FALLTHROUGH*/
|
||||
+ case 4:
|
||||
+ hval += asso_values[(unsigned char)str[3]];
|
||||
+ /*FALLTHROUGH*/
|
||||
+ case 3:
|
||||
+ hval += asso_values[(unsigned char)str[2]];
|
||||
+ /*FALLTHROUGH*/
|
||||
+ case 2:
|
||||
+ hval += asso_values[(unsigned char)str[1]];
|
||||
+ /*FALLTHROUGH*/
|
||||
+ case 1:
|
||||
+ hval += asso_values[(unsigned char)str[0]];
|
||||
+ break;
|
||||
+ }
|
||||
+ return hval;
|
||||
+}
|
||||
+
|
||||
+#ifdef __GNUC__
|
||||
+__inline
|
||||
+static
|
||||
+#ifdef __GNUC_STDC_INLINE__
|
||||
+__attribute__ ((__gnu_inline__))
|
||||
+#endif
|
||||
+#endif
|
||||
+const struct partition_limit *
|
||||
+pt_limit_lookup (register const char *str, register unsigned int len)
|
||||
+{
|
||||
+ static const struct partition_limit wordlist[] =
|
||||
+ {
|
||||
+#line 18 "pt-limit.gperf"
|
||||
+ {"sun",128ULL*UINT32_MAX,UINT32_MAX},
|
||||
+ {""}, {""}, {""}, {""},
|
||||
+#line 22 "pt-limit.gperf"
|
||||
+ {"loop",UINT32_MAX,UINT32_MAX},
|
||||
+ {""}, {""}, {""}, {""},
|
||||
+#line 10 "pt-limit.gperf"
|
||||
+ {"gpt",UINT64_MAX,UINT64_MAX},
|
||||
+ {""}, {""}, {""}, {""},
|
||||
+#line 12 "pt-limit.gperf"
|
||||
+ {"msdos",UINT32_MAX,UINT32_MAX},
|
||||
+ {""}, {""}, {""}, {""},
|
||||
+#line 8 "pt-limit.gperf"
|
||||
+ {"dasd",UINT32_MAX,UINT32_MAX},
|
||||
+ {""}, {""}, {""}, {""},
|
||||
+#line 26 "pt-limit.gperf"
|
||||
+ {"amiga",UINT32_MAX,UINT32_MAX},
|
||||
+ {""}, {""}, {""}, {""},
|
||||
+#line 9 "pt-limit.gperf"
|
||||
+ {"dvh",UINT32_MAX,UINT32_MAX},
|
||||
+ {""}, {""}, {""}, {""},
|
||||
+#line 11 "pt-limit.gperf"
|
||||
+ {"mac",UINT32_MAX,UINT32_MAX},
|
||||
+ {""}, {""}, {""}, {""},
|
||||
+#line 20 "pt-limit.gperf"
|
||||
+ {"bsd",UINT32_MAX,UINT32_MAX},
|
||||
+ {""}, {""}, {""}, {""},
|
||||
+#line 23 "pt-limit.gperf"
|
||||
+ {"pc98",UINT32_MAX,UINT32_MAX}
|
||||
+ };
|
||||
+
|
||||
+ if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
||||
+ {
|
||||
+ register int key = hash (str, len);
|
||||
+
|
||||
+ if (key <= MAX_HASH_VALUE && key >= 0)
|
||||
+ {
|
||||
+ register const char *s = wordlist[key].name;
|
||||
+
|
||||
+ if (*str == *s && !strcmp (str + 1, s + 1))
|
||||
+ return &wordlist[key];
|
||||
+ }
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
--- parted-1.9.0.orig/libparted/labels/pt-limit.gperf 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ parted-1.9.0/libparted/labels/pt-limit.gperf 2009-12-15 10:57:05.000000000 +0100
|
||||
@@ -0,0 +1,26 @@
|
||||
+struct partition_limit
|
||||
+{
|
||||
+ char const *name;
|
||||
+ uint64_t max_start_sector;
|
||||
+ uint64_t max_length;
|
||||
+};
|
||||
+%%
|
||||
+dasd,UINT32_MAX,UINT32_MAX
|
||||
+dvh,UINT32_MAX,UINT32_MAX
|
||||
+gpt,UINT64_MAX,UINT64_MAX
|
||||
+mac,UINT32_MAX,UINT32_MAX
|
||||
+msdos,UINT32_MAX,UINT32_MAX
|
||||
+#
|
||||
+# Sun partitions are cylinder-aligned, and it looks like there are 128 sectors
|
||||
+# in a cylinder. FIXME verify. Possibly compute sectors-per-cylinder, given
|
||||
+# u_int16_t ntrks; /* Tracks per cylinder */
|
||||
+# u_int16_t nsect; /* Sectors per track */
|
||||
+sun,128ULL*UINT32_MAX,UINT32_MAX
|
||||
+#
|
||||
+bsd,UINT32_MAX,UINT32_MAX
|
||||
+# aix,UINT32_MAX,UINT32_MAX
|
||||
+loop,UINT32_MAX,UINT32_MAX
|
||||
+pc98,UINT32_MAX,UINT32_MAX
|
||||
+#
|
||||
+# FIXME: not verified. looks like these are cylinder aligned, too
|
||||
+amiga,UINT32_MAX,UINT32_MAX
|
@ -1,43 +0,0 @@
|
||||
From fa2ad81437541251d6e47eccf3bc413cf68a0c31 Mon Sep 17 00:00:00 2001
|
||||
From: Hans de Goede <hdegoede@redhat.com>
|
||||
Date: Tue, 6 Oct 2009 11:18:25 +0200
|
||||
Subject: [PATCH] ped_partition_busy should not call the libparted exception handler
|
||||
|
||||
Modify libparted/arch/linux.c _partition_get_part_dev() to not call
|
||||
_device_stat() but instead use stat directly, as _device_stat() calls
|
||||
the libparted exception handler and we don't want this here, the only caller
|
||||
of _partition_get_part_dev() is _partition_is_mounted(), which in turn only
|
||||
gets called by linux_partition_is_busy(), and we don't want to "throw"
|
||||
exceptions from ped_partition_busy()
|
||||
|
||||
This issue was noticed in combination with pyparted as used by anaconda, see:
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=527035#c10
|
||||
---
|
||||
libparted/arch/linux.c | 4 +++-
|
||||
1 files changed, 3 insertions(+), 1 deletions(-)
|
||||
|
||||
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
|
||||
index 52f7d21..a8d6daf 100644
|
||||
--- a/libparted/arch/linux.c
|
||||
+++ b/libparted/arch/linux.c
|
||||
@@ -2127,7 +2127,7 @@ _partition_get_part_dev (const PedPartition* part)
|
||||
struct stat dev_stat;
|
||||
int dev_major, dev_minor;
|
||||
|
||||
- if (!_device_stat (part->disk->dev, &dev_stat))
|
||||
+ if (stat (part->disk->dev->path, &dev_stat))
|
||||
return (dev_t)0;
|
||||
dev_major = major (dev_stat.st_rdev);
|
||||
dev_minor = minor (dev_stat.st_rdev);
|
||||
@@ -2184,6 +2184,8 @@ _partition_is_mounted (const PedPartition *part)
|
||||
if (!ped_partition_is_active (part))
|
||||
return 0;
|
||||
dev = _partition_get_part_dev (part);
|
||||
+ if (!dev)
|
||||
+ return 0;
|
||||
return _partition_is_mounted_by_dev (dev);
|
||||
}
|
||||
|
||||
--
|
||||
1.6.5.rc2
|
||||
|
@ -1,280 +0,0 @@
|
||||
From 7c7d7b3efc1eb39f884083c852875e1451efc29f Mon Sep 17 00:00:00 2001
|
||||
From: Joel Granados Moreno <jgranado@redhat.com>
|
||||
Date: Thu, 11 Jun 2009 17:05:39 +0200
|
||||
Subject: [PATCH] return errro on push or pop update mode.
|
||||
|
||||
---
|
||||
libparted/disk.c | 85 +++++++++++++++++++++++++++++++++++------------------
|
||||
1 files changed, 56 insertions(+), 29 deletions(-)
|
||||
|
||||
diff --git a/libparted/disk.c b/libparted/disk.c
|
||||
index 3269b9d..39f3a74 100644
|
||||
--- a/libparted/disk.c
|
||||
+++ b/libparted/disk.c
|
||||
@@ -54,8 +54,8 @@
|
||||
#ifdef DEBUG
|
||||
static int _disk_check_sanity (PedDisk* disk);
|
||||
#endif
|
||||
-static void _disk_push_update_mode (PedDisk* disk);
|
||||
-static void _disk_pop_update_mode (PedDisk* disk);
|
||||
+static int _disk_push_update_mode (PedDisk* disk);
|
||||
+static int _disk_pop_update_mode (PedDisk* disk);
|
||||
static int _disk_raw_insert_before (PedDisk* disk, PedPartition* loc,
|
||||
PedPartition* part);
|
||||
static int _disk_raw_insert_after (PedDisk* disk, PedPartition* loc,
|
||||
@@ -215,9 +215,11 @@ _add_duplicate_part (PedDisk* disk, PedPartition* old_part)
|
||||
goto error;
|
||||
new_part->disk = disk;
|
||||
|
||||
- _disk_push_update_mode (disk);
|
||||
+ if (!_disk_push_update_mode (disk))
|
||||
+ goto error_destroy_new_part;
|
||||
ret = _disk_raw_add (disk, new_part);
|
||||
- _disk_pop_update_mode (disk);
|
||||
+ if (!_disk_pop_update_mode (disk))
|
||||
+ goto error_destroy_new_part;
|
||||
if (!ret)
|
||||
goto error_destroy_new_part;
|
||||
#ifdef DEBUG
|
||||
@@ -253,7 +255,8 @@ ped_disk_duplicate (const PedDisk* old_disk)
|
||||
if (!new_disk)
|
||||
goto error;
|
||||
|
||||
- _disk_push_update_mode (new_disk);
|
||||
+ if (!_disk_push_update_mode (new_disk))
|
||||
+ goto error_destroy_new_disk;
|
||||
for (old_part = ped_disk_next_partition (old_disk, NULL); old_part;
|
||||
old_part = ped_disk_next_partition (old_disk, old_part)) {
|
||||
if (ped_partition_is_active (old_part)) {
|
||||
@@ -261,7 +264,8 @@ ped_disk_duplicate (const PedDisk* old_disk)
|
||||
goto error_destroy_new_disk;
|
||||
}
|
||||
}
|
||||
- _disk_pop_update_mode (new_disk);
|
||||
+ if (!_disk_pop_update_mode (new_disk))
|
||||
+ goto error_destroy_new_disk;
|
||||
return new_disk;
|
||||
|
||||
error_destroy_new_disk:
|
||||
@@ -349,7 +353,8 @@ ped_disk_new_fresh (PedDevice* dev, const PedDiskType* type)
|
||||
disk = type->ops->alloc (dev);
|
||||
if (!disk)
|
||||
goto error;
|
||||
- _disk_pop_update_mode (disk);
|
||||
+ if (!_disk_pop_update_mode (disk))
|
||||
+ goto error_destroy_disk;
|
||||
PED_ASSERT (disk->update_mode == 0, goto error_destroy_disk);
|
||||
|
||||
disk->needs_clobber = 1;
|
||||
@@ -914,12 +919,13 @@ _disk_alloc_freespace (PedDisk* disk)
|
||||
* partitions are removed, making it much easier for various manipulation
|
||||
* routines...
|
||||
*/
|
||||
-static void
|
||||
+static int
|
||||
_disk_push_update_mode (PedDisk* disk)
|
||||
{
|
||||
if (!disk->update_mode) {
|
||||
#ifdef DEBUG
|
||||
- _disk_check_sanity (disk);
|
||||
+ if (!_disk_check_sanity (disk))
|
||||
+ return 0;
|
||||
#endif
|
||||
|
||||
_disk_remove_freespace (disk);
|
||||
@@ -927,24 +933,27 @@ _disk_push_update_mode (PedDisk* disk)
|
||||
_disk_remove_metadata (disk);
|
||||
|
||||
#ifdef DEBUG
|
||||
- _disk_check_sanity (disk);
|
||||
+ if (!_disk_check_sanity (disk))
|
||||
+ return 0;
|
||||
#endif
|
||||
} else {
|
||||
disk->update_mode++;
|
||||
}
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
-static void
|
||||
+static int
|
||||
_disk_pop_update_mode (PedDisk* disk)
|
||||
{
|
||||
- PED_ASSERT (disk->update_mode, return);
|
||||
+ PED_ASSERT (disk->update_mode, return 0);
|
||||
|
||||
if (disk->update_mode == 1) {
|
||||
/* re-allocate metadata BEFORE leaving update mode, to prevent infinite
|
||||
* recursion (metadata allocation requires update mode)
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
- _disk_check_sanity (disk);
|
||||
+ if (!_disk_check_sanity (disk))
|
||||
+ return 0;
|
||||
#endif
|
||||
|
||||
_disk_alloc_metadata (disk);
|
||||
@@ -952,11 +961,13 @@ _disk_pop_update_mode (PedDisk* disk)
|
||||
_disk_alloc_freespace (disk);
|
||||
|
||||
#ifdef DEBUG
|
||||
- _disk_check_sanity (disk);
|
||||
+ if (!_disk_check_sanity (disk))
|
||||
+ return 0;
|
||||
#endif
|
||||
} else {
|
||||
disk->update_mode--;
|
||||
}
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
@@ -1826,7 +1837,8 @@ ped_disk_add_partition (PedDisk* disk, PedPartition* part,
|
||||
if (!_partition_check_basic_sanity (disk, part))
|
||||
return 0;
|
||||
|
||||
- _disk_push_update_mode (disk);
|
||||
+ if (!_disk_push_update_mode (disk))
|
||||
+ return 0;
|
||||
|
||||
if (ped_partition_is_active (part)) {
|
||||
overlap_constraint
|
||||
@@ -1854,7 +1866,8 @@ ped_disk_add_partition (PedDisk* disk, PedPartition* part,
|
||||
|
||||
ped_constraint_destroy (overlap_constraint);
|
||||
ped_constraint_destroy (constraints);
|
||||
- _disk_pop_update_mode (disk);
|
||||
+ if (!_disk_pop_update_mode (disk))
|
||||
+ return 0;
|
||||
#ifdef DEBUG
|
||||
if (!_disk_check_sanity (disk))
|
||||
return 0;
|
||||
@@ -1883,10 +1896,12 @@ ped_disk_remove_partition (PedDisk* disk, PedPartition* part)
|
||||
PED_ASSERT (disk != NULL, return 0);
|
||||
PED_ASSERT (part != NULL, return 0);
|
||||
|
||||
- _disk_push_update_mode (disk);
|
||||
+ if (!_disk_push_update_mode (disk))
|
||||
+ return 0;
|
||||
PED_ASSERT (part->part_list == NULL, goto error);
|
||||
_disk_raw_remove (disk, part);
|
||||
- _disk_pop_update_mode (disk);
|
||||
+ if (!_disk_pop_update_mode (disk))
|
||||
+ return 0;
|
||||
ped_disk_enumerate_partitions (disk);
|
||||
return 1;
|
||||
|
||||
@@ -1909,12 +1924,14 @@ ped_disk_delete_partition (PedDisk* disk, PedPartition* part)
|
||||
PED_ASSERT (disk != NULL, return 0);
|
||||
PED_ASSERT (part != NULL, return 0);
|
||||
|
||||
- _disk_push_update_mode (disk);
|
||||
+ if (!_disk_push_update_mode (disk))
|
||||
+ return 0;
|
||||
if (part->type == PED_PARTITION_EXTENDED)
|
||||
ped_disk_delete_all_logical (disk);
|
||||
ped_disk_remove_partition (disk, part);
|
||||
ped_partition_destroy (part);
|
||||
- _disk_pop_update_mode (disk);
|
||||
+ if (!_disk_pop_update_mode (disk))
|
||||
+ return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1952,7 +1969,8 @@ ped_disk_delete_all (PedDisk* disk)
|
||||
|
||||
PED_ASSERT (disk != NULL, return 0);
|
||||
|
||||
- _disk_push_update_mode (disk);
|
||||
+ if (!_disk_push_update_mode (disk))
|
||||
+ return 0;
|
||||
|
||||
for (walk = disk->part_list; walk; walk = next) {
|
||||
next = walk->next;
|
||||
@@ -1961,7 +1979,8 @@ ped_disk_delete_all (PedDisk* disk)
|
||||
return 0;
|
||||
}
|
||||
|
||||
- _disk_pop_update_mode (disk);
|
||||
+ if (!_disk_pop_update_mode (disk))
|
||||
+ return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1995,7 +2014,8 @@ ped_disk_set_partition_geom (PedDisk* disk, PedPartition* part,
|
||||
old_geom = part->geom;
|
||||
ped_geometry_init (&new_geom, part->geom.dev, start, end - start + 1);
|
||||
|
||||
- _disk_push_update_mode (disk);
|
||||
+ if (!_disk_push_update_mode (disk))
|
||||
+ return 0;
|
||||
|
||||
overlap_constraint
|
||||
= _partition_get_overlap_constraint (part, &new_geom);
|
||||
@@ -2018,7 +2038,8 @@ ped_disk_set_partition_geom (PedDisk* disk, PedPartition* part,
|
||||
_disk_raw_remove (disk, part);
|
||||
_disk_raw_add (disk, part);
|
||||
|
||||
- _disk_pop_update_mode (disk);
|
||||
+ if (!_disk_pop_update_mode (disk))
|
||||
+ goto error;
|
||||
|
||||
ped_constraint_destroy (overlap_constraint);
|
||||
ped_constraint_destroy (constraints);
|
||||
@@ -2026,6 +2047,7 @@ ped_disk_set_partition_geom (PedDisk* disk, PedPartition* part,
|
||||
|
||||
error_pop_update_mode:
|
||||
_disk_pop_update_mode (disk);
|
||||
+error:
|
||||
ped_constraint_destroy (overlap_constraint);
|
||||
ped_constraint_destroy (constraints);
|
||||
part->geom = old_geom;
|
||||
@@ -2064,7 +2086,8 @@ ped_disk_maximize_partition (PedDisk* disk, PedPartition* part,
|
||||
|
||||
old_geom = part->geom;
|
||||
|
||||
- _disk_push_update_mode (disk);
|
||||
+ if (!_disk_push_update_mode (disk))
|
||||
+ return 0;
|
||||
|
||||
if (part->prev)
|
||||
new_start = part->prev->geom.end + 1;
|
||||
@@ -2080,7 +2103,8 @@ ped_disk_maximize_partition (PedDisk* disk, PedPartition* part,
|
||||
new_end))
|
||||
goto error;
|
||||
|
||||
- _disk_pop_update_mode (disk);
|
||||
+ if (!_disk_pop_update_mode (disk))
|
||||
+ return 0;
|
||||
return 1;
|
||||
|
||||
error:
|
||||
@@ -2152,11 +2176,13 @@ ped_disk_minimize_extended_partition (PedDisk* disk)
|
||||
if (!ext_part)
|
||||
return 1;
|
||||
|
||||
- _disk_push_update_mode (disk);
|
||||
+ if (!_disk_push_update_mode (disk))
|
||||
+ return 0;
|
||||
|
||||
first_logical = ext_part->part_list;
|
||||
if (!first_logical) {
|
||||
- _disk_pop_update_mode (disk);
|
||||
+ if (!_disk_pop_update_mode (disk))
|
||||
+ return 0;
|
||||
return ped_disk_delete_partition (disk, ext_part);
|
||||
}
|
||||
|
||||
@@ -2169,7 +2195,8 @@ ped_disk_minimize_extended_partition (PedDisk* disk)
|
||||
last_logical->geom.end);
|
||||
ped_constraint_destroy (constraint);
|
||||
|
||||
- _disk_pop_update_mode (disk);
|
||||
+ if (!_disk_pop_update_mode (disk))
|
||||
+ return 0;
|
||||
return status;
|
||||
}
|
||||
|
||||
--
|
||||
1.6.0.6
|
||||
|
@ -1,38 +0,0 @@
|
||||
From 456b8c4d2424e52f7861e14d667ba7c26ca1cce3 Mon Sep 17 00:00:00 2001
|
||||
From: Joel Granados Moreno <jgranado@redhat.com>
|
||||
Date: Fri, 5 Jun 2009 14:14:08 +0200
|
||||
Subject: [PATCH] Preserve first 446 bytes of the pmbr in gpt.
|
||||
|
||||
* libparted/label/gpt.c (_write_pmbr) : Make sure we read the first 446
|
||||
bytes of the device when we are creating the pmbr.
|
||||
---
|
||||
libparted/labels/gpt.c | 13 ++++++++++++-
|
||||
1 files changed, 12 insertions(+), 1 deletions(-)
|
||||
|
||||
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
|
||||
index 73bdbb2..f1c4f69 100644
|
||||
--- a/libparted/labels/gpt.c
|
||||
+++ b/libparted/labels/gpt.c
|
||||
@@ -982,7 +982,18 @@ _write_pmbr (PedDevice * dev)
|
||||
{
|
||||
LegacyMBR_t pmbr;
|
||||
|
||||
- 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).
|
||||
+ * With this in mind, we try not to modify these elements.
|
||||
+ */
|
||||
+ if(ped_device_read(dev, &pmbr, 0, GPT_PMBR_SECTORS) < GPT_PMBR_SECTORS)
|
||||
+ memset(&pmbr, 0, sizeof(pmbr));
|
||||
+
|
||||
+ /* Make sure we zero out all the legacy partitions.
|
||||
+ * There are 4 PartitionRecords. */
|
||||
+ memset(&(pmbr.PartitionRecord), 0, sizeof(PartitionRecord_t) * 4);
|
||||
+
|
||||
pmbr.Signature = PED_CPU_TO_LE16(MSDOS_MBR_SIGNATURE);
|
||||
pmbr.PartitionRecord[0].OSType = EFI_PMBR_OSTYPE_EFI;
|
||||
pmbr.PartitionRecord[0].StartSector = 1;
|
||||
--
|
||||
1.6.0.6
|
||||
|
@ -1,19 +0,0 @@
|
||||
commit 9a4166aa0420ca16c73ba11e0cb7bce4d326cbdf
|
||||
Author: Joel Granados Moreno <jgranado@redhat.com>
|
||||
Date: Fri Jun 12 14:41:53 2009 +0200
|
||||
|
||||
Remove unneeded struct element.
|
||||
|
||||
diff --git a/include/parted/disk.h b/include/parted/disk.h
|
||||
index 5207e0b..172fbee 100644
|
||||
--- a/include/parted/disk.h
|
||||
+++ b/include/parted/disk.h
|
||||
@@ -157,7 +157,7 @@ struct _PedDisk {
|
||||
PedDevice* dev; /**< the device where the
|
||||
partition table lies */
|
||||
const PedDiskType* type; /**< type of disk label */
|
||||
- const int* block_sizes; /**< block sizes supported
|
||||
+ /*const int* block_sizes; **< block sizes supported
|
||||
by this label */
|
||||
PedPartition* part_list; /**< list of partitions. Access with
|
||||
ped_disk_next_partition() */
|
@ -1,12 +0,0 @@
|
||||
diff -up parted-1.9.0/parted/parted.c.ru parted-1.9.0/parted/parted.c
|
||||
--- parted-1.9.0/parted/parted.c.ru 2009-12-17 10:32:41.000000000 +0100
|
||||
+++ parted-1.9.0/parted/parted.c 2009-12-17 10:32:01.000000000 +0100
|
||||
@@ -1227,7 +1227,7 @@ partition_print_flags (PedPartition* par
|
||||
ped_realloc (&_res, strlen (res) + 1
|
||||
+ strlen (name));
|
||||
res = _res;
|
||||
- strncat (res, name, 21);
|
||||
+ strcat (res, name);
|
||||
}
|
||||
}
|
||||
|
@ -1,137 +0,0 @@
|
||||
From 2df065840eda1ac1fc99a31627ea0f06ca7a4ca7 Mon Sep 17 00:00:00 2001
|
||||
From: Joel Granados Moreno <jgranado@redhat.com>
|
||||
Date: Wed, 10 Jun 2009 18:34:46 +0200
|
||||
Subject: [PATCH] Handle swap flag in msdos type labels.
|
||||
|
||||
* libparted/labels/dos.c (swap, raw_part_parse, msdos_partition_new)
|
||||
(msdos_partition_duplicate, msdos_partition_set_system)
|
||||
(msdos_partition_set_flag, msdos_partition_get_flag): Handle the swap
|
||||
flag. Set the partition type if the user sets the swap flag.
|
||||
---
|
||||
libparted/labels/dos.c | 28 ++++++++++++++++++++++++++++
|
||||
1 files changed, 28 insertions(+), 0 deletions(-)
|
||||
|
||||
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
|
||||
index 7ec15ee..f8307c5 100644
|
||||
--- a/libparted/labels/dos.c
|
||||
+++ b/libparted/labels/dos.c
|
||||
@@ -148,6 +148,7 @@ typedef struct {
|
||||
int lba;
|
||||
int palo;
|
||||
int prep;
|
||||
+ int swap;
|
||||
OrigState* orig; /* used for CHS stuff */
|
||||
} DosPartitionData;
|
||||
|
||||
@@ -818,6 +819,7 @@ raw_part_parse (const PedDisk* disk, const DosRawPartition* raw_part,
|
||||
dos_data->lba = raw_part_is_lba (raw_part);
|
||||
dos_data->palo = raw_part->type == PARTITION_PALO;
|
||||
dos_data->prep = raw_part->type == PARTITION_PREP;
|
||||
+ dos_data->swap = raw_part->type == PARTITION_LINUX_SWAP;
|
||||
dos_data->orig = ped_malloc (sizeof (OrigState));
|
||||
if (!dos_data->orig) {
|
||||
ped_partition_destroy (part);
|
||||
@@ -1202,6 +1204,7 @@ msdos_partition_new (const PedDisk* disk, PedPartitionType part_type,
|
||||
dos_data->lba = 0;
|
||||
dos_data->palo = 0;
|
||||
dos_data->prep = 0;
|
||||
+ dos_data->swap = 0;
|
||||
} else {
|
||||
part->disk_specific = NULL;
|
||||
}
|
||||
@@ -1237,6 +1240,7 @@ msdos_partition_duplicate (const PedPartition* part, PedDisk* disk)
|
||||
new_dos_data->lba = old_dos_data->lba;
|
||||
new_dos_data->palo = old_dos_data->palo;
|
||||
new_dos_data->prep = old_dos_data->prep;
|
||||
+ new_dos_data->swap = old_dos_data->swap;
|
||||
|
||||
if (old_dos_data->orig) {
|
||||
new_dos_data->orig = ped_malloc (sizeof (OrigState));
|
||||
@@ -1284,6 +1288,7 @@ msdos_partition_set_system (PedPartition* part,
|
||||
dos_data->lvm = 0;
|
||||
dos_data->palo = 0;
|
||||
dos_data->prep = 0;
|
||||
+ dos_data->swap = 0;
|
||||
if (dos_data->lba)
|
||||
dos_data->system = PARTITION_EXT_LBA;
|
||||
else
|
||||
@@ -1307,6 +1312,10 @@ msdos_partition_set_system (PedPartition* part,
|
||||
dos_data->system = PARTITION_PREP;
|
||||
return 1;
|
||||
}
|
||||
+ if (dos_data->swap) {
|
||||
+ dos_data->system = PARTITION_LINUX_SWAP;
|
||||
+ return 1;
|
||||
+ }
|
||||
|
||||
if (!fs_type)
|
||||
dos_data->system = PARTITION_LINUX;
|
||||
@@ -1379,6 +1388,7 @@ msdos_partition_set_flag (PedPartition* part,
|
||||
dos_data->lvm = 0;
|
||||
dos_data->palo = 0;
|
||||
dos_data->prep = 0;
|
||||
+ dos_data->swap = 0;
|
||||
}
|
||||
dos_data->raid = state;
|
||||
return ped_partition_set_system (part, part->fs_type);
|
||||
@@ -1389,6 +1399,7 @@ msdos_partition_set_flag (PedPartition* part,
|
||||
dos_data->raid = 0;
|
||||
dos_data->palo = 0;
|
||||
dos_data->prep = 0;
|
||||
+ dos_data->swap = 0;
|
||||
}
|
||||
dos_data->lvm = state;
|
||||
return ped_partition_set_system (part, part->fs_type);
|
||||
@@ -1402,6 +1413,7 @@ msdos_partition_set_flag (PedPartition* part,
|
||||
dos_data->hidden = 0;
|
||||
dos_data->raid = 0;
|
||||
dos_data->lvm = 0;
|
||||
+ dos_data->swap = 0;
|
||||
}
|
||||
dos_data->palo = state;
|
||||
return ped_partition_set_system (part, part->fs_type);
|
||||
@@ -1411,10 +1423,23 @@ msdos_partition_set_flag (PedPartition* part,
|
||||
dos_data->hidden = 0;
|
||||
dos_data->raid = 0;
|
||||
dos_data->lvm = 0;
|
||||
+ dos_data->swap = 0;
|
||||
+ dos_data->palo = 0;
|
||||
}
|
||||
dos_data->prep = state;
|
||||
return ped_partition_set_system (part, part->fs_type);
|
||||
|
||||
+ case PED_PARTITION_SWAP:
|
||||
+ if (state) {
|
||||
+ dos_data->hidden = 0;
|
||||
+ dos_data->raid = 0;
|
||||
+ dos_data->lvm = 0;
|
||||
+ dos_data->palo = 0;
|
||||
+ dos_data->prep = 0;
|
||||
+ }
|
||||
+ dos_data->swap = state;
|
||||
+ return ped_partition_set_system (part, part->fs_type);
|
||||
+
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -1451,6 +1476,9 @@ msdos_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
|
||||
case PED_PARTITION_PREP:
|
||||
return dos_data->prep;
|
||||
|
||||
+ case PED_PARTITION_SWAP:
|
||||
+ return dos_data->swap;
|
||||
+
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -1496,6 +1496,7 @@ msdos_partition_is_flag_available (const
|
||||
case PED_PARTITION_LBA:
|
||||
case PED_PARTITION_PALO:
|
||||
case PED_PARTITION_PREP:
|
||||
+ case PED_PARTITION_SWAP:
|
||||
return 1;
|
||||
|
||||
default:
|
||||
--
|
||||
1.6.0.6
|
||||
|
@ -1,586 +0,0 @@
|
||||
diff -up parted-1.9.0/doc/C/parted.8.align parted-1.9.0/doc/C/parted.8
|
||||
--- parted-1.9.0/doc/C/parted.8.align 2009-12-15 18:42:25.000000000 +0100
|
||||
+++ parted-1.9.0/doc/C/parted.8 2009-12-15 18:42:29.000000000 +0100
|
||||
@@ -30,6 +30,26 @@ never prompts for user intervention
|
||||
.TP
|
||||
.B -v, --version
|
||||
displays the version
|
||||
+.TP
|
||||
+.B -a \fIalignment-type\fP, --align \fIalignment-type\fP
|
||||
+Set alignment for newly created partitions, valid alignment types are:
|
||||
+.RS
|
||||
+.IP none
|
||||
+Use the minimum alignment allowed by the disk type.
|
||||
+.IP cylinder
|
||||
+Align partitions to cylinders.
|
||||
+.IP minimal
|
||||
+Use minimum alignment as given by the disk topology information. This and
|
||||
+the opt value will use layout information provided by the disk to align the
|
||||
+logical partition table addresses to actual physical blocks on the disks.
|
||||
+The min value is the minimum aligment needed to align the partition properly to
|
||||
+physical blocks, which avoids performance degradation.
|
||||
+.IP optimal
|
||||
+Use optimum alignment as given by the disk topology information. This
|
||||
+aligns to a multiple of the physical block size in a way that guarantees
|
||||
+optimal performance.
|
||||
+.RE
|
||||
+
|
||||
.SH COMMANDS
|
||||
.TP
|
||||
.B [device]
|
||||
diff -up parted-1.9.0/doc/parted.texi.align parted-1.9.0/doc/parted.texi
|
||||
--- parted-1.9.0/doc/parted.texi.align 2009-12-15 18:42:25.000000000 +0100
|
||||
+++ parted-1.9.0/doc/parted.texi 2009-12-15 18:42:29.000000000 +0100
|
||||
@@ -496,6 +496,11 @@ display a help message
|
||||
@itemx --script
|
||||
never prompt the user
|
||||
|
||||
+@item -a alignment-type
|
||||
+@itemx --align alignment-type
|
||||
+Set alignment for newly created partitions, valid alignment types are:
|
||||
+none, cylinder, minimal and optimal.
|
||||
+
|
||||
@item -v
|
||||
@itemx --version
|
||||
display the version
|
||||
diff -up parted-1.9.0/lib/argmatch.c.align parted-1.9.0/lib/argmatch.c
|
||||
--- parted-1.9.0/lib/argmatch.c.align 2009-12-15 18:42:25.000000000 +0100
|
||||
+++ parted-1.9.0/lib/argmatch.c 2009-12-15 18:43:16.000000000 +0100
|
||||
@@ -0,0 +1,274 @@
|
||||
+/* argmatch.c -- find a match for a string in an array
|
||||
+
|
||||
+ Copyright (C) 1990, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
||||
+ Free Software Foundation, Inc.
|
||||
+
|
||||
+ This program is free software: you can redistribute it and/or modify
|
||||
+ it under the terms of the GNU General Public License as published by
|
||||
+ the Free Software Foundation; either version 3 of the License, or
|
||||
+ (at your option) any later version.
|
||||
+
|
||||
+ This program is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ GNU General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU General Public License
|
||||
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+/* Written by David MacKenzie <djm@ai.mit.edu>
|
||||
+ Modified by Akim Demaille <demaille@inf.enst.fr> */
|
||||
+
|
||||
+#include <config.h>
|
||||
+
|
||||
+/* Specification. */
|
||||
+#include "argmatch.h"
|
||||
+
|
||||
+#include <stdbool.h>
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <string.h>
|
||||
+
|
||||
+#include "gettext.h"
|
||||
+#define _(msgid) gettext (msgid)
|
||||
+
|
||||
+#include "error.h"
|
||||
+
|
||||
+#if USE_UNLOCKED_IO
|
||||
+# include "unlocked-io.h"
|
||||
+#endif
|
||||
+
|
||||
+/* When reporting an invalid argument, show nonprinting characters
|
||||
+ by using the quoting style ARGMATCH_QUOTING_STYLE. Do not use
|
||||
+ literal_quoting_style. */
|
||||
+#ifndef ARGMATCH_QUOTING_STYLE
|
||||
+# define ARGMATCH_QUOTING_STYLE locale_quoting_style
|
||||
+#endif
|
||||
+
|
||||
+/* Non failing version of argmatch call this function after failing. */
|
||||
+#ifndef ARGMATCH_DIE
|
||||
+# include "exitfail.h"
|
||||
+# define ARGMATCH_DIE exit (exit_failure)
|
||||
+#endif
|
||||
+
|
||||
+#ifdef ARGMATCH_DIE_DECL
|
||||
+ARGMATCH_DIE_DECL;
|
||||
+#endif
|
||||
+
|
||||
+static void
|
||||
+__argmatch_die (void)
|
||||
+{
|
||||
+ ARGMATCH_DIE;
|
||||
+}
|
||||
+
|
||||
+/* Used by XARGMATCH and XARGCASEMATCH. See description in argmatch.h.
|
||||
+ Default to __argmatch_die, but allow caller to change this at run-time. */
|
||||
+argmatch_exit_fn argmatch_die = __argmatch_die;
|
||||
+
|
||||
+
|
||||
+/* If ARG is an unambiguous match for an element of the
|
||||
+ NULL-terminated array ARGLIST, return the index in ARGLIST
|
||||
+ of the matched element, else -1 if it does not match any element
|
||||
+ or -2 if it is ambiguous (is a prefix of more than one element).
|
||||
+
|
||||
+ If VALLIST is none null, use it to resolve ambiguities limited to
|
||||
+ synonyms, i.e., for
|
||||
+ "yes", "yop" -> 0
|
||||
+ "no", "nope" -> 1
|
||||
+ "y" is a valid argument, for `0', and "n" for `1'. */
|
||||
+
|
||||
+ptrdiff_t
|
||||
+argmatch (const char *arg, const char *const *arglist,
|
||||
+ const char *vallist, size_t valsize)
|
||||
+{
|
||||
+ size_t i; /* Temporary index in ARGLIST. */
|
||||
+ size_t arglen; /* Length of ARG. */
|
||||
+ ptrdiff_t matchind = -1; /* Index of first nonexact match. */
|
||||
+ bool ambiguous = false; /* If true, multiple nonexact match(es). */
|
||||
+
|
||||
+ arglen = strlen (arg);
|
||||
+
|
||||
+ /* Test all elements for either exact match or abbreviated matches. */
|
||||
+ for (i = 0; arglist[i]; i++)
|
||||
+ {
|
||||
+ if (!strncmp (arglist[i], arg, arglen))
|
||||
+ {
|
||||
+ if (strlen (arglist[i]) == arglen)
|
||||
+ /* Exact match found. */
|
||||
+ return i;
|
||||
+ else if (matchind == -1)
|
||||
+ /* First nonexact match found. */
|
||||
+ matchind = i;
|
||||
+ else
|
||||
+ {
|
||||
+ /* Second nonexact match found. */
|
||||
+ if (vallist == NULL
|
||||
+ || memcmp (vallist + valsize * matchind,
|
||||
+ vallist + valsize * i, valsize))
|
||||
+ {
|
||||
+ /* There is a real ambiguity, or we could not
|
||||
+ disambiguate. */
|
||||
+ ambiguous = true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if (ambiguous)
|
||||
+ return -2;
|
||||
+ else
|
||||
+ return matchind;
|
||||
+}
|
||||
+
|
||||
+/* Error reporting for argmatch.
|
||||
+ CONTEXT is a description of the type of entity that was being matched.
|
||||
+ VALUE is the invalid value that was given.
|
||||
+ PROBLEM is the return value from argmatch. */
|
||||
+
|
||||
+void
|
||||
+argmatch_invalid (const char *context, const char *value, ptrdiff_t problem)
|
||||
+{
|
||||
+ char const *format = (problem == -1
|
||||
+ ? _("invalid argument %s for %s")
|
||||
+ : _("ambiguous argument %s for %s"));
|
||||
+
|
||||
+ error (0, 0, format, value, context);
|
||||
+}
|
||||
+
|
||||
+/* List the valid arguments for argmatch.
|
||||
+ ARGLIST is the same as in argmatch.
|
||||
+ VALLIST is a pointer to an array of values.
|
||||
+ VALSIZE is the size of the elements of VALLIST */
|
||||
+void
|
||||
+argmatch_valid (const char *const *arglist,
|
||||
+ const char *vallist, size_t valsize)
|
||||
+{
|
||||
+ size_t i;
|
||||
+ const char *last_val = NULL;
|
||||
+
|
||||
+ /* We try to put synonyms on the same line. The assumption is that
|
||||
+ synonyms follow each other */
|
||||
+ fprintf (stderr, _("Valid arguments are:"));
|
||||
+ for (i = 0; arglist[i]; i++)
|
||||
+ if ((i == 0)
|
||||
+ || memcmp (last_val, vallist + valsize * i, valsize))
|
||||
+ {
|
||||
+ fprintf (stderr, "\n - `%s'", arglist[i]);
|
||||
+ last_val = vallist + valsize * i;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ fprintf (stderr, ", `%s'", arglist[i]);
|
||||
+ }
|
||||
+ putc ('\n', stderr);
|
||||
+}
|
||||
+
|
||||
+/* Never failing versions of the previous functions.
|
||||
+
|
||||
+ CONTEXT is the context for which argmatch is called (e.g.,
|
||||
+ "--version-control", or "$VERSION_CONTROL" etc.). Upon failure,
|
||||
+ calls the (supposed never to return) function EXIT_FN. */
|
||||
+
|
||||
+ptrdiff_t
|
||||
+__xargmatch_internal (const char *context,
|
||||
+ const char *arg, const char *const *arglist,
|
||||
+ const char *vallist, size_t valsize,
|
||||
+ argmatch_exit_fn exit_fn)
|
||||
+{
|
||||
+ ptrdiff_t res = argmatch (arg, arglist, vallist, valsize);
|
||||
+ if (res >= 0)
|
||||
+ /* Success. */
|
||||
+ return res;
|
||||
+
|
||||
+ /* We failed. Explain why. */
|
||||
+ argmatch_invalid (context, arg, res);
|
||||
+ argmatch_valid (arglist, vallist, valsize);
|
||||
+ (*exit_fn) ();
|
||||
+
|
||||
+ return -1; /* To please the compilers. */
|
||||
+}
|
||||
+
|
||||
+/* Look for VALUE in VALLIST, an array of objects of size VALSIZE and
|
||||
+ return the first corresponding argument in ARGLIST */
|
||||
+const char *
|
||||
+argmatch_to_argument (const char *value,
|
||||
+ const char *const *arglist,
|
||||
+ const char *vallist, size_t valsize)
|
||||
+{
|
||||
+ size_t i;
|
||||
+
|
||||
+ for (i = 0; arglist[i]; i++)
|
||||
+ if (!memcmp (value, vallist + valsize * i, valsize))
|
||||
+ return arglist[i];
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+#ifdef TEST
|
||||
+/*
|
||||
+ * Based on "getversion.c" by David MacKenzie <djm@gnu.ai.mit.edu>
|
||||
+ */
|
||||
+char *program_name;
|
||||
+
|
||||
+/* When to make backup files. */
|
||||
+enum backup_type
|
||||
+{
|
||||
+ /* Never make backups. */
|
||||
+ no_backups,
|
||||
+
|
||||
+ /* Make simple backups of every file. */
|
||||
+ simple_backups,
|
||||
+
|
||||
+ /* Make numbered backups of files that already have numbered backups,
|
||||
+ and simple backups of the others. */
|
||||
+ numbered_existing_backups,
|
||||
+
|
||||
+ /* Make numbered backups of every file. */
|
||||
+ numbered_backups
|
||||
+};
|
||||
+
|
||||
+/* Two tables describing arguments (keys) and their corresponding
|
||||
+ values */
|
||||
+static const char *const backup_args[] =
|
||||
+{
|
||||
+ "no", "none", "off",
|
||||
+ "simple", "never",
|
||||
+ "existing", "nil",
|
||||
+ "numbered", "t",
|
||||
+ 0
|
||||
+};
|
||||
+
|
||||
+static const enum backup_type backup_vals[] =
|
||||
+{
|
||||
+ no_backups, no_backups, no_backups,
|
||||
+ simple_backups, simple_backups,
|
||||
+ numbered_existing_backups, numbered_existing_backups,
|
||||
+ numbered_backups, numbered_backups
|
||||
+};
|
||||
+
|
||||
+int
|
||||
+main (int argc, const char *const *argv)
|
||||
+{
|
||||
+ const char *cp;
|
||||
+ enum backup_type backup_type = no_backups;
|
||||
+
|
||||
+ program_name = (char *) argv[0];
|
||||
+
|
||||
+ if (argc > 2)
|
||||
+ {
|
||||
+ fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", program_name);
|
||||
+ exit (1);
|
||||
+ }
|
||||
+
|
||||
+ if ((cp = getenv ("VERSION_CONTROL")))
|
||||
+ backup_type = XARGMATCH ("$VERSION_CONTROL", cp,
|
||||
+ backup_args, backup_vals);
|
||||
+
|
||||
+ if (argc == 2)
|
||||
+ backup_type = XARGMATCH (program_name, argv[1],
|
||||
+ backup_args, backup_vals);
|
||||
+
|
||||
+ printf ("The version control is `%s'\n",
|
||||
+ ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif
|
||||
diff -up parted-1.9.0/lib/argmatch.h.align parted-1.9.0/lib/argmatch.h
|
||||
--- parted-1.9.0/lib/argmatch.h.align 2009-12-15 18:42:25.000000000 +0100
|
||||
+++ parted-1.9.0/lib/argmatch.h 2009-12-15 18:42:29.000000000 +0100
|
||||
@@ -0,0 +1,102 @@
|
||||
+/* argmatch.h -- definitions and prototypes for argmatch.c
|
||||
+
|
||||
+ Copyright (C) 1990, 1998, 1999, 2001, 2002, 2004, 2005 Free Software
|
||||
+ Foundation, Inc.
|
||||
+
|
||||
+ This program is free software: you can redistribute it and/or modify
|
||||
+ it under the terms of the GNU General Public License as published by
|
||||
+ the Free Software Foundation; either version 3 of the License, or
|
||||
+ (at your option) any later version.
|
||||
+
|
||||
+ This program is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ GNU General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU General Public License
|
||||
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+/* Written by David MacKenzie <djm@ai.mit.edu>
|
||||
+ Modified by Akim Demaille <demaille@inf.enst.fr> */
|
||||
+
|
||||
+#ifndef ARGMATCH_H_
|
||||
+# define ARGMATCH_H_ 1
|
||||
+
|
||||
+# include <stddef.h>
|
||||
+
|
||||
+# include "verify.h"
|
||||
+
|
||||
+# define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
|
||||
+
|
||||
+/* Assert there are as many real arguments as there are values
|
||||
+ (argument list ends with a NULL guard). */
|
||||
+
|
||||
+# define ARGMATCH_VERIFY(Arglist, Vallist) \
|
||||
+ verify (ARRAY_CARDINALITY (Arglist) == ARRAY_CARDINALITY (Vallist) + 1)
|
||||
+
|
||||
+/* Return the index of the element of ARGLIST (NULL terminated) that
|
||||
+ matches with ARG. If VALLIST is not NULL, then use it to resolve
|
||||
+ false ambiguities (i.e., different matches of ARG but corresponding
|
||||
+ to the same values in VALLIST). */
|
||||
+
|
||||
+ptrdiff_t argmatch (char const *arg, char const *const *arglist,
|
||||
+ char const *vallist, size_t valsize);
|
||||
+
|
||||
+# define ARGMATCH(Arg, Arglist, Vallist) \
|
||||
+ argmatch (Arg, Arglist, (char const *) (Vallist), sizeof *(Vallist))
|
||||
+
|
||||
+/* xargmatch calls this function when it fails. This function should not
|
||||
+ return. By default, this is a function that calls ARGMATCH_DIE which
|
||||
+ in turn defaults to `exit (exit_failure)'. */
|
||||
+typedef void (*argmatch_exit_fn) (void);
|
||||
+extern argmatch_exit_fn argmatch_die;
|
||||
+
|
||||
+/* Report on stderr why argmatch failed. Report correct values. */
|
||||
+
|
||||
+void argmatch_invalid (char const *context, char const *value,
|
||||
+ ptrdiff_t problem);
|
||||
+
|
||||
+/* Left for compatibility with the old name invalid_arg */
|
||||
+
|
||||
+# define invalid_arg(Context, Value, Problem) \
|
||||
+ argmatch_invalid (Context, Value, Problem)
|
||||
+
|
||||
+
|
||||
+
|
||||
+/* Report on stderr the list of possible arguments. */
|
||||
+
|
||||
+void argmatch_valid (char const *const *arglist,
|
||||
+ char const *vallist, size_t valsize);
|
||||
+
|
||||
+# define ARGMATCH_VALID(Arglist, Vallist) \
|
||||
+ argmatch_valid (Arglist, (char const *) (Vallist), sizeof *(Vallist))
|
||||
+
|
||||
+
|
||||
+
|
||||
+/* Same as argmatch, but upon failure, reports a explanation on the
|
||||
+ failure, and exits using the function EXIT_FN. */
|
||||
+
|
||||
+ptrdiff_t __xargmatch_internal (char const *context,
|
||||
+ char const *arg, char const *const *arglist,
|
||||
+ char const *vallist, size_t valsize,
|
||||
+ argmatch_exit_fn exit_fn);
|
||||
+
|
||||
+/* Programmer friendly interface to __xargmatch_internal. */
|
||||
+
|
||||
+# define XARGMATCH(Context, Arg, Arglist, Vallist) \
|
||||
+ ((Vallist) [__xargmatch_internal (Context, Arg, Arglist, \
|
||||
+ (char const *) (Vallist), \
|
||||
+ sizeof *(Vallist), \
|
||||
+ argmatch_die)])
|
||||
+
|
||||
+/* Convert a value into a corresponding argument. */
|
||||
+
|
||||
+char const *argmatch_to_argument (char const *value,
|
||||
+ char const *const *arglist,
|
||||
+ char const *vallist, size_t valsize);
|
||||
+
|
||||
+# define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \
|
||||
+ argmatch_to_argument (Value, Arglist, \
|
||||
+ (char const *) (Vallist), sizeof *(Vallist))
|
||||
+
|
||||
+#endif /* ARGMATCH_H_ */
|
||||
diff -up parted-1.9.0/lib/gnulib.mk.align parted-1.9.0/lib/gnulib.mk
|
||||
--- parted-1.9.0/lib/gnulib.mk.align 2009-12-15 18:42:25.000000000 +0100
|
||||
+++ parted-1.9.0/lib/gnulib.mk 2009-12-15 18:42:29.000000000 +0100
|
||||
@@ -72,6 +72,15 @@ EXTRA_DIST += $(top_srcdir)/build-aux/an
|
||||
|
||||
## end gnulib module announce-gen
|
||||
|
||||
+## begin gnulib module argmatch
|
||||
+
|
||||
+
|
||||
+EXTRA_DIST += argmatch.c argmatch.h
|
||||
+
|
||||
+libgnulib_la_SOURCES += argmatch.c
|
||||
+
|
||||
+## end gnulib module argmatch
|
||||
+
|
||||
## begin gnulib module btowc
|
||||
|
||||
|
||||
diff -up parted-1.9.0/parted/parted.c.align parted-1.9.0/parted/parted.c
|
||||
--- parted-1.9.0/parted/parted.c.align 2009-12-15 18:42:25.000000000 +0100
|
||||
+++ parted-1.9.0/parted/parted.c 2009-12-15 18:42:29.000000000 +0100
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <config.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
+#include "argmatch.h"
|
||||
#include "closeout.h"
|
||||
#include "configmake.h"
|
||||
#include "version-etc.h"
|
||||
@@ -74,6 +75,31 @@ enum
|
||||
PRETEND_INPUT_TTY = CHAR_MAX + 1,
|
||||
};
|
||||
|
||||
+enum
|
||||
+{
|
||||
+ ALIGNMENT_NONE = 2,
|
||||
+ ALIGNMENT_CYLINDER,
|
||||
+ ALIGNMENT_MINIMAL,
|
||||
+ ALIGNMENT_OPTIMAL
|
||||
+};
|
||||
+
|
||||
+static char const *const align_args[] =
|
||||
+{
|
||||
+ "none",
|
||||
+ "cylinder",
|
||||
+ "minimal",
|
||||
+ "optimal",
|
||||
+ NULL
|
||||
+};
|
||||
+
|
||||
+static int const align_types[] =
|
||||
+{
|
||||
+ ALIGNMENT_NONE,
|
||||
+ ALIGNMENT_CYLINDER,
|
||||
+ ALIGNMENT_MINIMAL,
|
||||
+ ALIGNMENT_OPTIMAL
|
||||
+};
|
||||
+ARGMATCH_VERIFY (align_args, align_types);
|
||||
|
||||
typedef struct {
|
||||
time_t last_update;
|
||||
@@ -87,6 +113,7 @@ static struct option const options[] = {
|
||||
{"machine", 0, NULL, 'm'},
|
||||
{"script", 0, NULL, 's'},
|
||||
{"version", 0, NULL, 'v'},
|
||||
+ {"align", required_argument, NULL, 'a'},
|
||||
{"-pretend-input-tty", 0, NULL, PRETEND_INPUT_TTY},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
@@ -97,6 +124,7 @@ static const char *const options_help []
|
||||
{"machine", N_("displays machine parseable output")},
|
||||
{"script", N_("never prompts for user intervention")},
|
||||
{"version", N_("displays the version")},
|
||||
+ {"align=[none|cyl|min|opt]", N_("alignment for new partitions")},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -105,6 +133,7 @@ int pretend_input_tty = 0;
|
||||
int opt_machine_mode = 0;
|
||||
int disk_is_modified = 0;
|
||||
int is_toggle_mode = 0;
|
||||
+int alignment = ALIGNMENT_CYLINDER;
|
||||
|
||||
static const char* number_msg = N_(
|
||||
"NUMBER is the partition number used by Linux. On MS-DOS disk labels, the "
|
||||
@@ -569,7 +598,7 @@ print_options_help ()
|
||||
int i;
|
||||
|
||||
for (i=0; options_help [i][0]; i++) {
|
||||
- printf (" -%c, --%-23.23s %s\n",
|
||||
+ printf (" -%c, --%-25.25s %s\n",
|
||||
options_help [i][0][0],
|
||||
options_help [i][0],
|
||||
_(options_help [i][1]));
|
||||
@@ -700,6 +729,11 @@ do_mkpart (PedDevice** dev)
|
||||
if (!disk)
|
||||
goto error;
|
||||
|
||||
+ if (ped_disk_is_flag_available(disk, PED_DISK_CYLINDER_ALIGNMENT))
|
||||
+ if (!ped_disk_set_flag(disk, PED_DISK_CYLINDER_ALIGNMENT,
|
||||
+ alignment == ALIGNMENT_CYLINDER))
|
||||
+ goto error_destroy_disk;
|
||||
+
|
||||
if (!ped_disk_type_check_feature (disk->type, PED_DISK_TYPE_EXTENDED)) {
|
||||
part_type = PED_PARTITION_NORMAL;
|
||||
} else {
|
||||
@@ -752,7 +786,14 @@ do_mkpart (PedDevice** dev)
|
||||
range_end);
|
||||
PED_ASSERT (user_constraint != NULL, return 0);
|
||||
|
||||
- dev_constraint = ped_device_get_constraint (*dev);
|
||||
+ if (alignment == ALIGNMENT_OPTIMAL)
|
||||
+ dev_constraint =
|
||||
+ ped_device_get_optimal_aligned_constraint(*dev);
|
||||
+ else if (alignment == ALIGNMENT_MINIMAL)
|
||||
+ dev_constraint =
|
||||
+ ped_device_get_minimal_aligned_constraint(*dev);
|
||||
+ else
|
||||
+ dev_constraint = ped_device_get_constraint(*dev);
|
||||
PED_ASSERT (dev_constraint != NULL, return 0);
|
||||
|
||||
final_constraint = ped_constraint_intersect (user_constraint,
|
||||
@@ -2364,7 +2405,7 @@ int opt, help = 0, list = 0, version
|
||||
|
||||
while (1)
|
||||
{
|
||||
- opt = getopt_long (*argc_ptr, *argv_ptr, "hlmsv",
|
||||
+ opt = getopt_long (*argc_ptr, *argv_ptr, "hlmsva:",
|
||||
options, NULL);
|
||||
if (opt == -1)
|
||||
break;
|
||||
@@ -2375,16 +2416,22 @@ while (1)
|
||||
case 'm': opt_machine_mode = 1; break;
|
||||
case 's': opt_script_mode = 1; break;
|
||||
case 'v': version = 1; break;
|
||||
+ case 'a':
|
||||
+ alignment = XARGMATCH ("--align", optarg,
|
||||
+ align_args, align_types);
|
||||
+ break;
|
||||
case PRETEND_INPUT_TTY:
|
||||
pretend_input_tty = 1;
|
||||
break;
|
||||
- default: wrong = 1; break;
|
||||
+ default:
|
||||
+ wrong = 1;
|
||||
+ break;
|
||||
}
|
||||
}
|
||||
|
||||
if (wrong == 1) {
|
||||
fprintf (stderr,
|
||||
- _("Usage: %s [-hlmsv] [DEVICE [COMMAND [PARAMETERS]]...]\n"),
|
||||
+ _("Usage: %s [-hlmsv] [-a<align>] [DEVICE [COMMAND [PARAMETERS]]...]\n"),
|
||||
program_name);
|
||||
return 0;
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
diff -up parted-1.9.0/libparted/labels/vtoc.c.kh1 parted-1.9.0/libparted/labels/vtoc.c
|
||||
--- parted-1.9.0/libparted/labels/vtoc.c.kh1 2009-08-28 12:17:26.000000000 +0200
|
||||
+++ parted-1.9.0/libparted/labels/vtoc.c 2009-08-28 12:18:03.000000000 +0200
|
||||
@@ -263,7 +263,7 @@ vtoc_volume_label_init (volume_label_t *
|
||||
PDEBUG
|
||||
sprintf(buffer, "%84s", " ");
|
||||
vtoc_ebcdic_enc(buffer, buffer, 84);
|
||||
- strncpy(vlabel->volkey, buffer, 84);
|
||||
+ strncpy(vlabel->volkey, buffer, 4);
|
||||
}
|
||||
|
||||
/*
|
30
parted-2.1-blkid_topology_get_physical_sector_size.patch
Normal file
30
parted-2.1-blkid_topology_get_physical_sector_size.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From 503c54ef274a923dcac337361936062b37a0ac1a Mon Sep 17 00:00:00 2001
|
||||
From: Hans de Goede <hdegoede@redhat.com>
|
||||
Date: Mon, 11 Jan 2010 11:46:36 +0100
|
||||
Subject: [PATCH parted 1/3] linux: use blkid_topology_get_physical_sector_size
|
||||
|
||||
The official 2.17 release of util-linux-ng, has added a function to
|
||||
get the physical sector size, use that instead of getting the
|
||||
minimum io size.
|
||||
* libparted/arch/linux.c(_device_set_sector_size): use
|
||||
blkid_topology_get_physical_sector_size.
|
||||
---
|
||||
libparted/arch/linux.c | 2 +-
|
||||
1 files changed, 1 insertions(+), 1 deletions(-)
|
||||
|
||||
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
|
||||
index aefe788..bf33059 100644
|
||||
--- a/libparted/arch/linux.c
|
||||
+++ b/libparted/arch/linux.c
|
||||
@@ -668,7 +668,7 @@ _device_set_sector_size (PedDevice* dev)
|
||||
dev->path, strerror (errno), PED_SECTOR_SIZE_DEFAULT);
|
||||
} else {
|
||||
dev->phys_sector_size =
|
||||
- blkid_topology_get_minimum_io_size(
|
||||
+ blkid_topology_get_physical_sector_size(
|
||||
arch_specific->topology);
|
||||
}
|
||||
#endif
|
||||
--
|
||||
1.6.5.2
|
||||
|
81
parted.spec
81
parted.spec
@ -3,44 +3,20 @@
|
||||
|
||||
Summary: The GNU disk partition manipulation program
|
||||
Name: parted
|
||||
Version: 1.9.0
|
||||
Release: 25%{?dist}
|
||||
Version: 2.1
|
||||
Release: 1%{?dist}
|
||||
License: GPLv3+
|
||||
Group: Applications/System
|
||||
URL: http://www.gnu.org/software/parted
|
||||
|
||||
Source0: ftp://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
|
||||
Patch1: %{name}-1.9.0-appletv-support.patch
|
||||
Patch2: %{name}-1.9.0-extended-mbr.patch
|
||||
Patch3: %{name}-1.9.0-noheaders.patch
|
||||
Patch4: %{name}-1.9.0-pop-push-error.patch
|
||||
Patch6: %{name}-1.9.0-remove-struct-elem.patch
|
||||
Patch7: %{name}-1.9.0-move-function-declarations.patch
|
||||
Patch10: %{name}-1.9.0-handle-dup-error.patch
|
||||
Patch11: %{name}-1.9.0-swap-flag.patch
|
||||
Patch12: %{name}-1.9.0-volkeysize.patch
|
||||
Patch13: %{name}-1.9.0-no-BLKPG.patch
|
||||
Patch14: %{name}-1.9.0-commit-without-close.patch
|
||||
Patch15: %{name}-1.9.0-dont-touch-part-nodes.patch
|
||||
Patch16: %{name}-1.9.0-ped_partition_is_busy-no-exception.patch
|
||||
Patch17: %{name}-1.9.0-gpt-big-endian.patch
|
||||
Patch18: %{name}-1.9.0-export-alignment-info.patch
|
||||
Patch19: %{name}-1.9.0-dasd-fixes.patch
|
||||
Patch20: %{name}-1.9.0-dasd-533808.patch
|
||||
Patch21: %{name}-1.9.0-lo-as-file-rh546622.patch
|
||||
Patch22: %{name}-1.9.0-partition-limits-rh533417.patch
|
||||
Patch23: %{name}-1.9.0-diskflags.patch
|
||||
Patch24: %{name}-1.9.0-ui-align-rh361951.patch
|
||||
Patch25: %{name}-1.9.0-align-default-rh361951.patch
|
||||
Patch26: %{name}-1.9.0-entiredisk-rh533328.patch
|
||||
Patch27: %{name}-1.9.0-ru-rh543029.patch
|
||||
Patch28: %{name}-1.9.0-new-lvm-rh525095.patch
|
||||
Patch0: parted-1.9.0-align-default-rh361951.patch
|
||||
Patch1: parted-2.1-blkid_topology_get_physical_sector_size.patch
|
||||
|
||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: e2fsprogs-devel
|
||||
BuildRequires: readline-devel
|
||||
BuildRequires: ncurses-devel
|
||||
BuildRequires: libtool
|
||||
BuildRequires: gettext-devel
|
||||
BuildRequires: texinfo
|
||||
BuildRequires: device-mapper-devel
|
||||
@ -59,6 +35,7 @@ and copy hard disk partitions. Parted can be used for creating space
|
||||
for new operating systems, reorganizing disk usage, and copying data
|
||||
to new hard disks.
|
||||
|
||||
|
||||
%package devel
|
||||
Summary: Files for developing apps which will manipulate disk partitions
|
||||
Group: Development/Libraries
|
||||
@ -71,43 +48,22 @@ manipulation. If you want to develop programs that manipulate disk
|
||||
partitions and filesystems using the routines provided by the GNU
|
||||
Parted library, you need to install this package.
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q -n %{name}-%{version}
|
||||
%patch1 -p1 -b .appletv
|
||||
%patch2 -p1 -b .extended-mbr
|
||||
%patch3 -p1 -b .noheaders
|
||||
%patch4 -p1 -b .pop-push-error
|
||||
%patch6 -p1 -b .remove-struct-elem
|
||||
%patch7 -p1 -b .move-function-declarations
|
||||
%patch10 -p1 -b .handle-dup-error
|
||||
%patch11 -p1 -b .swap-flag
|
||||
%patch12 -p1 -b .volkeysize
|
||||
%patch13 -p1 -b .no-BLKPG
|
||||
%patch14 -p1 -b .commit-without-close
|
||||
%patch15 -p1 -b .dont-touch-part-nodes
|
||||
%patch16 -p1 -b .ped_partition_is_busy
|
||||
%patch17 -p1 -b .gpt-big-endian
|
||||
%patch18 -p1 -b .export-align
|
||||
%patch19 -p1 -b .dasd
|
||||
%patch20 -p1 -b .dasd2
|
||||
%patch21 -p1
|
||||
%patch22 -p1
|
||||
%patch23 -p1
|
||||
%patch24 -p1
|
||||
%patch25 -p1
|
||||
%patch26 -p1
|
||||
%patch27 -p1
|
||||
%patch28 -p1
|
||||
aclocal --force -I m4
|
||||
autoconf --force
|
||||
autoheader --force
|
||||
automake --add-missing --copy --force-missing
|
||||
%setup -q
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
iconv -f ISO-8859-1 -t UTF8 AUTHORS > tmp; touch -r AUTHORS tmp; mv tmp AUTHORS
|
||||
|
||||
|
||||
%build
|
||||
%configure --enable-selinux --disable-static
|
||||
# Don't use rpath!
|
||||
%{__sed} -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
|
||||
%{__sed} -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
|
||||
%{__make} %{?_smp_mflags}
|
||||
|
||||
|
||||
%install
|
||||
%{__rm} -rf %{buildroot}
|
||||
%{__make} install DESTDIR=%{buildroot}
|
||||
@ -130,9 +86,11 @@ popd
|
||||
|
||||
%find_lang %{name}
|
||||
|
||||
|
||||
%clean
|
||||
%{__rm} -rf %{buildroot}
|
||||
|
||||
|
||||
%post
|
||||
/sbin/ldconfig
|
||||
if [ -f %{_infodir}/parted.info.gz ]; then
|
||||
@ -146,6 +104,7 @@ fi
|
||||
|
||||
%postun -p /sbin/ldconfig
|
||||
|
||||
|
||||
%files -f %{name}.lang
|
||||
%defattr(-,root,root,-)
|
||||
%doc AUTHORS BUGS COPYING ChangeLog NEWS README THANKS TODO doc/API doc/FAT
|
||||
@ -164,6 +123,10 @@ fi
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Jan 11 2010 Hans de Goede <hdegoede@redhat.com> 2.1-1
|
||||
- New upstream release 2.1
|
||||
- Drop all our patches (all merged upstream)
|
||||
|
||||
* Sun Dec 20 2009 Hans de Goede <hdegoede@redhat.com> 1.9.0-25
|
||||
- Fix crash when partitioning loopback devices (#546622)
|
||||
- Drop no-cylinder-align patch:
|
||||
@ -807,7 +770,7 @@ fi
|
||||
* Thu Oct 25 2001 Jeremy Katz <katzj@redhat.com> 1.4.20-2
|
||||
- build both python1.5 and python2 modules
|
||||
|
||||
* Fri Oct 19 2001 Matt Wilson <msw@redhat.com> 1.4.20-1
|
||||
* Fri Oct 19 2001 Matt Wilson <msw@redhat.com> 1.4.20-1
|
||||
- 1.4.20 final
|
||||
|
||||
* Thu Oct 11 2001 Matt Wilson <msw@redhat.com> 1.4.20-0.1pre3
|
||||
|
Loading…
Reference in New Issue
Block a user