2024-05-04 00:27:27 +02:00
|
|
|
From eabcb26fa4a91d410a6f75a9915a9ebb9f702c6b Mon Sep 17 00:00:00 2001
|
|
|
|
From: Hannes Reinecke <hare@suse.de>
|
|
|
|
Date: Fri, 6 Oct 2017 09:55:40 +0200
|
|
|
|
Subject: [PATCH] dasdfmt: Implement '-Y/--yast_mode'
|
|
|
|
|
|
|
|
Implement an option '-Y' to suppress most output.
|
|
|
|
|
|
|
|
Signed-off-by: Hannes Reinecke <hare@suse.com>
|
|
|
|
---
|
2024-11-28 10:28:50 +01:00
|
|
|
dasdfmt/dasdfmt.8 | 7 ++++++-
|
|
|
|
dasdfmt/dasdfmt.c | 27 ++++++++++++++++++++-------
|
|
|
|
dasdfmt/dasdfmt.h | 1 +
|
|
|
|
3 files changed, 27 insertions(+), 8 deletions(-)
|
2024-05-04 00:27:27 +02:00
|
|
|
|
2024-11-28 10:28:50 +01:00
|
|
|
Index: s390-tools-2.30.0/dasdfmt/dasdfmt.8
|
|
|
|
===================================================================
|
|
|
|
--- s390-tools-2.30.0.orig/dasdfmt/dasdfmt.8
|
|
|
|
+++ s390-tools-2.30.0/dasdfmt/dasdfmt.8
|
2024-05-04 00:27:27 +02:00
|
|
|
@@ -7,7 +7,7 @@
|
|
|
|
dasdfmt \- formatting of DASD (ECKD) disk drives.
|
|
|
|
|
|
|
|
.SH SYNOPSIS
|
2024-11-28 10:28:50 +01:00
|
|
|
-\fBdasdfmt\fR [-h] [-t] [-v] [-y] [-p] [-Q] [-P] [-m \fIstep\fR]
|
|
|
|
+\fBdasdfmt\fR [-h] [-t] [-v] [-y] [-p] [-Q] [-P] [-Y] [-m \fIstep\fR]
|
2024-05-04 00:27:27 +02:00
|
|
|
.br
|
2024-11-28 10:28:50 +01:00
|
|
|
[-r \fIcylinder\fR] [-b \fIblksize\fR] [-l \fIvolser\fR] [-d \fIlayout\fR]
|
2024-05-04 00:27:27 +02:00
|
|
|
.br
|
2024-11-28 10:28:50 +01:00
|
|
|
@@ -113,6 +113,11 @@ The value will be at least as big as the
|
2024-05-04 00:27:27 +02:00
|
|
|
.br
|
|
|
|
|
|
|
|
.TP
|
|
|
|
+\fB-Y\fR or \fB--yast_mode\fR
|
|
|
|
+YaST mode; suppress most output.
|
|
|
|
+.br
|
|
|
|
+
|
|
|
|
+.TP
|
2024-11-28 10:28:50 +01:00
|
|
|
\fB-M\fR \fImode\fR or \fB--mode\fR=\fImode\fR
|
2024-05-04 00:27:27 +02:00
|
|
|
Specify the \fImode\fR to be used to format the device. Valid modes are:
|
|
|
|
.RS
|
2024-11-28 10:28:50 +01:00
|
|
|
Index: s390-tools-2.30.0/dasdfmt/dasdfmt.c
|
|
|
|
===================================================================
|
|
|
|
--- s390-tools-2.30.0.orig/dasdfmt/dasdfmt.c
|
|
|
|
+++ s390-tools-2.30.0/dasdfmt/dasdfmt.c
|
|
|
|
@@ -83,6 +83,7 @@ static struct dasdfmt_globals {
|
2024-05-04 00:27:27 +02:00
|
|
|
int ese;
|
|
|
|
int no_discard;
|
|
|
|
int procnum;
|
|
|
|
+ int yast_mode;
|
|
|
|
} g = {
|
|
|
|
.dasd_info = { 0 },
|
|
|
|
};
|
2024-11-28 10:28:50 +01:00
|
|
|
@@ -172,6 +173,10 @@ static struct util_opt opt_vec[] = {
|
2024-05-04 00:27:27 +02:00
|
|
|
.option = { "percentage", no_argument, NULL, 'Q' },
|
|
|
|
.desc = "Show progress in percent",
|
|
|
|
},
|
|
|
|
+ {
|
|
|
|
+ .option = { "yast_mode", no_argument, NULL, 'Y' },
|
|
|
|
+ .desc = "YaST mode",
|
|
|
|
+ },
|
|
|
|
UTIL_OPT_SECTION("MISC"),
|
|
|
|
{
|
|
|
|
.option = { "check_host_count", no_argument, NULL, 'C' },
|
2024-11-28 10:28:50 +01:00
|
|
|
@@ -318,7 +323,9 @@ static void draw_progress(int cyl, unsig
|
2024-05-04 00:27:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (g.print_hashmarks && (cyl / g.hashstep - hashcount) != 0) {
|
|
|
|
- printf("%d|", g.procnum);
|
|
|
|
+ if (g.yast_mode)
|
|
|
|
+ printf("%d|", g.procnum);
|
|
|
|
+ else printf("#");
|
|
|
|
fflush(stdout);
|
|
|
|
hashcount++;
|
|
|
|
}
|
2024-11-28 10:28:50 +01:00
|
|
|
@@ -392,7 +399,7 @@ static void evaluate_format_error(format
|
2024-05-04 00:27:27 +02:00
|
|
|
unsigned int kl = 0;
|
|
|
|
int blksize = cdata->expect.blksize;
|
|
|
|
|
|
|
|
- if (g.print_progressbar || g.print_hashmarks)
|
|
|
|
+ if ((g.print_progressbar || g.print_hashmarks) && !g.yast_mode)
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
/*
|
2024-11-28 10:28:50 +01:00
|
|
|
@@ -780,8 +787,9 @@ static void check_hashmarks(void)
|
2024-05-04 00:27:27 +02:00
|
|
|
g.hashstep = 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
- printf("Printing hashmark every %d cylinders.\n",
|
|
|
|
- g.hashstep);
|
|
|
|
+ if (!g.yast_mode)
|
|
|
|
+ printf("Printing hashmark every %d cylinders.\n",
|
|
|
|
+ g.hashstep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-28 10:28:50 +01:00
|
|
|
@@ -1475,17 +1483,19 @@ static void do_format_dasd(volume_label_
|
2024-05-04 00:27:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
- printf("Finished formatting the %s device.\n", g.dev_path);
|
|
|
|
+ if (!g.yast_mode)
|
|
|
|
+ printf("Finished formatting the %s device.\n", g.dev_path);
|
|
|
|
|
|
|
|
if (!(g.writenolabel || mode == EXPAND))
|
|
|
|
dasdfmt_write_labels(vlabel, cylinders, heads);
|
|
|
|
|
|
|
|
- printf("Rereading the partition table for %s... ", g.dev_path);
|
|
|
|
+ if (!g.yast_mode)
|
|
|
|
+ printf("Rereading the partition table for %s... ", g.dev_path);
|
|
|
|
err = dasd_reread_partition_table(g.dev_node, 5);
|
|
|
|
if (err != 0) {
|
|
|
|
ERRMSG("%s: error during rereading the partition "
|
|
|
|
"table: %s.\n", prog_name, strerror(err));
|
|
|
|
- } else {
|
|
|
|
+ } else if (!g.yast_mode) {
|
|
|
|
printf("ok\n");
|
|
|
|
}
|
|
|
|
}
|
2024-11-28 10:28:50 +01:00
|
|
|
@@ -1561,6 +1571,7 @@ void process_dasd(volume_label_t *orig_v
|
2024-05-04 00:27:27 +02:00
|
|
|
error("%s", str);
|
|
|
|
|
|
|
|
set_geo(&cylinders, &heads);
|
|
|
|
+
|
|
|
|
set_label(&vlabel, &format_params, cylinders);
|
|
|
|
|
|
|
|
if (g.check)
|
2024-11-28 10:28:50 +01:00
|
|
|
@@ -1570,6 +1581,29 @@ void process_dasd(volume_label_t *orig_v
|
2024-05-04 00:27:27 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
+static void yast_print_cylinfo(const char *dev_filename)
|
|
|
|
+{
|
|
|
|
+ unsigned int cylinders = -1u;
|
|
|
|
+ int fd;
|
|
|
|
+ dasd_information2_t dasd_info;
|
|
|
|
+ struct dasd_eckd_characteristics *characteristics;
|
|
|
|
+
|
|
|
|
+ fd = open(dev_filename, O_RDONLY);
|
|
|
|
+ if ((fd != -1) && ( ! ioctl(fd, BIODASDINFO2, &dasd_info))) {
|
|
|
|
+
|
|
|
|
+ characteristics = (struct dasd_eckd_characteristics *) &dasd_info.characteristics;
|
|
|
|
+ if (characteristics->no_cyl == LV_COMPAT_CYL && characteristics->long_no_cyl)
|
|
|
|
+ cylinders = characteristics->long_no_cyl;
|
|
|
|
+ else
|
|
|
|
+ cylinders = characteristics->no_cyl;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (fd != -1)
|
|
|
|
+ close(fd);
|
|
|
|
+ printf("%u\n", cylinders);
|
|
|
|
+ fflush(stdout);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
volume_label_t vlabel;
|
2024-11-28 10:28:50 +01:00
|
|
|
@@ -1706,6 +1740,10 @@ int main(int argc, char *argv[])
|
2024-05-04 00:27:27 +02:00
|
|
|
case OPT_NODISCARD:
|
|
|
|
g.no_discard = 1;
|
|
|
|
break;
|
|
|
|
+ case 'Y':
|
|
|
|
+ /* YaST mode */
|
|
|
|
+ g.yast_mode = 1;
|
|
|
|
+ break;
|
|
|
|
case 'P':
|
|
|
|
max_parallel = atoi(optarg);
|
|
|
|
break;
|
2024-11-28 10:28:50 +01:00
|
|
|
@@ -1741,6 +1779,21 @@ int main(int argc, char *argv[])
|
2024-05-04 00:27:27 +02:00
|
|
|
reqsize = DEFAULT_REQUESTSIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
+/* If -Y (YaST mode) was specified by the caller, then we need to suppress
|
|
|
|
+ * most of all the other output that might be generated. But, we _do_ want
|
|
|
|
+ * hashmarks printed so that YaST can track what's going on. If it wasn't
|
|
|
|
+ * specified on the command line, set it to a default of 10 cylinders.
|
|
|
|
+ */
|
|
|
|
+ if (g.yast_mode) {
|
|
|
|
+ g.verbosity = 0;
|
|
|
|
+ g.print_progressbar = 0;
|
|
|
|
+ g.print_percentage = 0;
|
|
|
|
+ if (! g.print_hashmarks) {
|
|
|
|
+ g.print_hashmarks = 1;
|
|
|
|
+ hashstep_str = "10";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (g.print_hashmarks)
|
|
|
|
PARSE_PARAM_INTO(g.hashstep, hashstep_str, 10, "hashstep");
|
|
|
|
|
2024-11-28 10:28:50 +01:00
|
|
|
@@ -1760,6 +1813,12 @@ int main(int argc, char *argv[])
|
2024-05-04 00:27:27 +02:00
|
|
|
if (numdev > 1 && g.labelspec)
|
|
|
|
error("Specifying a volser to be written doesn't make sense when formatting multiple DASD volumes.");
|
|
|
|
|
|
|
|
+ if (g.yast_mode) {
|
|
|
|
+ for (numproc = 0; numproc < numdev; numproc++)
|
|
|
|
+ yast_print_cylinfo(g.dev_path_array[numproc]);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
for (numproc = 0; numproc < numdev; numproc++) {
|
|
|
|
chpid = fork();
|
|
|
|
if (chpid == -1 )
|