Disable status file updates on error

If fio doesn't have permission to unlink() the status file,
it'll continually dump status updates. If this happens, stop
doing status updates and log an error indicating why.

Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/stat.c b/stat.c
index f018f33..c2c717b 100644
--- a/stat.c
+++ b/stat.c
@@ -1479,6 +1479,7 @@
 
 static int status_interval_init;
 static struct timeval status_time;
+static int status_file_disabled;
 
 #define FIO_STATUS_FILE		"fio-dump-status"
 
@@ -1488,6 +1489,9 @@
 	const char *temp_dir;
 	char fio_status_file_path[PATH_MAX];
 
+	if (status_file_disabled)
+		return 0;
+
 	temp_dir = getenv("TMPDIR");
 	if (temp_dir == NULL)
 		temp_dir = getenv("TEMP");
@@ -1499,7 +1503,13 @@
 	if (stat(fio_status_file_path, &sb))
 		return 0;
 
-	unlink(fio_status_file_path);
+	if (unlink(fio_status_file_path) < 0) {
+		log_err("fio: failed to unlink %s: %s\n", fio_status_file_path,
+							strerror(errno));
+		log_err("fio: disabling status file updates\n");
+		status_file_disabled = 1;
+	}
+
 	return 1;
 }