1999-01-21 00:45:11 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1997, 1998
|
|
|
|
* Nan Yang Computer Services Limited. All rights reserved.
|
|
|
|
*
|
|
|
|
* This software is distributed under the so-called ``Berkeley
|
|
|
|
* License'':
|
1998-09-16 05:57:36 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1999-01-21 00:45:11 +00:00
|
|
|
* This product includes software developed by Nan Yang Computer
|
|
|
|
* Services Limited.
|
|
|
|
* 4. Neither the name of the Company nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* This software is provided ``as is'', and any express or implied
|
|
|
|
* warranties, including, but not limited to, the implied warranties of
|
|
|
|
* merchantability and fitness for a particular purpose are disclaimed.
|
|
|
|
* In no event shall the company or contributors be liable for any
|
|
|
|
* direct, indirect, incidental, special, exemplary, or consequential
|
|
|
|
* damages (including, but not limited to, procurement of substitute
|
|
|
|
* goods or services; loss of use, data, or profits; or business
|
|
|
|
* interruption) however caused and on any theory of liability, whether
|
|
|
|
* in contract, strict liability, or tort (including negligence or
|
|
|
|
* otherwise) arising in any way out of the use of this software, even if
|
|
|
|
* advised of the possibility of such damage.
|
1998-09-16 05:57:36 +00:00
|
|
|
*/
|
|
|
|
|
1999-10-13 03:29:13 +00:00
|
|
|
/*
|
2001-05-22 02:39:48 +00:00
|
|
|
* $Id: vext.h,v 1.18 2000/05/31 07:03:45 grog Exp grog $
|
1999-10-13 03:29:13 +00:00
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
1998-09-16 05:57:36 +00:00
|
|
|
|
|
|
|
#define MAXARGS 64 /* maximum number of args on a line */
|
1999-10-13 03:29:13 +00:00
|
|
|
#define PLEXINITSIZE 65536 /* init in this size chunks */
|
|
|
|
#define MAXPLEXINITSIZE 65536 /* max chunk size to use for init */
|
1999-05-02 08:02:48 +00:00
|
|
|
#define MAXDATETEXT 128 /* date text in history (far too much) */
|
1998-09-16 05:57:36 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
KILOBYTE = 1024,
|
|
|
|
MEGABYTE = 1048576,
|
|
|
|
GIGABYTE = 1073741824
|
|
|
|
};
|
|
|
|
|
1999-03-02 07:02:09 +00:00
|
|
|
#define VINUMMOD "vinum"
|
|
|
|
|
2000-06-02 03:55:01 +00:00
|
|
|
#define DEFAULT_HISTORYFILE "/var/log/vinum_history" /* default name for history stuff */
|
1999-05-02 08:02:48 +00:00
|
|
|
|
2001-05-22 02:39:48 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/dkstat.h>
|
|
|
|
#include <sys/bio.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/disklabel.h>
|
|
|
|
#include <ufs/ffs/fs.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/fcntl.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <setjmp.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <dev/vinum/vinumvar.h>
|
|
|
|
#include <dev/vinum/vinumio.h>
|
|
|
|
#include <dev/vinum/vinumkw.h>
|
|
|
|
#include <dev/vinum/vinumutil.h>
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
|
1998-09-16 05:57:36 +00:00
|
|
|
/* Prototype declarations */
|
|
|
|
void parseline(int c, char *args[]); /* parse a line with c parameters at args */
|
|
|
|
void checkentry(int index);
|
|
|
|
int haveargs(int); /* check arg, error message if not valid */
|
2000-06-02 03:55:01 +00:00
|
|
|
void setsigs();
|
|
|
|
void catchsig(int ignore);
|
1998-09-16 05:57:36 +00:00
|
|
|
void vinum_create(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_read(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_modify(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_volume(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_plex(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_sd(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_drive(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_list(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_info(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_set(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_rm(int argc, char *argv[], char *arg0[]);
|
2000-01-05 05:58:01 +00:00
|
|
|
void vinum_mv(int argc, char *argv[], char *arg0[]);
|
1998-09-16 05:57:36 +00:00
|
|
|
void vinum_init(int argc, char *argv[], char *arg0[]);
|
2001-05-22 02:39:48 +00:00
|
|
|
void listconfig(void);
|
|
|
|
void resetstats(struct vinum_ioctl_msg *msg);
|
1999-08-14 06:20:55 +00:00
|
|
|
void initvol(int volno);
|
|
|
|
void initplex(int plexno, char *name);
|
1999-08-24 02:35:07 +00:00
|
|
|
void initsd(int sdno, int dowait);
|
1998-09-16 05:57:36 +00:00
|
|
|
void vinum_resetconfig(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_start(int argc, char *argv[], char *arg0[]);
|
|
|
|
void continue_revive(int plexno);
|
|
|
|
void vinum_stop(int argc, char *argv[], char *arg0[]);
|
1999-01-21 00:45:11 +00:00
|
|
|
void vinum_makedev(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_help(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_quit(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_setdaemon(int argc, char *argv[], char *arg0[]);
|
1999-08-07 08:20:07 +00:00
|
|
|
void vinum_replace(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_readpol(int argc, char *argv[], char *arg0[]);
|
1998-09-16 05:57:36 +00:00
|
|
|
void reset_volume_stats(int volno, int recurse);
|
|
|
|
void reset_plex_stats(int plexno, int recurse);
|
|
|
|
void reset_sd_stats(int sdno, int recurse);
|
|
|
|
void reset_drive_stats(int driveno);
|
|
|
|
void vinum_resetstats(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_attach(int argc, char *argv[], char *argv0[]);
|
|
|
|
void vinum_detach(int argc, char *argv[], char *argv0[]);
|
|
|
|
void vinum_rename(int argc, char *argv[], char *argv0[]);
|
|
|
|
void vinum_rename_2(char *, char *);
|
|
|
|
void vinum_replace(int argc, char *argv[], char *argv0[]);
|
|
|
|
void vinum_printconfig(int argc, char *argv[], char *argv0[]);
|
1999-05-02 08:02:48 +00:00
|
|
|
void printconfig(FILE * of, char *comment);
|
1999-03-02 07:02:09 +00:00
|
|
|
void vinum_saveconfig(int argc, char *argv[], char *argv0[]);
|
2000-02-29 06:22:09 +00:00
|
|
|
int checkupdates();
|
1999-07-02 23:57:45 +00:00
|
|
|
void genvolname();
|
2001-05-22 02:39:48 +00:00
|
|
|
struct _drive *create_drive(char *devicename);
|
1999-07-02 23:57:45 +00:00
|
|
|
void vinum_concat(int argc, char *argv[], char *argv0[]);
|
|
|
|
void vinum_stripe(int argc, char *argv[], char *argv0[]);
|
2000-02-29 06:22:09 +00:00
|
|
|
void vinum_raid4(int argc, char *argv[], char *argv0[]);
|
|
|
|
void vinum_raid5(int argc, char *argv[], char *argv0[]);
|
1999-07-02 23:57:45 +00:00
|
|
|
void vinum_mirror(int argc, char *argv[], char *argv0[]);
|
1998-09-16 05:57:36 +00:00
|
|
|
void vinum_label(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_ld(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_ls(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_lp(int argc, char *argv[], char *arg0[]);
|
|
|
|
void vinum_lv(int argc, char *argv[], char *arg0[]);
|
1999-08-24 02:35:07 +00:00
|
|
|
void vinum_setstate(int argc, char *argv[], char *argv0[]);
|
|
|
|
void vinum_checkparity(int argc, char *argv[], char *argv0[]);
|
|
|
|
void vinum_rebuildparity(int argc, char *argv[], char *argv0[]);
|
2000-03-01 07:21:21 +00:00
|
|
|
void parityops(int argc, char *argv[], enum parityop op);
|
1999-01-21 00:45:11 +00:00
|
|
|
void start_daemon(void);
|
1999-01-06 04:22:48 +00:00
|
|
|
#ifdef VINUMDEBUG
|
1998-09-16 05:57:36 +00:00
|
|
|
void vinum_debug(int argc, char *argv[], char *arg0[]);
|
|
|
|
#endif
|
|
|
|
void make_devices(void);
|
1999-08-07 08:20:07 +00:00
|
|
|
void make_vol_dev(int, int);
|
|
|
|
void make_plex_dev(int, int);
|
|
|
|
void make_sd_dev(int);
|
|
|
|
void list_defective_objects();
|
2000-06-02 03:55:01 +00:00
|
|
|
void vinum_dumpconfig(int argc, char *argv[], char *argv0[]);
|
|
|
|
void dumpconfig(char *part);
|
|
|
|
int check_drive(char *devicename);
|
2001-05-22 02:39:48 +00:00
|
|
|
void get_drive_info(struct _drive *drive, int index);
|
|
|
|
void get_sd_info(struct _sd *sd, int index);
|
|
|
|
void get_plex_sd_info(struct _sd *sd, int plexno, int sdno);
|
|
|
|
void get_plex_info(struct _plex *plex, int index);
|
|
|
|
void get_volume_info(struct _volume *volume, int index);
|
|
|
|
struct _drive *find_drive_by_devname(char *name);
|
1998-09-16 05:57:36 +00:00
|
|
|
int find_object(const char *name, enum objecttype *type);
|
2000-01-05 05:58:01 +00:00
|
|
|
char *lltoa(int64_t l, char *s);
|
1998-09-16 05:57:36 +00:00
|
|
|
void vinum_ldi(int, int);
|
|
|
|
void vinum_lvi(int, int);
|
|
|
|
void vinum_lpi(int, int);
|
|
|
|
void vinum_lsi(int, int);
|
|
|
|
int vinum_li(int object, enum objecttype type);
|
2000-01-05 05:58:01 +00:00
|
|
|
char *roughlength(int64_t bytes, int);
|
1998-09-16 05:57:36 +00:00
|
|
|
u_int64_t sizespec(char *spec);
|
2001-05-22 02:39:48 +00:00
|
|
|
char *sd_state(enum sdstate);
|
1999-05-02 08:02:48 +00:00
|
|
|
void timestamp();
|
|
|
|
|
1998-09-16 05:57:36 +00:00
|
|
|
extern int force; /* set to 1 to force some dangerous ops */
|
2000-05-11 08:57:09 +00:00
|
|
|
extern int interval; /* interval in ms between init/revive */
|
1999-10-13 03:29:13 +00:00
|
|
|
extern int vflag; /* set verbose operation or verify */
|
1998-09-16 05:57:36 +00:00
|
|
|
extern int Verbose; /* very verbose operation */
|
|
|
|
extern int recurse; /* set recursion */
|
1999-07-02 23:57:45 +00:00
|
|
|
extern int sflag; /* show statistics */
|
1999-10-13 03:29:13 +00:00
|
|
|
extern int SSize; /* sector size for revive */
|
1999-04-10 23:39:14 +00:00
|
|
|
extern int dowait; /* wait for children to exit */
|
1999-07-02 23:57:45 +00:00
|
|
|
extern char *objectname; /* name for some functions */
|
1998-09-16 05:57:36 +00:00
|
|
|
|
1999-05-02 08:02:48 +00:00
|
|
|
extern FILE *history; /* history file */
|
|
|
|
|
1998-09-16 05:57:36 +00:00
|
|
|
/* Structures to read kernel data into */
|
2001-05-22 02:39:48 +00:00
|
|
|
extern struct __vinum_conf vinum_conf; /* configuration information */
|
1998-09-16 05:57:36 +00:00
|
|
|
|
2001-05-22 02:39:48 +00:00
|
|
|
extern struct _volume vol;
|
|
|
|
extern struct _plex plex;
|
|
|
|
extern struct _sd sd;
|
|
|
|
extern struct _drive drive;
|
1998-09-16 05:57:36 +00:00
|
|
|
|
|
|
|
extern jmp_buf command_fail; /* return on a failed command */
|
|
|
|
extern int superdev; /* vinum super device */
|
2001-05-22 02:39:48 +00:00
|
|
|
extern int no_devfs; /* set if we don't have DEVFS */
|
1998-09-16 05:57:36 +00:00
|
|
|
|
|
|
|
extern int line; /* stdin line number for error messages */
|
|
|
|
extern int file_line; /* and line in input file (yes, this is tacky) */
|
|
|
|
|
|
|
|
extern char buffer[]; /* buffer to read in to */
|
1999-07-02 23:57:45 +00:00
|
|
|
|
|
|
|
#define min(a, b) a < b? a: b
|