mdctl-0.5
[thirdparty/mdadm.git] / mdctl.h
CommitLineData
64c4757e
NB
1/*
2 * mdctl - manage Linux "md" devices aka RAID arrays.
3 *
4 * Copyright (C) 2001 Neil Brown <neilb@cse.unsw.edu.au>
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * Author: Neil Brown
22 * Email: <neilb@cse.unsw.edu.au>
23 * Paper: Neil Brown
24 * School of Computer Science and Engineering
25 * The University of New South Wales
26 * Sydney, 2052
27 * Australia
28 */
29
30#define __USE_LARGEFILE64
31#include <unistd.h>
32extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
33
34#include <sys/types.h>
35#include <sys/stat.h>
36#include <stdlib.h>
37#include <time.h>
38#include <getopt.h>
39#include <fcntl.h>
40#include <stdio.h>
41#include <errno.h>
42#include <string.h>
43
44#include <linux/kdev_t.h>
45#include <linux/fs.h>
46#include <sys/ioctl.h>
47#define MD_MAJOR 9
48
49
50#include "md_u.h"
51
682c7051
NB
52#define Name "mdctl"
53
64c4757e
NB
54extern char short_options[];
55extern struct option long_options[];
56extern char Version[], Usage[], Help[], Help_create[], Help_build[], Help_assemble[];
57
58/* structures read from config file */
52826846
NB
59/* List of mddevice names and identifiers
60 * Identifiers can be:
61 * uuid=128-hex-uuid
62 * super-minor=decimal-minor-number-from-superblock
63 * devices=comma,separated,list,of,device,names,with,wildcards
64 *
65 * If multiple fields are present, the intersection of all matching
66 * devices is considered
67 */
68typedef struct mddev_ident_s {
64c4757e 69 char *devname;
52826846
NB
70
71 int uuid_set;
64c4757e 72 __u32 uuid[4];
52826846
NB
73
74 int super_minor; /* -1 if not set */
75
76 char *devices; /* comma separated list of device
77 * names with wild cards
78 */
79
80 char *spare_group;
81 struct mddev_ident_s *next;
82} *mddev_ident_t;
64c4757e
NB
83
84/* List of device names - wildcards expanded */
85typedef struct mddev_dev_s {
86 char *devname;
87 struct mddev_dev_s *next;
88} *mddev_dev_t;
89
682c7051
NB
90typedef struct mapping {
91 char *name;
92 int num;
93} mapping_t;
94
52826846
NB
95#ifndef Sendmail
96#define Sendmail "/usr/lib/sendmail -t"
97#endif
98
682c7051
NB
99extern char *map_num(mapping_t *map, int num);
100extern int map_name(mapping_t *map, char *name);
101extern mapping_t r5layout[], pers[];
102
82b27616 103extern char *map_dev(int major, int minor);
64c4757e
NB
104
105
106extern int Manage_ro(char *devname, int fd, int readonly);
107extern int Manage_runstop(char *devname, int fd, int runstop);
108extern int Manage_subdevs(char *devname, int fd,
109 int devcnt, char *devnames[], int devmodes[]);
110
111
112extern int Assemble(char *mddev, int mdfd,
52826846
NB
113 mddev_ident_t ident,
114 char *conffile,
64c4757e
NB
115 int subdevs, char *subdev[],
116 int readonly, int runstop,
117 int verbose, int force);
118
119extern int Build(char *mddev, int mdfd, int chunk, int level,
120 int raiddisks,
121 int subdevs, char *subdev[]);
122
123
124extern int Create(char *mddev, int mdfd,
682c7051 125 int chunk, int level, int layout, int size, int raiddisks, int sparedisks,
64c4757e 126 int subdevs, char *subdev[],
52826846 127 int runstop, int verbose, int force);
64c4757e
NB
128
129extern int Detail(char *dev);
130extern int Examine(char *dev);
52826846
NB
131extern int Monitor(int num_devs, char *devlist[],
132 char *mailaddr, char *alert_cmd,
133 int period,
134 char *config);
64c4757e
NB
135
136extern int md_get_version(int fd);
137extern int get_linux_version();
138extern int parse_uuid(char *str, int uuid[4]);
682c7051
NB
139extern int check_ext2(int fd, char *name);
140extern int check_reiser(int fd, char *name);
141extern int check_raid(int fd, char *name);
64c4757e 142
52826846 143extern mddev_ident_t conf_get_ident(char *, char*);
64c4757e 144extern mddev_dev_t conf_get_devs(char *);