]> granicus.if.org Git - zfs/blob - cmd/zed/zed_conf.h
Obtain advisory lock on ZED PID file
[zfs] / cmd / zed / zed_conf.h
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 from the top-level
9  * OPENSOLARIS.LICENSE or <http://opensource.org/licenses/CDDL-1.0>.
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 file
14  * and include the License file from the top-level 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  * Developed at Lawrence Livermore National Laboratory (LLNL-CODE-403049).
24  * Copyright (C) 2013-2014 Lawrence Livermore National Security, LLC.
25  */
26
27 #ifndef ZED_CONF_H
28 #define ZED_CONF_H
29
30 #include <libzfs.h>
31 #include <stdint.h>
32 #include "zed_strings.h"
33
34 struct zed_conf {
35         unsigned        do_force:1;             /* true if force enabled */
36         unsigned        do_foreground:1;        /* true if run in foreground */
37         unsigned        do_memlock:1;           /* true if locking memory */
38         unsigned        do_verbose:1;           /* true if verbosity enabled */
39         unsigned        do_zero:1;              /* true if zeroing state */
40         int             syslog_facility;        /* syslog facility value */
41         int             min_events;             /* RESERVED FOR FUTURE USE */
42         int             max_events;             /* RESERVED FOR FUTURE USE */
43         char            *conf_file;             /* abs path to config file */
44         char            *pid_file;              /* abs path to pid file */
45         int             pid_fd;                 /* fd to pid file for lock */
46         char            *zedlet_dir;            /* abs path to zedlet dir */
47         zed_strings_t   *zedlets;               /* names of enabled zedlets */
48         char            *state_file;            /* abs path to state file */
49         int             state_fd;               /* fd to state file */
50         libzfs_handle_t *zfs_hdl;               /* handle to libzfs */
51         int             zevent_fd;              /* fd for access to zevents */
52 };
53
54 struct zed_conf *zed_conf_create(void);
55
56 void zed_conf_destroy(struct zed_conf *zcp);
57
58 void zed_conf_parse_opts(struct zed_conf *zcp, int argc, char **argv);
59
60 void zed_conf_parse_file(struct zed_conf *zcp);
61
62 int zed_conf_scan_dir(struct zed_conf *zcp);
63
64 int zed_conf_write_pid(struct zed_conf *zcp);
65
66 int zed_conf_open_state(struct zed_conf *zcp);
67
68 int zed_conf_read_state(struct zed_conf *zcp, uint64_t *eidp, int64_t etime[]);
69
70 int zed_conf_write_state(struct zed_conf *zcp, uint64_t eid, int64_t etime[]);
71
72 #endif  /* !ZED_CONF_H */