From 82e414f1b2e4d3c45d107b79da4a750485038c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Tue, 18 May 2021 18:00:26 +0200 Subject: [PATCH] libshare: nfs: always try to mkdir() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also works out to one syscall if the directory exists, but is one syscall shorter if it doesn't. Reviewed-by: Don Brady Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Ahelenia ZiemiaƄska Closes #12067 --- lib/libshare/nfs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/libshare/nfs.c b/lib/libshare/nfs.c index 153de04c21..980e517cb6 100644 --- a/lib/libshare/nfs.c +++ b/lib/libshare/nfs.c @@ -89,11 +89,9 @@ struct tmpfile { static boolean_t nfs_init_tmpfile(const char *prefix, const char *mdir, struct tmpfile *tmpf) { - struct stat sb; - if (mdir != NULL && - stat(mdir, &sb) < 0 && - mkdir(mdir, 0755) < 0) { + mkdir(mdir, 0755) < 0 && + errno != EEXIST) { fprintf(stderr, "failed to create %s: %s\n", mdir, strerror(errno)); return (B_FALSE);