xref: /titanic_44/usr/src/cmd/fm/fmd/common/fmd_log.h (revision cb04b8739c50e3e6d12e89b790fa7b8d0d899865)
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  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef	_FMD_LOG_H
26 #define	_FMD_LOG_H
27 
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #include <pthread.h>
31 #include <exacct.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #include <fmd_api.h>
38 
39 typedef struct fmd_log {
40 	char *log_name;			/* file pathname */
41 	char *log_tag;			/* file content tag */
42 	int log_fd;			/* file descriptor */
43 	struct stat64 log_stat;		/* status of file at log_open() time */
44 	ea_file_t log_ea;		/* exacct file structure */
45 	pthread_mutex_t log_lock;	/* lock for flags, refs, off, append */
46 	pthread_cond_t log_cv;		/* condition variable for waiters */
47 	int log_flags;			/* file flags (see below) */
48 	uint_t log_refs;		/* file reference count */
49 	uint_t log_pending;		/* number of pending log commits */
50 	off64_t log_toc;		/* offset of table of contents */
51 	off64_t log_beg;		/* offset of first data record */
52 	off64_t log_off;		/* offset at which to append */
53 	off64_t log_skip;		/* offset to skip to for replay */
54 	uint64_t log_minfree;		/* minimum free bytes for filesystem */
55 	char *log_uuid;			/* uuid string for this log file */
56 	uint_t log_uuidlen;		/* length of log_uuid (not incl. \0) */
57 } fmd_log_t;
58 
59 #define	FMD_LF_EAOPEN	0x1		/* log_ea is open and valid */
60 #define	FMD_LF_REPLAY	0x2		/* log records should use replay tag */
61 #define	FMD_LF_DIRTY	0x4		/* log toc should be updated */
62 #define	FMD_LF_BUSY	0x8		/* log is busy; skip updates */
63 
64 typedef void fmd_log_f(fmd_log_t *, fmd_event_t *, void *);
65 
66 #define	FMD_LOG_ERROR	"error"		/* tag for error log files */
67 #define	FMD_LOG_FAULT	"fault"		/* tag for fault log files */
68 #define	FMD_LOG_ASRU	"asru"		/* tag for asru log files */
69 #define	FMD_LOG_XPRT	"xprt"		/* tag for transport log files */
70 #define	FMD_LOG_INFO	"info"		/* tag for info event log files */
71 
72 extern fmd_log_t *fmd_log_tryopen(const char *, const char *, const char *);
73 extern fmd_log_t *fmd_log_open(const char *, const char *, const char *);
74 extern void fmd_log_close(fmd_log_t *);
75 
76 extern void fmd_log_hold_pending(fmd_log_t *);
77 extern void fmd_log_hold(fmd_log_t *);
78 extern void fmd_log_rele(fmd_log_t *);
79 
80 extern void fmd_log_append(fmd_log_t *, fmd_event_t *, fmd_case_t *);
81 extern void fmd_log_commit(fmd_log_t *, fmd_event_t *);
82 extern void fmd_log_decommit(fmd_log_t *, fmd_event_t *);
83 extern void fmd_log_replay(fmd_log_t *, fmd_log_f *, void *);
84 extern void fmd_log_update(fmd_log_t *);
85 extern fmd_log_t *fmd_log_rotate(fmd_log_t *);
86 
87 #ifdef	__cplusplus
88 }
89 #endif
90 
91 #endif	/* _FMD_LOG_H */
92