Print this page
4095 minor cleanup up libshare
*** 19,28 ****
--- 19,29 ----
* CDDL HEADER END
*/
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 RackTop Systems.
*/
/*
* core library for common functions across all config store types
* and file systems to be exported. This includes legacy dfstab/sharetab
*** 88,98 ****
extern char *_sa_get_token(char *);
static void dfs_free_list(xfs_sharelist_t *);
/* prototypes */
void getlegacyconfig(sa_handle_t, char *, xmlNodePtr *);
extern sa_share_t _sa_add_share(sa_group_t, char *, int, int *, uint64_t);
! extern sa_group_t _sa_create_group(sa_handle_impl_t, char *);
static void outdfstab(FILE *, xfs_sharelist_t *);
extern int _sa_remove_optionset(sa_optionset_t);
extern int set_node_share(void *, char *, char *);
extern void set_node_attr(void *, char *, char *);
--- 89,99 ----
extern char *_sa_get_token(char *);
static void dfs_free_list(xfs_sharelist_t *);
/* prototypes */
void getlegacyconfig(sa_handle_t, char *, xmlNodePtr *);
extern sa_share_t _sa_add_share(sa_group_t, char *, int, int *, uint64_t);
! extern sa_group_t _sa_create_group(sa_handle_t, char *);
static void outdfstab(FILE *, xfs_sharelist_t *);
extern int _sa_remove_optionset(sa_optionset_t);
extern int set_node_share(void *, char *, char *);
extern void set_node_attr(void *, char *, char *);
*** 739,752 ****
*
* Check to see if optname is a security (named optionset) specific
* property for the specified protocol.
*/
! int
sa_is_security(char *optname, char *proto)
{
! int ret = 0;
if (proto != NULL)
ret = sa_proto_security_prop(proto, optname);
return (ret);
}
--- 740,753 ----
*
* Check to see if optname is a security (named optionset) specific
* property for the specified protocol.
*/
! boolean_t
sa_is_security(char *optname, char *proto)
{
! int ret = B_FALSE;
if (proto != NULL)
ret = sa_proto_security_prop(proto, optname);
return (ret);
}
*** 773,805 ****
* sa_is_share(object)
*
* returns true of the object is of type "share".
*/
! int
sa_is_share(void *object)
{
if (object != NULL) {
if (strcmp((char *)((xmlNodePtr)object)->name, "share") == 0)
! return (1);
}
! return (0);
}
/*
* sa_is_resource(object)
*
* returns true of the object is of type "share".
*/
! int
sa_is_resource(void *object)
{
if (object != NULL) {
if (strcmp((char *)((xmlNodePtr)object)->name, "resource") == 0)
! return (1);
}
! return (0);
}
/*
* _sa_remove_property(property)
*
--- 774,806 ----
* sa_is_share(object)
*
* returns true of the object is of type "share".
*/
! boolean_t
sa_is_share(void *object)
{
if (object != NULL) {
if (strcmp((char *)((xmlNodePtr)object)->name, "share") == 0)
! return (B_TRUE);
}
! return (B_FALSE);
}
/*
* sa_is_resource(object)
*
* returns true of the object is of type "share".
*/
! boolean_t
sa_is_resource(void *object)
{
if (object != NULL) {
if (strcmp((char *)((xmlNodePtr)object)->name, "resource") == 0)
! return (B_TRUE);
}
! return (B_FALSE);
}
/*
* _sa_remove_property(property)
*
*** 1516,1528 ****
group = sa_create_group(handle,
"zfs", &err);
if (group == NULL &&
err == SA_NO_PERMISSION) {
group = _sa_create_group(
! (sa_handle_impl_t)
! handle,
! "zfs");
}
if (group != NULL) {
(void) sa_create_optionset(
group, tmplist->fstype);
(void) sa_set_group_attr(group,
--- 1517,1527 ----
group = sa_create_group(handle,
"zfs", &err);
if (group == NULL &&
err == SA_NO_PERMISSION) {
group = _sa_create_group(
! handle, "zfs");
}
if (group != NULL) {
(void) sa_create_optionset(
group, tmplist->fstype);
(void) sa_set_group_attr(group,
*** 1573,1598 ****
* Get the transient shares from the sharetab (or other) file. since
* these are transient, they only appear in the working file and not
* in a repository.
*/
int
! gettransients(sa_handle_impl_t ihandle, xmlNodePtr *root)
{
int legacy = 0;
int numproto;
char **protocols = NULL;
int i;
if (root != NULL) {
if (*root == NULL)
*root = xmlNewNode(NULL, (xmlChar *)"sharecfg");
if (*root != NULL) {
! legacy = parse_sharetab(ihandle);
numproto = sa_get_protocols(&protocols);
for (i = 0; i < numproto; i++)
legacy |= sa_proto_get_transients(
! (sa_handle_t)ihandle, protocols[i]);
if (protocols != NULL)
free(protocols);
}
}
return (legacy);
--- 1572,1597 ----
* Get the transient shares from the sharetab (or other) file. since
* these are transient, they only appear in the working file and not
* in a repository.
*/
int
! gettransients(sa_handle_t handle, xmlNodePtr *root)
{
int legacy = 0;
int numproto;
char **protocols = NULL;
int i;
if (root != NULL) {
if (*root == NULL)
*root = xmlNewNode(NULL, (xmlChar *)"sharecfg");
if (*root != NULL) {
! legacy = parse_sharetab(handle);
numproto = sa_get_protocols(&protocols);
for (i = 0; i < numproto; i++)
legacy |= sa_proto_get_transients(
! handle, protocols[i]);
if (protocols != NULL)
free(protocols);
}
}
return (legacy);
*** 2087,2100 ****
void
sa_update_sharetab_ts(sa_handle_t handle)
{
struct stat st;
- sa_handle_impl_t implhandle = (sa_handle_impl_t)handle;
! if (implhandle != NULL && stat(SA_LEGACY_SHARETAB, &st) == 0)
! implhandle->tssharetab = TSTAMP(st.st_mtim);
}
/*
* sa_update_sharetab(share, proto)
*
--- 2086,2098 ----
void
sa_update_sharetab_ts(sa_handle_t handle)
{
struct stat st;
! if (handle != NULL && stat(SA_LEGACY_SHARETAB, &st) == 0)
! handle->tssharetab = TSTAMP(st.st_mtim);
}
/*
* sa_update_sharetab(share, proto)
*
*** 2173,2183 ****
* change by another process. B_FALSE returned otherwise.
*/
boolean_t
sa_needs_refresh(sa_handle_t handle)
{
- sa_handle_impl_t implhandle = (sa_handle_impl_t)handle;
struct stat st;
char *str;
uint64_t tstamp;
scf_simple_prop_t *prop;
--- 2171,2180 ----
*** 2189,2217 ****
* change. Check sharetab first since it is updated by ZFS as
* well as sharemgr. This is where external ZFS changes are
* caught.
*/
if (stat(SA_LEGACY_SHARETAB, &st) == 0 &&
! TSTAMP(st.st_mtim) != implhandle->tssharetab)
return (B_TRUE);
/*
* If sharetab wasn't changed, check whether there were any
* SMF transactions that modified the config but didn't
* initiate a share. This is less common but does happen.
*/
! prop = scf_simple_prop_get(implhandle->scfhandle->handle,
(const char *)SA_SVC_FMRI_BASE ":default", "state",
"lastupdate");
if (prop != NULL) {
str = scf_simple_prop_next_astring(prop);
if (str != NULL)
tstamp = strtoull(str, NULL, 0);
else
tstamp = 0;
scf_simple_prop_free(prop);
! if (tstamp != implhandle->tstrans)
return (B_TRUE);
}
return (B_FALSE);
}
--- 2186,2214 ----
* change. Check sharetab first since it is updated by ZFS as
* well as sharemgr. This is where external ZFS changes are
* caught.
*/
if (stat(SA_LEGACY_SHARETAB, &st) == 0 &&
! TSTAMP(st.st_mtim) != handle->tssharetab)
return (B_TRUE);
/*
* If sharetab wasn't changed, check whether there were any
* SMF transactions that modified the config but didn't
* initiate a share. This is less common but does happen.
*/
! prop = scf_simple_prop_get(handle->scfhandle->handle,
(const char *)SA_SVC_FMRI_BASE ":default", "state",
"lastupdate");
if (prop != NULL) {
str = scf_simple_prop_next_astring(prop);
if (str != NULL)
tstamp = strtoull(str, NULL, 0);
else
tstamp = 0;
scf_simple_prop_free(prop);
! if (tstamp != handle->tstrans)
return (B_TRUE);
}
return (B_FALSE);
}