summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
af909a1)
Delay executing exportfs command until its results are actually
required.
Signed-off-by: Cyril Plisko <cyril.plisko@mountall.com>
Signed-off-by: Gunnar Beutner <gunnar@beutner.name>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
/*
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011 Gunnar Beutner
/*
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011 Gunnar Beutner
+ * Copyright (c) 2012 Cyril Plisko. All rights reserved.
#include <libshare.h>
#include "libshare_impl.h"
#include <libshare.h>
#include "libshare_impl.h"
+static boolean_t nfs_available(void);
+
static sa_fstype_t *nfs_fstype;
static sa_fstype_t *nfs_fstype;
-static boolean_t nfs_available;
/*
* nfs_exportfs_temp_fd refers to a temporary copy of the output
/*
* nfs_exportfs_temp_fd refers to a temporary copy of the output
char *shareopts, *linux_opts;
int rc;
char *shareopts, *linux_opts;
int rc;
+ if (!nfs_available()) {
static int
nfs_disable_share(sa_share_impl_t impl_share)
{
static int
nfs_disable_share(sa_share_impl_t impl_share)
{
+ if (!nfs_available()) {
/*
* The share can't possibly be active, so nothing
* needs to be done to disable it.
/*
* The share can't possibly be active, so nothing
* needs to be done to disable it.
char *tab, *cur;
FILE *nfs_exportfs_temp_fp;
char *tab, *cur;
FILE *nfs_exportfs_temp_fp;
- if (nfs_exportfs_temp_fd < 0)
return B_FALSE;
nfs_exportfs_temp_fp = fdopen(dup(nfs_exportfs_temp_fd), "r");
return B_FALSE;
nfs_exportfs_temp_fp = fdopen(dup(nfs_exportfs_temp_fd), "r");
+ if (pid < 0) {
+ (void) close(nfs_exportfs_temp_fd);
+ nfs_exportfs_temp_fd = -1;
if (pid > 0) {
while ((rc = waitpid(pid, &status, 0)) <= 0 && errno == EINTR)
; /* empty loop body */
if (pid > 0) {
while ((rc = waitpid(pid, &status, 0)) <= 0 && errno == EINTR)
; /* empty loop body */
+ if (rc <= 0) {
+ (void) close(nfs_exportfs_temp_fd);
+ nfs_exportfs_temp_fd = -1;
- if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
+ if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
+ (void) close(nfs_exportfs_temp_fd);
+ nfs_exportfs_temp_fd = -1;
+/*
+ * Provides a convenient wrapper for determing nfs availability
+ */
+static boolean_t
+nfs_available(void)
+{
+ if (nfs_exportfs_temp_fd == -1)
+ (void) nfs_check_exportfs();
+
+ return (nfs_exportfs_temp_fd != -1) ? B_TRUE : B_FALSE;
+}
+
/**
* Initializes the NFS functionality of libshare.
*/
void
libshare_nfs_init(void)
{
/**
* Initializes the NFS functionality of libshare.
*/
void
libshare_nfs_init(void)
{
- nfs_available = (nfs_check_exportfs() == SA_OK);
-
nfs_fstype = register_fstype("nfs", &nfs_shareops);
}
nfs_fstype = register_fstype("nfs", &nfs_shareops);
}