File s390-tools-sles15-Implement-Y-yast_mode.patch of Package s390-tools

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>
---
 dasdfmt/dasdfmt.8 |  7 ++++++-
 dasdfmt/dasdfmt.c | 27 ++++++++++++++++++++-------
 dasdfmt/dasdfmt.h |  1 +
 3 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/dasdfmt/dasdfmt.8 b/dasdfmt/dasdfmt.8
index 07c674b..3fd10a2 100644
--- a/dasdfmt/dasdfmt.8
+++ b/dasdfmt/dasdfmt.8
@@ -7,7 +7,7 @@
 dasdfmt \- formatting of DASD (ECKD) disk drives.
 
 .SH SYNOPSIS
-\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]
 .br
         [-r \fIcylinder\fR] [-b \fIblksize\fR] [-l \fIvolser\fR] [-d \fIlayout\fR]
 .br
@@ -113,6 +113,11 @@ The value will be at least as big as the -r or --requestsize value.
 .br
 
 .TP
+\fB-Y\fR or \fB--yast_mode\fR
+YaST mode; suppress most output.
+.br
+
+.TP
 \fB-M\fR \fImode\fR or \fB--mode\fR=\fImode\fR
 Specify the \fImode\fR to be used to format the device. Valid modes are:
 .RS
diff --git a/dasdfmt/dasdfmt.c b/dasdfmt/dasdfmt.c
index 6dd28fa..5b6023a 100644
--- a/dasdfmt/dasdfmt.c
+++ b/dasdfmt/dasdfmt.c
@@ -137,6 +137,10 @@ static struct util_opt opt_vec[] = {
 		.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' },
@@ -343,7 +347,8 @@ static void evaluate_format_error(dasdfmt_info_t *info, format_check_t *cdata,
 	unsigned int kl = 0;
 	int blksize = cdata->expect.blksize;
 
-	if (info->print_progressbar || info->print_hashmarks)
+	if ((info->print_progressbar || info->print_hashmarks) &&
+	    !info->yast_mode)
 		printf("\n");
 
 	/*
@@ -749,9 +754,9 @@ static void check_hashmarks(dasdfmt_info_t *info)
 			       "using the default.\n");
 			info->hashstep = 10;
 		}
-
-		printf("Printing hashmark every %d cylinders.\n",
-		       info->hashstep);
+		if (!info->yast_mode)
+			printf("Printing hashmark every %d cylinders.\n",
+			       info->hashstep);
 	}
 }
 
@@ -985,7 +990,7 @@ static int dasdfmt_get_volser(char *devn
 /*
  * do all the labeling (volume label and initial VTOC)
  */
-static void dasdfmt_write_labels(dasdfmt_info_t *info, volume_label_t *vlabel,
+static void dasdfmt_write_labels(dasdfmt_info_t *info, char *dev_filename, volume_label_t *vlabel,
 				 unsigned int cylinders, unsigned int heads)
 {
 	int label_position;
@@ -1483,17 +1488,19 @@ static void do_format_dasd(dasdfmt_info_t *info, char *devname,
 			break;
 		}
 
-		printf("Finished formatting the device.\n");
+		if (!info->yast_mode)
+			printf("Finished formatting the device.\n");
 
 		if (!(info->writenolabel || mode == EXPAND))
 			dasdfmt_write_labels(info, devname, vlabel, cylinders, heads);
 
-		printf("Rereading the partition table... ");
+		if (!info->yast_mode)
+			printf("Rereading the partition table... ");
 		err = dasd_reread_partition_table(devname, 5);
 		if (err != 0) {
 			ERRMSG("%s: error during rereading the partition "
 			       "table: %s.\n", prog_name, strerror(err));
-		} else {
+		} else if (!info->yast_mode) {
 			printf("ok\n");
 		}
 	}
@@ -1569,6 +1576,8 @@ void do_dasdfmt(char *dev_filename, dasdfmt_info_t *info,
 		ERRMSG_EXIT(EXIT_MISUSE, "%s: %s\n", prog_name, str);
 
 	set_geo(&info, &cylinders, &heads);
+	if (info.yast_mode)
+		printf("%d\n", cylinders);
 	set_label(&info, &vlabel, &format_params, cylinders);
 
 	if (info.check)
@@ -1721,6 +1730,10 @@ int main(int argc, char *argv[])
 		case OPT_NODISCARD:
 			info.no_discard = 1;
 			break;
+		case 'Y':
+			/* YaST mode */
+			info.yast_mode = 1;
+			break;
 		case 'P':
 			max_parallel = atoi(optarg);
 			break;
diff --git a/dasdfmt/dasdfmt.h b/dasdfmt/dasdfmt.h
index fb6fc34..fe0cc7f 100644
--- a/dasdfmt/dasdfmt.h
+++ b/dasdfmt/dasdfmt.h
@@ -96,6 +96,7 @@ typedef struct dasdfmt_info {
 	int   ese;
 	int   no_discard;
 	int   procnum;
+	int   yast_mode;
 } dasdfmt_info_t;
 
 
-- 
1.7.12.4

openSUSE Build Service is sponsored by