GC !__DragonFly__ section.
[dragonfly.git] / sbin / vinum / vext.h
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 */
38 * $Id: vext.h,v 1.17 2000/05/07 04:17:12 grog Exp grog $
39 * $FreeBSD: src/sbin/vinum/vext.h,v 2000/06/08 01:53:16 grog Exp $
1de703da 40 * $DragonFly: src/sbin/vinum/vext.h,v 1.2 2003/06/17 04:27:35 dillon Exp $
41 */
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) */
48enum {
49 KILOBYTE = 1024,
50 MEGABYTE = 1048576,
51 GIGABYTE = 1073741824
54#define VINUMMOD "vinum"
56#define DEFAULT_HISTORYFILE "/var/log/vinum_history" /* default name for history stuff */
58/* Prototype declarations */
59void parseline(int c, char *args[]); /* parse a line with c parameters at args */
60void checkentry(int index);
61int haveargs(int); /* check arg, error message if not valid */
62void setsigs();
63void catchsig(int ignore);
64void vinum_create(int argc, char *argv[], char *arg0[]);
65void vinum_read(int argc, char *argv[], char *arg0[]);
66void vinum_modify(int argc, char *argv[], char *arg0[]);
67void vinum_volume(int argc, char *argv[], char *arg0[]);
68void vinum_plex(int argc, char *argv[], char *arg0[]);
69void vinum_sd(int argc, char *argv[], char *arg0[]);
70void vinum_drive(int argc, char *argv[], char *arg0[]);
71void vinum_list(int argc, char *argv[], char *arg0[]);
72void vinum_info(int argc, char *argv[], char *arg0[]);
73void vinum_set(int argc, char *argv[], char *arg0[]);
74void vinum_rm(int argc, char *argv[], char *arg0[]);
75void vinum_mv(int argc, char *argv[], char *arg0[]);
76void vinum_init(int argc, char *argv[], char *arg0[]);
77void initvol(int volno);
78void initplex(int plexno, char *name);
79void initsd(int sdno, int dowait);
80void vinum_resetconfig(int argc, char *argv[], char *arg0[]);
81void vinum_start(int argc, char *argv[], char *arg0[]);
82void continue_revive(int plexno);
83void vinum_stop(int argc, char *argv[], char *arg0[]);
84void vinum_makedev(int argc, char *argv[], char *arg0[]);
85void vinum_help(int argc, char *argv[], char *arg0[]);
86void vinum_quit(int argc, char *argv[], char *arg0[]);
87void vinum_setdaemon(int argc, char *argv[], char *arg0[]);
88void vinum_replace(int argc, char *argv[], char *arg0[]);
89void vinum_readpol(int argc, char *argv[], char *arg0[]);
90void reset_volume_stats(int volno, int recurse);
91void reset_plex_stats(int plexno, int recurse);
92void reset_sd_stats(int sdno, int recurse);
93void reset_drive_stats(int driveno);
94void vinum_resetstats(int argc, char *argv[], char *arg0[]);
95void vinum_attach(int argc, char *argv[], char *argv0[]);
96void vinum_detach(int argc, char *argv[], char *argv0[]);
97void vinum_rename(int argc, char *argv[], char *argv0[]);
98void vinum_rename_2(char *, char *);
99void vinum_replace(int argc, char *argv[], char *argv0[]);
100void vinum_printconfig(int argc, char *argv[], char *argv0[]);
101void printconfig(FILE * of, char *comment);
102void vinum_saveconfig(int argc, char *argv[], char *argv0[]);
103int checkupdates();
104void genvolname();
105struct drive *create_drive(char *devicename);
106void vinum_concat(int argc, char *argv[], char *argv0[]);
107void vinum_stripe(int argc, char *argv[], char *argv0[]);
108void vinum_raid4(int argc, char *argv[], char *argv0[]);
109void vinum_raid5(int argc, char *argv[], char *argv0[]);
110void vinum_mirror(int argc, char *argv[], char *argv0[]);
111void vinum_label(int argc, char *argv[], char *arg0[]);
112void vinum_ld(int argc, char *argv[], char *arg0[]);
113void vinum_ls(int argc, char *argv[], char *arg0[]);
114void vinum_lp(int argc, char *argv[], char *arg0[]);
115void vinum_lv(int argc, char *argv[], char *arg0[]);
116void vinum_setstate(int argc, char *argv[], char *argv0[]);
117void vinum_checkparity(int argc, char *argv[], char *argv0[]);
118void vinum_rebuildparity(int argc, char *argv[], char *argv0[]);
119void parityops(int argc, char *argv[], enum parityop op);
120void start_daemon(void);
121#ifdef VINUMDEBUG
122void vinum_debug(int argc, char *argv[], char *arg0[]);
124struct drive *find_drive_by_devname(char *name);
125void make_devices(void);
126void make_vol_dev(int, int);
127void make_plex_dev(int, int);
128void make_sd_dev(int);
129void list_defective_objects();
130void vinum_dumpconfig(int argc, char *argv[], char *argv0[]);
131void dumpconfig(char *part);
132int check_drive(char *devicename);
133void get_drive_info(struct drive *drive, int index);
134void get_sd_info(struct sd *sd, int index);
135void get_plex_sd_info(struct sd *sd, int plexno, int sdno);
136void get_plex_info(struct plex *plex, int index);
137void get_volume_info(struct volume *volume, int index);
138struct drive *find_drive_by_devname(char *name);
139int find_object(const char *name, enum objecttype *type);
140char *lltoa(int64_t l, char *s);
141void vinum_ldi(int, int);
142void vinum_lvi(int, int);
143void vinum_lpi(int, int);
144void vinum_lsi(int, int);
145int vinum_li(int object, enum objecttype type);
146char *roughlength(int64_t bytes, int);
147u_int64_t sizespec(char *spec);
149void timestamp();
151extern int force; /* set to 1 to force some dangerous ops */
152extern int interval; /* interval in ms between init/revive */
153extern int vflag; /* set verbose operation or verify */
154extern int Verbose; /* very verbose operation */
155extern int recurse; /* set recursion */
156extern int sflag; /* show statistics */
157extern int SSize; /* sector size for revive */
158extern int dowait; /* wait for children to exit */
159extern char *objectname; /* name for some functions */
161extern FILE *history; /* history file */
163/* Structures to read kernel data into */
164extern struct _vinum_conf vinum_conf; /* configuration information */
166extern struct volume vol;
167extern struct plex plex;
168extern struct sd sd;
169extern struct drive drive;
171extern jmp_buf command_fail; /* return on a failed command */
172extern int superdev; /* vinum super device */
174extern int line; /* stdin line number for error messages */
175extern int file_line; /* and line in input file (yes, this is tacky) */
177extern char buffer[]; /* buffer to read in to */
179#define min(a, b) a < b? a: b