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