parted/libparted-dasd-update-and-improve-fdasd-functions.patch
Marcus Meissner 5b97712c80 Accepting request 712877 from home:anicka:branches:Base:System
- port fixes for various bugs from upstream (bsc#1136245)
 - add: libparted-dasd-correct-the-offset-where-the-first-pa.patch
   4126d02, correct the offset where the first partition begins. 
   This patch implements libparted-dasd-do-not-use-first-tracks.patch 
 - remove: libparted-dasd-do-not-use-first-tracks.patch
 - add: parted-fix-crash-due-to-improper-partition-number-in.patch
   149f009, fix crash due to improper partition number input,
   changed call to strtol, use base 0 to fit our parted-type.patch
 - modify: parted-type.patch (removed ui.c part)
 - add: parted-check-the-name-of-partition-first-when-to-nam.patch
   d7a2ff1, check the name of partition first when to name a partition
 - add: libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch 
   c11f5c0, 571e078, add test cases for the new fdasd functions
 - add: libparted-dasd-add-an-exception-for-changing-DASD-LD.patch
   ee2c0c2, add an exception for changing DASD-LDL partition table
 - add: libpartd-dasd-improve-flag-processing-for-DASD-LDL.patch
   1545d6d, improve flag processing for DASD-LDL
 - add: clean-the-disk-information-when-commands-fail-in-int.patch
   5a61f15, clean the disk information when commands fail in 
   interactive mode
 - add: parted-ui-remove-unneccesary-information-of-command.patch
   0b7946a, remove unneccesary information of command line
 - add: parted-fix-wrong-error-label-jump-in-mkpart.patch
   af150f6, fix wrong error label jump in mkpart
 - refresh: libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch
   4f25d54, unify vtoc handling for cdl/ldl
 - refresh: libparted-dasd-update-and-improve-fdasd-functions.patch
   db37c8c, update and improve fdasd functions
 - refresh: libparted-dasd-add-new-fdasd-functions.patch
   b9e1281, add new fdasd functions

OBS-URL: https://build.opensuse.org/request/show/712877
OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=142
2019-07-08 12:12:35 +00:00

209 lines
6.5 KiB
Diff

From db37c8c017ebef8f241420dda071940957d4bbe5 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] 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.16.4