1 0 stevel /* 2 0 stevel * CDDL HEADER START 3 0 stevel * 4 0 stevel * The contents of this file are subject to the terms of the 5 6640 cth * Common Development and Distribution License (the "License"). 6 6640 cth * You may not use this file except in compliance with the License. 7 0 stevel * 8 0 stevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 0 stevel * or http://www.opensolaris.org/os/licensing. 10 0 stevel * See the License for the specific language governing permissions 11 0 stevel * and limitations under the License. 12 0 stevel * 13 0 stevel * When distributing Covered Code, include this CDDL HEADER in each 14 0 stevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 0 stevel * If applicable, add the following below this CDDL HEADER, with the 16 0 stevel * fields enclosed by brackets "[]" replaced with your own identifying 17 0 stevel * information: Portions Copyright [yyyy] [name of copyright owner] 18 0 stevel * 19 0 stevel * CDDL HEADER END 20 0 stevel */ 21 0 stevel /* 22 6640 cth * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 0 stevel * Use is subject to license terms. 24 0 stevel */ 25 0 stevel 26 0 stevel #ifndef _FMD_LOG_H 27 0 stevel #define _FMD_LOG_H 28 0 stevel 29 0 stevel #pragma ident "%Z%%M% %I% %E% SMI" 30 0 stevel 31 0 stevel #include <libnvpair.h> 32 0 stevel #include <exacct.h> 33 6640 cth #include <regex.h> 34 0 stevel 35 0 stevel #ifdef __cplusplus 36 0 stevel extern "C" { 37 0 stevel #endif 38 0 stevel 39 0 stevel /* 40 0 stevel * Fault Management Daemon Log File Interfaces 41 0 stevel * 42 0 stevel * Note: The contents of this file are private to the implementation of the 43 0 stevel * Solaris system and FMD subsystem and are subject to change at any time 44 0 stevel * without notice. Applications and drivers using these interfaces will fail 45 0 stevel * to run on future releases. These interfaces should not be used for any 46 0 stevel * purpose until they are publicly documented for use outside of Sun. 47 0 stevel */ 48 0 stevel 49 1052 dilpreet #define FMD_LOG_VERSION 2 /* library ABI interface version */ 50 0 stevel 51 0 stevel typedef struct fmd_log fmd_log_t; 52 0 stevel 53 0 stevel extern fmd_log_t *fmd_log_open(int, const char *, int *); 54 0 stevel extern void fmd_log_close(fmd_log_t *); 55 0 stevel extern const char *fmd_log_label(fmd_log_t *); 56 0 stevel 57 0 stevel extern const char *fmd_log_errmsg(fmd_log_t *, int); 58 0 stevel extern int fmd_log_errno(fmd_log_t *); 59 0 stevel 60 0 stevel typedef struct fmd_log_header { 61 0 stevel const char *log_creator; /* ea_get_creator(3EXACCT) string */ 62 0 stevel const char *log_hostname; /* ea_get_hostname(3EXACCT) string */ 63 0 stevel const char *log_label; /* fmd(1M) log file label */ 64 0 stevel const char *log_version; /* fmd(1M) log file version */ 65 0 stevel const char *log_osrelease; /* uname(1) -r value at creation time */ 66 0 stevel const char *log_osversion; /* uname(1) -v value at creation time */ 67 0 stevel const char *log_platform; /* uname(1) -i value at creation time */ 68 1052 dilpreet const char *log_uuid; /* fmd(1M) log file uuid */ 69 0 stevel } fmd_log_header_t; 70 0 stevel 71 0 stevel extern void fmd_log_header(fmd_log_t *, fmd_log_header_t *); 72 0 stevel 73 0 stevel typedef struct fmd_log_record { 74 0 stevel ea_object_t *rec_grp; /* log file exacct record group */ 75 0 stevel nvlist_t *rec_nvl; /* protocol name-value pair list */ 76 0 stevel const char *rec_class; /* protocol event class */ 77 0 stevel uint64_t rec_sec; /* time-of-day seconds */ 78 0 stevel uint64_t rec_nsec; /* time-of-day nanoseconds */ 79 0 stevel struct fmd_log_record *rec_xrefs; /* array of cross-references */ 80 0 stevel uint32_t rec_nrefs; /* size of rec_xrefs array */ 81 0 stevel off64_t rec_off; /* file offset (if requested) */ 82 0 stevel } fmd_log_record_t; 83 0 stevel 84 0 stevel typedef int fmd_log_rec_f(fmd_log_t *, const fmd_log_record_t *, void *); 85 0 stevel typedef int fmd_log_err_f(fmd_log_t *, void *); 86 0 stevel 87 0 stevel extern int fmd_log_rewind(fmd_log_t *); 88 0 stevel extern int fmd_log_iter(fmd_log_t *, fmd_log_rec_f *, void *); 89 0 stevel extern int fmd_log_seek(fmd_log_t *, off64_t); 90 0 stevel 91 0 stevel #define FMD_LOG_XITER_REFS 0x1 /* load event cross-references */ 92 0 stevel #define FMD_LOG_XITER_OFFS 0x2 /* compute rec_off for each record */ 93 0 stevel #define FMD_LOG_XITER_MASK 0x3 /* mask of all valid flag bits */ 94 0 stevel 95 0 stevel typedef struct fmd_log_filter { 96 0 stevel fmd_log_rec_f *filt_func; /* filter function (see below) */ 97 0 stevel void *filt_arg; /* filter argument (see below) */ 98 0 stevel } fmd_log_filter_t; 99 0 stevel 100 0 stevel extern fmd_log_rec_f fmd_log_filter_class; /* char *name of event class */ 101 0 stevel extern fmd_log_rec_f fmd_log_filter_uuid; /* char *uuid of list.suspect */ 102 0 stevel extern fmd_log_rec_f fmd_log_filter_before; /* struct timeval * latest */ 103 0 stevel extern fmd_log_rec_f fmd_log_filter_after; /* struct timeval * earliest */ 104 6640 cth extern fmd_log_rec_f fmd_log_filter_nv; /* char *namevalue in event */ 105 0 stevel 106 0 stevel extern int fmd_log_filter(fmd_log_t *, 107 0 stevel uint_t, fmd_log_filter_t *, const fmd_log_record_t *); 108 6640 cth 109 6640 cth typedef struct fmd_log_filter_nvarg { 110 6640 cth char *nvarg_name; 111 6640 cth char *nvarg_value; 112 6640 cth regex_t *nvarg_value_regex; 113 6640 cth } fmd_log_filter_nvarg_t; 114 0 stevel 115 0 stevel /* 116 0 stevel * fmd_log_xiter() can be used to perform sophisticated iteration over an fmd 117 0 stevel * log file such as that required by fmdump(1M). The arguments are as follows: 118 0 stevel * 119 0 stevel * fmd_log_t *lp - log to use for iteration from fmd_log_open() 120 0 stevel * uint_t iflags - FMD_LOG_XITER_* flags (see above) 121 0 stevel * uint_t filtc - count of number of filters (or zero for no filtering) 122 0 stevel * fmd_log_filter_t *filtv - array of 'filtc' filter structures 123 0 stevel * fmd_log_rec_f *rfunc - function to invoke for each record in log 124 0 stevel * fmd_log_err_f *efunc - function to invoke for any errors in log 125 0 stevel * void *private - argument to pass to 'rfunc' and 'efunc' callbacks 126 0 stevel * ulong_t *cntp - pointer to storage for record count (or NULL) 127 0 stevel */ 128 0 stevel extern int fmd_log_xiter(fmd_log_t *, uint_t, uint_t, fmd_log_filter_t *, 129 0 stevel fmd_log_rec_f *, fmd_log_err_f *, void *, ulong_t *); 130 0 stevel 131 0 stevel #ifdef __cplusplus 132 0 stevel } 133 0 stevel #endif 134 0 stevel 135 0 stevel #endif /* _FMD_LOG_H */ 136