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