Print this page
4095 minor cleanup up libshare

@@ -19,10 +19,11 @@
  * 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,11 +89,11 @@
 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 *);
+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,14 +740,14 @@
  *
  * Check to see if optname is a security (named optionset) specific
  * property for the specified protocol.
  */
 
-int
+boolean_t
 sa_is_security(char *optname, char *proto)
 {
-        int ret = 0;
+        int ret = B_FALSE;
         if (proto != NULL)
                 ret = sa_proto_security_prop(proto, optname);
         return (ret);
 }
 

@@ -773,33 +774,33 @@
  * sa_is_share(object)
  *
  * returns true of the object is of type "share".
  */
 
-int
+boolean_t
 sa_is_share(void *object)
 {
         if (object != NULL) {
                 if (strcmp((char *)((xmlNodePtr)object)->name, "share") == 0)
-                return (1);
+                return (B_TRUE);
         }
-        return (0);
+        return (B_FALSE);
 }
 /*
  * sa_is_resource(object)
  *
  * returns true of the object is of type "share".
  */
 
-int
+boolean_t
 sa_is_resource(void *object)
 {
         if (object != NULL) {
                 if (strcmp((char *)((xmlNodePtr)object)->name, "resource") == 0)
-                        return (1);
+                        return (B_TRUE);
         }
-        return (0);
+        return (B_FALSE);
 }
 
 /*
  * _sa_remove_property(property)
  *

@@ -1516,13 +1517,11 @@
                                         group = sa_create_group(handle,
                                             "zfs", &err);
                                         if (group == NULL &&
                                             err == SA_NO_PERMISSION) {
                                                 group = _sa_create_group(
-                                                    (sa_handle_impl_t)
-                                                    handle,
-                                                    "zfs");
+                                                    handle, "zfs");
                                         }
                                         if (group != NULL) {
                                                 (void) sa_create_optionset(
                                                     group, tmplist->fstype);
                                                 (void) sa_set_group_attr(group,

@@ -1573,26 +1572,26 @@
  * 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)
+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(ihandle);
+                        legacy = parse_sharetab(handle);
                         numproto = sa_get_protocols(&protocols);
                         for (i = 0; i < numproto; i++)
                                 legacy |= sa_proto_get_transients(
-                                    (sa_handle_t)ihandle, protocols[i]);
+                                    handle, protocols[i]);
                         if (protocols != NULL)
                                 free(protocols);
                 }
         }
         return (legacy);

@@ -2087,14 +2086,13 @@
 
 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);
+        if (handle != NULL && stat(SA_LEGACY_SHARETAB, &st) == 0)
+                handle->tssharetab = TSTAMP(st.st_mtim);
 }
 
 /*
  * sa_update_sharetab(share, proto)
  *

@@ -2173,11 +2171,10 @@
  * 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;
 

@@ -2189,29 +2186,29 @@
          * 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)
+            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(implhandle->scfhandle->handle,
+        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 != implhandle->tstrans)
+                if (tstamp != handle->tstrans)
                         return (B_TRUE);
         }
 
         return (B_FALSE);
 }