MFC numerous features from HEAD.
[dragonfly.git] / sbin / vinum / vext.h
blob92e97ae5216b6131b7a503fedda381ed1e09e687
1 /*-
2 * Copyright (c) 1997, 1998
3 * Nan Yang Computer Services Limited. All rights reserved.
5 * This software is distributed under the so-called ``Berkeley
6 * License'':
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the Company nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * This software is provided ``as is'', and any express or implied
21 * warranties, including, but not limited to, the implied warranties of
22 * merchantability and fitness for a particular purpose are disclaimed.
23 * In no event shall the company or contributors be liable for any
24 * direct, indirect, incidental, special, exemplary, or consequential
25 * damages (including, but not limited to, procurement of substitute
26 * goods or services; loss of use, data, or profits; or business
27 * interruption) however caused and on any theory of liability, whether
28 * in contract, strict liability, or tort (including negligence or
29 * otherwise) arising in any way out of the use of this software, even if
30 * advised of the possibility of such damage.
34 * $Id: vext.h,v 1.17 2000/05/07 04:17:12 grog Exp grog $
35 * $FreeBSD: src/sbin/vinum/vext.h,v 1.16.2.2 2000/06/08 01:53:16 grog Exp $
36 * $DragonFly: src/sbin/vinum/vext.h,v 1.4 2007/07/29 23:27:34 dillon Exp $
39 #define MAXARGS 64 /* maximum number of args on a line */
40 #define PLEXINITSIZE 65536 /* init in this size chunks */
41 #define MAXPLEXINITSIZE 65536 /* max chunk size to use for init */
42 #define MAXDATETEXT 128 /* date text in history (far too much) */
44 enum {
45 KILOBYTE = 1024,
46 MEGABYTE = 1048576,
47 GIGABYTE = 1073741824
50 #define VINUMMOD "vinum"
52 #define DEFAULT_HISTORYFILE "/var/log/vinum_history" /* default name for history stuff */
54 /* Prototype declarations */
55 void parseline(int c, char *args[]); /* parse a line with c parameters at args */
56 void checkentry(int index);
57 int haveargs(int); /* check arg, error message if not valid */
58 void setsigs();
59 void catchsig(int ignore);
60 void vinum_create(int argc, char *argv[], char *arg0[]);
61 void vinum_read(int argc, char *argv[], char *arg0[]);
62 void vinum_modify(int argc, char *argv[], char *arg0[]);
63 void vinum_volume(int argc, char *argv[], char *arg0[]);
64 void vinum_plex(int argc, char *argv[], char *arg0[]);
65 void vinum_sd(int argc, char *argv[], char *arg0[]);
66 void vinum_drive(int argc, char *argv[], char *arg0[]);
67 void vinum_list(int argc, char *argv[], char *arg0[]);
68 void vinum_info(int argc, char *argv[], char *arg0[]);
69 void vinum_set(int argc, char *argv[], char *arg0[]);
70 void vinum_rm(int argc, char *argv[], char *arg0[]);
71 void vinum_mv(int argc, char *argv[], char *arg0[]);
72 void vinum_init(int argc, char *argv[], char *arg0[]);
73 void initvol(int volno);
74 void initplex(int plexno, char *name);
75 void initsd(int sdno, int dowait);
76 void vinum_resetconfig(int argc, char *argv[], char *arg0[]);
77 void vinum_start(int argc, char *argv[], char *arg0[]);
78 void continue_revive(int plexno);
79 void vinum_stop(int argc, char *argv[], char *arg0[]);
80 void vinum_makedev(int argc, char *argv[], char *arg0[]);
81 void vinum_help(int argc, char *argv[], char *arg0[]);
82 void vinum_quit(int argc, char *argv[], char *arg0[]);
83 void vinum_setdaemon(int argc, char *argv[], char *arg0[]);
84 void vinum_replace(int argc, char *argv[], char *arg0[]);
85 void vinum_readpol(int argc, char *argv[], char *arg0[]);
86 void reset_volume_stats(int volno, int recurse);
87 void reset_plex_stats(int plexno, int recurse);
88 void reset_sd_stats(int sdno, int recurse);
89 void reset_drive_stats(int driveno);
90 void vinum_resetstats(int argc, char *argv[], char *arg0[]);
91 void vinum_attach(int argc, char *argv[], char *argv0[]);
92 void vinum_detach(int argc, char *argv[], char *argv0[]);
93 void vinum_rename(int argc, char *argv[], char *argv0[]);
94 void vinum_rename_2(char *, char *);
95 void vinum_replace(int argc, char *argv[], char *argv0[]);
96 void vinum_printconfig(int argc, char *argv[], char *argv0[]);
97 void printconfig(FILE * of, char *comment);
98 void vinum_saveconfig(int argc, char *argv[], char *argv0[]);
99 int checkupdates();
100 void genvolname();
101 struct drive *create_drive(char *devicename);
102 void vinum_concat(int argc, char *argv[], char *argv0[]);
103 void vinum_stripe(int argc, char *argv[], char *argv0[]);
104 void vinum_raid4(int argc, char *argv[], char *argv0[]);
105 void vinum_raid5(int argc, char *argv[], char *argv0[]);
106 void vinum_mirror(int argc, char *argv[], char *argv0[]);
107 void vinum_label(int argc, char *argv[], char *arg0[]);
108 void vinum_ld(int argc, char *argv[], char *arg0[]);
109 void vinum_ls(int argc, char *argv[], char *arg0[]);
110 void vinum_lp(int argc, char *argv[], char *arg0[]);
111 void vinum_lv(int argc, char *argv[], char *arg0[]);
112 void vinum_setstate(int argc, char *argv[], char *argv0[]);
113 void vinum_checkparity(int argc, char *argv[], char *argv0[]);
114 void vinum_rebuildparity(int argc, char *argv[], char *argv0[]);
115 void parityops(int argc, char *argv[], enum parityop op);
116 void start_daemon(void);
117 #ifdef VINUMDEBUG
118 void vinum_debug(int argc, char *argv[], char *arg0[]);
119 #endif
120 struct drive *find_drive_by_devname(char *name);
121 void make_devices(void);
122 void make_vol_dev(int, int);
123 void make_plex_dev(int, int);
124 void make_sd_dev(int);
125 void list_defective_objects();
126 void vinum_dumpconfig(int argc, char *argv[], char *argv0[]);
127 void dumpconfig(char *part);
128 int check_drive(char *devicename);
129 void get_drive_info(struct drive *drive, int index);
130 void get_sd_info(struct sd *sd, int index);
131 void get_plex_sd_info(struct sd *sd, int plexno, int sdno);
132 void get_plex_info(struct plex *plex, int index);
133 void get_volume_info(struct volume *volume, int index);
134 struct drive *find_drive_by_devname(char *name);
135 int find_object(const char *name, enum objecttype *type);
136 char *lltoa(int64_t l, char *s);
137 void vinum_ldi(int, int);
138 void vinum_lvi(int, int);
139 void vinum_lpi(int, int);
140 void vinum_lsi(int, int);
141 int vinum_li(int object, enum objecttype type);
142 char *roughlength(int64_t bytes, int);
143 u_int64_t sizespec(char *spec);
145 void timestamp();
147 extern int force; /* set to 1 to force some dangerous ops */
148 extern int interval; /* interval in ms between init/revive */
149 extern int vflag; /* set verbose operation or verify */
150 extern int Verbose; /* very verbose operation */
151 extern int recurse; /* set recursion */
152 extern int sflag; /* show statistics */
153 extern int SSize; /* sector size for revive */
154 extern int dowait; /* wait for children to exit */
155 extern char *objectname; /* name for some functions */
157 extern FILE *hist; /* history file */
159 /* Structures to read kernel data into */
160 extern struct _vinum_conf vinum_conf; /* configuration information */
162 extern struct volume vol;
163 extern struct plex plex;
164 extern struct sd sd;
165 extern struct drive drive;
167 extern jmp_buf command_fail; /* return on a failed command */
168 extern int superdev; /* vinum super device */
170 extern int line; /* stdin line number for error messages */
171 extern int file_line; /* and line in input file (yes, this is tacky) */
173 extern char buffer[]; /* buffer to read in to */
175 #define min(a, b) a < b? a: b