]> git.pld-linux.org Git - packages/busybox.git/blame - busybox-raid_start.patch
- typo
[packages/busybox.git] / busybox-raid_start.patch
CommitLineData
1d62e784
AM
1diff -urN busybox-1.00-pre2.org/include/applets.h busybox-1.00-pre2/include/applets.h
2--- busybox-1.00-pre2.org/include/applets.h 2003-08-02 23:46:48.000000000 +0200
3+++ busybox-1.00-pre2/include/applets.h 2003-08-02 23:54:03.000000000 +0200
4@@ -457,6 +457,9 @@
5 #ifdef CONFIG_PWD
6 APPLET(pwd, pwd_main, _BB_DIR_BIN, _BB_SUID_NEVER)
ab2882b2 7 #endif
1d62e784 8+#ifdef CONFIG_RAID_START
5286e124 9+ APPLET(raid_start, raid_start_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
ab2882b2 10+#endif
1d62e784
AM
11 #ifdef CONFIG_RDATE
12 APPLET(rdate, rdate_main, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)
ab2882b2 13 #endif
1d62e784
AM
14diff -urN busybox-1.00-pre2.org/include/usage.h busybox-1.00-pre2/include/usage.h
15--- busybox-1.00-pre2.org/include/usage.h 2003-08-02 23:46:48.000000000 +0200
16+++ busybox-1.00-pre2/include/usage.h 2003-08-02 23:52:05.000000000 +0200
17@@ -1924,6 +1924,12 @@
18 "$ pwd\n" \
19 "/root\n"
20
21+#define raid_start_trivial_usage \
22+ "MD_DEVICE DISK_DEVICE"
23+#define raid_start_full_usage \
24+ "Start MD_DEVICE, taking superblock from DISK_DEVICE.\n" \
25+ "Example: raid_start /dev/md0 /dev/sdb"
26+
27 #define rdate_trivial_usage \
28 "[-sp] HOST"
29 #define rdate_full_usage \
30diff -urN busybox-1.00-pre2.org/libbb/xfuncs.c.orig busybox-1.00-pre2/libbb/xfuncs.c.orig
31--- busybox-1.00-pre2.org/libbb/xfuncs.c.orig 1970-01-01 01:00:00.000000000 +0100
32+++ busybox-1.00-pre2/libbb/xfuncs.c.orig 2003-08-02 23:48:39.000000000 +0200
33@@ -0,0 +1,196 @@
34+/* vi: set sw=4 ts=4: */
35+/*
36+ * Utility routines.
37+ *
38+ * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
39+ *
40+ * This program is free software; you can redistribute it and/or modify
41+ * it under the terms of the GNU General Public License as published by
42+ * the Free Software Foundation; either version 2 of the License, or
43+ * (at your option) any later version.
44+ *
45+ * This program is distributed in the hope that it will be useful,
46+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
47+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
48+ * General Public License for more details.
49+ *
50+ * You should have received a copy of the GNU General Public License
51+ * along with this program; if not, write to the Free Software
52+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
53+ */
54+
55+#include <sys/types.h>
56+#include <sys/stat.h>
57+#include <stdio.h>
58+#include <string.h>
59+#include <stdlib.h>
60+#include <unistd.h>
61+#include <fcntl.h>
62+#include "libbb.h"
63+
64+
65+#ifndef DMALLOC
66+#ifdef L_xmalloc
67+extern void *xmalloc(size_t size)
68+{
69+ void *ptr = malloc(size);
70+ if (ptr == NULL && size != 0)
71+ bb_error_msg_and_die(bb_msg_memory_exhausted);
72+ return ptr;
73+}
74+#endif
75+
76+#ifdef L_xrealloc
77+extern void *xrealloc(void *ptr, size_t size)
78+{
79+ ptr = realloc(ptr, size);
80+ if (ptr == NULL && size != 0)
81+ bb_error_msg_and_die(bb_msg_memory_exhausted);
82+ return ptr;
83+}
84+#endif
85+
86+#ifdef L_xcalloc
87+extern void *xcalloc(size_t nmemb, size_t size)
88+{
89+ void *ptr = calloc(nmemb, size);
90+ if (ptr == NULL && nmemb != 0 && size != 0)
91+ bb_error_msg_and_die(bb_msg_memory_exhausted);
92+ return ptr;
93+}
94+#endif
95+#endif /* DMALLOC */
96+
97+#ifdef L_xstrdup
98+extern char * bb_xstrdup (const char *s) {
99+ char *t;
100+
101+ if (s == NULL)
102+ return NULL;
103+
104+ t = strdup (s);
105+
106+ if (t == NULL)
107+ bb_error_msg_and_die(bb_msg_memory_exhausted);
108+
109+ return t;
110+}
111+#endif
112+
113+#ifdef L_xstrndup
114+extern char * bb_xstrndup (const char *s, int n) {
115+ char *t;
116+
117+ if (s == NULL)
118+ bb_error_msg_and_die("bb_xstrndup bug");
119+
120+ t = xmalloc(++n);
121+
122+ return safe_strncpy(t,s,n);
123+}
124+#endif
125+
126+#ifdef L_xfopen
127+FILE *bb_xfopen(const char *path, const char *mode)
128+{
129+ FILE *fp;
130+ if ((fp = fopen(path, mode)) == NULL)
131+ bb_perror_msg_and_die("%s", path);
132+ return fp;
133+}
134+#endif
135+
136+#ifdef L_xopen
137+extern int bb_xopen(const char *pathname, int flags)
138+{
139+ int ret;
140+
141+ ret = open(pathname, flags, 0777);
142+ if (ret == -1) {
143+ bb_perror_msg_and_die("%s", pathname);
144+ }
145+ return ret;
146+}
147+#endif
148+
149+#ifdef L_xread
150+extern ssize_t bb_xread(int fd, void *buf, size_t count)
151+{
152+ ssize_t size;
153+
154+ size = read(fd, buf, count);
155+ if (size == -1) {
156+ bb_perror_msg_and_die("Read error");
157+ }
158+ return(size);
159+}
160+#endif
161+
162+#ifdef L_xread_all
163+extern void bb_xread_all(int fd, void *buf, size_t count)
164+{
165+ ssize_t size;
166+
167+ while (count) {
168+ if ((size = bb_xread(fd, buf, count)) == 0) { /* EOF */
169+ bb_error_msg_and_die("Short read");
170+ }
171+ count -= size;
172+ }
173+ return;
174+}
175+#endif
176+
177+#ifdef L_xread_char
178+extern unsigned char bb_xread_char(int fd)
179+{
180+ char tmp;
181+
182+ bb_xread_all(fd, &tmp, 1);
183+
184+ return(tmp);
185+}
186+#endif
187+
188+#ifdef L_xferror
189+extern void bb_xferror(FILE *fp, const char *fn)
190+{
191+ if (ferror(fp)) {
192+ bb_error_msg_and_die("%s", fn);
193+ }
194+}
195+#endif
196+
197+#ifdef L_xferror_stdout
198+extern void bb_xferror_stdout(void)
199+{
200+ bb_xferror(stdout, bb_msg_standard_output);
201+}
202+#endif
203+
204+#ifdef L_xfflush_stdout
205+extern void bb_xfflush_stdout(void)
206+{
207+ if (fflush(stdout)) {
208+ bb_perror_msg_and_die(bb_msg_standard_output);
209+ }
210+}
211+#endif
212+
213+#ifdef L_strlen
214+/* Stupid gcc always includes its own builtin strlen()... */
215+#undef strlen
216+size_t bb_strlen(const char *string)
217+{
218+ return(strlen(string));
219+}
220+#endif
221+
222+/* END CODE */
223+/*
224+Local Variables:
225+c-file-style: "linux"
226+c-basic-offset: 4
227+tab-width: 4
228+End:
229+*/
230diff -urN busybox-1.00-pre2.org/libbb/xfuncs.c.rej busybox-1.00-pre2/libbb/xfuncs.c.rej
231--- busybox-1.00-pre2.org/libbb/xfuncs.c.rej 1970-01-01 01:00:00.000000000 +0100
232+++ busybox-1.00-pre2/libbb/xfuncs.c.rej 2003-08-02 23:49:05.000000000 +0200
233@@ -0,0 +1,70 @@
234+***************
235+*** 35,41 ****
236+ #ifndef DMALLOC
237+ extern void *xmalloc(size_t size)
238+ {
239+- void *ptr = malloc(size);
240+
241+ if (!ptr)
242+ error_msg_and_die(memory_exhausted);
243+--- 35,46 ----
244+ #ifndef DMALLOC
245+ extern void *xmalloc(size_t size)
246+ {
247++ void *ptr;
248++
249++ if (size == 0)
250++ size++;
251++
252++ ptr = malloc(size);
253+
254+ if (!ptr)
255+ error_msg_and_die(memory_exhausted);
256+***************
257+*** 54,59 ****
258+ return NULL;
259+ }
260+
261+ ptr = realloc(old, size);
262+ if (!ptr)
263+ error_msg_and_die(memory_exhausted);
264+--- 59,67 ----
265+ return NULL;
266+ }
267+
268++ if (size == 0)
269++ size++;
270++
271+ ptr = realloc(old, size);
272+ if (!ptr)
273+ error_msg_and_die(memory_exhausted);
274+***************
275+*** 62,70 ****
276+
277+ extern void *xcalloc(size_t nmemb, size_t size)
278+ {
279+- void *ptr = calloc(nmemb, size);
280+ if (!ptr)
281+ error_msg_and_die(memory_exhausted);
282+ return ptr;
283+ }
284+
285+--- 70,87 ----
286+
287+ extern void *xcalloc(size_t nmemb, size_t size)
288+ {
289++ void *ptr;
290++
291++ if (nmemb == 0)
292++ nmemb++;
293++
294++ if (size == 0)
295++ size++;
296++
297++ ptr = calloc(nmemb, size);
298+ if (!ptr)
299+ error_msg_and_die(memory_exhausted);
300++
301+ return ptr;
302+ }
303+
304diff -urN busybox-1.00-pre2.org/sysdeps/linux/defconfig busybox-1.00-pre2/sysdeps/linux/defconfig
305--- busybox-1.00-pre2.org/sysdeps/linux/defconfig 2003-08-02 23:46:49.000000000 +0200
306+++ busybox-1.00-pre2/sysdeps/linux/defconfig 2003-08-02 23:55:23.000000000 +0200
307@@ -290,6 +290,7 @@
308 # CONFIG_FEATURE_USE_DEVPS_PATCH is not set
309 CONFIG_UMOUNT=y
310 # CONFIG_FEATURE_MOUNT_FORCE is not set
311+CONFIG_RAID_START=y
312
313 #
314 # Common options for mount/umount
315diff -urN busybox-1.00-pre2.org/util-linux/Config.in busybox-1.00-pre2/util-linux/Config.in
316--- busybox-1.00-pre2.org/util-linux/Config.in 2003-08-02 23:46:49.000000000 +0200
317+++ busybox-1.00-pre2/util-linux/Config.in 2003-08-02 23:58:22.000000000 +0200
318@@ -285,6 +285,12 @@
319 NFS filesystems. Most people using BusyBox will also want to enable
320 the 'mount' utility.
321
322+config CONFIG_RAID_START
323+ bool "raid_start"
324+ default y
325+ help
326+ Enable support for RAID starting.
327+
328 config CONFIG_NFSMOUNT
329 bool " Support mounting nfs file systems"
330 default n
331diff -urN busybox-1.00-pre2.org/util-linux/Makefile.in busybox-1.00-pre2/util-linux/Makefile.in
332--- busybox-1.00-pre2.org/util-linux/Makefile.in 2003-08-02 23:46:49.000000000 +0200
333+++ busybox-1.00-pre2/util-linux/Makefile.in 2003-08-02 23:59:35.000000000 +0200
334@@ -38,6 +38,7 @@
335 UTILLINUX-$(CONFIG_MKSWAP) += mkswap.o
336 UTILLINUX-$(CONFIG_MORE) += more.o
337 UTILLINUX-$(CONFIG_MOUNT) += mount.o
338+UTILLINUX-$(CONFIG_RAID_START) += raid_start.o
339 UTILLINUX-$(CONFIG_NFSMOUNT) += nfsmount.o
340 UTILLINUX-$(CONFIG_PIVOT_ROOT) += pivot_root.o
341 UTILLINUX-$(CONFIG_RDATE) += rdate.o
342diff -urN busybox-1.00-pre2.org/util-linux/raid_start.c busybox-1.00-pre2/util-linux/raid_start.c
343--- busybox-1.00-pre2.org/util-linux/raid_start.c 1970-01-01 01:00:00.000000000 +0100
344+++ busybox-1.00-pre2/util-linux/raid_start.c 2003-08-02 23:52:00.000000000 +0200
ab2882b2
MM
345@@ -0,0 +1,61 @@
346+/* vi: set sw=4 ts=4: */
347+/*
348+ * raid_start implementation for busybox
349+ *
350+ * Copyright (C) 2003 by Michal Moskal <malekith@pld-linux.org>
351+ *
352+ * This program is free software; you can redistribute it and/or modify
353+ * it under the terms of the GNU General Public License as published by
354+ * the Free Software Foundation; either version 2 of the License, or
355+ * (at your option) any later version.
356+ *
357+ * This program is distributed in the hope that it will be useful,
358+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
359+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
360+ * General Public License for more details.
361+ *
362+ * You should have received a copy of the GNU General Public License
363+ * along with this program; if not, write to the Free Software
364+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
365+ *
366+ */
367+
368+#include <sys/types.h>
369+#include <sys/stat.h>
370+#include <sys/ioctl.h>
371+#include <fcntl.h>
372+#include <unistd.h>
373+
374+#include "busybox.h"
375+
376+#define MD_MAJOR 9
377+#define START_ARRAY _IO (MD_MAJOR, 0x31)
378+
379+extern int raid_start_main(int argc, char **argv)
380+{
381+ int fd_md;
382+ struct stat st;
383+
384+ if (argc != 3)
385+ show_usage();
386+
387+ fd_md = open(argv[1], O_RDWR, 0);
388+ if (fd_md < 0)
389+ perror_msg_and_die("error opening raid device `%s'", argv[1]);
390+
391+ if (stat(argv[2], &st))
392+ perror_msg_and_die("error stating raid builing device `%s'", argv[2]);
393+
394+ if (ioctl(fd_md, START_ARRAY, (unsigned long) st.st_rdev) == -1)
395+ perror_msg_and_die("error starting raid device `%s:%s'", argv[1], argv[2]);
396+
397+ return 0;
398+}
399+
400+/*
401+Local Variables:
402+c-file-style: "linux"
403+c-basic-offset: 4
404+tab-width: 4
405+End:
406+*/
This page took 0.071427 seconds and 4 git commands to generate.