Line 0
Link Here
|
|
|
1 |
/* |
2 |
* Linux 2.6(+) RAID Autostarter |
3 |
* |
4 |
* Copyright (C) 2005 by Tim Yamin <plasmaroo@gentoo.org> <plasm@roo.me.uk> |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
* General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
* |
20 |
*/ |
21 |
|
22 |
#include <sys/types.h> |
23 |
#include <sys/stat.h> |
24 |
#include <fcntl.h> |
25 |
#include <sys/ioctl.h> |
26 |
#include <linux/major.h> |
27 |
#include <linux/raid/md_u.h> |
28 |
|
29 |
extern int |
30 |
mdstart_main(int argc, char *argv[]) |
31 |
{ |
32 |
int i, fd, part = 0, retval = 0; |
33 |
|
34 |
if(argc < 2) |
35 |
{ |
36 |
bb_show_usage(); |
37 |
} |
38 |
|
39 |
for(i = 1; i < argc; i++) |
40 |
{ |
41 |
if(sscanf(argv[i], "%d", &part) == 1) |
42 |
continue; |
43 |
|
44 |
fd = open(argv[i], 0, 0); |
45 |
if (fd >= 0) |
46 |
{ |
47 |
ioctl(fd, RAID_AUTORUN, part); |
48 |
close(fd); |
49 |
} else |
50 |
{ |
51 |
printf("Error: Failed to open %s!\n", argv[i]); |
52 |
retval=1; |
53 |
} |
54 |
|
55 |
part = 0; |
56 |
} |
57 |
|
58 |
return retval; |
59 |
} |