/etc/mail: Install 4 sample mailer.conf files
[dragonfly.git] / lib / libdevstat / devstat.h
1 /*
2  * Copyright (c) 1997, 1998 Kenneth D. Merry.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  *    derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD: src/lib/libdevstat/devstat.h,v 1.3 1999/08/28 00:04:27 peter Exp $
29  * $DragonFly: src/lib/libdevstat/devstat.h,v 1.4 2005/01/08 19:19:26 joerg Exp $
30  */
31
32 #ifndef _DEVSTAT_H
33 #define _DEVSTAT_H
34 #include <sys/cdefs.h>
35 #include <sys/devicestat.h>
36
37 #define DEVSTAT_ERRBUF_SIZE  2048 /* size of the devstat library error string */
38
39 extern char devstat_errbuf[];
40
41 typedef enum {
42         DEVSTAT_MATCH_NONE      = 0x00,
43         DEVSTAT_MATCH_TYPE      = 0x01,
44         DEVSTAT_MATCH_IF        = 0x02,
45         DEVSTAT_MATCH_PASS      = 0x04
46 } devstat_match_flags;
47
48 struct devstat_match {
49         devstat_match_flags     match_fields;
50         devstat_type_flags      device_type;
51         int                     num_match_categories;
52 };
53
54 struct devstat_match_table {
55         const char              *match_str;
56         devstat_type_flags      type;
57         devstat_match_flags     match_field;
58 };
59
60 struct device_selection {
61         u_int32_t       device_number;
62         char            device_name[DEVSTAT_NAME_LEN];
63         int             unit_number;
64         int             selected;
65         u_int64_t       bytes;
66         int             position;
67 };
68
69 struct devinfo {
70         struct devstat  *devices;
71         u_int8_t        *mem_ptr;
72         long            generation;
73         int             numdevs;
74 };
75
76 struct statinfo {
77         struct devinfo  *dinfo;
78         struct timeval  busy_time;
79 };
80
81 typedef enum {
82         DS_SELECT_ADD,
83         DS_SELECT_ONLY,
84         DS_SELECT_REMOVE,
85         DS_SELECT_ADDONLY
86 } devstat_select_mode;
87
88 __BEGIN_DECLS
89 int getnumdevs(void);
90 long getgeneration(void);
91 int getversion(void);
92 int checkversion(void);
93 int getdevs(struct statinfo *stats);
94 int selectdevs(struct device_selection **dev_select, int *num_selected,
95                int *num_selections, long *select_generation, 
96                long current_generation, struct devstat *devices, int numdevs,
97                struct devstat_match *matches, int num_matches,
98                char **dev_selections, int num_dev_selections,
99                devstat_select_mode select_mode, int maxshowdevs,
100                int perf_select);
101 int buildmatch(const char *match_str, struct devstat_match **matches,
102                int *num_matches);
103 int compute_stats(struct devstat *current, struct devstat *previous,
104                   long double etime, u_int64_t *total_bytes,
105                   u_int64_t *total_transfers, u_int64_t *total_blocks,
106                   long double *kb_per_transfer,
107                   long double *transfers_per_second, long double *mb_per_second,
108                   long double *blocks_per_second,
109                   long double *ms_per_transaction);
110 int compute_stats_read(struct devstat *current, struct devstat *previous,
111                   long double etime, u_int64_t *total_bytes,
112                   u_int64_t *total_transfers, u_int64_t *total_blocks,
113                   long double *kb_per_transfer,
114                   long double *transfers_per_second, long double *mb_per_second,
115                   long double *blocks_per_second,
116                   long double *ms_per_transaction);
117 int compute_stats_write(struct devstat *current, struct devstat *previous,
118                   long double etime, u_int64_t *total_bytes,
119                   u_int64_t *total_transfers, u_int64_t *total_blocks,
120                   long double *kb_per_transfer,
121                   long double *transfers_per_second, long double *mb_per_second,
122                   long double *blocks_per_second,
123                   long double *ms_per_transaction);
124 long double compute_etime(struct timeval cur_time, struct timeval prev_time);
125 __END_DECLS
126
127 #endif /* _DEVSTAT_H  */