File ppc64-diag.bug-1072708_remove_timestamp.patch of Package ppc64-diag.10030

commit 7be810122b48af0c095c1d1d5e8bd0b124026ed4
Author: Ankit Kumar <ankit@linux.vnet.ibm.com>
Date:   Tue Dec 5 14:56:13 2017 +0530

    diags: Remove timestamp from disk health log file
    
    This patch removes timestamp from filename. Function call sequence is
    changed as old and new file will have same name.
    
    Signed-off-by: Ankit Kumar <ankit@linux.vnet.ibm.com>
    [Modified to continue with file creation even if remove_old_log_file
     fails - Vasant]
    Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>

Index: ppc64-diag-2.7.4/diags/diag_disk.c
===================================================================
--- ppc64-diag-2.7.4.orig/diags/diag_disk.c
+++ ppc64-diag-2.7.4/diags/diag_disk.c
@@ -341,7 +341,7 @@ static int sysfs_sg_disk_scan(const char
 	return rc;
 }
 
-static int remove_old_log_file(char *xml_filename)
+static int remove_old_log_file(void)
 {
 	DIR *d;
 	struct dirent *namelist;
@@ -356,9 +356,6 @@ static int remove_old_log_file(char *xml
 		if (namelist->d_name[0] == '.')
 			continue;
 
-		if (!strcmp(xml_filename, namelist->d_name))
-			continue;
-
 		snprintf(filename, sizeof(filename) - 1, "%s/%s", OUTPUT_PATH,
 			namelist->d_name);
 		if (unlink(filename) < 0) {
@@ -413,10 +410,11 @@ int diag_disk(char *disk_name)
 
 	/* file format */
 	snprintf(xml_filename, sizeof(xml_filename) - 1,
-		 "%s~%s~%s~diskAnalytics~%d%02d%02d%02d%02d%02d.xml",
-		 mach_type_model, mach_model, serial_num,
-		 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
-		 tm.tm_hour, tm.tm_min, tm.tm_sec);
+		 "%s~%s~%s~diskAnalytics.xml",
+		 mach_type_model, mach_model, serial_num);
+
+	/* Try to remove old log file. We will continue even if this fails */
+	remove_old_log_file();
 
 	/* open file */
 	ret = open_output_xml_file(xml_filename);
@@ -438,12 +436,5 @@ int diag_disk(char *disk_name)
 	/* close output xml file descriptor */
 	close_output_xml_file();
 
-	/* remove old log file */
-	ret = remove_old_log_file(xml_filename);
-	if (ret) {
-		fprintf(stderr, "Unable to remove old output log file.\n");
-		return -1;
-	}
-
 	return 0;
 }
openSUSE Build Service is sponsored by