- Updating to upstream patches

- tests/t1701-rescue-fs wait for the device to appear. (bcl)
- Increase timeout for rmmod scsi_debug and make it a framework failure (bcl)
- libparted/dasd: add test cases for the new fdasd functions (dongdwdw)
- libparted/dasd: add an exception for changing DASD-LDL partition table (dongdwdw)
- libpartd/dasd: improve flag processing for DASD-LDL (dongdwdw)
- parted/ui: remove unneccesary information of command line (dongdwdw)
- parted: check the name of partition first when to name a partition (dongdwdw)
- Add support for RAM drives (sparschauer)
- Fix crash when localized (psusi)
- libparted: Fix typo in hfs error message (sebras)
- libparted: Fix MacOS boot support (laurent)
- mac: copy partition type and name correctly (saproj)
- libparted: Add support for atari partition tables (glaubitz)
- libparted:tests: Move get_sector_size() to common.c (glaubitz)
- tests: Update t0220 and t0280 for the swap flag. (bcl)
- libparted: set swap flag on GPT partitions (aschnell)
- libparted/dasd: add test cases for the new fdasd functions (dongdwdw)
- libparted/dasd: add new fdasd functions (dongdwdw)
- libparted/dasd: update and improve fdasd functions (dongdwdw)
- libparted/dasd: unify vtoc handling for cdl/ldl (dongdwdw)
- libparted: Don't warn if no HDIO_GET_IDENTITY ioctl (sparschauer)
- libparted: Fix starting CHS in protective MBR (petr.uzel)
- tests: Stop timing t9040 (#1172675) (bcl)
This commit is contained in:
Brian C. Lane 2017-05-02 09:41:50 -07:00
parent fd44e26140
commit d75d85cc43
24 changed files with 4145 additions and 1 deletions

View File

@ -0,0 +1,46 @@
From 582d7cddcda260684d2bca7265294dc651bcb091 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 29 Feb 2016 16:54:05 -0800
Subject: [PATCH 55/75] tests: Stop timing t9040 (#1172675)
parted doesn't have any control over how long this takes, there is no
reason to consider this a parted bug if it takes longer than expected.
Resolves: rhbz#1172675
(cherry picked from commit fdd2e12b504c1d8a7829055cf8195d4aae4cd708)
---
tests/t9040-many-partitions.sh | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/tests/t9040-many-partitions.sh b/tests/t9040-many-partitions.sh
index a3af5e7..4f58658 100644
--- a/tests/t9040-many-partitions.sh
+++ b/tests/t9040-many-partitions.sh
@@ -53,9 +53,7 @@ while :; do
done
# Time the actual command:
-t0=$(date +%s.%N)
parted -m -a min -s $scsi_dev mklabel gpt $cmd u s p > out 2>&1 || fail=1
-t_final=$(date +%s.%N)
i=1
while :; do
@@ -64,14 +62,6 @@ while :; do
printf "$i:${s}s:${e}s:${partition_sectors}s::p$i:;\n" >> exp
test $i = $n_partitions && break; i=$((i+1))
done
-
-# Fail the test if it takes too long.
-# On Fedora 16, this takes about 10 seconds for me.
-# With Fedora-12-era kernels, it typically took more than 150 seconds.
-$AWK "BEGIN {d = $t_final - $t0; n = $n_partitions; st = 60 < d;"\
-' printf "created %d partitions in %.2f seconds\n", n, d; exit st }' /dev/null \
- || fail=1
-
compare exp out || fail=1
Exit $fail
--
2.9.3

View File

@ -0,0 +1,33 @@
From ef6a998695636d81d7d24ad8ae7405b03bf75c2f Mon Sep 17 00:00:00 2001
From: Petr Uzel <petr.uzel@suse.cz>
Date: Thu, 10 Mar 2016 14:18:52 +0100
Subject: [PATCH 56/75] libparted: Fix starting CHS in protective MBR
The CHS address for protective partition start in protective MBR
should be 0/0/2, according to UEFI spec (v2.6, section 5.2.1).
* libparted/labels/gpt.c (_write_pmbr): Fix starting CHS address
Reported by Steffen Winterfeldt in https://bugzilla.suse.com/969165
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
libparted/labels/gpt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index d69377a..6027eb3 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1139,7 +1139,7 @@ _write_pmbr (PedDevice *dev, bool pmbr_boot)
pmbr->Signature = PED_CPU_TO_LE16 (MSDOS_MBR_SIGNATURE);
pmbr->PartitionRecord[0].OSType = EFI_PMBR_OSTYPE_EFI;
- pmbr->PartitionRecord[0].StartSector = 1;
+ pmbr->PartitionRecord[0].StartSector = 2;
pmbr->PartitionRecord[0].EndHead = 0xFE;
pmbr->PartitionRecord[0].EndSector = 0xFF;
pmbr->PartitionRecord[0].EndTrack = 0xFF;
--
2.9.3

View File

@ -0,0 +1,44 @@
From a6612fb6dd3746cfc9138ebc84210945a8fffa10 Mon Sep 17 00:00:00 2001
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Tue, 4 Oct 2016 11:37:30 +0200
Subject: [PATCH 57/75] libparted: Don't warn if no HDIO_GET_IDENTITY ioctl
Fully virtualized Xen VMs (HVM) use Linux IDE devices which don't
support the HDIO_GET_IDENTITY ioctl. EINVAL is returned, a warning
is printed and the device model is set to "Generic IDE" in that
case. The problem is seeing the warning all the time. So drop it
for this case.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/arch/linux.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index b7ba5de..2058697 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -931,6 +931,7 @@ init_ide (PedDevice* dev)
PedExceptionOption ex_status;
char hdi_buf[41];
int sector_multiplier = 0;
+ int r;
if (!_device_stat (dev, &dev_stat))
goto error;
@@ -938,7 +939,11 @@ init_ide (PedDevice* dev)
if (!_device_open_ro (dev))
goto error;
- if (ioctl (arch_specific->fd, HDIO_GET_IDENTITY, &hdi)) {
+ r = ioctl (arch_specific->fd, HDIO_GET_IDENTITY, &hdi);
+ if (r && errno == EINVAL) {
+ /* silently ignore unsupported ioctl */
+ dev->model = strdup(_("Generic IDE"));
+ } else if (r) {
ex_status = ped_exception_throw (
PED_EXCEPTION_WARNING,
PED_EXCEPTION_IGNORE_CANCEL,
--
2.9.3

View File

@ -0,0 +1,272 @@
From ebb6eef20792a17388da30f1c312ede4b03140fd Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Wed, 26 Oct 2016 04:22:46 +0200
Subject: [PATCH 58/75] libparted/dasd: unify vtoc handling for cdl/ldl
Merge volume label cdl and ldl. It is convenient to manipulate
the same structure. Also remove unused arguments in the functions.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
include/parted/vtoc.in.h | 34 +++++++++++++++++++---------------
libparted/labels/dasd.c | 8 +++-----
libparted/labels/vtoc.c | 38 +++++++++++++++++---------------------
3 files changed, 39 insertions(+), 41 deletions(-)
diff --git a/include/parted/vtoc.in.h b/include/parted/vtoc.in.h
index 499c2d3..b9da23a 100644
--- a/include/parted/vtoc.in.h
+++ b/include/parted/vtoc.in.h
@@ -62,7 +62,6 @@ typedef struct cchh cchh_t;
typedef struct labeldate labeldate_t;
typedef struct volume_label volume_label_t;
typedef struct cms_volume_label cms_volume_label_t;
-typedef struct ldl_volume_label ldl_volume_label_t;
typedef struct extent extent_t;
typedef struct dev_const dev_const_t;
typedef struct format1_label format1_label_t;
@@ -94,6 +93,19 @@ struct __attribute__ ((packed)) labeldate {
u_int16_t day;
};
+/*
+ * The following structure is a merger of the cdl and ldl volume label.
+ * On an ldl disk there is no key information, so when reading an
+ * ldl label from disk, the data should be copied at the address of vollbl.
+ * On the other side, the field ldl_version is reserved in a cdl record
+ * and the field formatted_blocks exists only for ldl labels. So when
+ * reading a cdl label from disk, the formatted_blocks field will contain
+ * arbitrary data.
+ * This layout may be a bit awkward, but the advantage of having the
+ * same label type for both disk layout types is bigger than the effort
+ * for taking a bit of extra care at the fringes.
+ */
+
struct __attribute__ ((packed)) volume_label {
char volkey[4]; /* volume key = volume label */
char vollbl[4]; /* volume label ("VOL1" in EBCDIC) */
@@ -107,15 +119,8 @@ struct __attribute__ ((packed)) volume_label {
char labperci[4]; /* no of labels per CI (FBA), blanks for CKD */
char res2[4]; /* reserved */
char lvtoc[14]; /* owner code for LVTOC */
- char res3[29]; /* reserved */
- char fudge[4]; /* filler to match length of ldl label */
-};
-
-struct __attribute__ ((packed)) ldl_volume_label {
- char vollbl[4]; /* Label identifier ("LNX1" in EBCDIC) */
- char volid[6]; /* Volume identifier */
- char res3[69]; /* Reserved field */
- char ldl_version[1]; /* Version number, valid for ldl format */
+ char res3[28]; /* reserved */
+ char ldl_version; /* version number, valid for ldl format */
u_int64_t formatted_blocks; /* valid when ldl_version >= "2" (in
EBCDIC) */
};
@@ -335,11 +340,10 @@ void vtoc_write_label (int fd, unsigned long position,
format7_label_t const *f7,
format9_label_t const *f9);
-void vtoc_init_format1_label (char *volid, unsigned int blksize,
+void vtoc_init_format1_label (unsigned int blksize,
extent_t *part_extent, format1_label_t *f1);
void vtoc_init_format4_label (format4_label_t *f4lbl,
- unsigned int usable_partitions,
unsigned int compat_cylinders,
unsigned int real_cylinders,
unsigned int tracks,
@@ -352,11 +356,11 @@ void vtoc_update_format4_label (format4_label_t *f4, cchhb_t *highest_f1,
void vtoc_init_format5_label (format5_label_t *f5);
-void vtoc_update_format5_label_add (format5_label_t *f5, int verbose, int cyl,
+void vtoc_update_format5_label_add (format5_label_t *f5, int verbose,
int trk, u_int16_t a, u_int16_t b,
u_int8_t c);
-void vtoc_update_format5_label_del (format5_label_t *f5, int verbose, int cyl,
+void vtoc_update_format5_label_del (format5_label_t *f5, int verbose,
int trk, u_int16_t a, u_int16_t b,
u_int8_t c);
@@ -368,7 +372,7 @@ void vtoc_update_format7_label_add (format7_label_t *f7, int verbose,
void vtoc_update_format7_label_del (format7_label_t *f7, int verbose,
u_int32_t a, u_int32_t b);
-void vtoc_init_format8_label (char *volid, unsigned int blksize,
+void vtoc_init_format8_label (unsigned int blksize,
extent_t *part_extent, format1_label_t *f1);
void vtoc_update_format8_label (cchhb_t *associated_f9, format1_label_t *f8);
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index 4e68512..7594e96 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -330,13 +330,12 @@ dasd_read (PedDisk* disk)
DasdPartitionData* dasd_data;
union vollabel {
- volume_label_t unused;
- ldl_volume_label_t ldl;
+ volume_label_t ldl;
cms_volume_label_t cms;
};
union vollabel *cms_ptr1 = (union vollabel *) anchor.vlabel;
cms_volume_label_t *cms_ptr = &cms_ptr1->cms;
- ldl_volume_label_t *ldl_ptr = &cms_ptr1->ldl;
+ volume_label_t *ldl_ptr = &cms_ptr1->ldl;
int partition_start_block;
disk_specific->format_type = 1;
@@ -360,8 +359,7 @@ dasd_read (PedDisk* disk)
* (long long) cms_ptr->disk_offset;
if (is_ldl)
- if (strncmp(ldl_ptr->ldl_version,
- vtoc_ebcdic_enc("2", str, 1), 1) >= 0)
+ if (ldl_ptr->ldl_version >= 0xf2)
end = (long long) arch_specific->real_sector_size
/ (long long) disk->dev->sector_size
* (long long) ldl_ptr->formatted_blocks - 1;
diff --git a/libparted/labels/vtoc.c b/libparted/labels/vtoc.c
index fdfa94f..d47b791 100644
--- a/libparted/labels/vtoc.c
+++ b/libparted/labels/vtoc.c
@@ -150,7 +150,7 @@ enum failure {
unable_to_read
};
-static char buffer[89];
+static char buffer[93];
static void
vtoc_error (enum failure why, char const *s1, char const *s2)
@@ -329,7 +329,7 @@ void
vtoc_volume_label_init (volume_label_t *vlabel)
{
PDEBUG
- sprintf(buffer, "%88s", " ");
+ sprintf(buffer, "%92s", " ");
vtoc_ebcdic_enc(buffer, buffer, sizeof *vlabel);
memcpy(vlabel, buffer, sizeof *vlabel);
}
@@ -348,8 +348,8 @@ vtoc_read_volume_label (int f, unsigned long vlabel_start,
typedef union vollabel vollabel_t;
union __attribute__((packed)) vollabel {
+ /* cdl and ldl have the same data struct */
volume_label_t cdl;
- ldl_volume_label_t ldl;
cms_volume_label_t cms;
};
@@ -373,9 +373,7 @@ vtoc_read_volume_label (int f, unsigned long vlabel_start,
}
rc = read(f, vlabel, sizeof(volume_label_t));
- if (rc != sizeof(volume_label_t) &&
- /* For CDL we ask to read 88 bytes, but only get 84 */
- rc != sizeof(volume_label_t) - 4) {
+ if (rc != sizeof(volume_label_t)) {
vtoc_error(unable_to_read, "vtoc_read_volume_label",
_("Could not read volume label."));
return 1;
@@ -427,10 +425,8 @@ vtoc_write_volume_label (int f, unsigned long vlabel_start,
vtoc_error(unable_to_seek, "vtoc_write_volume_label",
_("Could not write volume label."));
- rc = write(f, vlabel, sizeof(volume_label_t) - 4);
- /* Subtract 4 to leave off the "fudge" variable when writing.
- We only write CDL volume labels, never LDL or CMS. */
- if (rc != sizeof(volume_label_t) - 4)
+ rc = write(f, vlabel, sizeof(volume_label_t));
+ if (rc != sizeof(volume_label_t))
vtoc_error(unable_to_write, "vtoc_write_volume_label",
_("Could not write volume label."));
@@ -632,7 +628,7 @@ vtoc_write_label (int f, unsigned long position,
* initializes a format4 label
*/
void
-vtoc_init_format4_label (format4_label_t *f4, unsigned int usable_partitions,
+vtoc_init_format4_label (format4_label_t *f4,
unsigned int compat_cylinders,
unsigned int real_cylinders, unsigned int tracks,
unsigned int blocks, unsigned int blksize,
@@ -740,7 +736,7 @@ vtoc_init_format7_label (format7_label_t *f7)
* format1 or format 8 label, all but the field DS1FMTID
*/
void
-vtoc_init_format_1_8_label (char *volid, unsigned int blksize,
+vtoc_init_format_1_8_label (unsigned int blksize,
extent_t *part_extent, format1_label_t *f1)
{
PDEBUG
@@ -794,18 +790,18 @@ vtoc_init_format_1_8_label (char *volid, unsigned int blksize,
}
void
-vtoc_init_format1_label (char *volid, unsigned int blksize,
+vtoc_init_format1_label (unsigned int blksize,
extent_t *part_extent, format1_label_t *f1)
{
- vtoc_init_format_1_8_label(volid, blksize, part_extent, f1);
+ vtoc_init_format_1_8_label(blksize, part_extent, f1);
f1->DS1FMTID = 0xf1;
}
void
-vtoc_init_format8_label (char *volid, unsigned int blksize,
+vtoc_init_format8_label (unsigned int blksize,
extent_t *part_extent, format1_label_t *f8)
{
- vtoc_init_format_1_8_label(volid, blksize, part_extent, f8);
+ vtoc_init_format_1_8_label(blksize, part_extent, f8);
f8->DS1FMTID = 0xf8;
}
@@ -886,7 +882,7 @@ vtoc_reorganize_FMT5_extents (format5_label_t *f5)
* add a free space extent description to the VTOC FMT5 DSCB
*/
void
-vtoc_update_format5_label_add (format5_label_t *f5, int verbose, int cyl,
+vtoc_update_format5_label_add (format5_label_t *f5, int verbose,
int trk, u_int16_t a, u_int16_t b, u_int8_t c)
{
PDEBUG
@@ -974,7 +970,7 @@ vtoc_update_format5_label_add (format5_label_t *f5, int verbose, int cyl,
* remove a free space extent description from the VTOC FMT5 DSCB
*/
void
-vtoc_update_format5_label_del (format5_label_t *f5, int verbose, int cyl,
+vtoc_update_format5_label_del (format5_label_t *f5, int verbose,
int trk, u_int16_t a, u_int16_t b, u_int8_t c)
{
PDEBUG
@@ -1054,7 +1050,7 @@ vtoc_update_format5_label_del (format5_label_t *f5, int verbose, int cyl,
ext->ft = (a - ext->t) % trk;
vtoc_update_format5_label_add(f5, verbose,
- cyl, trk, x, y, z);
+ trk, x, y, z);
if (verbose)
puts ("FMT5 del extent: 2 pieces");
@@ -1322,9 +1318,9 @@ vtoc_set_freespace(format4_label_t *f4, format5_label_t *f5,
z = (u_int8_t) ((stop - start + 1) % trk);
if (ch == '+')
- vtoc_update_format5_label_add(f5, verbose, cyl, trk, x, y, z);
+ vtoc_update_format5_label_add(f5, verbose, trk, x, y, z);
else if (ch == '-')
- vtoc_update_format5_label_del(f5, verbose, cyl, trk, x, y, z);
+ vtoc_update_format5_label_del(f5, verbose, trk, x, y, z);
else
puts ("BUG: syntax error in vtoc_set_freespace call");
--
2.9.3

View File

@ -0,0 +1,208 @@
From 1666d22aa8a044d57797d2f4c7f5448d5ef9606c Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Wed, 26 Oct 2016 04:22:47 +0200
Subject: [PATCH 59/75] libparted/dasd: update and improve fdasd functions
Update the fdasd_anchor_t data structure and the fdasd_cleanup()
function. Also correct vtoc_changed and vlabel_changed accounting
because they are important to rewrite vtoc to save the changes.
Wang Dong <dongdwdw@linux.vnet.ibm.com>
Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
include/parted/fdasd.in.h | 14 +++++-------
libparted/labels/fdasd.c | 56 ++++++++++++++++++++++++-----------------------
2 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/include/parted/fdasd.in.h b/include/parted/fdasd.in.h
index 4e351c4..09a35a0 100644
--- a/include/parted/fdasd.in.h
+++ b/include/parted/fdasd.in.h
@@ -186,6 +186,7 @@ typedef struct format_data_t {
/*****************************************************************************
* SECTION: Further IOCTL Definitions (see fs.h) *
*****************************************************************************/
+#define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
/* re-read partition table */
#define BLKRRPART _IO(0x12,95)
/* get block device sector size */
@@ -198,15 +199,14 @@ typedef struct format_data_t {
/*****************************************************************************
* SECTION: FDASD internal types *
*****************************************************************************/
+#define PARTN_MASK ((1 << DASD_PARTN_BITS) - 1)
+#define USABLE_PARTITIONS ((1 << DASD_PARTN_BITS) - 1)
#define DASD_MIN_API_VERSION 0
#define DEFAULT_FDASD_CONF "/etc/fdasd.conf" /* default config file */
-#define PARTN_MASK ((1 << DASD_PARTN_BITS) - 1)
-#define USABLE_PARTITIONS ((1 << DASD_PARTN_BITS) - 1)
-
-#define FDASD_VERSION "1.05"
+#define FDASD_VERSION "1.32.0"
#define DEVICE "device"
#define DISC "disc"
#define PART "part"
@@ -233,9 +233,6 @@ typedef struct config_data {
typedef struct fdasd_anchor {
int vlabel_changed;
int vtoc_changed;
- int devname_specified;
- int volid_specified;
- int config_specified;
int auto_partition;
int print_table;
int big_disk;
@@ -282,7 +279,8 @@ enum fdasd_failure {
vlabel_corrupted,
dsname_corrupted,
malloc_failed,
- device_verification_failed
+ device_verification_failed,
+ volser_not_found
};
void fdasd_cleanup (fdasd_anchor_t *anchor);
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index 968b332..e5df5cf 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -106,28 +106,26 @@ fdasd_cleanup (fdasd_anchor_t *anchor)
{
PDEBUG
int i;
- partition_info_t *p, *q;
+ partition_info_t *part_info, *next;
if (anchor == NULL)
return;
- free(anchor->f4);
- free(anchor->f5);
- free(anchor->f7);
- free(anchor->f9);
- free(anchor->vlabel);
-
- p = anchor->first;
- if (p == NULL)
- return;
-
- for (i=1; i <= USABLE_PARTITIONS; i++) {
- if (p == NULL)
- return;
- q = p->next;
- free(p->f1);
- free(p);
- p = q;
+ if (anchor->f4 != NULL)
+ free(anchor->f4);
+ if (anchor->f5 != NULL)
+ free(anchor->f5);
+ if (anchor->f7 != NULL)
+ free(anchor->f7);
+ if (anchor->vlabel != NULL)
+ free(anchor->vlabel);
+
+ part_info = anchor->first;
+ for (i = 1; i <= USABLE_PARTITIONS && part_info != NULL; i++) {
+ next = part_info->next;
+ free(part_info->f1);
+ free(part_info);
+ part_info = next;
}
}
@@ -190,6 +188,9 @@ fdasd_error (fdasd_anchor_t *anc, enum fdasd_failure why, char const *str)
_("Device verification failed"),
_("The specified device is not a valid DASD device"));
break;
+ case volser_not_found:
+ sprintf(error, "fdasd: %s -- %s\n", _("VOLSER not found on device"), str);
+ break;
default:
sprintf(error, "fdasd: %s: %s\n", _("Fatal error"), str);
}
@@ -287,7 +288,7 @@ fdasd_write_vtoc_labels (fdasd_anchor_t * anc, int fd)
PDEBUG
partition_info_t *p;
unsigned long b, maxblk;
- char dsno[6], s1[7], s2[45], *c1, *c2, *ch;
+ char dsno[6], s1[VOLSER_LENGTH + 1], s2[45], *c1, *c2, *ch;
int i = 0, k = 0;
cchhb_t f9addr;
format1_label_t emptyf1;
@@ -519,7 +520,6 @@ fdasd_recreate_vtoc (fdasd_anchor_t *anc)
int i;
vtoc_init_format4_label(anc->f4,
- USABLE_PARTITIONS,
anc->geo.cylinders,
anc->formatted_cylinders,
anc->geo.heads,
@@ -767,7 +767,7 @@ fdasd_invalid_vtoc_pointer(fdasd_anchor_t *anc)
anc->formatted_cylinders = anc->hw_cylinders;
anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
- FIRST_USABLE_TRK;
- vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS,
+ vtoc_init_format4_label(anc->f4,
anc->geo.cylinders, anc->formatted_cylinders,
anc->geo.heads, anc->geo.sectors,
anc->blksize, anc->dev_type);
@@ -781,6 +781,8 @@ fdasd_invalid_vtoc_pointer(fdasd_anchor_t *anc)
anc->formatted_cylinders, anc->geo.heads);
vtoc_set_cchhb(&anc->vlabel->vtoc, VTOC_START_CC, VTOC_START_HH, 0x01);
+ anc->vtoc_changed++;
+ anc->vlabel_changed++;
}
/*
@@ -792,7 +794,7 @@ fdasd_process_invalid_vtoc(fdasd_anchor_t *anc)
anc->formatted_cylinders = anc->hw_cylinders;
anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
- FIRST_USABLE_TRK;
- vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS,
+ vtoc_init_format4_label(anc->f4,
anc->geo.cylinders, anc->formatted_cylinders,
anc->geo.heads, anc->geo.sectors,
anc->blksize, anc->dev_type);
@@ -803,6 +805,8 @@ fdasd_process_invalid_vtoc(fdasd_anchor_t *anc)
FIRST_USABLE_TRK,
anc->formatted_cylinders * anc->geo.heads - 1,
anc->formatted_cylinders, anc->geo.heads);
+
+ anc->vtoc_changed++;
}
@@ -875,7 +879,7 @@ fdasd_check_volume (fdasd_anchor_t *anc, int fd)
fdasd_init_volume_label(anc, fd);
- vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS,
+ vtoc_init_format4_label(anc->f4,
anc->geo.cylinders, anc->formatted_cylinders,
anc->geo.heads, anc->geo.sectors,
anc->blksize, anc->dev_type);
@@ -1286,12 +1290,10 @@ fdasd_add_partition (fdasd_anchor_t *anc, unsigned int start,
return 0;
if (anc->formatted_cylinders > LV_COMPAT_CYL) {
- vtoc_init_format8_label(anc->vlabel->volid, anc->blksize, &ext,
- p->f1);
+ vtoc_init_format8_label(anc->blksize, &ext, p->f1);
} else {
PDEBUG;
- vtoc_init_format1_label(anc->vlabel->volid, anc->blksize, &ext,
- p->f1);
+ vtoc_init_format1_label(anc->blksize, &ext, p->f1);
}
PDEBUG;
--
2.9.3

View File

@ -0,0 +1,171 @@
From 3267b55ff764840cf267fd1e02fa467e4d87d388 Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Wed, 26 Oct 2016 04:22:48 +0200
Subject: [PATCH 60/75] libparted/dasd: add new fdasd functions
Introduce a set of new functions from the fdasd utility of the s390-tools
to keep the code base in parted and s390-tools in sync.
These new functions are:
fdasd_check_volser(): validate the volser input
fdasd_get_volser(): get volume serial (volser)
fdasd_change_volser(): change volser with string
fdasd_reuse_vtoc(): re-create vtoc labels based on the existing vtoc
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
include/parted/fdasd.in.h | 4 ++
libparted/labels/fdasd.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 127 insertions(+)
diff --git a/include/parted/fdasd.in.h b/include/parted/fdasd.in.h
index 09a35a0..9e5d7d1 100644
--- a/include/parted/fdasd.in.h
+++ b/include/parted/fdasd.in.h
@@ -293,5 +293,9 @@ void fdasd_recreate_vtoc(fdasd_anchor_t *anc);
partition_info_t * fdasd_add_partition (fdasd_anchor_t *anc,
unsigned int start, unsigned int stop);
int fdasd_prepare_labels (fdasd_anchor_t *anc, int fd) ;
+void fdasd_check_volser(char *volser, int devno);
+int fdasd_get_volser(fdasd_anchor_t *anc, char *volser, int fd);
+void fdasd_change_volser(fdasd_anchor_t *anc, char *str);
+void fdasd_reuse_vtoc(fdasd_anchor_t *anc);
#endif /* FDASD_H */
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index e5df5cf..713ed6b 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -1320,4 +1320,127 @@ fdasd_add_partition (fdasd_anchor_t *anc, unsigned int start,
return p;
}
+/*
+ * Check for valid volume serial characters (max. 6) - remove invalid.
+ * If volser is empty, fill with default volser.
+ */
+void fdasd_check_volser (char *volser, int devno)
+{
+ int from, to;
+
+ for (from = 0, to = 0; volser[from] && from < VOLSER_LENGTH; from++) {
+
+ if ((volser[from] >= 0x23 &&
+ volser[from] <= 0x25) ||
+ (volser[from] >= 0x30 &&
+ volser[from] <= 0x39) ||
+ (volser[from] >= 0x40 &&
+ volser[from] <= 0x5a) ||
+ (volser[from] >= 0x61 &&
+ volser[from] <= 0x7a))
+ volser[to++] = toupper(volser[from]);
+ }
+
+ volser[to] = 0x00;
+
+ if (volser[0] == 0x00)
+ sprintf(volser, "0X%04x", devno);
+}
+
+/*
+ * get volser from vtoc
+ */
+int fdasd_get_volser (fdasd_anchor_t *anc, char *volser, int fd)
+{
+ volume_label_t vlabel;
+
+ vtoc_read_volume_label(fd, anc->label_pos, &vlabel);
+ vtoc_volume_label_get_volser(&vlabel, volser);
+ return 0;
+}
+
+/* Changes the volume serial (menu option)
+ *
+ */
+void fdasd_change_volser (fdasd_anchor_t *anc, char *str)
+{
+ fdasd_check_volser(str, anc->devno);
+ vtoc_volume_label_set_volser(anc->vlabel, str);
+
+ vtoc_set_cchhb(&anc->vlabel->vtoc, VTOC_START_CC, VTOC_START_HH, 0x01);
+ anc->vlabel_changed++;
+ anc->vtoc_changed++;
+}
+
+/*
+ * re-create all VTOC labels, but use the partition information
+ * from existing VTOC
+ */
+void fdasd_reuse_vtoc (fdasd_anchor_t *anc)
+{
+ partition_info_t *part_info = anc->first;
+ struct fdasd_hd_geometry geo = anc->geo;
+ format1_label_t f1;
+ format4_label_t f4;
+ format5_label_t f5;
+ format7_label_t f7;
+
+ vtoc_init_format4_label(&f4, geo.cylinders, anc->formatted_cylinders,
+ geo.heads, geo.sectors,
+ anc->blksize, anc->dev_type);
+
+ /* reuse some FMT4 values */
+ f4.DS4HPCHR = anc->f4->DS4HPCHR;
+ f4.DS4DSREC = anc->f4->DS4DSREC;
+
+ /* re-initialize both free-space labels */
+ vtoc_init_format5_label(&f5);
+ vtoc_init_format7_label(&f7);
+
+ if (anc->fspace_trk > 0)
+ vtoc_set_freespace(&f4, &f5, &f7, '+', anc->verbose,
+ FIRST_USABLE_TRK,
+ FIRST_USABLE_TRK + anc->fspace_trk - 1,
+ anc->formatted_cylinders, geo.heads);
+
+ while (part_info != NULL) {
+ if (part_info->used != 0x01) {
+ part_info = part_info->next;
+ continue;
+ }
+
+ if (anc->formatted_cylinders > LV_COMPAT_CYL)
+ vtoc_init_format8_label(anc->blksize,
+ &part_info->f1->DS1EXT1, &f1);
+ else
+ vtoc_init_format1_label(anc->blksize,
+ &part_info->f1->DS1EXT1, &f1);
+
+
+ strncpy(f1.DS1DSNAM, part_info->f1->DS1DSNAM, 44);
+ strncpy((char *)f1.DS1DSSN, (char *)part_info->f1->DS1DSSN, 6);
+ f1.DS1CREDT = part_info->f1->DS1CREDT;
+
+ memcpy(part_info->f1, &f1, sizeof(format1_label_t));
+
+ if (part_info->fspace_trk > 0)
+ vtoc_set_freespace(&f4, &f5, &f7, '+', anc->verbose,
+ part_info->end_trk + 1,
+ part_info->end_trk +
+ part_info->fspace_trk,
+ anc->formatted_cylinders, geo.heads);
+
+ part_info = part_info->next;
+ }
+
+ /* over-write old labels with new ones */
+ memcpy(anc->f4, &f4, sizeof(format4_label_t));
+ memcpy(anc->f5, &f5, sizeof(format5_label_t));
+ memcpy(anc->f7, &f7, sizeof(format7_label_t));
+
+ anc->vtoc_changed++;
+
+ return;
+}
+
/* vim:set tabstop=4 shiftwidth=4 softtabstop=4: */
--
2.9.3

View File

@ -0,0 +1,43 @@
From 6872c0d2fd2038b366cc8086588a272465d6a553 Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Wed, 26 Oct 2016 04:22:49 +0200
Subject: [PATCH 61/75] libparted/dasd: add test cases for the new fdasd
functions
The test case uses a temporary file in libparted/tests under
Check framwork. It can be issued by "make check" in the test dir.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/tests/Makefile.am | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libparted/tests/Makefile.am b/libparted/tests/Makefile.am
index c7c10a9..9689fb3 100644
--- a/libparted/tests/Makefile.am
+++ b/libparted/tests/Makefile.am
@@ -3,9 +3,9 @@
#
# This file may be modified and/or distributed without restriction.
-TESTS = t1000-label.sh t2000-disk.sh t2100-zerolen.sh t3000-symlink.sh
+TESTS = t1000-label.sh t2000-disk.sh t2100-zerolen.sh t3000-symlink.sh t4000-volser.sh
EXTRA_DIST = $(TESTS)
-check_PROGRAMS = label disk zerolen symlink
+check_PROGRAMS = label disk zerolen symlink volser
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
LDADD = \
@@ -23,6 +23,7 @@ label_SOURCES = common.h common.c label.c
disk_SOURCES = common.h common.c disk.c
zerolen_SOURCES = common.h common.c zerolen.c
symlink_SOURCES = common.h common.c symlink.c
+volser_SOURCES = common.h common.c volser.c
# Arrange to symlink to tests/init.sh.
CLEANFILES = init.sh
--
2.9.3

View File

@ -0,0 +1,202 @@
From f209b71efc693b97b7c812678e811698ffd2bc79 Mon Sep 17 00:00:00 2001
From: Arvin Schnell <aschnell@suse.com>
Date: Thu, 22 Dec 2016 14:36:43 -0800
Subject: [PATCH 62/75] libparted: set swap flag on GPT partitions
The filesystem type is still detected as befor, but now setting the
'swap' flag will set the partition GUID to PARTITION_SWAP_GUID.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/labels/gpt.c | 42 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 39 insertions(+), 3 deletions(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 6027eb3..4f922b2 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -290,6 +290,7 @@ typedef struct _GPTPartitionData
efi_char16_t name[37];
char *translated_name;
int lvm;
+ int swap;
int raid;
int boot;
int bios_grub;
@@ -818,7 +819,8 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
gpt_part_data->name[i] = 0;
gpt_part_data->translated_name = 0;
- gpt_part_data->lvm = gpt_part_data->raid
+ gpt_part_data->lvm = gpt_part_data->swap
+ = gpt_part_data->raid
= gpt_part_data->boot = gpt_part_data->hp_service
= gpt_part_data->hidden = gpt_part_data->msftres
= gpt_part_data->msftdata
@@ -841,6 +843,8 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
gpt_part_data->raid = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_LVM_GUID))
gpt_part_data->lvm = 1;
+ else if (!guid_cmp (gpt_part_data->type, PARTITION_SWAP_GUID))
+ gpt_part_data->swap = 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))
@@ -1361,6 +1365,7 @@ gpt_partition_new (const PedDisk *disk,
gpt_part_data->type = PARTITION_LINUX_DATA_GUID;
gpt_part_data->lvm = 0;
+ gpt_part_data->swap = 0;
gpt_part_data->raid = 0;
gpt_part_data->boot = 0;
gpt_part_data->bios_grub = 0;
@@ -1449,6 +1454,11 @@ gpt_partition_set_system (PedPartition *part,
gpt_part_data->type = PARTITION_LVM_GUID;
return 1;
}
+ if (gpt_part_data->swap)
+ {
+ gpt_part_data->type = PARTITION_SWAP_GUID;
+ return 1;
+ }
if (gpt_part_data->raid)
{
gpt_part_data->type = PARTITION_RAID_GUID;
@@ -1636,6 +1646,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
if (state)
gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1650,6 +1661,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
if (state)
gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->boot
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1664,6 +1676,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
if (state)
gpt_part_data->boot
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1677,6 +1690,22 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
gpt_part_data->lvm = state;
if (state)
gpt_part_data->boot
+ = gpt_part_data->swap
+ = gpt_part_data->raid
+ = gpt_part_data->bios_grub
+ = gpt_part_data->hp_service
+ = gpt_part_data->msftres
+ = gpt_part_data->msftdata
+ = gpt_part_data->msftrecv
+ = gpt_part_data->prep
+ = gpt_part_data->irst
+ = gpt_part_data->atvrecv = 0;
+ return gpt_partition_set_system (part, part->fs_type);
+ case PED_PARTITION_SWAP:
+ gpt_part_data->swap = state;
+ if (state)
+ gpt_part_data->boot
+ = gpt_part_data->lvm
= gpt_part_data->raid
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
@@ -1693,6 +1722,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->msftres
= gpt_part_data->msftdata
@@ -1707,6 +1737,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftdata
@@ -1721,6 +1752,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1739,6 +1771,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftdata
@@ -1753,6 +1786,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1766,6 +1800,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1779,6 +1814,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1793,7 +1829,6 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
case PED_PARTITION_LEGACY_BOOT:
gpt_part_data->legacy_boot = state;
return 1;
- case PED_PARTITION_SWAP:
case PED_PARTITION_ROOT:
case PED_PARTITION_LBA:
default:
@@ -1839,6 +1874,7 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag)
case PED_PARTITION_IRST:
return gpt_part_data->irst;
case PED_PARTITION_SWAP:
+ return gpt_part_data->swap;
case PED_PARTITION_LBA:
case PED_PARTITION_ROOT:
default:
@@ -1855,6 +1891,7 @@ gpt_partition_is_flag_available (const PedPartition *part,
{
case PED_PARTITION_RAID:
case PED_PARTITION_LVM:
+ case PED_PARTITION_SWAP:
case PED_PARTITION_BOOT:
case PED_PARTITION_BIOS_GRUB:
case PED_PARTITION_HPSERVICE:
@@ -1868,7 +1905,6 @@ gpt_partition_is_flag_available (const PedPartition *part,
case PED_PARTITION_IRST:
case PED_PARTITION_ESP:
return 1;
- case PED_PARTITION_SWAP:
case PED_PARTITION_ROOT:
case PED_PARTITION_LBA:
default:
--
2.9.3

View File

@ -0,0 +1,43 @@
From 3228fcc714347701f48034288b5fa98c6bb0a50d Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 22 Dec 2016 16:59:27 -0800
Subject: [PATCH 63/75] tests: Update t0220 and t0280 for the swap flag.
---
tests/t0220-gpt-msftres.sh | 6 +++++-
tests/t0280-gpt-corrupt.sh | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/tests/t0220-gpt-msftres.sh b/tests/t0220-gpt-msftres.sh
index 79518ae..6721a47 100755
--- a/tests/t0220-gpt-msftres.sh
+++ b/tests/t0220-gpt-msftres.sh
@@ -56,7 +56,11 @@ printf "BYT;\n$dev:${n_sectors}s:file:$ss:$ss:gpt::;\n" > exp
i=1
for type in $fs_types; do
end=$(expr $start + $part_size - 1)
- case $type in fat*|NTFS) flag=msftdata;; *) flag=;; esac
+ case $type in
+ fat*|NTFS) flag=msftdata;;
+ linux-swap) flag=swap;;
+ *) flag=;;
+ esac
echo "$i:${start}s:${end}s:${part_size}s::$type:$flag;" >> exp || fail=1
parted -s $dev mkpart p-name $type ${start}s ${end}s > err 2>&1 || fail=1
compare /dev/null err || fail=1
diff --git a/tests/t0280-gpt-corrupt.sh b/tests/t0280-gpt-corrupt.sh
index a7c8d82..1b4d86b 100755
--- a/tests/t0280-gpt-corrupt.sh
+++ b/tests/t0280-gpt-corrupt.sh
@@ -89,7 +89,7 @@ compare exp err || fail=1
parted -m -s $dev u s print > out 2>&1 || fail=1
# check for expected output
-printf "BYT;\nfile\n1:2048s:4095s:2048s::foo:;\n" > exp || fail=1
+printf "BYT;\nfile\n1:2048s:4095s:2048s::foo:swap;\n" > exp || fail=1
sed "s/.*gpt::;/file/" out > k && mv k out || fail=1
compare exp out || fail=1
--
2.9.3

View File

@ -0,0 +1,94 @@
From 105746f40724d94499a04a0d7036380aaa41c1f5 Mon Sep 17 00:00:00 2001
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Date: Sun, 4 Dec 2016 17:12:45 +0100
Subject: [PATCH 64/75] libparted:tests: Move get_sector_size() to common.c
Moving get_sector_size() from disk.c to common.c allows
us to use it in _implemented_disk_label() to test for
512-byte sectors. This change is required to be able to
enable this test for atari partition tables for which
support is added in a follow-up patch.
Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/tests/common.c | 14 ++++++++++++++
libparted/tests/common.h | 5 +++++
libparted/tests/disk.c | 15 ---------------
3 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/libparted/tests/common.c b/libparted/tests/common.c
index a0be997..9115686 100644
--- a/libparted/tests/common.c
+++ b/libparted/tests/common.c
@@ -7,9 +7,23 @@
#include <check.h>
#include "common.h"
+#include "xstrtol.h"
#define STREQ(a, b) (strcmp (a, b) == 0)
+size_t get_sector_size (void)
+{
+ char *p = getenv ("PARTED_SECTOR_SIZE");
+ size_t ss = 512;
+ unsigned long val;
+ if (p
+ && xstrtoul (p, NULL, 10, &val, NULL) == LONGINT_OK
+ && val % 512 == 0)
+ ss = val;
+
+ return ss;
+}
+
PedExceptionOption
_test_exception_handler (PedException* e)
{
diff --git a/libparted/tests/common.h b/libparted/tests/common.h
index 1b1c801..5d7485e 100644
--- a/libparted/tests/common.h
+++ b/libparted/tests/common.h
@@ -1,5 +1,10 @@
#include <parted/parted.h>
+/* Determine sector size from environment
+ *
+ */
+size_t get_sector_size (void);
+
/* Create an empty disk image
*
* filename: file (with full path) where to write the disk image
diff --git a/libparted/tests/disk.c b/libparted/tests/disk.c
index 48561b9..62d20c1 100644
--- a/libparted/tests/disk.c
+++ b/libparted/tests/disk.c
@@ -7,24 +7,9 @@
#include "common.h"
#include "progname.h"
-#include "xstrtol.h"
static char* temporary_disk;
-static
-size_t get_sector_size (void)
-{
- char *p = getenv ("PARTED_SECTOR_SIZE");
- size_t ss = 512;
- unsigned long val;
- if (p
- && xstrtoul (p, NULL, 10, &val, NULL) == LONGINT_OK
- && val % 512 == 0)
- ss = val;
-
- return ss;
-}
-
static void
create_disk (void)
{
--
2.9.3

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,42 @@
From 783e08a4e5f6769f7ebd2f3e43ca4ccfab003e8b Mon Sep 17 00:00:00 2001
From: Sergei Antonov <saproj@gmail.com>
Date: Fri, 3 Jul 2015 00:21:23 +0200
Subject: [PATCH 66/75] mac: copy partition type and name correctly
Use strncpy() instead of strcpy() to copy partition name and type.
This prevents possible buffer overflow, because the source string
occupies up to 33 bytes with a terminating null.
Static analysis tools complain about the code as it is now:
Function: _generate_raw_part
Destination buffer too small
string_overflow: You might overrun the 32 byte destination string
part_map_entry->type by writing 33 bytes from mac_part_data->system_name
(Destination buffer too small, line 933)
Cc: Sabas Rosales, Blanca E <blanca.e.sabas.rosales@intel.com>
Signed-off-by: Sergei Antonov <saproj@gmail.com>
Signed-off-by: Brian C. Lane <bcl@brianlane.com>
(cherry picked from commit 282e25e0384e8d1275ccacf904fdaf65f1d4a8af)
---
libparted/labels/mac.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c
index 1034418..d8da941 100644
--- a/libparted/labels/mac.c
+++ b/libparted/labels/mac.c
@@ -930,8 +930,8 @@ _generate_raw_part (PedDisk* disk, PedPartition* part,
= PED_CPU_TO_BE32 (mac_disk_data->last_part_entry_num);
part_map_entry->start_block = PED_CPU_TO_BE32 (part->geom.start);
part_map_entry->block_count = PED_CPU_TO_BE32 (part->geom.length);
- strcpy (part_map_entry->name, mac_part_data->volume_name);
- strcpy (part_map_entry->type, mac_part_data->system_name);
+ strncpy (part_map_entry->name, mac_part_data->volume_name, 32);
+ strncpy (part_map_entry->type, mac_part_data->system_name, 32);
if (mac_part_data->is_driver) {
mac_part_data->boot_region_length = part->geom.length;
--
2.9.3

View File

@ -0,0 +1,122 @@
From 526f3ee2afbe7cd90d282915b7b580d4f356c4eb Mon Sep 17 00:00:00 2001
From: Laurent Vivier <laurent@vivier.eu>
Date: Fri, 9 Dec 2016 15:10:53 +0100
Subject: [PATCH 67/75] libparted: Fix MacOS boot support
boot_region_length (or BootSize in the MacOS dialect) is the length
of the driver code in the driver partition. This length is used
to compute the checksum of the driver.
libparted updates this value by setting the whole size of the partition
without computing the checksum of the driver using this size.
As the checksum is wrong, the driver is broken and cannot be loaded
by the MacOS ROM, and thus the disk is not bootable anymore.
Moreover, parted try to update the driver list and makes it disappear.
As parted is not able to insert a driver in a partition,
the driver is generally inserted by the Apple HD Tool,
this patch removes the line updating the driver size.
We also simplify the driver list scan and fix endianess use.
This has been tested... and it works, now.
I have updated a bootable disk with parted on x86_64 and
then been able to boot it (again) on a Mac LC III.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/labels/mac.c | 41 ++++++++++++++++++++---------------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c
index d8da941..fa4e43f 100644
--- a/libparted/labels/mac.c
+++ b/libparted/labels/mac.c
@@ -411,14 +411,14 @@ _rawpart_has_driver (const MacRawPartition* raw_part, MacDiskData* mac_disk_data
{
MacDeviceDriver *driverlist;
uint16_t i;
- uint32_t driver_bs, driver_be, part_be;
+ uint32_t start_block, block_count;
+ start_block = PED_BE32_TO_CPU(raw_part->start_block);
+ block_count = PED_BE32_TO_CPU(raw_part->block_count);
driverlist = &mac_disk_data->driverlist[0];
for (i = 0; i < mac_disk_data->driver_count; i++) {
- driver_bs = driverlist->block;
- driver_be = driver_bs + driverlist->size;
- part_be = raw_part->start_block + raw_part->block_count;
- if (driver_bs >= raw_part->start_block && driver_be <= part_be)
+ if (start_block == PED_BE32_TO_CPU(driverlist->block) &&
+ block_count == PED_BE16_TO_CPU(driverlist->size))
return 1;
driverlist++;
}
@@ -751,11 +751,12 @@ mac_read (PedDisk* disk)
if (!ped_disk_delete_all (disk))
goto error;
- if (raw_disk->driver_count && raw_disk->driver_count < 62) {
+ if (PED_BE16_TO_CPU(raw_disk->driver_count) &&
+ PED_BE16_TO_CPU(raw_disk->driver_count) < 62) {
memcpy(&mac_disk_data->driverlist[0], &raw_disk->driverlist[0],
sizeof(mac_disk_data->driverlist));
- mac_disk_data->driver_count = raw_disk->driver_count;
- mac_disk_data->block_size = raw_disk->block_size;
+ mac_disk_data->driver_count = PED_BE16_TO_CPU(raw_disk->driver_count);
+ mac_disk_data->block_size = PED_BE16_TO_CPU(raw_disk->block_size);
}
/* If _disk_analyse_block_size has increased the sector_size,
@@ -877,17 +878,16 @@ static void
_update_driver_count (MacRawPartition* part_map_entry,
MacDiskData *mac_driverdata, const MacDiskData* mac_disk_data)
{
- uint16_t i, count_orig, count_cur;
- uint32_t driver_bs, driver_be, part_be;
-
- count_cur = mac_driverdata->driver_count;
- count_orig = mac_disk_data->driver_count;
- for (i = 0; i < count_orig; i++) {
- driver_bs = mac_disk_data->driverlist[i].block;
- driver_be = driver_bs + mac_disk_data->driverlist[i].size;
- part_be = part_map_entry->start_block + part_map_entry->block_count;
- if (driver_bs >= part_map_entry->start_block
- && driver_be <= part_be) {
+ uint16_t i;
+ uint32_t start_block, block_count;
+
+ start_block = PED_BE32_TO_CPU(part_map_entry->start_block);
+ block_count = PED_BE32_TO_CPU(part_map_entry->block_count);
+
+ for (i = 0; i < mac_disk_data->driver_count; i++) {
+ if (start_block == PED_BE32_TO_CPU(mac_disk_data->driverlist[i].block) &&
+ block_count == PED_BE16_TO_CPU(mac_disk_data->driverlist[i].size)) {
+ uint16_t count_cur = mac_driverdata->driver_count;
mac_driverdata->driverlist[count_cur].block
= mac_disk_data->driverlist[i].block;
mac_driverdata->driverlist[count_cur].size
@@ -934,7 +934,6 @@ _generate_raw_part (PedDisk* disk, PedPartition* part,
strncpy (part_map_entry->type, mac_part_data->system_name, 32);
if (mac_part_data->is_driver) {
- mac_part_data->boot_region_length = part->geom.length;
if (mac_part_data->has_driver)
_update_driver_count(part_map_entry, mac_driverdata,
mac_disk_data);
@@ -1042,7 +1041,7 @@ write_block_zero (PedDisk* disk, MacDiskData* mac_driverdata)
raw_disk->block_size = PED_CPU_TO_BE16 (dev->sector_size);
raw_disk->block_count = PED_CPU_TO_BE32 (dev->length);
- raw_disk->driver_count = mac_driverdata->driver_count;
+ raw_disk->driver_count = PED_CPU_TO_BE16(mac_driverdata->driver_count);
memcpy(&raw_disk->driverlist[0], &mac_driverdata->driverlist[0],
sizeof(raw_disk->driverlist));
--
2.9.3

View File

@ -0,0 +1,27 @@
From c625f6769144472f3c099cdd512318cea18e2766 Mon Sep 17 00:00:00 2001
From: Sebastian Rasmussen <sebras@gmail.com>
Date: Thu, 19 Jan 2017 23:38:40 +0100
Subject: [PATCH 68/75] libparted: Fix typo in hfs error message
---
libparted/fs/r/hfs/cache.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libparted/fs/r/hfs/cache.c b/libparted/fs/r/hfs/cache.c
index 68be366..03c2913 100644
--- a/libparted/fs/r/hfs/cache.c
+++ b/libparted/fs/r/hfs/cache.c
@@ -210,8 +210,8 @@ hfsc_cache_move_extent(HfsCPrivateCache* cache, uint32_t old_start,
ped_exception_throw (
PED_EXCEPTION_BUG,
PED_EXCEPTION_CANCEL,
- _("Trying to move an extent from block Ox%X to block "
- "Ox%X, but another one already exists at this "
+ _("Trying to move an extent from block 0x%X to block "
+ "0x%X, but another one already exists at this "
"position. This should not happen!"),
old_start, new_start);
return NULL;
--
2.9.3

View File

@ -0,0 +1,28 @@
From 1f1382ab8672b9bb679ecc7e79583fd826908f6f Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 1 May 2017 17:04:11 -0700
Subject: [PATCH 69/75] Fix crash when localized
The _() macro is only for translating string literals. It was
incorrectly applied to a runtime string representing the name
of a partition and this sometimes caused a gettext crash.
---
parted/parted.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/parted/parted.c b/parted/parted.c
index bd848c3..f767bec 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1276,7 +1276,7 @@ do_print (PedDevice** dev, PedDisk** diskp)
putchar (':');
if (has_name)
- printf ("%s:", _(ped_partition_get_name (part)));
+ printf ("%s:", ped_partition_get_name (part));
else
putchar (':');
--
2.9.3

View File

@ -0,0 +1,102 @@
From eb927155680f75e570dc7375514e344a936a3fb5 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 1 May 2017 17:05:01 -0700
Subject: [PATCH 70/75] Add support for RAM drives
Recognize RAM drives, so "parted -s /dev/ram0 p" now prints
"RAM Drive (brd)" instead of "Model: Unknown (unknown)".
In order for a device to be recognized as RAM drive, it has to
have major number 1. Also the BLKFLSBUF ioctl shouldn't be used
on RAM drives as it is used to zero the device.
* NEWS: Mention the change
* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_RAM.
* libparted/arch/linux.c(RAM_MAJOR): New define.
* libparted/arch/linux.c(_device_probe_type): Recognize RAM drives.
* libparted/arch/linux.c(linux_new): Handle RAM drives.
* libparted/arch/linux.c(_flush_cache): Skip RAM drives.
* parted/parted.c(do_print): Add "brd" to list of transports.
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
include/parted/device.in.h | 3 ++-
libparted/arch/linux.c | 12 ++++++++++--
parted/parted.c | 2 +-
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/include/parted/device.in.h b/include/parted/device.in.h
index d38db44..1b6e7b8 100644
--- a/include/parted/device.in.h
+++ b/include/parted/device.in.h
@@ -50,7 +50,8 @@ typedef enum {
PED_DEVICE_AOE = 16,
PED_DEVICE_MD = 17,
PED_DEVICE_LOOP = 18,
- PED_DEVICE_NVME = 19
+ PED_DEVICE_NVME = 19,
+ PED_DEVICE_RAM = 20
} PedDeviceType;
typedef struct _PedDevice PedDevice;
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 2058697..c2fdab0 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -279,6 +279,7 @@ struct blkdev_ioctl_param {
#define LOOP_MAJOR 7
#define MD_MAJOR 9
#define BLKEXT_MAJOR 259
+#define RAM_MAJOR 1
#define SCSI_BLK_MAJOR(M) ( \
(M) == SCSI_DISK0_MAJOR \
@@ -701,6 +702,8 @@ _device_probe_type (PedDevice* dev)
dev->type = PED_DEVICE_MD;
} else if (_is_blkext_major(dev_major) && dev->path && strstr(dev->path, "nvme")) {
dev->type = PED_DEVICE_NVME;
+ } else if (dev_major == RAM_MAJOR) {
+ dev->type = PED_DEVICE_RAM;
} else {
dev->type = PED_DEVICE_UNKNOWN;
}
@@ -1547,6 +1550,11 @@ linux_new (const char* path)
goto error_free_arch_specific;
break;
+ case PED_DEVICE_RAM:
+ if (!init_generic (dev, _("RAM Drive")))
+ goto error_free_arch_specific;
+ break;
+
default:
ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
PED_EXCEPTION_CANCEL,
@@ -1619,9 +1627,9 @@ _flush_cache (PedDevice* dev)
{
LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
int i;
- int lpn = _device_get_partition_range(dev);
+ int lpn = _device_get_partition_range(dev);
- if (dev->read_only)
+ if (dev->read_only || dev->type == PED_DEVICE_RAM)
return;
dev->dirty = 0;
diff --git a/parted/parted.c b/parted/parted.c
index f767bec..a7fcd3b 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -979,7 +979,7 @@ _print_disk_info (const PedDevice *dev, const PedDisk *diskp)
"cpqarray", "file", "ataraid", "i2o",
"ubd", "dasd", "viodasd", "sx8", "dm",
"xvd", "sd/mmc", "virtblk", "aoe",
- "md", "loopback", "nvme"};
+ "md", "loopback", "nvme", "brd"};
char* start = ped_unit_format (dev, 0);
PedUnit default_unit = ped_unit_get_default ();
--
2.9.3

View File

@ -0,0 +1,43 @@
From 1a891f6d352d47a6a9422083bbb38a2c4c4e901b Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Fri, 24 Mar 2017 03:11:08 +0100
Subject: [PATCH 71/75] parted: check the name of partition first when to name
a partition
The previous function works well for the labels supporting naming
partition, but not for these which don't. If the disk label does not
support partition naming, two exceptions will be raised. Even after the first
error indicates it does not support name, parted yet asks user for
name in iteractive mode.
First check if the disk label supports partition naming and if it
does, it will continue; otherwise, it will stop and raise an
exception.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
---
parted/parted.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/parted/parted.c b/parted/parted.c
index a7fcd3b..d2e1f24 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -870,6 +870,13 @@ do_name (PedDevice** dev, PedDisk** diskp)
if (!*diskp)
goto error;
+ if (!ped_disk_type_check_feature((*diskp)->type, PED_DISK_TYPE_PARTITION_NAME)) {
+ ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
+ _("%s disk labels do not support partition name."),
+ (*diskp)->type->name);
+ goto error;
+ }
+
if (!command_line_get_partition (_("Partition number?"), *diskp, &part))
goto error;
--
2.9.3

View File

@ -0,0 +1,42 @@
From eb5eb44f6ef009c68cc8867e3277fa832cad7f10 Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Fri, 24 Mar 2017 03:11:10 +0100
Subject: [PATCH 72/75] parted/ui: remove unneccesary information of command
line
When some command fails, the information still exists in
command_line buffer. When in command mode or interactive mode,
if an interactive exception prompts, the remained information
will be processed as option from user. This will raise some other
information or even unexpected results. So before getting option
input from user, clean the command line buffer.
Example: When the disk label is invalid and user tries to make
new partition on the device with command like,
mkpart 0 50%. Then parted will raise an exception
telling an invalid disk label found and whether to correct it.
But at this time 0 as the input of mkpart will be
considered as the option input for the exception(yes/no).
So one more exception will raised with error information.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
---
parted/ui.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/parted/ui.c b/parted/ui.c
index 505b8ac..c603ed2 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -1270,6 +1270,7 @@ command_line_get_ex_opt (const char* prompt, PedExceptionOption options)
PedExceptionOption opt;
char* opt_name;
+ command_line_flush ();
for (opt = option_get_next (options, 0); opt;
opt = option_get_next (options, opt)) {
options_strlist = str_list_append_unique (options_strlist,
--
2.9.3

View File

@ -0,0 +1,47 @@
From fb8167365502c7476d571fb279889ad2c6c2785e Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Fri, 24 Mar 2017 03:11:12 +0100
Subject: [PATCH 73/75] libpartd/dasd: improve flag processing for DASD-LDL
DASD-LDL does not support flag now, so all the flags are
unavailable to it.
Signed-off-by: Andre Wild <wild@linux.vnet.ibm.com>
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
---
libparted/labels/dasd.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index 7594e96..e246ecb 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -773,10 +773,24 @@ dasd_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
}
}
+/*
+ * The DASD-LDL does not support flags now.
+ * So just return 0.
+*/
static int
dasd_partition_is_flag_available (const PedPartition* part,
PedPartitionFlag flag)
{
+ DasdDiskSpecific* disk_specific;
+ PED_ASSERT (part != NULL);
+ PED_ASSERT (part->disk != NULL);
+ PED_ASSERT (part->disk->disk_specific != NULL);
+
+ disk_specific = part->disk->disk_specific;
+
+ if (disk_specific->format_type == 1)
+ return 0;
+
switch (flag) {
case PED_PARTITION_RAID:
return 1;
--
2.9.3

View File

@ -0,0 +1,38 @@
From c6ada23e466d824efcaff699a3de2923895c2244 Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Fri, 24 Mar 2017 11:20:09 +0100
Subject: [PATCH 74/75] libparted/dasd: add an exception for changing DASD-LDL
partition table
The partition table of DASD-LDL device with the dasd disk label
should not be changed according to its character in Linux.
When the user tries to modify the partition table, an exception
will be raised to inform user of this character.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
---
libparted/labels/dasd.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index e246ecb..632ec8e 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -619,8 +619,12 @@ dasd_write (const PedDisk* disk)
PDEBUG;
/* If not formated in CDL, don't write anything. */
- if (disk_specific->format_type == 1)
+ if (disk_specific->format_type == 1) {
+ ped_exception_throw (PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_CANCEL,
+ _("The partition table of DASD-LDL device cannot be changed.\n"));
return 1;
+ }
/* initialize the anchor */
fdasd_initialize_anchor(&anchor);
--
2.9.3

View File

@ -0,0 +1,241 @@
From e76ec6107f63fbf17cc6daf00a9cdb21994e54c1 Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Thu, 20 Apr 2017 10:20:07 +0200
Subject: [PATCH 75/75] libparted/dasd: add test cases for the new fdasd
functions
The test case uses a temporary file in libparted/tests under
Check framwork.It can be issued by "make check" in the test dir.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
---
libparted/tests/t4000-volser.sh | 20 +++++
libparted/tests/volser.c | 188 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 208 insertions(+)
create mode 100755 libparted/tests/t4000-volser.sh
create mode 100644 libparted/tests/volser.c
diff --git a/libparted/tests/t4000-volser.sh b/libparted/tests/t4000-volser.sh
new file mode 100755
index 0000000..89688ba
--- /dev/null
+++ b/libparted/tests/t4000-volser.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# 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/>.
+
+. "${top_srcdir=../..}/tests/init.sh"; path_prepend_ .
+
+volser || fail=1
+
+Exit $fail
diff --git a/libparted/tests/volser.c b/libparted/tests/volser.c
new file mode 100644
index 0000000..9063821
--- /dev/null
+++ b/libparted/tests/volser.c
@@ -0,0 +1,188 @@
+/*
+ * Author: Wang Dong <dongdwdw@cn.ibm.com>
+ */
+
+#include <config.h>
+#include <unistd.h>
+#include <check.h>
+
+#include <parted/vtoc.h>
+#include <parted/device.h>
+#include <parted/fdasd.h>
+#include <parted/vtoc.h>
+#include "../arch/linux.h"
+#include "common.h"
+#include "progname.h"
+
+/* set dasd first */
+static char vol_devno[7] = {0};
+static char *tmp_disk;
+static int fd;
+
+static PedDisk *disk;
+static struct fdasd_anchor anc;
+static fdasd_anchor_t *anchor = &anc;
+static LinuxSpecific *arch_specific;
+
+/* set the enviroment */
+static void set_test (void)
+{
+ PedDevice *dev;
+ PedDiskType *type;
+ type = ped_disk_type_get ("dasd");
+
+ tmp_disk = _create_disk (20*1024*1024);
+ fail_if (tmp_disk == NULL, "Failed to create temporary disk");
+ dev = ped_device_get (tmp_disk);
+ if (dev == NULL)
+ return;
+
+ disk = _create_disk_label (dev, type);
+ if (!ped_device_open (disk->dev))
+ return;
+
+ fdasd_initialize_anchor (anchor);
+ arch_specific = LINUX_SPECIFIC (disk->dev);
+ fd = arch_specific->fd;
+ if (!fdasd_get_geometry (dev, anchor, fd))
+ return;
+
+ fdasd_check_volume (anchor, fd);
+ sprintf (vol_devno, "0X%04x", anchor->devno);
+ ck_assert (strlen (vol_devno) == VOLSER_LENGTH);
+}
+
+static void free_test (void)
+{
+ ped_device_close (disk->dev);
+ ped_device_destroy (disk->dev);
+ unlink (tmp_disk);
+ free (tmp_disk);
+ fdasd_cleanup (anchor);
+}
+
+/* Test with default volser */
+START_TEST (test_get_volser)
+{
+ char volser[7] = {0};
+ fdasd_change_volser (anchor, vol_devno);
+ fdasd_write_labels (anchor, fd);
+
+ fdasd_get_volser (anchor, volser, fd);
+ ck_assert (!strcmp (volser, vol_devno));
+}
+END_TEST
+
+START_TEST (test_check_volser)
+{
+ char vol[7] = {0};
+ char vol_long[] = "abcdefg";
+ char vol_short[] = "ab_c ";
+ char vol_null[] = " ";
+ char *vol_input = NULL;
+
+ vol_input = vol_long;
+ fdasd_check_volser (vol_input, anchor->devno);
+ ck_assert(!strcmp (vol_input, "ABCDEF"));
+
+ vol_input = vol_short;
+ fdasd_check_volser (vol_input, anchor->devno);
+ ck_assert (!strcmp (vol_input, "ABC"));
+
+ vol_input = vol_null;
+ fdasd_check_volser (vol_input, anchor->devno);
+ ck_assert (!strcmp (vol_input, vol_devno));
+}
+END_TEST
+
+START_TEST (test_change_volser)
+{
+
+ char vol[] = "000000";
+ char volser[7] = {0};
+
+ fdasd_change_volser (anchor, vol);
+ fdasd_write_labels (anchor, fd);
+
+ fdasd_get_volser (anchor, volser, fd);
+ ck_assert (!strcmp (volser, vol));
+}
+END_TEST
+
+/*
+ * fdsad_recreate_vtoc recreate the VTOC with existing one.
+ * So the partition information should be not changed after recreating
+ * VTOC.
+*/
+START_TEST (test_reuse_vtoc)
+{
+ ds5ext_t before;
+ ds5ext_t after;
+
+ memcpy (&before, &anchor->f5->DS5AVEXT, sizeof(ds5ext_t));
+
+ if (anchor->fspace_trk) {
+ fdasd_reuse_vtoc (anchor);
+ memcpy (&after, &anchor->f5->DS5AVEXT, sizeof(ds5ext_t));
+ if ((before.t != after.t) && (before.fc != after.fc) && (before.ft != after.ft))
+ ck_abort ();
+ } else {
+ fdasd_reuse_vtoc (anchor);
+ memcpy (&after, &anchor->f5->DS5AVEXT, sizeof(ds5ext_t));
+ if ((before.t != after.t) && (before.fc != after.fc) && (before.ft != after.ft))
+ ck_abort ();
+ }
+}
+END_TEST
+
+int main (int argc, char **argv)
+{
+
+ set_program_name (argv[0]);
+
+#if defined __s390__ || defined __s390x__
+
+ int number_failed = 0;
+
+ Suite *suite = suite_create ("Volser");
+
+ TCase *tcase_get = tcase_create ("Get");
+ TCase *tcase_check = tcase_create ("Check");
+ TCase *tcase_change = tcase_create ("Change");
+ TCase *tcase_vtoc = tcase_create ("Vtoc");
+
+ ped_exception_set_handler (_test_exception_handler);
+
+ tcase_add_checked_fixture (tcase_check, set_test, free_test);
+ tcase_add_test (tcase_check, test_check_volser);
+ tcase_set_timeout (tcase_check, 0);
+ suite_add_tcase (suite, tcase_check);
+
+ tcase_add_checked_fixture (tcase_change, set_test, free_test);
+ tcase_add_test (tcase_change, test_change_volser);
+ tcase_set_timeout (tcase_change, 0);
+ suite_add_tcase (suite, tcase_change);
+
+ tcase_add_checked_fixture (tcase_get, set_test, free_test);
+ tcase_add_test (tcase_get, test_get_volser);
+ tcase_set_timeout (tcase_get, 0);
+ suite_add_tcase (suite, tcase_get);
+
+ tcase_add_checked_fixture (tcase_vtoc, set_test, free_test);
+ tcase_add_test (tcase_vtoc, test_reuse_vtoc);
+ tcase_set_timeout (tcase_vtoc, 0);
+ suite_add_tcase (suite, tcase_vtoc);
+
+ SRunner *srunner = srunner_create (suite);
+ /* When to debug, uncomment this line */
+ /* srunner_set_fork_status (srunner, CK_NOFORK); */
+
+ srunner_run_all (srunner, CK_VERBOSE);
+
+ number_failed = srunner_ntests_failed (srunner);
+ srunner_free (srunner);
+ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+
+#endif
+ return 0;
+}
--
2.9.3

View File

@ -0,0 +1,41 @@
From 58986a509da1c6387435b27c4071944ee14613a2 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Fri, 24 Feb 2017 11:06:20 -0800
Subject: [PATCH 76/77] Increase timeout for rmmod scsi_debug and make it a
framework failure
On some hardware scsi_debug can take longer to remove. If this fails it
inevitably results in the next test failing since it cannot load
scsi_debug.
Increse the timeout to 40 loops (8 seconds), and if it hits the limit
without succeeding call framework_failure_
(cherry picked from commit 40e55a0819862d5dbe2098803735f8c48fb30b6d)
---
tests/t-local.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/t-local.sh b/tests/t-local.sh
index 13073d2..2ba7ee1 100644
--- a/tests/t-local.sh
+++ b/tests/t-local.sh
@@ -27,13 +27,14 @@ scsi_debug_cleanup_()
# "Module scsi_debug is in use".
i=0
udevadm settle
- while [ $i -lt 10 ] ; do
+ while [ $i -lt 40 ] ; do
rmmod scsi_debug \
&& { test "$VERBOSE" = yes && warn_ $ME_ rmmod scsi_debug...; break; }
sleep .2 || sleep 1
i=$((i + 1))
done
udevadm settle
+ test $i = 40 && framework_failure_ rmmod scsi_debug failed.
fi
rm -fr $scsi_debug_lock_dir_
}
--
2.9.3

View File

@ -0,0 +1,27 @@
From 1eb7c40bcf7aeb359e9e605ebf2ae7e4a602a23c Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Fri, 24 Feb 2017 12:12:03 -0800
Subject: [PATCH 77/77] tests/t1701-rescue-fs wait for the device to appear.
After mkpart it needs to wait for the new partition to appear.
(cherry picked from commit 8d149b24eb2789fdf00743ef735e0cffde598040)
---
tests/t1701-rescue-fs.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/t1701-rescue-fs.sh b/tests/t1701-rescue-fs.sh
index 9b726cf..bbf5eac 100644
--- a/tests/t1701-rescue-fs.sh
+++ b/tests/t1701-rescue-fs.sh
@@ -30,6 +30,7 @@ scsi_dev=$(cat dev-name)
|| { warn_ "$ME: no ext4 support"; Exit $fail; }
parted -s $scsi_dev mklabel msdos mkpart primary ext2 1m 100%
+wait_for_dev_to_appear_ ${scsi_dev}1 || fail=1
mkfs.ext4 ${scsi_dev}1 || { warn_ $ME: mkfs.ext4 failed; fail=1; Exit $fail; }
# remove the partition
--
2.9.3

View File

@ -4,7 +4,7 @@
Summary: The GNU disk partition manipulation program
Name: parted
Version: 3.2
Release: 24%{?dist}
Release: 25%{?dist}
License: GPLv3+
Group: Applications/System
URL: http://www.gnu.org/software/parted
@ -68,6 +68,31 @@ Patch0051: 0051-tests-t3310-flags.sh-Add-test-for-dvh-table-flags.patch
Patch0052: 0052-tests-t3310-flags.sh-Add-tests-for-remaining-table-t.patch
Patch0053: 0053-tests-Set-optimal-blocks-to-64-for-scsi_debug-device.patch
Patch0054: 0054-tests-t3310-flags.sh-skip-pc98-when-sector-size-512.patch
Patch0055: 0055-tests-Stop-timing-t9040-1172675.patch
Patch0056: 0056-libparted-Fix-starting-CHS-in-protective-MBR.patch
Patch0057: 0057-libparted-Don-t-warn-if-no-HDIO_GET_IDENTITY-ioctl.patch
Patch0058: 0058-libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch
Patch0059: 0059-libparted-dasd-update-and-improve-fdasd-functions.patch
Patch0060: 0060-libparted-dasd-add-new-fdasd-functions.patch
Patch0061: 0061-libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch
Patch0062: 0062-libparted-set-swap-flag-on-GPT-partitions.patch
Patch0063: 0063-tests-Update-t0220-and-t0280-for-the-swap-flag.patch
Patch0064: 0064-libparted-tests-Move-get_sector_size-to-common.c.patch
Patch0065: 0065-libparted-Add-support-for-atari-partition-tables.patch
Patch0066: 0066-mac-copy-partition-type-and-name-correctly.patch
Patch0067: 0067-libparted-Fix-MacOS-boot-support.patch
Patch0068: 0068-libparted-Fix-typo-in-hfs-error-message.patch
Patch0069: 0069-Fix-crash-when-localized.patch
Patch0070: 0070-Add-support-for-RAM-drives.patch
Patch0071: 0071-parted-check-the-name-of-partition-first-when-to-nam.patch
Patch0072: 0072-parted-ui-remove-unneccesary-information-of-command-.patch
Patch0073: 0073-libpartd-dasd-improve-flag-processing-for-DASD-LDL.patch
Patch0074: 0074-libparted-dasd-add-an-exception-for-changing-DASD-LD.patch
Patch0075: 0075-libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch
Patch0076: 0076-Increase-timeout-for-rmmod-scsi_debug-and-make-it-a-.patch
Patch0077: 0077-tests-t1701-rescue-fs-wait-for-the-device-to-appear.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: e2fsprogs-devel
BuildRequires: readline-devel
@ -87,6 +112,7 @@ BuildRequires: dosfstools
BuildRequires: perl-Digest-CRC
BuildRequires: bc
Buildrequires: python2
BuildRequires: gperf
Requires(post): /sbin/ldconfig
Requires(post): /sbin/install-info
@ -203,6 +229,33 @@ fi
%changelog
* Mon May 01 2017 Brian C. Lane <bcl@redhat.com> - 3.2-25
+ Updating to upstream patches
- tests/t1701-rescue-fs wait for the device to appear. (bcl)
- Increase timeout for rmmod scsi_debug and make it a framework failure (bcl)
- libparted/dasd: add test cases for the new fdasd functions (dongdwdw)
- libparted/dasd: add an exception for changing DASD-LDL partition table
(dongdwdw)
- libpartd/dasd: improve flag processing for DASD-LDL (dongdwdw)
- parted/ui: remove unneccesary information of command line (dongdwdw)
- parted: check the name of partition first when to name a partition (dongdwdw)
- Add support for RAM drives (sparschauer)
- Fix crash when localized (psusi)
- libparted: Fix typo in hfs error message (sebras)
- libparted: Fix MacOS boot support (laurent)
- mac: copy partition type and name correctly (saproj)
- libparted: Add support for atari partition tables (glaubitz)
- libparted:tests: Move get_sector_size() to common.c (glaubitz)
- tests: Update t0220 and t0280 for the swap flag. (bcl)
- libparted: set swap flag on GPT partitions (aschnell)
- libparted/dasd: add test cases for the new fdasd functions (dongdwdw)
- libparted/dasd: add new fdasd functions (dongdwdw)
- libparted/dasd: update and improve fdasd functions (dongdwdw)
- libparted/dasd: unify vtoc handling for cdl/ldl (dongdwdw)
- libparted: Don't warn if no HDIO_GET_IDENTITY ioctl (sparschauer)
- libparted: Fix starting CHS in protective MBR (petr.uzel)
- tests: Stop timing t9040 (#1172675) (bcl)
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 3.2-24
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild