Print this page
4095 minor cleanup up libshare

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libshare/common/scfutil.c
          +++ new/usr/src/lib/libshare/common/scfutil.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
       27 +/*
       28 + * Copyright (c) 2013 RackTop Systems.
       29 + */
       30 +
  27   31  /* helper functions for using libscf with sharemgr */
  28   32  
  29   33  #include <libscf.h>
  30   34  #include <libxml/parser.h>
  31   35  #include <libxml/tree.h>
  32   36  #include "libshare.h"
  33   37  #include "libshare_impl.h"
  34   38  #include "scfutil.h"
  35   39  #include <string.h>
  36   40  #include <ctype.h>
  37   41  #include <errno.h>
  38   42  #include <uuid/uuid.h>
  39   43  #include <sys/param.h>
  40   44  #include <signal.h>
  41   45  #include <sys/time.h>
  42   46  #include <libintl.h>
  43   47  
  44   48  ssize_t scf_max_name_len;
  45   49  extern struct sa_proto_plugin *sap_proto_list;
  46      -extern sa_handle_impl_t get_handle_for_root(xmlNodePtr);
  47      -static void set_transaction_tstamp(sa_handle_impl_t);
       50 +extern sa_handle_t get_handle_for_root(xmlNodePtr);
       51 +static void set_transaction_tstamp(sa_handle_t);
  48   52  /*
  49   53   * The SMF facility uses some properties that must exist. We want to
  50   54   * skip over these when processing protocol options.
  51   55   */
  52   56  static char *skip_props[] = {
  53   57          "modify_authorization",
  54   58          "action_authorization",
  55   59          "value_authorization",
  56   60          NULL
  57   61  };
↓ open down ↓ 32 lines elided ↑ open up ↑
  90   94  }
  91   95  
  92   96  /*
  93   97   * sa_scf_init()
  94   98   *
  95   99   * Must be called before using any of the SCF functions. Called by
  96  100   * sa_init() during the API setup.
  97  101   */
  98  102  
  99  103  scfutilhandle_t *
 100      -sa_scf_init(sa_handle_impl_t ihandle)
      104 +sa_scf_init(sa_handle_t ihandle)
 101  105  {
 102  106          scfutilhandle_t *handle;
 103  107  
 104  108          scf_max_name_len = scf_limit(SCF_LIMIT_MAX_NAME_LENGTH);
 105  109          if (scf_max_name_len <= 0)
 106  110                  scf_max_name_len = SA_MAX_NAME_LEN + 1;
 107  111  
 108  112          handle = calloc(1, sizeof (scfutilhandle_t));
 109  113          if (handle == NULL)
 110  114                  return (handle);
↓ open down ↓ 23 lines elided ↑ open up ↑
 134  138          if (scf_handle_get_scope(handle->handle,
 135  139              SCF_SCOPE_LOCAL, handle->scope) != 0)
 136  140                  goto err;
 137  141          if (scf_scope_get_service(handle->scope,
 138  142              SA_GROUP_SVC_NAME, handle->service) != 0)
 139  143                  goto err;
 140  144  
 141  145          handle->scf_state = SCH_STATE_INIT;
 142  146          if (sa_get_instance(handle, "default") != SA_OK) {
 143  147                  sa_group_t defgrp;
 144      -                defgrp = sa_create_group((sa_handle_t)ihandle, "default", NULL);
      148 +                defgrp = sa_create_group(ihandle, "default", NULL);
 145  149                  /* Only NFS enabled for "default" group. */
 146  150                  if (defgrp != NULL)
 147  151                          (void) sa_create_optionset(defgrp, "nfs");
 148  152          }
 149  153  
 150  154          return (handle);
 151  155  
 152  156          /* Error handling/unwinding */
 153  157  err:
 154  158          (void) sa_scf_fini(handle);
↓ open down ↓ 1187 lines elided ↑ open up ↑
1342 1346  
1343 1347  
1344 1348  /*
1345 1349   * sa_end_transaction(scfhandle, sahandle)
1346 1350   *
1347 1351   * Commit the changes that were added to the transaction in the
1348 1352   * handle. Do all necessary cleanup.
1349 1353   */
1350 1354  
1351 1355  int
1352      -sa_end_transaction(scfutilhandle_t *handle, sa_handle_impl_t sahandle)
     1356 +sa_end_transaction(scfutilhandle_t *handle, sa_handle_t sahandle)
1353 1357  {
1354 1358          int ret = SA_OK;
1355 1359  
1356 1360          if (handle == NULL || handle->trans == NULL || sahandle == NULL) {
1357 1361                  ret = SA_SYSTEM_ERR;
1358 1362          } else {
1359 1363                  if (scf_transaction_commit(handle->trans) < 0)
1360 1364                          ret = SA_SYSTEM_ERR;
1361 1365                  scf_transaction_destroy_children(handle->trans);
1362 1366                  scf_transaction_destroy(handle->trans);
↓ open down ↓ 22 lines elided ↑ open up ↑
1385 1389          }
1386 1390  }
1387 1391  
1388 1392  /*
1389 1393   * set_transaction_tstamp(sahandle)
1390 1394   *
1391 1395   * After a successful transaction commit, update the timestamp of the
1392 1396   * last transaction. This lets us detect changes from other processes.
1393 1397   */
1394 1398  static void
1395      -set_transaction_tstamp(sa_handle_impl_t sahandle)
     1399 +set_transaction_tstamp(sa_handle_t sahandle)
1396 1400  {
1397 1401          char tstring[32];
1398 1402          struct timeval tv;
1399 1403          scfutilhandle_t *scfhandle;
1400 1404  
1401 1405          if (sahandle == NULL || sahandle->scfhandle == NULL)
1402 1406                  return;
1403 1407  
1404 1408          scfhandle = sahandle->scfhandle;
1405 1409  
↓ open down ↓ 363 lines elided ↑ open up ↑
1769 1773                                  description = sa_get_share_description(share);
1770 1774                                  if (description != NULL) {
1771 1775                                          ret = sa_set_property(handle,
1772 1776                                              "description",
1773 1777                                              description);
1774 1778                                          sa_free_share_description(description);
1775 1779                                  }
1776 1780                          }
1777 1781                          /* Make sure we cleanup the transaction */
1778 1782                          if (ret == SA_OK) {
1779      -                                sa_handle_impl_t sahandle;
1780      -                                sahandle = (sa_handle_impl_t)
1781      -                                    sa_find_group_handle(group);
     1783 +                                sa_handle_t sahandle;
     1784 +                                sahandle = sa_find_group_handle(group);
1782 1785                                  if (sahandle != NULL)
1783 1786                                          ret = sa_end_transaction(handle,
1784 1787                                              sahandle);
1785 1788                                  else
1786 1789                                          ret = SA_SYSTEM_ERR;
1787 1790                          } else {
1788 1791                                  sa_abort_transaction(handle);
1789 1792                          }
1790 1793  
1791 1794                          (void) sigprocmask(SIG_SETMASK, &old, NULL);
↓ open down ↓ 148 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX