67 lines
2.0 KiB
Diff
67 lines
2.0 KiB
Diff
|
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>
|
||
|
|
||
|
diff --git a/diags/diag_disk.c b/diags/diag_disk.c
|
||
|
index 9c1acbe..f524774 100644
|
||
|
--- a/diags/diag_disk.c
|
||
|
+++ b/diags/diag_disk.c
|
||
|
@@ -344,7 +344,7 @@ static int sysfs_sg_disk_scan(const char *dir_name, char *disk_name)
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
-static int remove_old_log_file(char *xml_filename)
|
||
|
+static int remove_old_log_file(void)
|
||
|
{
|
||
|
DIR *d;
|
||
|
struct dirent *namelist;
|
||
|
@@ -359,9 +359,6 @@ static int remove_old_log_file(char *xml_filename)
|
||
|
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) {
|
||
|
@@ -416,10 +413,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);
|
||
|
@@ -441,12 +439,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;
|
||
|
}
|