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
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.
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]
23 * Copyright (c) 2000-2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #ifndef _RCM_SCRIPT_IMPL_H
28 #define _RCM_SCRIPT_IMPL_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
39 /* Minimum and maximum rcm scripting API version supported. */
40 #define SCRIPT_API_MIN_VER 1
41 #define SCRIPT_API_MAX_VER 1
44 * Default maximum time (in seconds) allocated for an rcm command
45 * before SIGABRT is sent.
47 #define SCRIPT_CMD_TIMEOUT 60
50 * Maximum time (in seconds) allocated after sending SIGABRT before
51 * the script is killed.
53 #define SCRIPT_ABORT_TIMEOUT 10
56 * Maximum time (in seconds) for which the rcm daemon checks whether
57 * a script is killed or not after the rcm daemon kills the script.
59 #define SCRIPT_KILL_TIMEOUT 3
61 /* Maximum number of command line parameters passed to a script */
64 /* Maximum number of environment parameters passed to a script */
65 #define MAX_ENV_PARAMS 64
67 #define MAX_LINE_LEN (4*1024)
68 #define MAX_FLAGS_NAME_LEN 64
76 } script_exit_codes_t
;
78 /* This structure is used to maintain a list of current dr'ed resources */
85 * Main data structure for rcm scripting. There will be one instance of
86 * this structure for every rcm script. A pointer to this structure is
87 * kept in module structure.
89 typedef struct script_info
{
91 * Used to maintain a queue of script_info structures
92 * Global variable script_info_q is the head of the queue.
96 rcm_queue_t drreq_q
; /* queue head for current dr'ed resources */
101 char *script_full_name
; /* name of the script including path */
102 char *script_name
; /* name of the script without path component */
105 * file descriptors used to communicate with the script
106 * pipe1 is used to capture script's stdout
107 * pipe2 is used to capture script's stderr
112 pid_t pid
; /* process id of the script process */
113 thread_t tid
; /* thread id of the stderr reader thread */
116 * Lock to protect the fileds in this structure and also to protect
117 * the communication channel to the script.
119 mutex_t channel_lock
;
121 int ver
; /* scripting api version of the script */
122 int cmd
; /* current rcm scripting command */
123 int cmd_timeout
; /* timeout value in seconds */
124 int exit_status
; /* exit status of the script */
126 /* time stamp of the script when it was last run */
130 char *func_info_buf_curptr
;
131 int func_info_buf_len
;
133 char *resource_usage_info_buf
;
134 char *resource_usage_info_buf_curptr
;
135 int resource_usage_info_buf_len
;
137 char *failure_reason_buf
;
138 char *failure_reason_buf_curptr
;
139 int failure_reason_buf_len
;
144 * script_info_t:flags
146 #define STDERR_THREAD_CREATED 1
148 #define PARENT_END_OF_PIPE 0
149 #define CHILD_END_OF_PIPE 1
151 #define PS_STATE_FILE_VER 1
153 typedef struct state_element
{
155 uint32_t reserved
; /* for 64 bit alignment */
156 /* followed by actual state element */
160 * state_element_t:flags
161 * The following flag when set indicates that the state element is
162 * currently in use. When not set indicates that the state element is free.
164 #define STATE_ELEMENT_IN_USE 0x1
167 * This structure defines the layout of state file used by rcm scripting
169 typedef struct state_file
{
171 uint32_t max_elements
; /* number of state elements */
172 /* followed by an array of state elements of type state_element_t */
175 typedef struct state_file_descr
{
177 int fd
; /* file descriptor to the state file */
178 size_t element_size
; /* size of one state element */
181 * number of state elements to allocate at a time when the state file
187 * index into the state element array where the next search will
188 * begin for an empty slot.
192 /* pointer to mmapped state file */
193 state_file_t
*state_file
;
194 } state_file_descr_t
;
196 /* round up to n byte boundary. n must be power of 2 for this macro to work */
197 #define RSCR_ROUNDUP(x, n) (((x) + ((n) - 1)) & (~((n) - 1)))
199 typedef struct ps_state_element
{
201 char script_name
[MAXNAMELEN
];
202 } ps_state_element_t
;
204 /* maximum number of additional env variables for capacity specific stuff */
205 #define MAX_CAPACITY_PARAMS 10
207 typedef struct capacity_descr
{
213 } param
[MAX_CAPACITY_PARAMS
];
216 /* capacity_descr_t:match_type */
217 #define MATCH_INVALID 0
218 #define MATCH_EXACT 1
219 #define MATCH_PREFIX 2
225 #endif /* _RCM_SCRIPT_IMPL_H */