fmd_asru.h revision 5750ef5c2584f7399d9b98bfd513c0ca9f79f66e
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _FMD_ASRU_H
#define _FMD_ASRU_H
#include <pthread.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <fmd_api.h>
#include <fmd_log.h>
#include <fmd_list.h>
#include <fmd_topo.h>
/*
* The resource is represented by an fmd_asru_t structure and one or more
* fmd_asru_link_t structures. Each of the latter represents a separate
* unrepaired case (problem) involving the resource. There are separate
* reference counts for both the fmd_asru_t and fmd_asru_link_t structures,
* but only one lock is used (asru_lock) which protects both the parent
* fmd_asru_t and its associated fmd_asru_link_t structures. The FMD_ASRU_FAULTY
* flags in the fmd_asru_t represents the cumulative value of the associated
* FMD_ASRU_FAULTY flags in the fmd_asru_link_t structures (and therefore of
* all independant unrepaired problems that are affecting that resource).
*/
typedef struct fmd_asru {
char *asru_name; /* string form of resource fmri (ro) */
char *asru_root; /* directory for cache entry (ro) */
char *asru_uuid; /* uuid for asru cache entry (ro) */
} fmd_asru_t;
typedef struct fmd_asru_link {
char *al_uuid; /* uuid for asru cache entry (ro) */
char *al_asru_name; /* string form of asru fmri (ro) */
char *al_fru_name; /* string form of fru fmri (ro) */
char *al_rsrc_name; /* string form of resource fmri (ro) */
char *al_label; /* label */
char *al_case_uuid; /* case uuid */
/*
* Note the following are defined in order of increasing precedence and
* this should not be changed
*/
#define FMD_ASRU_REMOVED 0 /* asru removed */
#define FMD_ASRU_AL_HASH_NAME(a, off) \
#define FMD_ASRU_AL_HASH_NEXT(a, off) \
#define FMD_ASRU_AL_HASH_NEXTP(a, off) \
typedef struct fmd_asru_hash {
char *ah_dirpath; /* path of hash's log file directory */
int ah_error; /* error from opening asru log */
extern fmd_asru_hash_t *fmd_asru_hash_create(const char *, const char *);
extern void fmd_asru_hash_destroy(fmd_asru_hash_t *);
extern void fmd_asru_hash_refresh(fmd_asru_hash_t *);
extern void fmd_asru_hash_replay(fmd_asru_hash_t *);
extern void fmd_asru_hash_apply(fmd_asru_hash_t *,
void (*)(fmd_asru_t *, void *), void *);
extern void fmd_asru_al_hash_apply(fmd_asru_hash_t *,
void (*)(fmd_asru_link_t *, void *), void *);
extern void fmd_asru_hash_apply_by_asru(fmd_asru_hash_t *, const char *,
void (*)(fmd_asru_link_t *, void *), void *);
extern void fmd_asru_hash_apply_by_label(fmd_asru_hash_t *, const char *,
void (*)(fmd_asru_link_t *, void *), void *);
extern void fmd_asru_hash_apply_by_fru(fmd_asru_hash_t *, const char *,
void (*)(fmd_asru_link_t *, void *), void *);
extern void fmd_asru_hash_apply_by_rsrc(fmd_asru_hash_t *, const char *,
void (*)(fmd_asru_link_t *, void *), void *);
void (*)(fmd_asru_link_t *, void *), void *);
fmd_case_t *, nvlist_t *);
extern void fmd_asru_clear_aged_rsrcs();
/*
* flags used in fara_bywhat field in fmd_asru_rep_arg_t
*/
#define FARA_ALL 0
#define FARA_BY_CASE 1
#define FARA_BY_ASRU 2
#define FARA_BY_FRU 3
#define FARA_BY_RSRC 4
#define FARA_BY_LABEL 5
/*
* Return values for fmd_asru_repaired. May return "ok" or "not replaced".
* If no fault is found we will get default value of "not found".
*/
#define FARA_OK 0
#define FARA_ERR_RSRCNOTF 1
#define FARA_ERR_RSRCNOTR 2
/*
* The following structures are used to pass arguments to the corresponding
* function when walking the resource cache by case etc.
*/
typedef struct {
int *fara_rval; /* for return success or failure */
char *fara_uuid; /* uuid can be passed in for comparison */
extern void fmd_asru_repaired(fmd_asru_link_t *, void *);
extern void fmd_asru_flush(fmd_asru_link_t *, void *);
typedef struct {
int *faus_countp;
int faus_maxcount;
typedef struct {
int *fasp_countp;
int fasp_maxcount;
int fasp_proxy_external; /* is this an external transport? */
int fasp_proxy_rdonly; /* is this a rdonly transport? */
typedef struct {
int *facs_countp;
int facs_maxcount;
extern void fmd_asru_log_resolved(fmd_asru_link_t *, void *);
extern int fmd_asru_al_getstate(fmd_asru_link_t *);
extern int fmd_asru_getstate(fmd_asru_t *);
extern void fmd_asru_check_if_aged(fmd_asru_link_t *, void *);
void fmd_asru_most_recent(fmd_asru_link_t *, void *);
#ifdef __cplusplus
}
#endif
#endif /* _FMD_ASRU_H */