SHA256
1
0
forked from pool/s390-tools
s390-tools/s390-tools-sles12sp3-dasdfmt-06-Make-the-IOCTL-BLKSSZGET-reusable.patch
2017-02-21 11:14:26 +00:00

94 lines
3.1 KiB
Diff

Subject: [PATCH] [FEAT LS1501] dasdfmt: Add new formatting modes
From: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Summary: dasdfmt: Add new formatting modes
Description: Introduce new formatting modes 'quick' and 'expand' to either
format an earlier formatted DASD that could potentially be
re-initialized very easily or format unformatted tracks at the
end of a device that was previously extended.
Also add the command line argument --check to provide a function
that checks a DASD volume for correct formatting.
Upstream-ID: -
Problem-ID: LS1501
Upstream-Description:
dasdfmt: Make the IOCTL BLKSSZGET reusable
The IOCTL BLKSSZGET is used to get blocksize information of a device.
Since it is used several times already and could be used for new
features as well, move the call to a separate function and make it
reusable.
Signed-off-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
---
dasdfmt/dasdfmt.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
--- a/dasdfmt/dasdfmt.c
+++ b/dasdfmt/dasdfmt.c
@@ -252,6 +252,17 @@ static void get_device_info(dasdfmt_info
}
/*
+ * Retrieve blocksize of device
+ */
+static void get_blocksize(unsigned int *blksize)
+{
+ if (ioctl(filedes, BLKSSZGET, blksize) != 0)
+ ERRMSG_EXIT(EXIT_FAILURE, "%s: the ioctl to get the blocksize "
+ "of the device failed (%s).\n", prog_name,
+ strerror(errno));
+}
+
+/*
* check for disk type and set some variables (e.g. usage count)
*/
static void check_disk(dasdfmt_info_t *info)
@@ -510,7 +521,7 @@ static void dasdfmt_print_info(dasdfmt_i
*/
static int dasdfmt_get_volser(dasdfmt_info_t *info, char *volser)
{
- int blksize;
+ unsigned int blksize;
int f;
volume_label_t vlabel;
@@ -519,9 +530,7 @@ static int dasdfmt_get_volser(dasdfmt_in
ERRMSG_EXIT(EXIT_FAILURE, "%s: Unable to open device %s: %s\n",
prog_name, info->devname, strerror(errno));
- if (ioctl(filedes, BLKSSZGET, &blksize) != 0)
- ERRMSG_EXIT(EXIT_FAILURE, "%s: (label pos) IOCTL BLKSSZGET "
- "failed (%s).\n", prog_name, strerror(errno));
+ get_blocksize(&blksize);
if (close(f) != 0)
ERRMSG("%s: error during close: %s\ncontinuing...\n",
@@ -551,7 +560,8 @@ static void dasdfmt_write_labels(dasdfmt
format4_label_t f4;
format5_label_t f5;
format7_label_t f7;
- int rc, blksize;
+ unsigned int blksize;
+ int rc;
void *ipl1_record, *ipl2_record;
int ipl1_record_len, ipl2_record_len;
@@ -559,9 +569,7 @@ static void dasdfmt_write_labels(dasdfmt
if (info->verbosity > 0)
printf("Retrieving dasd information... ");
- if (ioctl(filedes, BLKSSZGET, &blksize) != 0)
- ERRMSG_EXIT(EXIT_FAILURE, "%s: (write labels) IOCTL BLKSSZGET "
- "failed (%s).\n", prog_name, strerror(errno));
+ get_blocksize(&blksize);
/*
* Don't rely on the cylinders returned by HDIO_GETGEO, they might be