stats.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 1996-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _CACHEFS_LIB_STATS_H
#define _CACHEFS_LIB_STATS_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <kstat.h>
#include <ndbm.h>
#ifndef DEBUG
#define NDEBUG
#endif /* DEBUG */
#define STATS_MAGIC 54545
typedef struct stats_cookie {
int st_magic;
char *st_progname;
int st_fsid; /* id # for kstat `cachefs.#.stat' */
struct cachefs_log_logfile_header st_loghead;
char st_asciirec[BUFSIZ];
char st_dbm_name[MAXPATHLEN];
int st_ws_init;
int st_ws_expensive;
char st_errorstr[BUFSIZ];
int st_errno;
/*
* error types for the API (given by stats_errno())
*/
enum stats_error {
SE_NOERROR, /* placeholder so no errors == 0 */
SE_INVAL, /* invalid use of the API */
SE_NOMEM, /* ran out of memory */
SE_FILE, /* trouble with file i/o */
SE_CORRUPT, /* trouble with a corrupt file */
SE_KERNEL /* trouble coming from communication with the kernel */
};
/*
* flags in cookie->st_flags
*/
/*
* flags for logfile-to-workingset
*/
/*
* structures for logfile-to-workingset
*/
/*
* len and offset are now u_offset_t in sync with struct cachefs_allocmap in
* file cachefs_fs.h
*/
typedef struct fid_info {
int fi_magic;
struct fid_info_allocent {
} fid_info;
#define FI_MAGIC (3748321)
typedef struct mount_info {
int mi_magic;
char mi_path[2];
} mount_info;
#define MI_MAGIC (837492)
/*
* Define the maximum size of char mi_path[]
*
* The maximum size of mi_path is a path (MAXPATHLEN) and a cacheid
* (C_MAX_MOUNT_FSCDIRNAME) plus terminating nulls (2).
*
* Additional space is allocated to mi_path at runtime using malloc().
*/
typedef struct filegrp_info {
int fg_magic;
} fg_info;
#define FG_MAGIC (673492)
/*
* the cachefs stats (stats_*) API.
*/
/* stats_create.c */
stats_cookie_t *stats_create_mountpath(char *, char *);
stats_cookie_t *stats_create_unbound(char *);
void stats_destroy(stats_cookie_t *);
int stats_good(stats_cookie_t *);
char *stats_errorstr(stats_cookie_t *);
int stats_errno(stats_cookie_t *);
int stats_inerror(stats_cookie_t *);
void stats_perror(stats_cookie_t *, int, char *, ...);
/* stats_log.c */
int stats_log_kernel_setname(stats_cookie_t *, char *);
int stats_log_which(stats_cookie_t *, int, int);
char *stats_log_kernel_getname(stats_cookie_t *);
int stats_log_logfile_open(stats_cookie_t *, char *);
void *stats_log_logfile_read(stats_cookie_t *, int *);
char *stats_log_record_toascii(stats_cookie_t *, void *);
void stats_log_compute_wssize(stats_cookie_t *);
int stats_log_wssize_init(stats_cookie_t *);
/* stats_stats.c */
int stats_zero_stats(stats_cookie_t *);
/* stats_dbm.c */
void stats_dbm_open(stats_cookie_t *);
void stats_dbm_rm(stats_cookie_t *);
void stats_dbm_close(stats_cookie_t *);
#ifdef __cplusplus
}
#endif
#endif /* _CACHEFS_LIB_STATS_H */