commands.c revision 549ec3fff108310966327d1dc9004551b63210b7
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * CDDL HEADER START
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * The contents of this file are subject to the terms of the
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * Common Development and Distribution License (the "License").
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * You may not use this file except in compliance with the License.
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * or http://www.opensolaris.org/os/licensing.
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * See the License for the specific language governing permissions
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * and limitations under the License.
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * When distributing Covered Code, include this CDDL HEADER in each
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * If applicable, add the following below this CDDL HEADER, with the
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * fields enclosed by brackets "[]" replaced with your own identifying
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * information: Portions Copyright [yyyy] [name of copyright owner]
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * CDDL HEADER END
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * Use is subject to license terms.
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi#pragma ident "%Z%%M% %I% %E% SMI"
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * Implementation of the common sub-commands supported by sharemgr.
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * A number of helper functions are also included.
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * has_protocol(group, proto)
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * If the group has an optionset with the specified protocol,
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * return true (1) otherwise false (0).
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchihas_protocol(sa_group_t group, char *protocol)
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi optionset = sa_get_optionset(group, protocol);
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * add_list(list, item)
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * Adds a new list member that points to item to the list.
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi * If list is NULL, it starts a new list. The function returns
struct list *
return (listp);
return (new);
return (listp);
ret = 0;
switch (which) {
case SVC_SET:
case SVC_ACTION:
endauthattr();
ret = 0;
return (ret);
int ret1 = 0;
int ret2 = 0;
int ret;
switch (flags) {
case SVC_ACTION:
case SVC_SET:
return (ret);
char *state;
char *name;
if (setstate)
if (online) {
return (ret);
int notfirst = 0;
int ret;
char *optname;
if (!security)
if (security)
if (notfirst == 0)
switch (ret) {
case OPT_ADD_SYNTAX:
case OPT_ADD_SECURITY:
case OPT_ADD_PROPERTY:
notfirst++;
if (notfirst) {
return (ret);
return (ret);
int result = 0;
return (result);
char *groupname;
int verbose = 0;
int dryrun = 0;
int err = 0;
int auth;
verbose++;
dryrun++;
protocol);
return (SA_INVALID_PROTOCOL);
switch (ret) {
case OPT_ADD_SYNTAX:
optarg);
return (SA_SYNTAX_ERR);
case OPT_ADD_SECURITY:
optarg);
return (SA_SYNTAX_ERR);
return (SA_BAD_PATH);
return (SA_SYNTAX_ERR);
return (SA_INVALID_PROTOCOL);
return (SA_SYNTAX_ERR);
char **protolist;
int numprotos, i;
for (i = 0; i < numprotos; i++) {
return (ret);
char *state;
int enabled = 0;
char *groupname;
int verbose = 0;
int dryrun = 0;
int force = 0;
int auth;
verbose++;
dryrun++;
protocol);
return (SA_INVALID_PROTOCOL);
force++;
return (SA_SYNTAX_ERR);
return (SA_SYNTAX_ERR);
return (SA_SYNTAX_ERR);
if (!dryrun) {
char *secprot;
if (!dryrun)
return (ret);
int limit;
return (NULL);
return (buff);
char *proto;
int buffsize = 0;
int addspace = 0;
if (addspace++)
return (buff);
int verbose = 0;
#ifdef lint
verbose++;
protocol);
return (SA_INVALID_PROTOCOL);
char *name;
char *proto;
if (verbose) {
char *type;
char *value;
int spacer;
char *value;
char *secvalue;
char *subgroup)
char *groupname;
char *sharepath;
char *resource;
char *description;
char *type;
int iszfs = 0;
if (properties) {
if (verbose) {
if (properties)
if (properties)
return (doc);
int verbose = 0;
int properties = 0;
int xml = 0;
#ifdef lint
verbose++;
properties++;
protocol);
return (SA_INVALID_PROTOCOL);
xml++;
if (xml) {
if (xml)
if (xml)
return (ret);
int update_legacy)
char *value;
int enabled;
int iszfs = 0;
if (update_legacy)
iszfs++;
if (enabled)
return (ret);
int verbose = 0;
int dryrun = 0;
int auth;
dryrun++;
verbose++;
char *groupname;
if (dryrun)
resource);
switch (ret) {
case SA_DUPLICATE_NAME:
resource);
case SA_OK:
return (ret);
int verbose = 0;
int dryrun = 0;
dryrun++;
verbose++;
return (SA_BAD_PATH);
char *zfsold;
char *zfsnew;
char *pname;
char *oldstate;
verbose) {
return (ret);
int verbose = 0;
int dryrun = 0;
int force = 0;
int auth;
dryrun++;
verbose++;
force++;
return (SA_SYNTAX_ERR);
if (!dryrun) {
char *pname;
return (ret);
int dryrun = 0;
int auth;
int verbose = 0;
dryrun++;
verbose++;
return (SA_BAD_PATH);
return (SA_OK);
char *groupname;
int delgroupname = 0;
if (delgroupname) {
if (!dryrun) {
resource);
resource);
switch (ret) {
case SA_DUPLICATE_NAME:
resource);
case SA_OK:
return (ret);
int result = 0;
if (result)
return (result);
int change = 0;
&ret);
&ret);
return (ret);
int change = 0;
sectype);
return (SA_INVALID_SECURITY);
&ret);
&ret);
return (ret);
char *groupname;
int verbose = 0;
int dryrun = 0;
int auth;
verbose++;
dryrun++;
protocol);
return (SA_INVALID_PROTOCOL);
switch (ret) {
case OPT_ADD_SYNTAX:
optarg);
return (SA_SYNTAX_ERR);
case OPT_ADD_MEMORY:
optarg);
return (SA_NO_MEMORY);
return (SA_OK);
return (ret);
int change = 0;
return (change);
return (ret);
char *sectype)
char *sec;
sectype);
return (ret);
int change = 0;
return (change);
int change = 0;
&ret);
protocol);
&ret);
return (ret);
int change = 0;
&ret);
protocol);
&ret);
char *sec;
return (ret);
char *groupname;
int verbose = 0;
int dryrun = 0;
int auth;
verbose++;
dryrun++;
protocol);
return (SA_INVALID_PROTOCOL);
switch (ret) {
case OPT_ADD_SYNTAX:
optarg);
return (SA_SYNTAX_ERR);
case OPT_ADD_PROPERTY:
optarg);
return (SA_SYNTAX_ERR);
return (SA_OK);
sep);
return (ret);
int verbose = 0;
int dryrun = 0;
int all = 0;
char *state;
dryrun++;
protocol);
return (SA_INVALID_PROTOCOL);
verbose++;
if (!all) {
if (verbose)
if (verbose)
optind++;
return (ret);
return (ret);
if (setstate)
char *name;
return (ret);
int verbose = 0;
int dryrun = 0;
int all = 0;
char *protocol;
char *state;
dryrun++;
protocol);
return (SA_INVALID_PROTOCOL);
verbose++;
if (!all) {
if (verbose)
if (verbose)
optind++;
return (ret);
int fd;
if (fd >= 0) {
endutxent();
int verbose = 0;
int all = 0;
char *state;
#ifdef lint
protocol);
return (SA_INVALID_PROTOCOL);
verbose++;
return (SA_OK);
if (!all) {
if (verbose)
optind++;
return (ret);
int verbose = 0;
int all = 0;
char *state;
#ifdef lint
protocol);
return (SA_INVALID_PROTOCOL);
verbose++;
if (!all) {
if (verbose)
optind++;
return (ret);
char *type;
int err;
int ret = 0;
return (ret);
int ret;
if (ret < 0) {
switch (errno) {
case EACCES:
return (ret);
char *path;
char *type;
char *resource;
char *description;
char *groupname;
char *sharedstate;
char *soptions;
shared = 0;
if (shared) {
path,
char *options;
char *zfs;
int argsused = 0;
int zfs = 0;
int true_legacy = 0;
#ifdef lint
argsused++;
true_legacy++;
protocol);
return (SA_INVALID_PROTOCOL);
argsused++;
argsused++;
return (SA_OK);
return (SA_LEGACY_ERR);
if (true_legacy) {
return (ret);
char *type;
protocol);
if (!zfs) {
resource);
return (ret);
int argsused = 0;
int true_legacy = 0;
#ifdef lint
true_legacy++;
return (SA_INVALID_PROTOCOL);
argsused++;
argsused++;
return (SA_OK);
if (true_legacy) {
return (ret);
switch (ret) {
case SA_SYNTAX_ERR:
case SA_OK:
return (ret);
switch (index) {
case USAGE_ADD_SHARE:
case USAGE_CREATE:
case USAGE_DELETE:
case USAGE_DISABLE:
case USAGE_ENABLE:
case USAGE_LIST:
case USAGE_MOVE_SHARE:
case USAGE_REMOVE_SHARE:
case USAGE_SET:
case USAGE_SET_SECURITY:
case USAGE_SET_SHARE:
case USAGE_SHOW:
case USAGE_SHARE:
case USAGE_START:
case USAGE_STOP:
case USAGE_UNSET:
case USAGE_UNSET_SECURITY:
case USAGE_UNSHARE:
return (ret);
#ifdef lint
return (&commands[i]);
return (NULL);
#ifdef lint