blob: 6f95ea9404cdb518556057a341e5ac6d09858ddd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYSEVENTCONFD_H
#define _SYSEVENTCONFD_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* debug levels
*/
#define DBG_EXEC 1 /* path and args for each fork/exec */
#define DBG_EVENTS 2 /* received events */
#define DBG_CHILD 3 /* child exit status */
#define DBG_EXEC_ARGS 4 /* more detail on exec args */
/*
* list of cmds received from syseventd/sysevent_conf_mod
*/
struct cmd {
nvlist_t *cmd_nvlist;
struct cmd *cmd_next;
struct cmd *cmd_taiL;
};
/*
* Structures for building arbitarily long strings and argument lists
*/
typedef struct arg {
char **arg_args;
int arg_nargs;
int arg_alloc;
int arg_hint;
} arg_t;
typedef struct str {
char *s_str;
int s_len;
int s_alloc;
int s_hint;
} str_t;
/*
* Prototypes
*/
static void event_handler(sysevent_t *event);
static void exec_cmd(struct cmd *cmd);
static void sigwait_thr(void);
static void reapchild(int sig);
static void flt_handler(int sig);
static void syserrmsg(char *message, ...);
static void printmsg(int level, char *message, ...);
static void set_root_dir(char *dir);
static void usage(void);
static arg_t *init_arglist(int hint);
static void free_arglist(arg_t *arglist);
static int add_arg(arg_t *arglist, char *arg);
static char *next_arg(char **cpp);
static struct cmd *alloc_cmd(nvlist_t *nvlist);
static void free_cmd(struct cmd *cmd);
static void *sc_malloc(size_t n);
static void *sc_realloc(void *p, size_t n);
static sysevent_handle_t *open_channel(void);
#ifdef __cplusplus
}
#endif
#endif /* _SYSEVENTCONFD_H */
|