created UTIL_chmod()

protecting "/dev/null" from having its permissions changed.

also : minor : improved consistency of util.h API
This commit is contained in:
Yann Collet
2019-11-25 13:45:22 -08:00
parent 60db21a677
commit 9a22140ef4
4 changed files with 58 additions and 57 deletions
+3 -5
View File
@@ -502,7 +502,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 */
chmod(path, _S_IWRITE);
UTIL_chmod(path, _S_IWRITE);
#endif
return remove(path);
}
@@ -526,9 +526,7 @@ static FILE* FIO_openSrcFile(const char* srcFileName)
}
if (!UTIL_isRegularFile(srcFileName)
#ifndef _MSC_VER
&& !UTIL_isFIFO(srcFileName)
#endif /* _MSC_VER */
&& !UTIL_isFIFO(srcFileName)
) {
DISPLAYLEVEL(1, "zstd: %s is not a regular file -- ignored \n",
srcFileName);
@@ -613,7 +611,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 */
chmod(dstFileName, 00600);
UTIL_chmod(dstFileName, 00600);
}
return f;
}