xref: /dragonfly/sbin/vinum/vext.h (revision d8d5b238)
1 /*-
2  * Copyright (c) 1997, 1998
3  *	Nan Yang Computer Services Limited.  All rights reserved.
4  *
5  *  This software is distributed under the so-called ``Berkeley
6  *  License'':
7  *
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.
19  *
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.
31  */
32 
33 /*
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  */
37 
38 #define MAXARGS 64					    /* maximum number of args on a line */
39 #define PLEXINITSIZE 65536				    /* init in this size chunks */
40 #define MAXPLEXINITSIZE 65536				    /* max chunk size to use for init */
41 #define MAXDATETEXT 128					    /* date text in history (far too much) */
42 
43 enum {
44     KILOBYTE = 1024,
45     MEGABYTE = 1048576,
46     GIGABYTE = 1073741824
47 };
48 
49 #define VINUMMOD "vinum"
50 
51 #define DEFAULT_HISTORYFILE "/var/log/vinum_history"	    /* default name for history stuff */
52 
53 /* Prototype declarations */
54 void parseline(int c, char *args[]);			    /* parse a line with c parameters at args */
55 void checkentry(int index);
56 int haveargs(int);					    /* check arg, error message if not valid */
57 void setsigs();
58 void catchsig(int ignore) __dead2;
59 void vinum_create(int argc, char *argv[], char *arg0[]);
60 void vinum_read(int argc, char *argv[], char *arg0[]);
61 void vinum_modify(int argc, char *argv[], char *arg0[]);
62 void vinum_volume(int argc, char *argv[], char *arg0[]);
63 void vinum_plex(int argc, char *argv[], char *arg0[]);
64 void vinum_sd(int argc, char *argv[], char *arg0[]);
65 void vinum_drive(int argc, char *argv[], char *arg0[]);
66 void vinum_list(int argc, char *argv[], char *arg0[]);
67 void vinum_info(int argc, char *argv[], char *arg0[]);
68 void vinum_set(int argc, char *argv[], char *arg0[]);
69 void vinum_rm(int argc, char *argv[], char *arg0[]);
70 void vinum_mv(int argc, char *argv[], char *arg0[]);
71 void vinum_init(int argc, char *argv[], char *arg0[]);
72 void initvol(int volno);
73 void initplex(int plexno, char *name);
74 void initsd(int sdno, int dowait);
75 void vinum_resetconfig(int argc, char *argv[], char *arg0[]);
76 void vinum_start(int argc, char *argv[], char *arg0[]);
77 void continue_revive(int plexno);
78 void vinum_stop(int argc, char *argv[], char *arg0[]);
79 void vinum_makedev(int argc, char *argv[], char *arg0[]);
80 void vinum_help(int argc, char *argv[], char *arg0[]);
81 void vinum_quit(int argc, char *argv[], char *arg0[]) __dead2;
82 void vinum_setdaemon(int argc, char *argv[], char *arg0[]);
83 void vinum_replace(int argc, char *argv[], char *arg0[]);
84 void vinum_readpol(int argc, char *argv[], char *arg0[]);
85 void reset_volume_stats(int volno, int recurse);
86 void reset_plex_stats(int plexno, int recurse);
87 void reset_sd_stats(int sdno, int recurse);
88 void reset_drive_stats(int driveno);
89 void vinum_resetstats(int argc, char *argv[], char *arg0[]);
90 void vinum_attach(int argc, char *argv[], char *argv0[]);
91 void vinum_detach(int argc, char *argv[], char *argv0[]);
92 void vinum_rename(int argc, char *argv[], char *argv0[]);
93 void vinum_rename_2(char *, char *);
94 void vinum_replace(int argc, char *argv[], char *argv0[]);
95 void vinum_printconfig(int argc, char *argv[], char *argv0[]);
96 void printconfig(FILE * of, char *comment);
97 void vinum_saveconfig(int argc, char *argv[], char *argv0[]);
98 int checkupdates();
99 void genvolname();
100 struct drive *create_drive(char *devicename);
101 void vinum_concat(int argc, char *argv[], char *argv0[]);
102 void vinum_stripe(int argc, char *argv[], char *argv0[]);
103 void vinum_raid4(int argc, char *argv[], char *argv0[]);
104 void vinum_raid5(int argc, char *argv[], char *argv0[]);
105 void vinum_mirror(int argc, char *argv[], char *argv0[]);
106 void vinum_label(int argc, char *argv[], char *arg0[]);
107 void vinum_ld(int argc, char *argv[], char *arg0[]);
108 void vinum_ls(int argc, char *argv[], char *arg0[]);
109 void vinum_lp(int argc, char *argv[], char *arg0[]);
110 void vinum_lv(int argc, char *argv[], char *arg0[]);
111 void vinum_setstate(int argc, char *argv[], char *argv0[]);
112 void vinum_checkparity(int argc, char *argv[], char *argv0[]);
113 void vinum_rebuildparity(int argc, char *argv[], char *argv0[]);
114 void parityops(int argc, char *argv[], enum parityop op);
115 void start_daemon(void);
116 #ifdef VINUMDEBUG
117 void vinum_debug(int argc, char *argv[], char *arg0[]);
118 #endif
119 struct drive *find_drive_by_devname(char *name);
120 void make_devices(void);
121 void make_vol_dev(int, int);
122 void make_plex_dev(int, int);
123 void make_sd_dev(int);
124 void list_defective_objects();
125 void vinum_dumpconfig(int argc, char *argv[], char *argv0[]);
126 void dumpconfig(char *part);
127 int check_drive(char *devicename);
128 void get_drive_info(struct drive *drive, int index);
129 void get_sd_info(struct sd *sd, int index);
130 void get_plex_sd_info(struct sd *sd, int plexno, int sdno);
131 void get_plex_info(struct plex *plex, int index);
132 void get_volume_info(struct volume *volume, int index);
133 struct drive *find_drive_by_devname(char *name);
134 int find_object(const char *name, enum objecttype *type);
135 char *lltoa(int64_t l, char *s);
136 void vinum_ldi(int, int);
137 void vinum_lvi(int, int);
138 void vinum_lpi(int, int);
139 void vinum_lsi(int, int);
140 int vinum_li(int object, enum objecttype type);
141 char *roughlength(int64_t bytes, int);
142 u_int64_t sizespec(char *spec);
143 
144 void timestamp();
145 
146 extern int force;					    /* set to 1 to force some dangerous ops */
147 extern int interval;					    /* interval in ms between init/revive */
148 extern int vflag;					    /* set verbose operation or verify */
149 extern int Verbose;					    /* very verbose operation */
150 extern int recurse;					    /* set recursion */
151 extern int sflag;					    /* show statistics */
152 extern int SSize;					    /* sector size for revive */
153 extern int dowait;					    /* wait for children to exit */
154 extern char *objectname;				    /* name for some functions */
155 
156 extern FILE *hist;					    /* history file */
157 
158 /* Structures to read kernel data into */
159 extern struct _vinum_conf vinum_conf;			    /* configuration information */
160 
161 extern struct volume vol;
162 extern struct plex plex;
163 extern struct sd sd;
164 extern struct drive drive;
165 
166 extern jmp_buf command_fail;				    /* return on a failed command */
167 extern int superdev;					    /* vinum super device */
168 
169 extern int line;					    /* stdin line number for error messages */
170 extern int file_line;					    /* and line in input file (yes, this is tacky) */
171 
172 extern char buffer[];					    /* buffer to read in to */
173 
174 #define min(a, b) a < b? a: b
175