xref: /illumos-gate/usr/src/cmd/pools/common/utils.h (revision ddb365bfc9e868ad24ccdcb0dc91af18b10df082)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_UTILS_H
28 #define	_UTILS_H
29 
30 #include <sys/types.h>
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /* Error messages for pool commands */
37 #define	ERR_SET_TERM		"cleanup installation failed: %s\n"
38 #define	ERR_CONF_LOAD		"cannot load configuration from %s: %s\n"
39 #define	ERR_CMD_FILE_INIT	"cannot initialise command sequence: %s\n"
40 #define	ERR_PROP_TO_LIST	"cannot add property %s to property list\n"
41 #define	ERR_UNKNOWN_ENTITY	"unrecognised entity %lld\n"
42 #define	ERR_ASSOC_TO_LIST	"cannot add association %s to association " \
43 	"list\n"
44 #define	ERR_GET_ELEMENT_DETAILS	"cannot get the %s details for %s: %s\n"
45 #define	ERR_LOCATE_ELEMENT	"cannot locate the %s, %s: %s\n"
46 #define	ERR_CREATE_ELEMENT	"cannot create the %s, %s: %s\n"
47 #define	ERR_DESTROY_ELEMENT	"cannot destroy the %s, %s: %s\n"
48 #define	ERR_ALLOC_ELEMENT	"cannot allocate %s: %s\n"
49 #define	ERR_PUT_PROPERTY	"put property %s failed: %s\n"
50 #define	ERR_REMOVE_PROPERTY	"remove property %s failed: %s\n"
51 #define	ERR_GET_PROPERTY	"get property %s failed: %s\n"
52 #define	ERR_UNKNOWN_RESOURCE	"unrecognized resource type: %d\n"
53 #define	ERR_ASSOC_RESOURCE	"cannot associate resource %s to pool: %s\n"
54 #define	ERR_VALIDATION_FAILED	"configuration failed strict validation: %s\n"
55 #define	ERR_CONFIG_OPEN_FAILED	"cannot open the configuration: %s\n"
56 #define	ERR_CONFIG_SAVE_FAILED	"cannot save the configuration: %s\n"
57 #define	ERR_WRONG_SYSTEM_NAME	"incorrect system name supplied: %s\n"
58 #define	ERR_CMD_LINE_ALLOC	"cannot create command, not enough memory\n"
59 #define	ERR_PROP_ALLOC		"cannot create property, not enough memory\n"
60 #define	ERR_ASSOC_ALLOC		"cannot create association, not enough memory\n"
61 
62 #define	ERR_DISABLE		"cannot disable pools"
63 #define	ERR_ENABLE		"cannot enable pools"
64 #define	ERR_NOMEM		"not enough memory\n"
65 #define	ERR_PERMISSIONS		"insufficient privileges\n"
66 #define	ERR_PRIVILEGE		"cannot access %s privileges"
67 #define	ERR_OPEN_DYNAMIC	"couldn't open pools state file: %s\n"
68 #define	ERR_OPEN_STATIC		"couldn't open configuration at '%s': %s\n"
69 #define	ERR_VALIDATE_RUNTIME	"configuration at '%s' cannot be instantiated "\
70 	"on current system\n"
71 #define	ERR_COMMIT_DYNAMIC	"couldn't commit configuration changes at '%s'"\
72 	": %s\n"
73 #define	ERR_REMOVE_DYNAMIC	"couldn't remove dynamic configuration: %s\n"
74 #define	ERR_COMMIT_STATIC	"couldn't commit configuration changes at '%s'"\
75 	": %s\n"
76 #define	ERR_EXPORT_DYNAMIC	"couldn't export pools state file to '%s': %s\n"
77 #define	ERR_NO_POOLS		"no pools defined\n"
78 #define	ERR_XFER_COMPONENT	"cannot transfer %s %s to %s: %s\n"
79 #define	ERR_XFER_QUANTITY	"cannot transfer %llu from %s to %s: %s\n"
80 #define	ERR_CMDPARSE_FAILED	"command parsing failed, terminating...\n"
81 
82 #define	CONFIGURATION		"configuration"
83 #define	RESOURCE		"resource"
84 #define	POOL			"pool"
85 #define	PSET			"pset"
86 #define	COMPONENT		"component"
87 #define	CPU			"cpu"
88 #define	SYSTEM_NAME		"system.name"
89 #define	POOL_NAME		"pool.name"
90 #define	PSET_NAME		"pset.name"
91 #define	CPU_SYSID		"cpu.sys_id"
92 
93 #define	E_PO_SUCCESS	0		/* Exit status for success */
94 #define	E_ERROR		1		/* Exit status for error */
95 #define	E_USAGE		2		/* Exit status for usage error */
96 
97 extern const char *get_errstr(void);
98 extern const char *get_errstr_err(int, int);
99 extern void warn(const char *, ...);
100 extern void die(const char *, ...) __NORETURN;
101 extern const char *getpname(const char *);
102 
103 #ifdef	__cplusplus
104 }
105 #endif
106 
107 #endif	/* _UTILS_H */
108