xref: /titanic_52/usr/src/cmd/syseventd/daemons/syseventconfd/syseventconfd.h (revision 80ab886d233f514d54c2a6bdeb9fdfd951bd6881)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*80ab886dSwesolows  * Common Development and Distribution License (the "License").
6*80ab886dSwesolows  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21*80ab886dSwesolows 
227c478bd9Sstevel@tonic-gate /*
23*80ab886dSwesolows  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24*80ab886dSwesolows  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SYSEVENTCONFD_H
287c478bd9Sstevel@tonic-gate #define	_SYSEVENTCONFD_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
337c478bd9Sstevel@tonic-gate extern "C" {
347c478bd9Sstevel@tonic-gate #endif
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate /*
387c478bd9Sstevel@tonic-gate  * debug levels
397c478bd9Sstevel@tonic-gate  */
407c478bd9Sstevel@tonic-gate #define	DBG_EXEC	1	/* path and args for each fork/exec */
417c478bd9Sstevel@tonic-gate #define	DBG_EVENTS	2	/* received events */
427c478bd9Sstevel@tonic-gate #define	DBG_CHILD	3	/* child exit status */
437c478bd9Sstevel@tonic-gate #define	DBG_EXEC_ARGS	4	/* more detail on exec args */
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * list of cmds received from syseventd/sysevent_conf_mod
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate struct cmd {
507c478bd9Sstevel@tonic-gate 	nvlist_t	*cmd_nvlist;
517c478bd9Sstevel@tonic-gate 	struct cmd	*cmd_next;
527c478bd9Sstevel@tonic-gate 	struct cmd	*cmd_taiL;
537c478bd9Sstevel@tonic-gate };
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  * Structures for building arbitarily long strings and argument lists
587c478bd9Sstevel@tonic-gate  */
597c478bd9Sstevel@tonic-gate typedef struct arg {
607c478bd9Sstevel@tonic-gate 	char	**arg_args;
617c478bd9Sstevel@tonic-gate 	int	arg_nargs;
627c478bd9Sstevel@tonic-gate 	int	arg_alloc;
637c478bd9Sstevel@tonic-gate 	int	arg_hint;
647c478bd9Sstevel@tonic-gate } arg_t;
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate typedef struct str {
677c478bd9Sstevel@tonic-gate 	char	*s_str;
687c478bd9Sstevel@tonic-gate 	int	s_len;
697c478bd9Sstevel@tonic-gate 	int	s_alloc;
707c478bd9Sstevel@tonic-gate 	int	s_hint;
717c478bd9Sstevel@tonic-gate } str_t;
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate /*
757c478bd9Sstevel@tonic-gate  * Prototypes
767c478bd9Sstevel@tonic-gate  */
777c478bd9Sstevel@tonic-gate static void event_handler(sysevent_t *event);
787c478bd9Sstevel@tonic-gate static void exec_cmd(struct cmd *cmd);
797c478bd9Sstevel@tonic-gate static void sigwait_thr(void);
807c478bd9Sstevel@tonic-gate static void reapchild(int sig);
817c478bd9Sstevel@tonic-gate static void flt_handler(int sig);
827c478bd9Sstevel@tonic-gate static void syserrmsg(char *message, ...);
837c478bd9Sstevel@tonic-gate static void printmsg(int level, char *message, ...);
847c478bd9Sstevel@tonic-gate static void set_root_dir(char *dir);
857c478bd9Sstevel@tonic-gate static void usage(void);
867c478bd9Sstevel@tonic-gate static arg_t *init_arglist(int hint);
877c478bd9Sstevel@tonic-gate static void free_arglist(arg_t *arglist);
887c478bd9Sstevel@tonic-gate static int add_arg(arg_t *arglist, char *arg);
897c478bd9Sstevel@tonic-gate static char *next_arg(char **cpp);
907c478bd9Sstevel@tonic-gate static struct cmd *alloc_cmd(nvlist_t *nvlist);
917c478bd9Sstevel@tonic-gate static void free_cmd(struct cmd *cmd);
927c478bd9Sstevel@tonic-gate static void *sc_malloc(size_t n);
937c478bd9Sstevel@tonic-gate static void *sc_realloc(void *p, size_t n);
947c478bd9Sstevel@tonic-gate static sysevent_handle_t *open_channel(void);
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
987c478bd9Sstevel@tonic-gate }
997c478bd9Sstevel@tonic-gate #endif
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate #endif	/* _SYSEVENTCONFD_H */
102