libshare: nfs: always try to mkdir()

This also works out to one syscall if the directory exists,
but is one syscall shorter if it doesn't.

Reviewed-by: Don Brady <don.brady@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12067
This commit is contained in:
наб 2021-05-18 18:00:26 +02:00 committed by Brian Behlendorf
parent 1e78b4eee0
commit 82e414f1b2
1 changed files with 2 additions and 4 deletions

View File

@ -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);