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