mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
libzfs: use zfs_strerror() in place of strerror()
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de> Signed-off-by: Richard Kojedzinszky <richard@kojedz.in> Closes #15793
This commit is contained in:
committed by
Brian Behlendorf
parent
692f0daba3
commit
401c3563d4
+12
-9
@@ -29,6 +29,7 @@
|
||||
#include <errno.h>
|
||||
#include <libshare.h>
|
||||
#include <unistd.h>
|
||||
#include <libzutil.h>
|
||||
#include "nfs.h"
|
||||
|
||||
|
||||
@@ -45,7 +46,8 @@ nfs_exports_lock(const char *name, int *nfs_lock_fd)
|
||||
*nfs_lock_fd = open(name, O_RDWR | O_CREAT | O_CLOEXEC, 0600);
|
||||
if (*nfs_lock_fd == -1) {
|
||||
err = errno;
|
||||
fprintf(stderr, "failed to lock %s: %s\n", name, strerror(err));
|
||||
fprintf(stderr, "failed to lock %s: %s\n", name,
|
||||
zfs_strerror(err));
|
||||
return (err);
|
||||
}
|
||||
|
||||
@@ -53,7 +55,8 @@ nfs_exports_lock(const char *name, int *nfs_lock_fd)
|
||||
;
|
||||
if (err != 0) {
|
||||
err = errno;
|
||||
fprintf(stderr, "failed to lock %s: %s\n", name, strerror(err));
|
||||
fprintf(stderr, "failed to lock %s: %s\n", name,
|
||||
zfs_strerror(err));
|
||||
(void) close(*nfs_lock_fd);
|
||||
*nfs_lock_fd = -1;
|
||||
return (err);
|
||||
@@ -69,7 +72,7 @@ nfs_exports_unlock(const char *name, int *nfs_lock_fd)
|
||||
|
||||
if (flock(*nfs_lock_fd, LOCK_UN) != 0)
|
||||
fprintf(stderr, "failed to unlock %s: %s\n",
|
||||
name, strerror(errno));
|
||||
name, zfs_strerror(errno));
|
||||
|
||||
(void) close(*nfs_lock_fd);
|
||||
*nfs_lock_fd = -1;
|
||||
@@ -92,7 +95,7 @@ nfs_init_tmpfile(const char *prefix, const char *mdir, struct tmpfile *tmpf)
|
||||
errno != EEXIST) {
|
||||
fprintf(stderr, "failed to create %s: %s\n",
|
||||
// cppcheck-suppress uninitvar
|
||||
mdir, strerror(errno));
|
||||
mdir, zfs_strerror(errno));
|
||||
return (B_FALSE);
|
||||
}
|
||||
|
||||
@@ -102,14 +105,14 @@ nfs_init_tmpfile(const char *prefix, const char *mdir, struct tmpfile *tmpf)
|
||||
int fd = mkostemp(tmpf->name, O_CLOEXEC);
|
||||
if (fd == -1) {
|
||||
fprintf(stderr, "Unable to create temporary file: %s",
|
||||
strerror(errno));
|
||||
zfs_strerror(errno));
|
||||
return (B_FALSE);
|
||||
}
|
||||
|
||||
tmpf->fp = fdopen(fd, "w+");
|
||||
if (tmpf->fp == NULL) {
|
||||
fprintf(stderr, "Unable to reopen temporary file: %s",
|
||||
strerror(errno));
|
||||
zfs_strerror(errno));
|
||||
close(fd);
|
||||
return (B_FALSE);
|
||||
}
|
||||
@@ -129,14 +132,14 @@ nfs_fini_tmpfile(const char *exports, struct tmpfile *tmpf)
|
||||
{
|
||||
if (fflush(tmpf->fp) != 0) {
|
||||
fprintf(stderr, "Failed to write to temporary file: %s\n",
|
||||
strerror(errno));
|
||||
zfs_strerror(errno));
|
||||
nfs_abort_tmpfile(tmpf);
|
||||
return (SA_SYSTEM_ERR);
|
||||
}
|
||||
|
||||
if (rename(tmpf->name, exports) == -1) {
|
||||
fprintf(stderr, "Unable to rename %s -> %s: %s\n",
|
||||
tmpf->name, exports, strerror(errno));
|
||||
tmpf->name, exports, zfs_strerror(errno));
|
||||
nfs_abort_tmpfile(tmpf);
|
||||
return (SA_SYSTEM_ERR);
|
||||
}
|
||||
@@ -213,7 +216,7 @@ nfs_process_exports(const char *exports, const char *mountpoint,
|
||||
|
||||
if (fclose(oldfp) != 0) {
|
||||
fprintf(stderr, "Unable to close file %s: %s\n",
|
||||
exports, strerror(errno));
|
||||
exports, zfs_strerror(errno));
|
||||
error = error != SA_OK ? error : SA_SYSTEM_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user