17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*f6e214c7SGavin Maltby * Common Development and Distribution License (the "License"). 6*f6e214c7SGavin Maltby * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*f6e214c7SGavin Maltby * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #ifndef _FMD_LOG_H 267c478bd9Sstevel@tonic-gate #define _FMD_LOG_H 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <sys/types.h> 297c478bd9Sstevel@tonic-gate #include <sys/stat.h> 307c478bd9Sstevel@tonic-gate #include <pthread.h> 317c478bd9Sstevel@tonic-gate #include <exacct.h> 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 347c478bd9Sstevel@tonic-gate extern "C" { 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include <fmd_api.h> 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate typedef struct fmd_log { 407c478bd9Sstevel@tonic-gate char *log_name; /* file pathname */ 417c478bd9Sstevel@tonic-gate char *log_tag; /* file content tag */ 427c478bd9Sstevel@tonic-gate int log_fd; /* file descriptor */ 437c478bd9Sstevel@tonic-gate struct stat64 log_stat; /* status of file at log_open() time */ 447c478bd9Sstevel@tonic-gate ea_file_t log_ea; /* exacct file structure */ 457c478bd9Sstevel@tonic-gate pthread_mutex_t log_lock; /* lock for flags, refs, off, append */ 467c478bd9Sstevel@tonic-gate pthread_cond_t log_cv; /* condition variable for waiters */ 477c478bd9Sstevel@tonic-gate int log_flags; /* file flags (see below) */ 487c478bd9Sstevel@tonic-gate uint_t log_refs; /* file reference count */ 497c478bd9Sstevel@tonic-gate uint_t log_pending; /* number of pending log commits */ 507c478bd9Sstevel@tonic-gate off64_t log_toc; /* offset of table of contents */ 517c478bd9Sstevel@tonic-gate off64_t log_beg; /* offset of first data record */ 527c478bd9Sstevel@tonic-gate off64_t log_off; /* offset at which to append */ 537c478bd9Sstevel@tonic-gate off64_t log_skip; /* offset to skip to for replay */ 547c478bd9Sstevel@tonic-gate uint64_t log_minfree; /* minimum free bytes for filesystem */ 557ee93e3bSdilpreet char *log_uuid; /* uuid string for this log file */ 567ee93e3bSdilpreet uint_t log_uuidlen; /* length of log_uuid (not incl. \0) */ 577c478bd9Sstevel@tonic-gate } fmd_log_t; 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate #define FMD_LF_EAOPEN 0x1 /* log_ea is open and valid */ 607c478bd9Sstevel@tonic-gate #define FMD_LF_REPLAY 0x2 /* log records should use replay tag */ 617c478bd9Sstevel@tonic-gate #define FMD_LF_DIRTY 0x4 /* log toc should be updated */ 627c478bd9Sstevel@tonic-gate #define FMD_LF_BUSY 0x8 /* log is busy; skip updates */ 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate typedef void fmd_log_f(fmd_log_t *, fmd_event_t *, void *); 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate #define FMD_LOG_ERROR "error" /* tag for error log files */ 677c478bd9Sstevel@tonic-gate #define FMD_LOG_FAULT "fault" /* tag for fault log files */ 687c478bd9Sstevel@tonic-gate #define FMD_LOG_ASRU "asru" /* tag for asru log files */ 69d9638e54Smws #define FMD_LOG_XPRT "xprt" /* tag for transport log files */ 70*f6e214c7SGavin Maltby #define FMD_LOG_INFO "info" /* tag for info event log files */ 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate extern fmd_log_t *fmd_log_tryopen(const char *, const char *, const char *); 737c478bd9Sstevel@tonic-gate extern fmd_log_t *fmd_log_open(const char *, const char *, const char *); 747c478bd9Sstevel@tonic-gate extern void fmd_log_close(fmd_log_t *); 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate extern void fmd_log_hold_pending(fmd_log_t *); 777c478bd9Sstevel@tonic-gate extern void fmd_log_hold(fmd_log_t *); 787c478bd9Sstevel@tonic-gate extern void fmd_log_rele(fmd_log_t *); 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate extern void fmd_log_append(fmd_log_t *, fmd_event_t *, fmd_case_t *); 817c478bd9Sstevel@tonic-gate extern void fmd_log_commit(fmd_log_t *, fmd_event_t *); 827c478bd9Sstevel@tonic-gate extern void fmd_log_decommit(fmd_log_t *, fmd_event_t *); 837c478bd9Sstevel@tonic-gate extern void fmd_log_replay(fmd_log_t *, fmd_log_f *, void *); 847c478bd9Sstevel@tonic-gate extern void fmd_log_update(fmd_log_t *); 857c478bd9Sstevel@tonic-gate extern fmd_log_t *fmd_log_rotate(fmd_log_t *); 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate #ifdef __cplusplus 887c478bd9Sstevel@tonic-gate } 897c478bd9Sstevel@tonic-gate #endif 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate #endif /* _FMD_LOG_H */ 92