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 2005 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 65 #define FMD_ASRU_STATE (FMD_ASRU_FAULTY | FMD_ASRU_UNUSABLE) 66 67 typedef struct fmd_asru_hash { 68 pthread_rwlock_t ah_lock; /* r/w lock protecting hash contents */ 69 fmd_asru_t **ah_hash; /* hash bucket array for asrus */ 70 uint_t ah_hashlen; /* length of hash bucket array */ 71 char *ah_dirpath; /* path of hash's log file directory */ 72 uint64_t ah_lifetime; /* max lifetime of log if not present */ 73 uint_t ah_count; /* count of number of entries in hash */ 74 int ah_error; /* error from opening asru log */ 75 } fmd_asru_hash_t; 76 77 extern fmd_asru_hash_t *fmd_asru_hash_create(const char *, const char *); 78 extern void fmd_asru_hash_destroy(fmd_asru_hash_t *); 79 extern void fmd_asru_hash_refresh(fmd_asru_hash_t *); 80 81 extern void fmd_asru_hash_apply(fmd_asru_hash_t *, 82 void (*)(fmd_asru_t *, void *), void *); 83 84 extern fmd_asru_t *fmd_asru_hash_lookup_name(fmd_asru_hash_t *, const char *); 85 extern fmd_asru_t *fmd_asru_hash_lookup_nvl(fmd_asru_hash_t *, nvlist_t *, int); 86 extern void fmd_asru_hash_release(fmd_asru_hash_t *, fmd_asru_t *); 87 extern int fmd_asru_hash_delete_name(fmd_asru_hash_t *, const char *); 88 89 extern int fmd_asru_setflags(fmd_asru_t *, uint_t, fmd_case_t *, nvlist_t *); 90 extern int fmd_asru_clrflags(fmd_asru_t *, uint_t, fmd_case_t *, nvlist_t *); 91 extern int fmd_asru_getstate(fmd_asru_t *); 92 93 #ifdef __cplusplus 94 } 95 #endif 96 97 #endif /* _FMD_ASRU_H */ 98