1*7836SJohn.Forte@Sun.COM /* 2*7836SJohn.Forte@Sun.COM * CDDL HEADER START 3*7836SJohn.Forte@Sun.COM * 4*7836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the 5*7836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License"). 6*7836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License. 7*7836SJohn.Forte@Sun.COM * 8*7836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*7836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*7836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions 11*7836SJohn.Forte@Sun.COM * and limitations under the License. 12*7836SJohn.Forte@Sun.COM * 13*7836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*7836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*7836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*7836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*7836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*7836SJohn.Forte@Sun.COM * 19*7836SJohn.Forte@Sun.COM * CDDL HEADER END 20*7836SJohn.Forte@Sun.COM */ 21*7836SJohn.Forte@Sun.COM /* 22*7836SJohn.Forte@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23*7836SJohn.Forte@Sun.COM * Use is subject to license terms. 24*7836SJohn.Forte@Sun.COM */ 25*7836SJohn.Forte@Sun.COM 26*7836SJohn.Forte@Sun.COM #ifndef _CFG_H 27*7836SJohn.Forte@Sun.COM #define _CFG_H 28*7836SJohn.Forte@Sun.COM 29*7836SJohn.Forte@Sun.COM #ifdef __cplusplus 30*7836SJohn.Forte@Sun.COM extern "C" { 31*7836SJohn.Forte@Sun.COM #endif 32*7836SJohn.Forte@Sun.COM 33*7836SJohn.Forte@Sun.COM #include <sys/nsctl/nsctl.h> 34*7836SJohn.Forte@Sun.COM 35*7836SJohn.Forte@Sun.COM #define CFG_MAX_BUF 1024 /* maximum buffer size for cfg_get_?string() */ 36*7836SJohn.Forte@Sun.COM #define CFG_MAX_KEY 256 /* maximum key size for cfg_get_?string() */ 37*7836SJohn.Forte@Sun.COM 38*7836SJohn.Forte@Sun.COM #ifndef _CFG_IMPL_H 39*7836SJohn.Forte@Sun.COM /* 40*7836SJohn.Forte@Sun.COM * These are really declared in cfg_impl.h, declare as dummy's here to 41*7836SJohn.Forte@Sun.COM * allow clients to compile without including cfg_impl.h. 42*7836SJohn.Forte@Sun.COM */ 43*7836SJohn.Forte@Sun.COM typedef struct cfgfile CFGFILE; 44*7836SJohn.Forte@Sun.COM typedef struct cfp cfp_t; 45*7836SJohn.Forte@Sun.COM 46*7836SJohn.Forte@Sun.COM #endif /* _CFG_IMPL_H */ 47*7836SJohn.Forte@Sun.COM 48*7836SJohn.Forte@Sun.COM int cfg_get_cstring(CFGFILE *cfg, const char *key, void *value, int value_len); 49*7836SJohn.Forte@Sun.COM int cfg_put_cstring(CFGFILE *cfg, const char *key, void *value, int value_len); 50*7836SJohn.Forte@Sun.COM int cfg_find_cstring(CFGFILE *cfg, const char *target, const char *section, 51*7836SJohn.Forte@Sun.COM int numflds, ...); 52*7836SJohn.Forte@Sun.COM int cfg_get_options(CFGFILE *cfg, int section, const char *basekey, 53*7836SJohn.Forte@Sun.COM char *tag, int tag_len, char *val, int val_len); 54*7836SJohn.Forte@Sun.COM int cfg_put_options(CFGFILE *cfg, int section, const char *basekey, 55*7836SJohn.Forte@Sun.COM char *tag, char *val); 56*7836SJohn.Forte@Sun.COM int cfg_get_single_option(CFGFILE *, int, const char *, char *, char *, int); 57*7836SJohn.Forte@Sun.COM int cfg_del_option(CFGFILE *, int, const char *, char *); 58*7836SJohn.Forte@Sun.COM 59*7836SJohn.Forte@Sun.COM int cfg_get_num_entries(CFGFILE *cfg, char *section); 60*7836SJohn.Forte@Sun.COM 61*7836SJohn.Forte@Sun.COM int cfg_get_tags(CFGFILE *cfg, char ***taglist); 62*7836SJohn.Forte@Sun.COM 63*7836SJohn.Forte@Sun.COM int cfg_cfg_isempty(CFGFILE *cfg); 64*7836SJohn.Forte@Sun.COM int cfg_get_section(CFGFILE *cfg, char ***buf, const char *section); 65*7836SJohn.Forte@Sun.COM CFGFILE *cfg_open(char *filename); 66*7836SJohn.Forte@Sun.COM void cfg_rewind(CFGFILE *cfg, int section); 67*7836SJohn.Forte@Sun.COM int cfg_is_cfg(CFGFILE *cfg); 68*7836SJohn.Forte@Sun.COM int cfg_shldskip_vtoc(int fd, const char *loc); 69*7836SJohn.Forte@Sun.COM int cfg_get_srtdsec(CFGFILE *cfg, char ***list, 70*7836SJohn.Forte@Sun.COM const char *sec, const char *field); 71*7836SJohn.Forte@Sun.COM void cfg_free_section(char ***, int); 72*7836SJohn.Forte@Sun.COM 73*7836SJohn.Forte@Sun.COM 74*7836SJohn.Forte@Sun.COM /* 75*7836SJohn.Forte@Sun.COM * Handle cluster configuration 76*7836SJohn.Forte@Sun.COM */ 77*7836SJohn.Forte@Sun.COM #define FP_SUN_CLUSTER(x) \ 78*7836SJohn.Forte@Sun.COM (((x->cf_node) && (x->cf[1].cf_fd)) ? &x->cf[1] : &x->cf[0]) 79*7836SJohn.Forte@Sun.COM 80*7836SJohn.Forte@Sun.COM /* 81*7836SJohn.Forte@Sun.COM * rewind sections 82*7836SJohn.Forte@Sun.COM */ 83*7836SJohn.Forte@Sun.COM #define CFG_SEC_CONF 0 /* configuration section */ 84*7836SJohn.Forte@Sun.COM #define CFG_SEC_PERS 1 /* persistent section */ 85*7836SJohn.Forte@Sun.COM #define CFG_SEC_ALL 2 /* rewind both sections */ 86*7836SJohn.Forte@Sun.COM 87*7836SJohn.Forte@Sun.COM int cfg_update_parser_config(CFGFILE *, const char *key, int section); 88*7836SJohn.Forte@Sun.COM /* 89*7836SJohn.Forte@Sun.COM * parser sections 90*7836SJohn.Forte@Sun.COM */ 91*7836SJohn.Forte@Sun.COM #define CFG_PARSE_CONF 0 /* config section key */ 92*7836SJohn.Forte@Sun.COM #define CFG_PARSE_PERS 1 /* persistent section key */ 93*7836SJohn.Forte@Sun.COM 94*7836SJohn.Forte@Sun.COM char *cfg_error(int *severity); 95*7836SJohn.Forte@Sun.COM /* 96*7836SJohn.Forte@Sun.COM * error codes 97*7836SJohn.Forte@Sun.COM */ 98*7836SJohn.Forte@Sun.COM #define CFG_ENONFATAL 0 /* non fatal error */ 99*7836SJohn.Forte@Sun.COM #define CFG_EFATAL 1 /* fatal error exit */ 100*7836SJohn.Forte@Sun.COM 101*7836SJohn.Forte@Sun.COM /* 102*7836SJohn.Forte@Sun.COM * some error strings 103*7836SJohn.Forte@Sun.COM */ 104*7836SJohn.Forte@Sun.COM #define CFG_NOTLOCKED "Configuration not locked" 105*7836SJohn.Forte@Sun.COM #define CFG_RDFAILED "Unable to read configuration" 106*7836SJohn.Forte@Sun.COM #define CFG_EINVAL "Invalid Argument" 107*7836SJohn.Forte@Sun.COM #define CFG_EGENERIC "Generic cfg failure" 108*7836SJohn.Forte@Sun.COM 109*7836SJohn.Forte@Sun.COM 110*7836SJohn.Forte@Sun.COM char *cfg_location(char *location, int mode, char *altroot); 111*7836SJohn.Forte@Sun.COM 112*7836SJohn.Forte@Sun.COM /* 113*7836SJohn.Forte@Sun.COM * location modes 114*7836SJohn.Forte@Sun.COM */ 115*7836SJohn.Forte@Sun.COM #define CFG_LOC_SET_LOCAL 0 116*7836SJohn.Forte@Sun.COM #define CFG_LOC_GET_LOCAL 1 117*7836SJohn.Forte@Sun.COM #define CFG_LOC_SET_CLUSTER 2 118*7836SJohn.Forte@Sun.COM #define CFG_LOC_GET_CLUSTER 3 119*7836SJohn.Forte@Sun.COM 120*7836SJohn.Forte@Sun.COM /* 121*7836SJohn.Forte@Sun.COM * location strings 122*7836SJohn.Forte@Sun.COM */ 123*7836SJohn.Forte@Sun.COM #define CFG_LOCAL_LOCATION "/etc/dscfg_local" 124*7836SJohn.Forte@Sun.COM #define CFG_CLUSTER_LOCATION "/etc/dscfg_cluster" 125*7836SJohn.Forte@Sun.COM 126*7836SJohn.Forte@Sun.COM void cfg_close(CFGFILE *); 127*7836SJohn.Forte@Sun.COM 128*7836SJohn.Forte@Sun.COM /* 129*7836SJohn.Forte@Sun.COM * lock mode 130*7836SJohn.Forte@Sun.COM */ 131*7836SJohn.Forte@Sun.COM typedef enum { 132*7836SJohn.Forte@Sun.COM CFG_RDLOCK, 133*7836SJohn.Forte@Sun.COM CFG_WRLOCK, 134*7836SJohn.Forte@Sun.COM CFG_UPGRADE 135*7836SJohn.Forte@Sun.COM } CFGLOCK; 136*7836SJohn.Forte@Sun.COM 137*7836SJohn.Forte@Sun.COM int cfg_lock(CFGFILE *, CFGLOCK); /* lock the configuration */ 138*7836SJohn.Forte@Sun.COM void cfp_unlock(cfp_t *); /* unlock the configuration */ 139*7836SJohn.Forte@Sun.COM void cfg_unlock(CFGFILE *); 140*7836SJohn.Forte@Sun.COM int cfg_get_lock(CFGFILE *, CFGLOCK *, pid_t *); /* get config lock */ 141*7836SJohn.Forte@Sun.COM 142*7836SJohn.Forte@Sun.COM int cfg_commit(CFGFILE *); 143*7836SJohn.Forte@Sun.COM void cfg_resource(CFGFILE *, const char *); /* Set/clear cluster node */ 144*7836SJohn.Forte@Sun.COM char *cfg_get_resource(CFGFILE *); /* get current cluster node */ 145*7836SJohn.Forte@Sun.COM char *cfg_dgname(const char *, char *, size_t); /* parse dg from pathname */ 146*7836SJohn.Forte@Sun.COM char *cfg_l_dgname(const char *, char *, size_t); /* parse dg from pathname */ 147*7836SJohn.Forte@Sun.COM int cfg_dgname_islocal(char *, char **); /* find locality of dg */ 148*7836SJohn.Forte@Sun.COM int cfg_iscluster(void); /* running in a cluster? */ 149*7836SJohn.Forte@Sun.COM int cfg_issuncluster(void); /* running in a Sun Cluster? */ 150*7836SJohn.Forte@Sun.COM void cfg_invalidate_sizes(int); 151*7836SJohn.Forte@Sun.COM 152*7836SJohn.Forte@Sun.COM /* 153*7836SJohn.Forte@Sun.COM * add/rem result codes 154*7836SJohn.Forte@Sun.COM */ 155*7836SJohn.Forte@Sun.COM #define CFG_USER_ERR 1 156*7836SJohn.Forte@Sun.COM #define CFG_USER_OK 2 157*7836SJohn.Forte@Sun.COM #define CFG_USER_FIRST 3 158*7836SJohn.Forte@Sun.COM #define CFG_USER_LAST 4 159*7836SJohn.Forte@Sun.COM #define CFG_USER_GONE 5 160*7836SJohn.Forte@Sun.COM #define CFG_USER_REPEAT 6 161*7836SJohn.Forte@Sun.COM 162*7836SJohn.Forte@Sun.COM int cfg_add_user(CFGFILE *, char *, char *, char *); /* add volume user */ 163*7836SJohn.Forte@Sun.COM int cfg_rem_user(CFGFILE *, char *, char *, char *); /* remove vol user */ 164*7836SJohn.Forte@Sun.COM int cfg_vol_enable(CFGFILE *, char *, char *, char *); /* enable volume */ 165*7836SJohn.Forte@Sun.COM int cfg_vol_disable(CFGFILE *, char *, char *, char *); /* disable volume */ 166*7836SJohn.Forte@Sun.COM 167*7836SJohn.Forte@Sun.COM int cfg_load_dsvols(CFGFILE *); /* load dsvol: section */ 168*7836SJohn.Forte@Sun.COM void cfg_unload_dsvols(); /* unload dsvol: section */ 169*7836SJohn.Forte@Sun.COM int cfg_load_svols(CFGFILE *); /* load sv: section */ 170*7836SJohn.Forte@Sun.COM void cfg_unload_svols(); /* unload sv: section */ 171*7836SJohn.Forte@Sun.COM int cfg_load_shadows(CFGFILE *); /* load shadows & bitmaps from ii: */ 172*7836SJohn.Forte@Sun.COM void cfg_unload_shadows(); /* unload ii: */ 173*7836SJohn.Forte@Sun.COM 174*7836SJohn.Forte@Sun.COM int cfg_get_canonical_name(CFGFILE *, const char *, char **); 175*7836SJohn.Forte@Sun.COM 176*7836SJohn.Forte@Sun.COM #ifdef __cplusplus 177*7836SJohn.Forte@Sun.COM } 178*7836SJohn.Forte@Sun.COM #endif 179*7836SJohn.Forte@Sun.COM 180*7836SJohn.Forte@Sun.COM #endif /* _CFG_H */ 181