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 /* 24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. 26 */ 27 28 #ifndef _FMD_ASRU_H 29 #define _FMD_ASRU_H 30 31 #pragma ident "%Z%%M% %I% %E% SMI" 32 33 #include <sys/types.h> 34 #include <pthread.h> 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 #include <fmd_api.h> 41 #include <fmd_log.h> 42 43 typedef struct fmd_asru { 44 struct fmd_asru *asru_next; /* next asru on hash chain */ 45 char *asru_name; /* string form of resource fmri (ro) */ 46 nvlist_t *asru_fmri; /* nvlist form of resource fmri (ro) */ 47 char *asru_root; /* directory for cache entry (ro) */ 48 char *asru_uuid; /* uuid for asru cache entry (ro) */ 49 uint_t asru_uuidlen; /* length of asru_uuid (not incl. \0) */ 50 fmd_log_t *asru_log; /* persistent event log */ 51 pthread_mutex_t asru_lock; /* lock protecting remaining members */ 52 pthread_cond_t asru_cv; /* condition variable for asru_flags */ 53 uint_t asru_refs; /* reference count */ 54 uint_t asru_flags; /* flags (see below) */ 55 fmd_case_t *asru_case; /* case associated with last change */ 56 nvlist_t *asru_event; /* case event inside of asru_case */ 57 } fmd_asru_t; 58 59 #define FMD_ASRU_FAULTY 0x01 /* asru has been diagnosed as faulty */ 60 #define FMD_ASRU_UNUSABLE 0x02 /* asru can not be used at present */ 61 #define FMD_ASRU_VALID 0x04 /* asru is initialized and valid */ 62 #define FMD_ASRU_INTERNAL 0x08 /* asru is managed by fmd itself */ 63 #define FMD_ASRU_INVISIBLE 0x10 /* asru is not visibly administered */ 64 #define FMD_ASRU_RECREATED 0x20 /* asru recreated by cache replay */ 65 66 #define FMD_ASRU_STATE (FMD_ASRU_FAULTY | FMD_ASRU_UNUSABLE) 67 68 typedef struct fmd_asru_hash { 69 pthread_rwlock_t ah_lock; /* r/w lock protecting hash contents */ 70 fmd_asru_t **ah_hash; /* hash bucket array for asrus */ 71 uint_t ah_hashlen; /* length of hash bucket array */ 72 char *ah_dirpath; /* path of hash's log file directory */ 73 uint64_t ah_lifetime; /* max lifetime of log if not present */ 74 uint_t ah_count; /* count of number of entries in hash */ 75 int ah_error; /* error from opening asru log */ 76 } fmd_asru_hash_t; 77 78 extern fmd_asru_hash_t *fmd_asru_hash_create(const char *, const char *); 79 extern void fmd_asru_hash_destroy(fmd_asru_hash_t *); 80 extern void fmd_asru_hash_refresh(fmd_asru_hash_t *); 81 82 extern void fmd_asru_hash_apply(fmd_asru_hash_t *, 83 void (*)(fmd_asru_t *, void *), void *); 84 85 extern fmd_asru_t *fmd_asru_hash_lookup_name(fmd_asru_hash_t *, const char *); 86 extern fmd_asru_t *fmd_asru_hash_lookup_nvl(fmd_asru_hash_t *, nvlist_t *, int); 87 extern void fmd_asru_hash_release(fmd_asru_hash_t *, fmd_asru_t *); 88 extern int fmd_asru_hash_delete_name(fmd_asru_hash_t *, const char *); 89 90 extern int fmd_asru_setflags(fmd_asru_t *, uint_t, fmd_case_t *, nvlist_t *); 91 extern int fmd_asru_clrflags(fmd_asru_t *, uint_t, fmd_case_t *, nvlist_t *); 92 extern int fmd_asru_getstate(fmd_asru_t *); 93 94 #ifdef __cplusplus 95 } 96 #endif 97 98 #endif /* _FMD_ASRU_H */ 99