aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libshare
diff options
context:
space:
mode:
authorнаб <[email protected]>2022-04-17 15:00:15 +0200
committerBrian Behlendorf <[email protected]>2022-05-12 09:27:08 -0700
commit086af23e683c62d24055b46a6b93de78825a5219 (patch)
tree0cb2b8fa46de6de320fb908e06c3945c6f6d6301 /lib/libshare
parent1ec9218faa2f0d11b66ec1eb9d202692b1eec2cd (diff)
linux: libshare/smb: cache smb_available
Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #13165
Diffstat (limited to 'lib/libshare')
-rw-r--r--lib/libshare/os/linux/smb.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/libshare/os/linux/smb.c b/lib/libshare/os/linux/smb.c
index 1f32d0e10..2a2b32bc1 100644
--- a/lib/libshare/os/linux/smb.c
+++ b/lib/libshare/os/linux/smb.c
@@ -378,14 +378,18 @@ const sa_fstype_t libshare_smb_type = {
static boolean_t
smb_available(void)
{
- struct stat statbuf;
+ static int avail;
- if (lstat(SHARE_DIR, &statbuf) != 0 ||
- !S_ISDIR(statbuf.st_mode))
- return (B_FALSE);
+ if (!avail) {
+ struct stat statbuf;
- if (access(NET_CMD_PATH, F_OK) != 0)
- return (B_FALSE);
+ if (access(NET_CMD_PATH, F_OK) != 0 ||
+ lstat(SHARE_DIR, &statbuf) != 0 ||
+ !S_ISDIR(statbuf.st_mode))
+ avail = -1;
+ else
+ avail = 1;
+ }
- return (B_TRUE);
+ return (avail == 1);
}