Use stat() to Check that File Should be chmod()-ed

Rather than special-casing a check for `/dev/null`, this uses `stat()` to
avoid `chmod()`-ing any non-regular file. I believe this is the desirable
behavior. `UTIL_chmod()` is never called on directories at the moment, only
output files.
This commit is contained in:
W. Felix Handte
2020-08-05 12:00:12 -04:00
parent 7238cca1a1
commit 0a8aacb4db
3 changed files with 16 additions and 6 deletions
+2 -2
View File
@@ -509,7 +509,7 @@ static int FIO_remove(const char* path)
#if defined(_WIN32) || defined(WIN32)
/* windows doesn't allow remove read-only files,
* so try to make it writable first */
UTIL_chmod(path, _S_IWRITE);
UTIL_chmod(path, NULL, _S_IWRITE);
#endif
return remove(path);
}
@@ -619,7 +619,7 @@ FIO_openDstFile(FIO_prefs_t* const prefs,
&& strcmp (srcFileName, stdinmark)
&& strcmp(dstFileName, nulmark) ) {
/* reduce rights on newly created dst file while compression is ongoing */
UTIL_chmod(dstFileName, 00600);
UTIL_chmod(dstFileName, NULL, 00600);
}
return f;
}