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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _FMD_LOG_H 28 #define _FMD_LOG_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <sys/types.h> 33 #include <sys/stat.h> 34 #include <pthread.h> 35 #include <exacct.h> 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 #include <fmd_api.h> 42 43 typedef struct fmd_log { 44 char *log_name; /* file pathname */ 45 char *log_tag; /* file content tag */ 46 int log_fd; /* file descriptor */ 47 struct stat64 log_stat; /* status of file at log_open() time */ 48 ea_file_t log_ea; /* exacct file structure */ 49 pthread_mutex_t log_lock; /* lock for flags, refs, off, append */ 50 pthread_cond_t log_cv; /* condition variable for waiters */ 51 int log_flags; /* file flags (see below) */ 52 uint_t log_refs; /* file reference count */ 53 uint_t log_pending; /* number of pending log commits */ 54 off64_t log_toc; /* offset of table of contents */ 55 off64_t log_beg; /* offset of first data record */ 56 off64_t log_off; /* offset at which to append */ 57 off64_t log_skip; /* offset to skip to for replay */ 58 uint64_t log_minfree; /* minimum free bytes for filesystem */ 59 } fmd_log_t; 60 61 #define FMD_LF_EAOPEN 0x1 /* log_ea is open and valid */ 62 #define FMD_LF_REPLAY 0x2 /* log records should use replay tag */ 63 #define FMD_LF_DIRTY 0x4 /* log toc should be updated */ 64 #define FMD_LF_BUSY 0x8 /* log is busy; skip updates */ 65 66 typedef void fmd_log_f(fmd_log_t *, fmd_event_t *, void *); 67 68 #define FMD_LOG_ERROR "error" /* tag for error log files */ 69 #define FMD_LOG_FAULT "fault" /* tag for fault log files */ 70 #define FMD_LOG_ASRU "asru" /* tag for asru 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