Summary:     dasdfmt: Add --norecordzero option
Description: Per default in recent dasd drivers, subsystems are granted the
             permission to format write record zero. This option is used
             to remove this permission.
---
 dasdfmt/dasdfmt.8 |    9 +++++++++
 dasdfmt/dasdfmt.c |   23 +++++++++++++++--------
 dasdfmt/dasdfmt.h |    2 ++
 3 files changed, 26 insertions(+), 8 deletions(-)

Index: s390-tools-sles11/dasdfmt/dasdfmt.8
===================================================================
--- s390-tools-sles11.orig/dasdfmt/dasdfmt.8
+++ s390-tools-sles11/dasdfmt/dasdfmt.8
@@ -41,6 +41,15 @@ Increases verbosity.
 Start formatting without further user-confirmation.
 
 .TP
+\fB--norecordzero\fR
+Remove permission for subsystem to format write record zero.
+.br
+This is an expert option: Per default in recent dasd drivers, subsystems are
+granted the permission to format write record zero. This option is used
+to remove this permission.
+.br
+
+.TP
 \fB-L\fR or \fB--no_label\fR
 Omit the writing of a disk label after formatting.
 .br
Index: s390-tools-sles11/dasdfmt/dasdfmt.c
===================================================================
--- s390-tools-sles11.orig/dasdfmt/dasdfmt.c
+++ s390-tools-sles11/dasdfmt/dasdfmt.c
@@ -52,7 +52,9 @@ static void exit_usage(int exitcode)
 	       "cylinders\n"
 	       "       -v means verbose mode\n"
 	       "       -F means don't check if the device is in use\n"
-	       "       -k means keep volume serial\n\n"
+	       "       -k means keep volume serial\n"
+	       "       --norecordzero prevent storage server from modifying"
+	       " record 0\n\n"
 	       "       <volser> is the volume identifier, which is converted\n"
 	       "                to EBCDIC and written to disk. \n"
 	       "                (6 characters, e.g. LNX001\n"
@@ -677,7 +679,8 @@ static void dasdfmt_prepare_and_format (
 		start_unit: 0,
 		stop_unit:  0,
 		blksize:    p->blksize,
-		intensity: (p->intensity | DASD_FMT_INT_INVAL)
+		intensity: ((p->intensity & ~DASD_FMT_INT_FMT_NOR0)
+			    | DASD_FMT_INT_INVAL)
 	};
 
 	if (info->verbosity > 0) printf("Detaching the device...\n");
@@ -751,7 +754,7 @@ static void do_format_dasd(dasdfmt_info_
 			vtoc_volume_label_set_volser(vlabel, buf);
 		}
 
-                if (p->intensity == 0x08) {
+                if (p->intensity & DASD_FMT_INT_COMPAT) {
 			info->cdl_format = 1;
 			vtoc_volume_label_set_label(vlabel, "VOL1");
 			vtoc_volume_label_set_key(vlabel, "VOL1");
@@ -849,13 +852,13 @@ int main(int argc,char *argv[]) 
 			break;
 
 		case 'C':
-                	format_params.intensity=0x08;
+                	format_params.intensity |= DASD_FMT_INT_COMPAT;
 			break;
 
                 case 'd' :
                         if (strncmp(optarg,"cdl",3)==0)
 			{
-				format_params.intensity=0x08;
+				format_params.intensity |= DASD_FMT_INT_COMPAT;
 				if (info.writenolabel)
 				{
 					printf("WARNING: using the cdl " \
@@ -866,7 +869,7 @@ int main(int argc,char *argv[]) 
 				}
 			}
 			else if (strncmp(optarg,"ldl",3)==0)
-				format_params.intensity=0x00;
+				format_params.intensity &= ~DASD_FMT_INT_COMPAT;
 			else
 			{
 				printf("%s is not a valid option!\n", optarg);
@@ -878,6 +881,10 @@ int main(int argc,char *argv[]) 
 			info.withoutprompt=1;
 			break;
 
+		case 'z':
+                	format_params.intensity |= DASD_FMT_INT_FMT_NOR0;
+			break;
+
 		case 't':
 			info.testmode=1;
 			break;
@@ -914,7 +921,7 @@ int main(int argc,char *argv[]) 
 			break;
 
 		case 'L':
-			if (format_params.intensity == 0x08) 
+			if (format_params.intensity & DASD_FMT_INT_COMPAT)
 			{
 				printf("WARNING: using the cdl format " \
 				       "without writing a label doesn't " \
@@ -1040,7 +1047,7 @@ int main(int argc,char *argv[]) 
 				format_params = ask_user_for_blksize(format_params);
 
 			if (info.keep_volser) {
-				if(format_params.intensity == 0x00) {
+				if(!(format_params.intensity & DASD_FMT_INT_COMPAT)) {
 					printf("WARNING: VOLSER cannot be kept " \
 					       "when using the ldl format!\n");
 					exit(1);
Index: s390-tools-sles11/dasdfmt/dasdfmt.h
===================================================================
--- s390-tools-sles11.orig/dasdfmt/dasdfmt.h
+++ s390-tools-sles11/dasdfmt/dasdfmt.h
@@ -80,6 +80,7 @@ typedef struct format_data_t {
 #define DASD_FMT_INT_FMT_HA 2 /* write home address, also set FMT_R0 ! */
 #define DASD_FMT_INT_INVAL  4 /* invalidate tracks */
 #define DASD_FMT_INT_COMPAT 8 /* use OS/390 compatible disk layout */
+#define DASD_FMT_INT_FMT_NOR0 16 /* remove permission to write record zero */
 
 
 /* Disable the volume (for Linux) */
@@ -167,6 +168,7 @@ static struct option dasdfmt_getopt_long
         { "max_parallel",1, 0, 'P'},
         { "yast_mode",   0, 0, 'Y'},
         { "keep_volser", 0, 0, 'k'},
+        { "norecordzero",  0, 0, 'z'},
         {0, 0, 0, 0}
 };
 
