libshare.c revision f345c0beb4c8f75cb54c2e070498e56febd468ac
6185db853e024a486ff8837e6784dd290d866112dougm * CDDL HEADER START
6185db853e024a486ff8837e6784dd290d866112dougm * The contents of this file are subject to the terms of the
6185db853e024a486ff8837e6784dd290d866112dougm * Common Development and Distribution License (the "License").
6185db853e024a486ff8837e6784dd290d866112dougm * You may not use this file except in compliance with the License.
6185db853e024a486ff8837e6784dd290d866112dougm * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
6185db853e024a486ff8837e6784dd290d866112dougm * See the License for the specific language governing permissions
6185db853e024a486ff8837e6784dd290d866112dougm * and limitations under the License.
6185db853e024a486ff8837e6784dd290d866112dougm * When distributing Covered Code, include this CDDL HEADER in each
6185db853e024a486ff8837e6784dd290d866112dougm * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
6185db853e024a486ff8837e6784dd290d866112dougm * If applicable, add the following below this CDDL HEADER, with the
6185db853e024a486ff8837e6784dd290d866112dougm * fields enclosed by brackets "[]" replaced with your own identifying
6185db853e024a486ff8837e6784dd290d866112dougm * information: Portions Copyright [yyyy] [name of copyright owner]
6185db853e024a486ff8837e6784dd290d866112dougm * CDDL HEADER END
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
6185db853e024a486ff8837e6784dd290d866112dougm * Use is subject to license terms.
6185db853e024a486ff8837e6784dd290d866112dougm#pragma ident "%Z%%M% %I% %E% SMI"
6185db853e024a486ff8837e6784dd290d866112dougm * Share control API
6185db853e024a486ff8837e6784dd290d866112dougm#define TSTAMP(tm) (uint64_t)(((uint64_t)tm.tv_sec << 32) | \
6185db853e024a486ff8837e6784dd290d866112dougm * internal data structures
6185db853e024a486ff8837e6784dd290d866112dougmstatic xmlNodePtr sa_config_tree; /* the current config */
6185db853e024a486ff8837e6784dd290d866112dougmstatic xmlDocPtr sa_config_doc = NULL; /* current config document */
6185db853e024a486ff8837e6784dd290d866112dougm/* current SMF/SVC repository handle */
6185db853e024a486ff8837e6784dd290d866112dougmextern int sa_valid_property(void *, char *, sa_property_t);
6185db853e024a486ff8837e6784dd290d866112dougmextern char *sa_fstype(char *);
6185db853e024a486ff8837e6784dd290d866112dougmextern int sa_is_share(void *);
6185db853e024a486ff8837e6784dd290d866112dougmextern ssize_t scf_max_name_len; /* defined in scfutil during initialization */
6185db853e024a486ff8837e6784dd290d866112dougmextern int sa_path_is_zfs(char *);
6185db853e024a486ff8837e6784dd290d866112dougmextern int sa_zfs_set_sharenfs(sa_group_t, char *, int);
6185db853e024a486ff8837e6784dd290d866112dougmextern void update_legacy_config(void);
6185db853e024a486ff8837e6784dd290d866112dougmextern int issubdir(char *, char *);
1cea05af420c1992d793dc442f4e30c7269fc107dougmextern void sa_zfs_init(void);
1cea05af420c1992d793dc442f4e30c7269fc107dougmextern void sa_zfs_fini(void);
6185db853e024a486ff8837e6784dd290d866112dougmstatic int sa_initialized = 0;
6185db853e024a486ff8837e6784dd290d866112dougm/* helper functions */
6185db853e024a486ff8837e6784dd290d866112dougm switch (err) {
6185db853e024a486ff8837e6784dd290d866112dougm * get_legacy_timestamp(root, path)
6185db853e024a486ff8837e6784dd290d866112dougm * gets the timestamp of the last time sharemgr updated the legacy
6185db853e024a486ff8837e6784dd290d866112dougm * files. This is used to determine if someone has modified them by
6185db853e024a486ff8837e6784dd290d866112dougm if (xmlStrcmp(node->name, (xmlChar *)"legacy") == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm /* a possible legacy node for this path */
6185db853e024a486ff8837e6784dd290d866112dougm if (lpath != NULL && xmlStrcmp(lpath, (xmlChar *)path) == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm /* now have the node, extract the data */
6185db853e024a486ff8837e6784dd290d866112dougm * set_legacy_timestamp(root, path, timevalue)
6185db853e024a486ff8837e6784dd290d866112dougm * add the current timestamp value to the configuration for use in
6185db853e024a486ff8837e6784dd290d866112dougm * determining when to update the legacy files. For SMF, this
6185db853e024a486ff8837e6784dd290d866112dougm * property is kept in default/operation/legacy_timestamp
6185db853e024a486ff8837e6784dd290d866112dougmset_legacy_timestamp(xmlNodePtr root, char *path, uint64_t tval)
6185db853e024a486ff8837e6784dd290d866112dougm if (xmlStrcmp(node->name, (xmlChar *)"legacy") == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm /* a possible legacy node for this path */
6185db853e024a486ff8837e6784dd290d866112dougm if (lpath != NULL && xmlStrcmp(lpath, (xmlChar *)path) == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm /* need to create the first legacy timestamp node */
6185db853e024a486ff8837e6784dd290d866112dougm node = xmlNewChild(root, NULL, (xmlChar *)"legacy", NULL);
6185db853e024a486ff8837e6784dd290d866112dougm (void) snprintf(tstring, sizeof (tstring), "%lld", tval);
6185db853e024a486ff8837e6784dd290d866112dougm xmlSetProp(node, (xmlChar *)"timestamp", (xmlChar *)tstring);
6185db853e024a486ff8837e6784dd290d866112dougm /* now commit to SMF */
6185db853e024a486ff8837e6784dd290d866112dougm * is_shared(share)
6185db853e024a486ff8837e6784dd290d866112dougm * determine if the specified share is currently shared or not.
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * checksubdir(newpath, strictness)
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * checksubdir determines if the specified path (newpath) is a
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * subdirectory of another share. It calls issubdir() from the old
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * share implementation to do the complicated work. The strictness
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * parameter determines how strict a check to make against the
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * path. The strictness values mean:
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * SA_CHECK_NORMAL == only check newpath against shares that are active
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * SA_CHECK_STRICT == check newpath against both active shares and those
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * stored in the repository
6185db853e024a486ff8837e6784dd290d866112dougm for (share = sa_get_share(group, NULL); share != NULL;
6185db853e024a486ff8837e6784dd290d866112dougm * The original behavior of share never checked
6185db853e024a486ff8837e6784dd290d866112dougm * against the permanent configuration
6185db853e024a486ff8837e6784dd290d866112dougm * (/etc/dfs/dfstab). PIT has a number of cases where
6185db853e024a486ff8837e6784dd290d866112dougm * it depends on this older behavior even though it
6185db853e024a486ff8837e6784dd290d866112dougm * could be considered incorrect. We may tighten this
6185db853e024a486ff8837e6784dd290d866112dougm * up in the future.
f345c0beb4c8f75cb54c2e070498e56febd468acdougm if (strictness == SA_CHECK_NORMAL && !is_shared(share))
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * If path is NULL, then a share is in the process of
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * construction or someone has modified the property
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * group inappropriately. It should be ignored.
6185db853e024a486ff8837e6784dd290d866112dougm (strcmp(path, newpath) == 0 || issubdir(newpath, path) ||
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * validpath(path, strictness)
6185db853e024a486ff8837e6784dd290d866112dougm * determine if the provided path is valid for a share. It shouldn't
6185db853e024a486ff8837e6784dd290d866112dougm * be a sub-dir of an already shared path or the parent directory of a
6185db853e024a486ff8837e6784dd290d866112dougm * share path.
6185db853e024a486ff8837e6784dd290d866112dougm * check for special case with file system that might
6185db853e024a486ff8837e6784dd290d866112dougm * have restrictions. For now, ZFS is the only case
6185db853e024a486ff8837e6784dd290d866112dougm * since it has its own idea of how to configure
6185db853e024a486ff8837e6784dd290d866112dougm * shares. We do this before subdir checking since
6185db853e024a486ff8837e6784dd290d866112dougm * things like ZFS will do that for us. This should
6185db853e024a486ff8837e6784dd290d866112dougm * also be done via plugin interface.
6185db853e024a486ff8837e6784dd290d866112dougm * check to see if group/share is persistent.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_valid_group_name(name)
6185db853e024a486ff8837e6784dd290d866112dougm * check that the "name" contains only valid characters and otherwise
6185db853e024a486ff8837e6784dd290d866112dougm * fits the required naming conventions. Valid names must start with
6185db853e024a486ff8837e6784dd290d866112dougm * an alphabetic and the remainder may consist of only alphanumeric
6185db853e024a486ff8837e6784dd290d866112dougm * plus the '-' and '_' characters. This name limitation comes from
6185db853e024a486ff8837e6784dd290d866112dougm * inherent limitations in SMF.
6185db853e024a486ff8837e6784dd290d866112dougm for (c = *name++; c != '\0' && ret != 0; c = *name++) {
6185db853e024a486ff8837e6784dd290d866112dougm * is_zfs_group(group)
6185db853e024a486ff8837e6784dd290d866112dougm * Determine if the specified group is a ZFS sharenfs group
6185db853e024a486ff8837e6784dd290d866112dougm if (strcmp((char *)((xmlNodePtr)group)->name, "share") == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm * sa_optionset_name(optionset, oname, len, id)
6185db853e024a486ff8837e6784dd290d866112dougm * return the SMF name for the optionset. If id is not NULL, it
6185db853e024a486ff8837e6784dd290d866112dougm * will have the GUID value for a share and should be used
6185db853e024a486ff8837e6784dd290d866112dougm * instead of the keyword "optionset" which is used for
6185db853e024a486ff8837e6784dd290d866112dougm * groups. If the optionset doesn't have a protocol type
6185db853e024a486ff8837e6784dd290d866112dougm * associated with it, "default" is used. This shouldn't happen
6185db853e024a486ff8837e6784dd290d866112dougm * at this point but may be desirable in the future if there are
6185db853e024a486ff8837e6784dd290d866112dougm * protocol independent properties added. The name is returned in
6185db853e024a486ff8837e6784dd290d866112dougmsa_optionset_name(sa_optionset_t optionset, char *oname, size_t len, char *id)
6185db853e024a486ff8837e6784dd290d866112dougm len = snprintf(oname, len, "%s_%s", id, proto ? proto : "default");
6185db853e024a486ff8837e6784dd290d866112dougm * sa_security_name(optionset, oname, len, id)
6185db853e024a486ff8837e6784dd290d866112dougm * return the SMF name for the security. If id is not NULL, it will
6185db853e024a486ff8837e6784dd290d866112dougm * have the GUID value for a share and should be used instead of the
6185db853e024a486ff8837e6784dd290d866112dougm * keyword "optionset" which is used for groups. If the optionset
6185db853e024a486ff8837e6784dd290d866112dougm * doesn't have a protocol type associated with it, "default" is
6185db853e024a486ff8837e6784dd290d866112dougm * used. This shouldn't happen at this point but may be desirable in
6185db853e024a486ff8837e6784dd290d866112dougm * the future if there are protocol independent properties added. The
6185db853e024a486ff8837e6784dd290d866112dougm * name is returned in oname. The security type is also encoded into
6185db853e024a486ff8837e6784dd290d866112dougm * the name. In the future, this wil *be handled a bit differently.
6185db853e024a486ff8837e6784dd290d866112dougmsa_security_name(sa_security_t security, char *oname, size_t len, char *id)
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * sa_init(init_service)
6185db853e024a486ff8837e6784dd290d866112dougm * Initialize the API
6185db853e024a486ff8837e6784dd290d866112dougm * find all the shared objects
6185db853e024a486ff8837e6784dd290d866112dougm * init the tables with all objects
6185db853e024a486ff8837e6784dd290d866112dougm * read in the current configuration
6185db853e024a486ff8837e6784dd290d866112dougm /* get protocol specific structures */
1cea05af420c1992d793dc442f4e30c7269fc107dougm * initialize access into libzfs. We use this when
1cea05af420c1992d793dc442f4e30c7269fc107dougm * collecting info about ZFS datasets and shares.
6185db853e024a486ff8837e6784dd290d866112dougm * since we want to use SMF, initialize an svc handle
6185db853e024a486ff8837e6784dd290d866112dougm * and find out what is there.
6185db853e024a486ff8837e6784dd290d866112dougm if (tval == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm /* first time so make sure default is setup */
6185db853e024a486ff8837e6784dd290d866112dougm /* NFS is the default for default */
6185db853e024a486ff8837e6784dd290d866112dougm * sa_fini()
6185db853e024a486ff8837e6784dd290d866112dougm * Uninitialize the API structures including the configuration
1cea05af420c1992d793dc442f4e30c7269fc107dougm * data structures and ZFS related data.
6185db853e024a486ff8837e6784dd290d866112dougm /* free the config trees */
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_protocols(char **protocol)
6185db853e024a486ff8837e6784dd290d866112dougm * Get array of protocols that are supported
6185db853e024a486ff8837e6784dd290d866112dougm * Returns pointer to an allocated and NULL terminated
6185db853e024a486ff8837e6784dd290d866112dougm * array of strings. Caller must free.
6185db853e024a486ff8837e6784dd290d866112dougm * This really should be determined dynamically.
6185db853e024a486ff8837e6784dd290d866112dougm * If there aren't any defined, return -1.
6185db853e024a486ff8837e6784dd290d866112dougm * Use free() to return memory.
6185db853e024a486ff8837e6784dd290d866112dougm for (numproto = 0, plug = sap_proto_list; plug != NULL;
6185db853e024a486ff8837e6784dd290d866112dougm /* faking for now */
6185db853e024a486ff8837e6784dd290d866112dougm * find_group_by_name(node, group)
6185db853e024a486ff8837e6784dd290d866112dougm * search the XML document subtree specified by node to find the group
6185db853e024a486ff8837e6784dd290d866112dougm * specified by group. Searching subtree allows subgroups to be
6185db853e024a486ff8837e6784dd290d866112dougm * searched for.
6185db853e024a486ff8837e6784dd290d866112dougm /* if no groupname, return the first found */
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_group(groupname)
6185db853e024a486ff8837e6784dd290d866112dougm * Return the "group" specified. If groupname is NULL,
6185db853e024a486ff8837e6784dd290d866112dougm * return the first group of the list of groups.
6185db853e024a486ff8837e6784dd290d866112dougm node = find_group_by_name(sa_config_tree, (xmlChar *)group);
6185db853e024a486ff8837e6784dd290d866112dougm /* if a subgroup, find it before returning */
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_next_group(group)
6185db853e024a486ff8837e6784dd290d866112dougm * Return the "next" group after the specified group from
6185db853e024a486ff8837e6784dd290d866112dougm * the internal group list. NULL if there are no more.
6185db853e024a486ff8837e6784dd290d866112dougm for (ngroup = ((xmlNodePtr)group)->next; ngroup != NULL;
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_share(group, sharepath)
6185db853e024a486ff8837e6784dd290d866112dougm * Return the share object for the share specified. The share
6185db853e024a486ff8837e6784dd290d866112dougm * must be in the specified group. Return NULL if not found.
6185db853e024a486ff8837e6784dd290d866112dougm * For future scalability, this should end up building a cache
6185db853e024a486ff8837e6784dd290d866112dougm * since it will get called regularly by the mountd and info
6185db853e024a486ff8837e6784dd290d866112dougm * services.
6185db853e024a486ff8837e6784dd290d866112dougm for (node = ((xmlNodePtr)group)->children; node != NULL;
6185db853e024a486ff8837e6784dd290d866112dougm /* is it the correct share? */
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_next_share(share)
6185db853e024a486ff8837e6784dd290d866112dougm * Return the next share following the specified share
6185db853e024a486ff8837e6784dd290d866112dougm * from the internal list of shares. Returns NULL if there
6185db853e024a486ff8837e6784dd290d866112dougm * are no more shares. The list is relative to the same
6185db853e024a486ff8837e6784dd290d866112dougm * _sa_get_child_node(node, type)
6185db853e024a486ff8837e6784dd290d866112dougm * find the child node of the specified node that has "type". This is
6185db853e024a486ff8837e6784dd290d866112dougm * used to implement several internal functions.
6185db853e024a486ff8837e6784dd290d866112dougm * find_share(group, path)
6185db853e024a486ff8837e6784dd290d866112dougm * Search all the shares in the specified group for one that has the
6185db853e024a486ff8837e6784dd290d866112dougm * specified path.
6185db853e024a486ff8837e6784dd290d866112dougm for (share = sa_get_share(group, NULL); share != NULL;
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_sub_group(group)
6185db853e024a486ff8837e6784dd290d866112dougm * Get the first sub-group of group. The sa_get_next_group() function
6185db853e024a486ff8837e6784dd290d866112dougm * can be used to get the rest. This is currently only used for ZFS
6185db853e024a486ff8837e6784dd290d866112dougm * sub-groups but could be used to implement a more general mechanism.
6185db853e024a486ff8837e6784dd290d866112dougm return ((sa_group_t)_sa_get_child_node((xmlNodePtr)group,
6185db853e024a486ff8837e6784dd290d866112dougm * sa_find_share(sharepath)
6185db853e024a486ff8837e6784dd290d866112dougm * Finds a share regardless of group. In the future, this
6185db853e024a486ff8837e6784dd290d866112dougm * function should utilize a cache and hash table of some kind.
6185db853e024a486ff8837e6784dd290d866112dougm * The current assumption is that a path will only be shared
6185db853e024a486ff8837e6784dd290d866112dougm * once. In the future, this may change as implementation of
6185db853e024a486ff8837e6784dd290d866112dougm * resource names comes into being.
6185db853e024a486ff8837e6784dd290d866112dougm for (group = sa_get_group(NULL); group != NULL && !done;
6185db853e024a486ff8837e6784dd290d866112dougm for (zgroup = (sa_group_t)_sa_get_child_node((xmlNodePtr)group,
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * sa_check_path(group, path, strictness)
6185db853e024a486ff8837e6784dd290d866112dougm * check that path is a valid path relative to the group. Currently,
6185db853e024a486ff8837e6784dd290d866112dougm * we are ignoring the group and checking only the NFS rules. Later,
6185db853e024a486ff8837e6784dd290d866112dougm * we may want to use the group to then check against the protocols
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * enabled on the group. The strictness values mean:
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * SA_CHECK_NORMAL == only check newpath against shares that are active
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * SA_CHECK_STRICT == check newpath against both active shares and those
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * stored in the repository
f345c0beb4c8f75cb54c2e070498e56febd468acdougmsa_check_path(sa_group_t group, char *path, int strictness)
6185db853e024a486ff8837e6784dd290d866112dougm * _sa_add_share(group, sharepath, persist, *error)
6185db853e024a486ff8837e6784dd290d866112dougm * common code for all types of add_share. sa_add_share() is the
6185db853e024a486ff8837e6784dd290d866112dougm * public API, we also need to be able to do this when parsing legacy
6185db853e024a486ff8837e6784dd290d866112dougm * files and construction of the internal configuration while
6185db853e024a486ff8837e6784dd290d866112dougm * extracting config info from SMF.
6185db853e024a486ff8837e6784dd290d866112dougm_sa_add_share(sa_group_t group, char *sharepath, int persist, int *error)
6185db853e024a486ff8837e6784dd290d866112dougm xmlSetProp(node, (xmlChar *)"path", (xmlChar *)sharepath);
6185db853e024a486ff8837e6784dd290d866112dougm * persistent shares come in two flavors: SMF and
6185db853e024a486ff8837e6784dd290d866112dougm * ZFS. Sort this one out based on target group and
6185db853e024a486ff8837e6784dd290d866112dougm * path type. Currently, only NFS is supported in the
6185db853e024a486ff8837e6784dd290d866112dougm * ZFS group and it is always on.
6185db853e024a486ff8837e6784dd290d866112dougm if (sa_group_is_zfs(group) && sa_path_is_zfs(sharepath)) {
6185db853e024a486ff8837e6784dd290d866112dougm if (err == SA_NO_PERMISSION && persist & SA_SHARE_PARSER) {
6185db853e024a486ff8837e6784dd290d866112dougm /* called by the dfstab parser so could be a show */
6185db853e024a486ff8837e6784dd290d866112dougm * we couldn't commit to the repository so undo
6185db853e024a486ff8837e6784dd290d866112dougm * our internal state to reflect reality.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_add_share(group, sharepath, persist, *error)
6185db853e024a486ff8837e6784dd290d866112dougm * Add a new share object to the specified group. The share will
6185db853e024a486ff8837e6784dd290d866112dougm * have the specified sharepath and will only be constructed if
6185db853e024a486ff8837e6784dd290d866112dougm * it is a valid path to be shared. NULL is returned on error
6185db853e024a486ff8837e6784dd290d866112dougm * and a detailed error value will be returned via the error
6185db853e024a486ff8837e6784dd290d866112dougmsa_add_share(sa_group_t group, char *sharepath, int persist, int *error)
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * If the share is to be permanent, use strict checking so a
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * bad config doesn't get created. Transient shares only need
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * to check against the currently active
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * shares. SA_SHARE_PARSER is a modifier used internally to
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * indicate that we are being called by the dfstab parser and
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * that we need strict checking in all cases. Normally persist
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * is in integer value but SA_SHARE_PARSER may be or'd into
f345c0beb4c8f75cb54c2e070498e56febd468acdougm * it as an override.
f345c0beb4c8f75cb54c2e070498e56febd468acdougm if (persist & SA_SHARE_PARSER || persist == SA_SHARE_PERMANENT)
f345c0beb4c8f75cb54c2e070498e56febd468acdougm (*error = sa_check_path(group, sharepath, strictness)) ==
6185db853e024a486ff8837e6784dd290d866112dougm node = _sa_add_share(group, sharepath, persist, error);
6185db853e024a486ff8837e6784dd290d866112dougm * sa_enable_share(share, protocol)
6185db853e024a486ff8837e6784dd290d866112dougm * Enable the specified share to the specified protocol.
6185db853e024a486ff8837e6784dd290d866112dougm * If protocol is NULL, then all protocols.
6185db853e024a486ff8837e6784dd290d866112dougm /* tell the server about the share */
6185db853e024a486ff8837e6784dd290d866112dougm /* lookup protocol specific handler */
6185db853e024a486ff8837e6784dd290d866112dougm /* tell all protocols */
6185db853e024a486ff8837e6784dd290d866112dougm err = sa_proto_share("nfs", share); /* only NFS for now */
6185db853e024a486ff8837e6784dd290d866112dougm * sa_disable_share(share, protocol)
6185db853e024a486ff8837e6784dd290d866112dougm * Disable the specified share to the specified protocol.
6185db853e024a486ff8837e6784dd290d866112dougm * If protocol is NULL, then all protocols.
6185db853e024a486ff8837e6784dd290d866112dougm /* need to do all protocols */
6185db853e024a486ff8837e6784dd290d866112dougm * sa_remove_share(share)
6185db853e024a486ff8837e6784dd290d866112dougm * remove the specified share from its containing group.
6185db853e024a486ff8837e6784dd290d866112dougm * Remove from the SMF or ZFS configuration space.
6185db853e024a486ff8837e6784dd290d866112dougm /* remove the node from its group then free the memory */
6185db853e024a486ff8837e6784dd290d866112dougm * need to test if "busy"
6185db853e024a486ff8837e6784dd290d866112dougm /* only do SMF action if permanent */
6185db853e024a486ff8837e6784dd290d866112dougm /* remove from legacy dfstab as well as possible SMF */
6185db853e024a486ff8837e6784dd290d866112dougm * sa_move_share(group, share)
6185db853e024a486ff8837e6784dd290d866112dougm * move the specified share to the specified group. Update SMF
6185db853e024a486ff8837e6784dd290d866112dougm * appropriately.
6185db853e024a486ff8837e6784dd290d866112dougm /* remove the node from its group then free the memory */
6185db853e024a486ff8837e6784dd290d866112dougm /* now that the share isn't in its old group, add to the new one */
6185db853e024a486ff8837e6784dd290d866112dougm /* need to deal with SMF */
6185db853e024a486ff8837e6784dd290d866112dougm * need to remove from old group first and then add to
6185db853e024a486ff8837e6784dd290d866112dougm * new group. Ideally, we would do the other order but
6185db853e024a486ff8837e6784dd290d866112dougm * need to avoid having the share in two groups at the
6185db853e024a486ff8837e6784dd290d866112dougm * same time.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_parent_group(share)
6185db853e024a486ff8837e6784dd290d866112dougm * Return the containg group for the share. If a group was actually
6185db853e024a486ff8837e6784dd290d866112dougm * passed in, we don't want a parent so return NULL.
6185db853e024a486ff8837e6784dd290d866112dougm * make sure parent is a group and not sharecfg since
6185db853e024a486ff8837e6784dd290d866112dougm * we may be cheating and passing in a group.
6185db853e024a486ff8837e6784dd290d866112dougm * Eventually, groups of groups might come into being.
6185db853e024a486ff8837e6784dd290d866112dougm * _sa_create_group(groupname)
6185db853e024a486ff8837e6784dd290d866112dougm * Create a group in the document. The caller will need to deal with
6185db853e024a486ff8837e6784dd290d866112dougm * configuration store and activation.
6185db853e024a486ff8837e6784dd290d866112dougm xmlSetProp(node, (xmlChar *)"name", (xmlChar *)groupname);
6185db853e024a486ff8837e6784dd290d866112dougm xmlSetProp(node, (xmlChar *)"state", (xmlChar *)"enabled");
6185db853e024a486ff8837e6784dd290d866112dougm * _sa_create_zfs_group(group, groupname)
6185db853e024a486ff8837e6784dd290d866112dougm * Create a ZFS subgroup under the specified group. This may
6185db853e024a486ff8837e6784dd290d866112dougm * eventually form the basis of general sub-groups, but is currently
6185db853e024a486ff8837e6784dd290d866112dougm * restricted to ZFS.
6185db853e024a486ff8837e6784dd290d866112dougm_sa_create_zfs_group(sa_group_t group, char *groupname)
6185db853e024a486ff8837e6784dd290d866112dougm xmlSetProp(node, (xmlChar *)"name", (xmlChar *)groupname);
6185db853e024a486ff8837e6784dd290d866112dougm xmlSetProp(node, (xmlChar *)"state", (xmlChar *)"enabled");
6185db853e024a486ff8837e6784dd290d866112dougm * sa_create_group(groupname, *error)
6185db853e024a486ff8837e6784dd290d866112dougm * Create a new group with groupname. Need to validate that it is a
6185db853e024a486ff8837e6784dd290d866112dougm * legal name for SMF and the construct the SMF service instance of
6185db853e024a486ff8837e6784dd290d866112dougm * svc:/network/shares/group to implement the group. All necessary
6185db853e024a486ff8837e6784dd290d866112dougm * operational properties must be added to the group at this point
6185db853e024a486ff8837e6784dd290d866112dougm * (via the SMF transaction model).
6185db853e024a486ff8837e6784dd290d866112dougm xmlSetProp(node, (xmlChar *)"name", (xmlChar *)groupname);
6185db853e024a486ff8837e6784dd290d866112dougm /* default to the group being enabled */
6185db853e024a486ff8837e6784dd290d866112dougm xmlSetProp(node, (xmlChar *)"state", (xmlChar *)"enabled");
6185db853e024a486ff8837e6784dd290d866112dougm ret = sa_set_property(scf_handle, "state", "enabled");
6185db853e024a486ff8837e6784dd290d866112dougm /* initialize the RBAC strings */
6185db853e024a486ff8837e6784dd290d866112dougm "action_authorization",
6185db853e024a486ff8837e6784dd290d866112dougm "value_authorization",
6185db853e024a486ff8837e6784dd290d866112dougm * Couldn't commit the group so we need to
6185db853e024a486ff8837e6784dd290d866112dougm * undo internally.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_remove_group(group)
6185db853e024a486ff8837e6784dd290d866112dougm * Remove the specified group. This deletes from the SMF repository.
6185db853e024a486ff8837e6784dd290d866112dougm * All property groups and properties are removed.
6185db853e024a486ff8837e6784dd290d866112dougm xmlUnlinkNode((xmlNodePtr)group); /* make sure unlinked */
6185db853e024a486ff8837e6784dd290d866112dougm * sa_update_config()
6185db853e024a486ff8837e6784dd290d866112dougm * Used to update legacy files that need to be updated in bulk
6185db853e024a486ff8837e6784dd290d866112dougm * Currently, this is a placeholder and will go away in a future
6185db853e024a486ff8837e6784dd290d866112dougm * do legacy files first so we can tell when they change.
6185db853e024a486ff8837e6784dd290d866112dougm * This will go away when we start updating individual records
6185db853e024a486ff8837e6784dd290d866112dougm * rather than the whole file.
6185db853e024a486ff8837e6784dd290d866112dougm * get_node_attr(node, tag)
6185db853e024a486ff8837e6784dd290d866112dougm * Get the speficied tag(attribute) if it exists on the node. This is
6185db853e024a486ff8837e6784dd290d866112dougm * used internally by a number of attribute oriented functions.
6185db853e024a486ff8837e6784dd290d866112dougmstatic char *
6185db853e024a486ff8837e6784dd290d866112dougm return ((char *)name);
6185db853e024a486ff8837e6784dd290d866112dougm * get_node_attr(node, tag)
6185db853e024a486ff8837e6784dd290d866112dougm * Set the speficied tag(attribute) to the specified value This is
6185db853e024a486ff8837e6784dd290d866112dougm * used internally by a number of attribute oriented functions. It
6185db853e024a486ff8837e6784dd290d866112dougm * doesn't update the repository, only the internal document state.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_group_attr(group, tag)
6185db853e024a486ff8837e6784dd290d866112dougm * Get the specied attribute, if defined, for the group.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_set_group_attr(group, tag, value)
6185db853e024a486ff8837e6784dd290d866112dougm * set the specified tag/attribute on the group using value as its
6185db853e024a486ff8837e6784dd290d866112dougm * This will result in setting the property in the SMF repository as
6185db853e024a486ff8837e6784dd290d866112dougm * well as in the internal document.
6185db853e024a486ff8837e6784dd290d866112dougmsa_set_group_attr(sa_group_t group, char *tag, char *value)
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_share_attr(share, tag)
6185db853e024a486ff8837e6784dd290d866112dougm * Return the value of the tag/attribute set on the specified
6185db853e024a486ff8837e6784dd290d866112dougm * share. Returns NULL if the tag doesn't exist.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_resource(group, resource)
6185db853e024a486ff8837e6784dd290d866112dougm * Search all the shares in the speified group for a share with a
6185db853e024a486ff8837e6784dd290d866112dougm * resource name matching the one specified.
6185db853e024a486ff8837e6784dd290d866112dougm * In the future, it may be advantageous to allow group to be NULL and
6185db853e024a486ff8837e6784dd290d866112dougm * search all groups but that isn't needed at present.
6185db853e024a486ff8837e6784dd290d866112dougm for (share = sa_get_share(group, NULL); share != NULL;
6185db853e024a486ff8837e6784dd290d866112dougm * _sa_set_share_description(share, description)
6185db853e024a486ff8837e6784dd290d866112dougm * Add a description tag with text contents to the specified share.
6185db853e024a486ff8837e6784dd290d866112dougm * A separate XML tag is used rather than a property.
6185db853e024a486ff8837e6784dd290d866112dougm_sa_set_share_description(sa_share_t share, char *content)
6185db853e024a486ff8837e6784dd290d866112dougm * sa_set_share_attr(share, tag, value)
6185db853e024a486ff8837e6784dd290d866112dougm * Set the share attribute specified by tag to the specified value. In
6185db853e024a486ff8837e6784dd290d866112dougm * the case of "resource", enforce a no duplicates in a group rule. If
6185db853e024a486ff8837e6784dd290d866112dougm * the share is not transient, commit the changes to the repository
6185db853e024a486ff8837e6784dd290d866112dougm * else just update the share internally.
6185db853e024a486ff8837e6784dd290d866112dougmsa_set_share_attr(sa_share_t share, char *tag, char *value)
6185db853e024a486ff8837e6784dd290d866112dougm * There are some attributes that may have specific
6185db853e024a486ff8837e6784dd290d866112dougm * restrictions on them. Initially, only "resource" has
6185db853e024a486ff8837e6784dd290d866112dougm * special meaning that needs to be checked. Only one instance
6185db853e024a486ff8837e6784dd290d866112dougm * of a resource name may exist within a group.
6185db853e024a486ff8837e6784dd290d866112dougm /* we can probably optimize this some */
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_property_attr(prop, tag)
6185db853e024a486ff8837e6784dd290d866112dougm * Get the value of the specified property attribute. Standard
6185db853e024a486ff8837e6784dd290d866112dougm * attributes are "type" and "value".
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_optionset_attr(prop, tag)
6185db853e024a486ff8837e6784dd290d866112dougm * Get the value of the specified property attribute. Standard
6185db853e024a486ff8837e6784dd290d866112dougm * attribute is "type".
6185db853e024a486ff8837e6784dd290d866112dougmsa_get_optionset_attr(sa_property_t optionset, char *tag)
6185db853e024a486ff8837e6784dd290d866112dougm * sa_set_optionset_attr(optionset, tag, value)
6185db853e024a486ff8837e6784dd290d866112dougm * Set the specified attribute(tag) to the specified value on the
6185db853e024a486ff8837e6784dd290d866112dougm * optionset.
6185db853e024a486ff8837e6784dd290d866112dougmsa_set_optionset_attr(sa_group_t optionset, char *tag, char *value)
6185db853e024a486ff8837e6784dd290d866112dougm * sa_free_attr_string(string)
6185db853e024a486ff8837e6784dd290d866112dougm * Free the string that was returned in one of the sa_get_*_attr()
6185db853e024a486ff8837e6784dd290d866112dougm * functions.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_optionset(group, proto)
6185db853e024a486ff8837e6784dd290d866112dougm * Return the optionset, if it exists, that is associated with the
6185db853e024a486ff8837e6784dd290d866112dougm * specified protocol.
6185db853e024a486ff8837e6784dd290d866112dougm for (node = ((xmlNodePtr)group)->children; node != NULL;
6185db853e024a486ff8837e6784dd290d866112dougm if (xmlStrcmp(node->name, (xmlChar *)"optionset") == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_next_optionset(optionset)
6185db853e024a486ff8837e6784dd290d866112dougm * Return the next optionset in the group. NULL if this was the last.
6185db853e024a486ff8837e6784dd290d866112dougm for (node = ((xmlNodePtr)optionset)->next; node != NULL;
6185db853e024a486ff8837e6784dd290d866112dougm if (xmlStrcmp(node->name, (xmlChar *)"optionset") == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_security(group, sectype, proto)
6185db853e024a486ff8837e6784dd290d866112dougm * Return the security optionset. The internal name is a hold over
6185db853e024a486ff8837e6784dd290d866112dougm * from the implementation and will be changed before the API is
6185db853e024a486ff8837e6784dd290d866112dougm * finalized. This is really a named optionset that can be negotiated
6185db853e024a486ff8837e6784dd290d866112dougm * as a group of properties (like NFS security options).
6185db853e024a486ff8837e6784dd290d866112dougmsa_get_security(sa_group_t group, char *sectype, char *proto)
6185db853e024a486ff8837e6784dd290d866112dougm for (node = ((xmlNodePtr)group)->children; node != NULL;
6185db853e024a486ff8837e6784dd290d866112dougm if (xmlStrcmp(node->name, (xmlChar *)"security") == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm /* it doesn't match so continue */
6185db853e024a486ff8837e6784dd290d866112dougm /* potential match */
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_next_security(security)
6185db853e024a486ff8837e6784dd290d866112dougm * Get the next security optionset if one exists.
6185db853e024a486ff8837e6784dd290d866112dougm for (node = ((xmlNodePtr)security)->next; node != NULL;
6185db853e024a486ff8837e6784dd290d866112dougm if (xmlStrcmp(node->name, (xmlChar *)"security") == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_property(optionset, prop)
6185db853e024a486ff8837e6784dd290d866112dougm * Get the property object with the name specified in prop from the
6185db853e024a486ff8837e6784dd290d866112dougm * optionset.
6185db853e024a486ff8837e6784dd290d866112dougm if (xmlStrcmp(node->name, (xmlChar *)"option") == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm if (value != NULL && xmlStrcmp(value, (xmlChar *)prop) == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm if (node != NULL && xmlStrcmp(node->name, (xmlChar *)"option") != 0) {
6185db853e024a486ff8837e6784dd290d866112dougm /* avoid a non option node -- it is possible to be a text node */
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_next_property(property)
6185db853e024a486ff8837e6784dd290d866112dougm * Get the next property following the specified property. NULL if
6185db853e024a486ff8837e6784dd290d866112dougm * this was the last.
6185db853e024a486ff8837e6784dd290d866112dougm for (node = ((xmlNodePtr)property)->next; node != NULL;
6185db853e024a486ff8837e6784dd290d866112dougm if (xmlStrcmp(node->name, (xmlChar *)"option") == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm * sa_set_share_description(share, content)
6185db853e024a486ff8837e6784dd290d866112dougm * Set the description of share to content.
6185db853e024a486ff8837e6784dd290d866112dougmsa_set_share_description(sa_share_t share, char *content)
6185db853e024a486ff8837e6784dd290d866112dougm for (node = ((xmlNodePtr)share)->children; node != NULL;
6185db853e024a486ff8837e6784dd290d866112dougm if (xmlStrcmp(node->name, (xmlChar *)"description") == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm /* no existing description but want to add */
6185db853e024a486ff8837e6784dd290d866112dougm /* add a description */
6185db853e024a486ff8837e6784dd290d866112dougm /* update a description */
6185db853e024a486ff8837e6784dd290d866112dougm /* remove an existing description */
6185db853e024a486ff8837e6784dd290d866112dougm if (group != NULL && is_persistent((sa_group_t)share))
6185db853e024a486ff8837e6784dd290d866112dougm * fixproblemchars(string)
6185db853e024a486ff8837e6784dd290d866112dougm * don't want any newline or tab characters in the text since these
6185db853e024a486ff8837e6784dd290d866112dougm * could break display of data and legacy file formats.
6185db853e024a486ff8837e6784dd290d866112dougm else if (c == '"')
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_share_description(share)
6185db853e024a486ff8837e6784dd290d866112dougm * Return the description text for the specified share if it
6185db853e024a486ff8837e6784dd290d866112dougm * exists. NULL if no description exists.
6185db853e024a486ff8837e6784dd290d866112dougm for (node = ((xmlNodePtr)share)->children; node != NULL;
6185db853e024a486ff8837e6784dd290d866112dougm if (xmlStrcmp(node->name, (xmlChar *)"description") == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm return ((char *)description);
6185db853e024a486ff8837e6784dd290d866112dougm * sa_free(share_description(description)
6185db853e024a486ff8837e6784dd290d866112dougm * Free the description string.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_create_optionset(group, proto)
6185db853e024a486ff8837e6784dd290d866112dougm * Create an optionset for the specified protocol in the specied
6185db853e024a486ff8837e6784dd290d866112dougm * group. This is manifested as a property group within SMF.
6185db853e024a486ff8837e6784dd290d866112dougm /* can't have a duplicate protocol */
6185db853e024a486ff8837e6784dd290d866112dougm optionset = (sa_optionset_t)xmlNewChild((xmlNodePtr)group,
6185db853e024a486ff8837e6784dd290d866112dougm * only put to repository if on a group and we were
6185db853e024a486ff8837e6784dd290d866112dougm * able to create an optionset.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_property_parent(property)
6185db853e024a486ff8837e6784dd290d866112dougm * Given a property, return the object it is a property of. This will
6185db853e024a486ff8837e6784dd290d866112dougm * be an optionset of some type.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_optionset_parent(optionset)
6185db853e024a486ff8837e6784dd290d866112dougm * Return the parent of the specified optionset. This could be a group
6185db853e024a486ff8837e6784dd290d866112dougm * or a share.
6185db853e024a486ff8837e6784dd290d866112dougm * zfs_needs_update(share)
6185db853e024a486ff8837e6784dd290d866112dougm * In order to avoid making multiple updates to a ZFS share when
6185db853e024a486ff8837e6784dd290d866112dougm * setting properties, the share attribute "changed" will be set to
6185db853e024a486ff8837e6784dd290d866112dougm * true when a property is added or modifed. When done adding
6185db853e024a486ff8837e6784dd290d866112dougm * properties, we can then detect that an update is needed. We then
6185db853e024a486ff8837e6784dd290d866112dougm * clear the state here to detect additional changes.
6185db853e024a486ff8837e6784dd290d866112dougm * zfs_set_update(share)
6185db853e024a486ff8837e6784dd290d866112dougm * Set the changed attribute of the share to true.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_commit_properties(optionset, clear)
6185db853e024a486ff8837e6784dd290d866112dougm * Check if SMF or ZFS config and either update or abort the pending
6185db853e024a486ff8837e6784dd290d866112dougmsa_commit_properties(sa_optionset_t optionset, int clear)
6185db853e024a486ff8837e6784dd290d866112dougm if (group != NULL && (sa_is_share(group) || is_zfs_group(group))) {
6185db853e024a486ff8837e6784dd290d866112dougm /* only update ZFS if on a share */
6185db853e024a486ff8837e6784dd290d866112dougm * sa_destroy_optionset(optionset)
6185db853e024a486ff8837e6784dd290d866112dougm * Remove the optionset from its group. Update the repostory to
6185db853e024a486ff8837e6784dd290d866112dougm * reflect this change.
6185db853e024a486ff8837e6784dd290d866112dougm /* now delete the prop group */
6185db853e024a486ff8837e6784dd290d866112dougm len = sa_optionset_name(optionset, name, sizeof (name), id);
6185db853e024a486ff8837e6784dd290d866112dougm if (len > 0) {
6185db853e024a486ff8837e6784dd290d866112dougm/* private to the implementation */
6185db853e024a486ff8837e6784dd290d866112dougm * sa_create_security(group, sectype, proto)
6185db853e024a486ff8837e6784dd290d866112dougm * Create a security optionset (one that has a type name and a
6185db853e024a486ff8837e6784dd290d866112dougm * proto). Security is left over from a pure NFS implementation. The
6185db853e024a486ff8837e6784dd290d866112dougm * naming will change in the future when the API is released.
6185db853e024a486ff8837e6784dd290d866112dougmsa_create_security(sa_group_t group, char *sectype, char *proto)
6185db853e024a486ff8837e6784dd290d866112dougm /* can't have a duplicate security option */
6185db853e024a486ff8837e6784dd290d866112dougm security = (sa_security_t)xmlNewChild((xmlNodePtr)group,
6185db853e024a486ff8837e6784dd290d866112dougm * sa_destroy_security(security)
6185db853e024a486ff8837e6784dd290d866112dougm * Remove the specified optionset from the document and the
6185db853e024a486ff8837e6784dd290d866112dougm * configuration.
6185db853e024a486ff8837e6784dd290d866112dougm len = sa_security_name(security, name, sizeof (name), id);
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_security_attr(optionset, tag)
6185db853e024a486ff8837e6784dd290d866112dougm * Return the specified attribute value from the optionset.
6185db853e024a486ff8837e6784dd290d866112dougmsa_get_security_attr(sa_property_t optionset, char *tag)
6185db853e024a486ff8837e6784dd290d866112dougm * sa_set_security_attr(optionset, tag, value)
6185db853e024a486ff8837e6784dd290d866112dougm * Set the optioset attribute specied by tag to the specified value.
6185db853e024a486ff8837e6784dd290d866112dougmsa_set_security_attr(sa_group_t optionset, char *tag, char *value)
6185db853e024a486ff8837e6784dd290d866112dougm * is_nodetype(node, type)
6185db853e024a486ff8837e6784dd290d866112dougm * Check to see if node is of the type specified.
6185db853e024a486ff8837e6784dd290d866112dougm return (strcmp((char *)((xmlNodePtr)node)->name, type) == 0);
6185db853e024a486ff8837e6784dd290d866112dougm * sa_set_prop_by_prop(optionset, group, prop, type)
6185db853e024a486ff8837e6784dd290d866112dougm * Add/remove/update the specified property prop into the optionset or
6185db853e024a486ff8837e6784dd290d866112dougm * share. If a share, sort out which property group based on GUID. In
6185db853e024a486ff8837e6784dd290d866112dougm * all cases, the appropriate transaction is set (or ZFS share is
6185db853e024a486ff8837e6784dd290d866112dougm * marked as needing an update)
6185db853e024a486ff8837e6784dd290d866112dougmsa_set_prop_by_prop(sa_optionset_t optionset, sa_group_t group,
6185db853e024a486ff8837e6784dd290d866112dougm * if the group/share is not persistent we don't need
6185db853e024a486ff8837e6784dd290d866112dougm * to do anything here
6185db853e024a486ff8837e6784dd290d866112dougm opttype = is_nodetype((void *)optionset, "optionset");
6185db853e024a486ff8837e6784dd290d866112dougm ret = scf_transaction_property_delete(scf_handle->trans,
6185db853e024a486ff8837e6784dd290d866112dougm if (ret == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm if (ret != 0) {
6185db853e024a486ff8837e6784dd290d866112dougm * ZFS update. The calling function would have updated
6185db853e024a486ff8837e6784dd290d866112dougm * the internal XML structure. Just need to flag it as
6185db853e024a486ff8837e6784dd290d866112dougm * changed for ZFS.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_create_property(name, value)
6185db853e024a486ff8837e6784dd290d866112dougm * Create a new property with the specified name and value.
6185db853e024a486ff8837e6784dd290d866112dougm xmlSetProp(node, (xmlChar *)"value", (xmlChar *)value);
6185db853e024a486ff8837e6784dd290d866112dougm * sa_add_property(object, property)
6185db853e024a486ff8837e6784dd290d866112dougm * Add the specified property to the object. Issue the appropriate
6185db853e024a486ff8837e6784dd290d866112dougm * transaction or mark a ZFS object as needing an update.
6185db853e024a486ff8837e6784dd290d866112dougm if ((ret = sa_valid_property(object, proto, property)) == SA_OK) {
6185db853e024a486ff8837e6784dd290d866112dougm property = (sa_property_t)xmlAddChild((xmlNodePtr)object,
6185db853e024a486ff8837e6784dd290d866112dougm * ZFS is a special case. We do want to allow editing
6185db853e024a486ff8837e6784dd290d866112dougm * property/security lists since we can have a better
6185db853e024a486ff8837e6784dd290d866112dougm * syntax and we also want to keep things consistent
6185db853e024a486ff8837e6784dd290d866112dougm * when possible.
6185db853e024a486ff8837e6784dd290d866112dougm * Right now, we defer until the sa_commit_properties
6185db853e024a486ff8837e6784dd290d866112dougm * so we can get them all at once. We do need to mark
6185db853e024a486ff8837e6784dd290d866112dougm * the share as "changed"
6185db853e024a486ff8837e6784dd290d866112dougm * sa_remove_property(property)
6185db853e024a486ff8837e6784dd290d866112dougm * Remove the specied property from its containing object. Update the
6185db853e024a486ff8837e6784dd290d866112dougm * repository as appropriate.
6185db853e024a486ff8837e6784dd290d866112dougm * sa_update_property(property, value)
6185db853e024a486ff8837e6784dd290d866112dougm * Update the specified property to the new value. If value is NULL,
6185db853e024a486ff8837e6784dd290d866112dougm * we currently treat this as a remove.
6185db853e024a486ff8837e6784dd290d866112dougmsa_update_property(sa_property_t property, char *value)
6185db853e024a486ff8837e6784dd290d866112dougm * _sa_get_next_error(node)
6185db853e024a486ff8837e6784dd290d866112dougm * Get the next (first if node==NULL) error node in the
6185db853e024a486ff8837e6784dd290d866112dougm * document. "error" nodes are added if there were syntax errors
6185db853e024a486ff8837e6784dd290d866112dougm * during parsing of the /etc/dfs/dfstab file. They are preserved in
6185db853e024a486ff8837e6784dd290d866112dougm * comments and recreated in the doc on the next parse.
6185db853e024a486ff8837e6784dd290d866112dougm for (node = node->next; node != NULL; node = node->next)
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_protocol_property(propset, prop)
6185db853e024a486ff8837e6784dd290d866112dougm * Get the specified protocol specific property. These are global to
6185db853e024a486ff8837e6784dd290d866112dougm * the protocol and not specific to a group or share.
6185db853e024a486ff8837e6784dd290d866112dougmsa_get_protocol_property(sa_protocol_properties_t propset, char *prop)
6185db853e024a486ff8837e6784dd290d866112dougm if (xmlStrcmp(node->name, (xmlChar *)"option") == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm if (node != NULL && xmlStrcmp(node->name, (xmlChar *)"option") != 0) {
6185db853e024a486ff8837e6784dd290d866112dougm /* avoid a non option node -- it is possible to be a text node */
6185db853e024a486ff8837e6784dd290d866112dougm * sa_get_next_protocol_property(prop)
6185db853e024a486ff8837e6784dd290d866112dougm * Get the next protocol specific property in the list.
6185db853e024a486ff8837e6784dd290d866112dougm if (xmlStrcmp(node->name, (xmlChar *)"option") == 0) {
6185db853e024a486ff8837e6784dd290d866112dougm * sa_set_protocol_property(prop, value)
6185db853e024a486ff8837e6784dd290d866112dougm * Set the specified property to have the new value. The protocol
6185db853e024a486ff8837e6784dd290d866112dougm * specific plugin will then be called to update the property.
6185db853e024a486ff8837e6784dd290d866112dougmsa_set_protocol_property(sa_property_t prop, char *value)
6185db853e024a486ff8837e6784dd290d866112dougm * sa_add_protocol_property(propset, prop)
6185db853e024a486ff8837e6784dd290d866112dougm * Add a new property to the protocol sepcific property set.
6185db853e024a486ff8837e6784dd290d866112dougmsa_add_protocol_property(sa_protocol_properties_t propset, sa_property_t prop)
6185db853e024a486ff8837e6784dd290d866112dougm /* should check for legitimacy */
6185db853e024a486ff8837e6784dd290d866112dougm node = xmlAddChild((xmlNodePtr)propset, (xmlNodePtr)prop);
6185db853e024a486ff8837e6784dd290d866112dougm * sa_create_protocol_properties(proto)
6185db853e024a486ff8837e6784dd290d866112dougm * Create a protocol specifity property set.
6185db853e024a486ff8837e6784dd290d866112dougm xmlSetProp(node, (xmlChar *)"type", (xmlChar *)proto);