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 <libnvpair.h> 33 #include <exacct.h> 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 /* 40 * Fault Management Daemon Log File Interfaces 41 * 42 * Note: The contents of this file are private to the implementation of the 43 * Solaris system and FMD subsystem and are subject to change at any time 44 * without notice. Applications and drivers using these interfaces will fail 45 * to run on future releases. These interfaces should not be used for any 46 * purpose until they are publicly documented for use outside of Sun. 47 */ 48 49 #define FMD_LOG_VERSION 1 /* library ABI interface version */ 50 51 typedef struct fmd_log fmd_log_t; 52 53 extern fmd_log_t *fmd_log_open(int, const char *, int *); 54 extern void fmd_log_close(fmd_log_t *); 55 extern const char *fmd_log_label(fmd_log_t *); 56 57 extern const char *fmd_log_errmsg(fmd_log_t *, int); 58 extern int fmd_log_errno(fmd_log_t *); 59 60 typedef struct fmd_log_header { 61 const char *log_creator; /* ea_get_creator(3EXACCT) string */ 62 const char *log_hostname; /* ea_get_hostname(3EXACCT) string */ 63 const char *log_label; /* fmd(1M) log file label */ 64 const char *log_version; /* fmd(1M) log file version */ 65 const char *log_osrelease; /* uname(1) -r value at creation time */ 66 const char *log_osversion; /* uname(1) -v value at creation time */ 67 const char *log_platform; /* uname(1) -i value at creation time */ 68 } fmd_log_header_t; 69 70 extern void fmd_log_header(fmd_log_t *, fmd_log_header_t *); 71 72 typedef struct fmd_log_record { 73 ea_object_t *rec_grp; /* log file exacct record group */ 74 nvlist_t *rec_nvl; /* protocol name-value pair list */ 75 const char *rec_class; /* protocol event class */ 76 uint64_t rec_sec; /* time-of-day seconds */ 77 uint64_t rec_nsec; /* time-of-day nanoseconds */ 78 struct fmd_log_record *rec_xrefs; /* array of cross-references */ 79 uint32_t rec_nrefs; /* size of rec_xrefs array */ 80 off64_t rec_off; /* file offset (if requested) */ 81 } fmd_log_record_t; 82 83 typedef int fmd_log_rec_f(fmd_log_t *, const fmd_log_record_t *, void *); 84 typedef int fmd_log_err_f(fmd_log_t *, void *); 85 86 extern int fmd_log_rewind(fmd_log_t *); 87 extern int fmd_log_iter(fmd_log_t *, fmd_log_rec_f *, void *); 88 extern int fmd_log_seek(fmd_log_t *, off64_t); 89 90 #define FMD_LOG_XITER_REFS 0x1 /* load event cross-references */ 91 #define FMD_LOG_XITER_OFFS 0x2 /* compute rec_off for each record */ 92 #define FMD_LOG_XITER_MASK 0x3 /* mask of all valid flag bits */ 93 94 typedef struct fmd_log_filter { 95 fmd_log_rec_f *filt_func; /* filter function (see below) */ 96 void *filt_arg; /* filter argument (see below) */ 97 } fmd_log_filter_t; 98 99 extern fmd_log_rec_f fmd_log_filter_class; /* char *name of event class */ 100 extern fmd_log_rec_f fmd_log_filter_uuid; /* char *uuid of list.suspect */ 101 extern fmd_log_rec_f fmd_log_filter_before; /* struct timeval * latest */ 102 extern fmd_log_rec_f fmd_log_filter_after; /* struct timeval * earliest */ 103 104 extern int fmd_log_filter(fmd_log_t *, 105 uint_t, fmd_log_filter_t *, const fmd_log_record_t *); 106 107 /* 108 * fmd_log_xiter() can be used to perform sophisticated iteration over an fmd 109 * log file such as that required by fmdump(1M). The arguments are as follows: 110 * 111 * fmd_log_t *lp - log to use for iteration from fmd_log_open() 112 * uint_t iflags - FMD_LOG_XITER_* flags (see above) 113 * uint_t filtc - count of number of filters (or zero for no filtering) 114 * fmd_log_filter_t *filtv - array of 'filtc' filter structures 115 * fmd_log_rec_f *rfunc - function to invoke for each record in log 116 * fmd_log_err_f *efunc - function to invoke for any errors in log 117 * void *private - argument to pass to 'rfunc' and 'efunc' callbacks 118 * ulong_t *cntp - pointer to storage for record count (or NULL) 119 */ 120 extern int fmd_log_xiter(fmd_log_t *, uint_t, uint_t, fmd_log_filter_t *, 121 fmd_log_rec_f *, fmd_log_err_f *, void *, ulong_t *); 122 123 #ifdef __cplusplus 124 } 125 #endif 126 127 #endif /* _FMD_LOG_H */ 128