2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#ifndef _CFG_H
2N/A#define _CFG_H
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include <sys/nsctl/nsctl.h>
2N/A
2N/A#define CFG_MAX_BUF 1024 /* maximum buffer size for cfg_get_?string() */
2N/A#define CFG_MAX_KEY 256 /* maximum key size for cfg_get_?string() */
2N/A
2N/A#ifndef _CFG_IMPL_H
2N/A/*
2N/A * These are really declared in cfg_impl.h, declare as dummy's here to
2N/A * allow clients to compile without including cfg_impl.h.
2N/A */
2N/Atypedef struct cfgfile CFGFILE;
2N/Atypedef struct cfp cfp_t;
2N/A
2N/A#endif /* _CFG_IMPL_H */
2N/A
2N/Aint cfg_get_cstring(CFGFILE *cfg, const char *key, void *value, int value_len);
2N/Aint cfg_put_cstring(CFGFILE *cfg, const char *key, void *value, int value_len);
2N/Aint cfg_find_cstring(CFGFILE *cfg, const char *target, const char *section,
2N/A int numflds, ...);
2N/Aint cfg_get_options(CFGFILE *cfg, int section, const char *basekey,
2N/A char *tag, int tag_len, char *val, int val_len);
2N/Aint cfg_put_options(CFGFILE *cfg, int section, const char *basekey,
2N/A char *tag, char *val);
2N/Aint cfg_get_single_option(CFGFILE *, int, const char *, char *, char *, int);
2N/Aint cfg_del_option(CFGFILE *, int, const char *, char *);
2N/A
2N/Aint cfg_get_num_entries(CFGFILE *cfg, char *section);
2N/A
2N/Aint cfg_get_tags(CFGFILE *cfg, char ***taglist);
2N/A
2N/Aint cfg_cfg_isempty(CFGFILE *cfg);
2N/Aint cfg_get_section(CFGFILE *cfg, char ***buf, const char *section);
2N/ACFGFILE *cfg_open(char *filename);
2N/Avoid cfg_rewind(CFGFILE *cfg, int section);
2N/Aint cfg_is_cfg(CFGFILE *cfg);
2N/Aint cfg_shldskip_vtoc(int fd, const char *loc);
2N/Aint cfg_get_srtdsec(CFGFILE *cfg, char ***list,
2N/A const char *sec, const char *field);
2N/Avoid cfg_free_section(char ***, int);
2N/A
2N/A
2N/A/*
2N/A * Handle cluster configuration
2N/A */
2N/A#define FP_SUN_CLUSTER(x) \
2N/A (((x->cf_node) && (x->cf[1].cf_fd)) ? &x->cf[1] : &x->cf[0])
2N/A
2N/A/*
2N/A * rewind sections
2N/A */
2N/A#define CFG_SEC_CONF 0 /* configuration section */
2N/A#define CFG_SEC_PERS 1 /* persistent section */
2N/A#define CFG_SEC_ALL 2 /* rewind both sections */
2N/A
2N/Aint cfg_update_parser_config(CFGFILE *, const char *key, int section);
2N/A/*
2N/A * parser sections
2N/A */
2N/A#define CFG_PARSE_CONF 0 /* config section key */
2N/A#define CFG_PARSE_PERS 1 /* persistent section key */
2N/A
2N/Achar *cfg_error(int *severity);
2N/A/*
2N/A * error codes
2N/A */
2N/A#define CFG_ENONFATAL 0 /* non fatal error */
2N/A#define CFG_EFATAL 1 /* fatal error exit */
2N/A
2N/A/*
2N/A * some error strings
2N/A */
2N/A#define CFG_NOTLOCKED "Configuration not locked"
2N/A#define CFG_RDFAILED "Unable to read configuration"
2N/A#define CFG_EINVAL "Invalid Argument"
2N/A#define CFG_EGENERIC "Generic cfg failure"
2N/A
2N/A
2N/Achar *cfg_location(char *location, int mode, char *altroot);
2N/A
2N/A/*
2N/A * location modes
2N/A */
2N/A#define CFG_LOC_SET_LOCAL 0
2N/A#define CFG_LOC_GET_LOCAL 1
2N/A#define CFG_LOC_SET_CLUSTER 2
2N/A#define CFG_LOC_GET_CLUSTER 3
2N/A
2N/A/*
2N/A * location strings
2N/A */
2N/A#define CFG_LOCAL_LOCATION "/etc/dscfg_local"
2N/A#define CFG_CLUSTER_LOCATION "/etc/dscfg_cluster"
2N/A
2N/Avoid cfg_close(CFGFILE *);
2N/A
2N/A/*
2N/A * lock mode
2N/A */
2N/Atypedef enum {
2N/A CFG_RDLOCK,
2N/A CFG_WRLOCK,
2N/A CFG_UPGRADE
2N/A} CFGLOCK;
2N/A
2N/Aint cfg_lock(CFGFILE *, CFGLOCK); /* lock the configuration */
2N/Avoid cfp_unlock(cfp_t *); /* unlock the configuration */
2N/Avoid cfg_unlock(CFGFILE *);
2N/Aint cfg_get_lock(CFGFILE *, CFGLOCK *, pid_t *); /* get config lock */
2N/A
2N/Aint cfg_commit(CFGFILE *);
2N/Avoid cfg_resource(CFGFILE *, const char *); /* Set/clear cluster node */
2N/Achar *cfg_get_resource(CFGFILE *); /* get current cluster node */
2N/Achar *cfg_dgname(const char *, char *, size_t); /* parse dg from pathname */
2N/Achar *cfg_l_dgname(const char *, char *, size_t); /* parse dg from pathname */
2N/Aint cfg_dgname_islocal(char *, char **); /* find locality of dg */
2N/Aint cfg_iscluster(void); /* running in a cluster? */
2N/Aint cfg_issuncluster(void); /* running in a Sun Cluster? */
2N/Avoid cfg_invalidate_sizes(int);
2N/A
2N/A/*
2N/A * add/rem result codes
2N/A */
2N/A#define CFG_USER_ERR 1
2N/A#define CFG_USER_OK 2
2N/A#define CFG_USER_FIRST 3
2N/A#define CFG_USER_LAST 4
2N/A#define CFG_USER_GONE 5
2N/A#define CFG_USER_REPEAT 6
2N/A
2N/Aint cfg_add_user(CFGFILE *, char *, char *, char *); /* add volume user */
2N/Aint cfg_rem_user(CFGFILE *, char *, char *, char *); /* remove vol user */
2N/Aint cfg_vol_enable(CFGFILE *, char *, char *, char *); /* enable volume */
2N/Aint cfg_vol_disable(CFGFILE *, char *, char *, char *); /* disable volume */
2N/A
2N/Aint cfg_load_dsvols(CFGFILE *); /* load dsvol: section */
2N/Avoid cfg_unload_dsvols(); /* unload dsvol: section */
2N/Aint cfg_load_svols(CFGFILE *); /* load sv: section */
2N/Avoid cfg_unload_svols(); /* unload sv: section */
2N/Aint cfg_load_shadows(CFGFILE *); /* load shadows & bitmaps from ii: */
2N/Avoid cfg_unload_shadows(); /* unload ii: */
2N/A
2N/Aint cfg_get_canonical_name(CFGFILE *, const char *, char **);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _CFG_H */