Skip to content

Commit

Permalink
libshare: nfs: always try to mkdir()
Browse files Browse the repository at this point in the history
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 openzfs#12067
  • Loading branch information
nabijaczleweli authored and nicman23 committed Aug 22, 2022
1 parent d392592 commit 1a57d40
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/libshare/nfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1a57d40

Please sign in to comment.