aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2005-08-13 04:05:50 +0000
committerRob Landley <rob@landley.net>2005-08-13 04:05:50 +0000
commitb309ec71c8bac3ee19fbb0d5a83612f122d64e81 (patch)
treeb457d8645a933dc34917b5bc422a844923cd5b6b
parent866bad310fe448ddb605b77e8dd5557a4d863c3f (diff)
downloadbusybox-w32-b309ec71c8bac3ee19fbb0d5a83612f122d64e81.tar.gz
busybox-w32-b309ec71c8bac3ee19fbb0d5a83612f122d64e81.tar.bz2
busybox-w32-b309ec71c8bac3ee19fbb0d5a83612f122d64e81.zip
Delete the patches directory from 1.0.
-rw-r--r--busybox/patches/cmp_n.diff377
-rw-r--r--busybox/patches/dd_ibs_and_obs.diff252
-rw-r--r--busybox/patches/eject.diff164
-rw-r--r--busybox/patches/makdevs_table.diff294
-rw-r--r--busybox/patches/rpm2cpio_bzip2.patch63
-rw-r--r--busybox/patches/tftp_timeout_multicast.diff1053
-rw-r--r--busybox/patches/top_system_cpu.diff51
-rw-r--r--busybox/patches/udhcp_additional_items.diff126
-rw-r--r--busybox/patches/udhcp_config_paths.diff333
-rw-r--r--busybox/patches/udhcpd_foreground.diff33
10 files changed, 0 insertions, 2746 deletions
diff --git a/busybox/patches/cmp_n.diff b/busybox/patches/cmp_n.diff
deleted file mode 100644
index fc4661cf5..000000000
--- a/busybox/patches/cmp_n.diff
+++ /dev/null
@@ -1,377 +0,0 @@
1Index: coreutils/Config.in
2===================================================================
3RCS file: /var/cvs/busybox/coreutils/Config.in,v
4retrieving revision 1.24
5diff -u -r1.24 Config.in
6--- a/coreutils/Config.in 15 Mar 2004 08:28:19 -0000 1.24
7+++ b/coreutils/Config.in 31 Mar 2004 11:51:17 -0000
8@@ -59,6 +59,21 @@
9 cmp is used to compare two files and returns the result
10 to standard output.
11
12+config CONFIG_FEATURE_CMP_SKIP
13+ bool " Enable optional arguments SKIP1 and SKIP2"
14+ default n
15+ depends on CONFIG_CMP
16+ help
17+ SKIP1 and SKIP2 specify how many bytes to ignore
18+ at the start of each file.
19+
20+config CONFIG_FEATURE_CMP_LIMIT
21+ bool " Enable limit of inputs"
22+ default n
23+ depends on CONFIG_CMP
24+ help
25+ Enable cmp option (-n).
26+
27 config CONFIG_CP
28 bool "cp"
29 default n
30Index: coreutils/cmp.c
31===================================================================
32RCS file: /var/cvs/busybox/coreutils/cmp.c,v
33retrieving revision 1.9
34diff -u -r1.9 cmp.c
35--- a/coreutils/cmp.c 19 Mar 2003 09:11:32 -0000 1.9
36+++ b/coreutils/cmp.c 31 Mar 2004 11:51:17 -0000
37@@ -39,6 +39,12 @@
38 #include <unistd.h>
39 #include "busybox.h"
40
41+#ifdef CONFIG_FEATURE_CMP_SKIP
42+#define MAX_OPTIONAL_ARGS 3
43+#else
44+#define MAX_OPTIONAL_ARGS 1
45+#endif
46+
47 static FILE *cmp_xfopen_input(const char *filename)
48 {
49 FILE *fp;
50@@ -58,12 +64,57 @@
51 static const char fmt_l_opt[] = "%.0s%.0s%d %3o %3o\n"; /* nicer gnu format */
52 #endif
53
54-static const char opt_chars[] = "sl";
55+#ifdef CONFIG_FEATURE_CMP_LIMIT
56+#define OPTCHR_LIMIT "n:"
57+#define OPTARG_LIMIT ,&limit_str
58+#else
59+#define OPTCHR_LIMIT
60+#define OPTARG_LIMIT
61+#endif
62+
63+static const char opt_chars[] = "sl" OPTCHR_LIMIT;
64
65 enum {
66 OPT_s = 1,
67- OPT_l = 2
68+ OPT_l = 2,
69+ OPT_n = 4
70+};
71+
72+#ifdef CONFIG_LFS
73+#define SUFFIX_STRUCT suffix_mult64
74+#define PARSE_FUNC bb_xgetllarg10_sfx
75+#else
76+#define SUFFIX_STRUCT suffix_mult
77+#define PARSE_FUNC bb_xgetlarg10_sfx
78+#endif
79+
80+#if defined(CONFIG_FEATURE_CMP_SKIP) || defined(CONFIG_FEATURE_CMP_LIMIT)
81+static const struct SUFFIX_STRUCT suffixes[] = {
82+ { "k", 1UL << 10 },
83+ { "M", 1UL << 20 },
84+ { "G", 1UL << 30 },
85+#ifdef CONFIG_LFS
86+ { "T", 1ULL << 40 },
87+ { "P", 1ULL << 50 },
88+ { "E", 1ULL << 60 },
89+#endif
90+ { NULL, 0 }
91 };
92+#endif
93+
94+#ifdef CONFIG_FEATURE_CMP_SKIP
95+static void skip_input(FILE *fp, off_t skip, const char *filename)
96+{
97+ if (skip > 0 && fseeko(fp, skip, SEEK_CUR) != 0) {
98+ while (skip-- > 0) {
99+ if (getc(fp) == EOF) {
100+ bb_xferror(fp, filename);
101+ break;
102+ }
103+ }
104+ }
105+}
106+#endif
107
108 int cmp_main(int argc, char **argv)
109 {
110@@ -73,12 +124,26 @@
111 int c1, c2, char_pos, line_pos;
112 int opt_flags;
113 int exit_val = 0;
114+#ifdef CONFIG_FEATURE_CMP_SKIP
115+ off_t skip1 = 0, skip2 = 0;
116+#endif
117+#ifdef CONFIG_FEATURE_CMP_LIMIT
118+ off_t limit = -1;
119+ char *limit_str;
120+#endif
121
122 bb_default_error_retval = 2; /* 1 is returned if files are different. */
123
124- opt_flags = bb_getopt_ulflags(argc, argv, opt_chars);
125+ opt_flags = bb_getopt_ulflags(argc, argv, opt_chars OPTARG_LIMIT);
126
127- if ((opt_flags == 3) || (((unsigned int)(--argc - optind)) > 1)) {
128+#ifdef CONFIG_FEATURE_CMP_LIMIT
129+ if (opt_flags & OPT_n) {
130+ limit = PARSE_FUNC(limit_str, suffixes);
131+ opt_flags &= 3;
132+ }
133+#endif
134+
135+ if ((opt_flags == 3) || (((unsigned int)(--argc - optind)) > MAX_OPTIONAL_ARGS)) {
136 bb_show_usage();
137 }
138
139@@ -87,6 +152,13 @@
140 filename2 = "-";
141 if (*++argv) {
142 filename2 = *argv;
143+#ifdef CONFIG_FEATURE_CMP_SKIP
144+ if (*++argv) {
145+ skip1 = PARSE_FUNC(*argv, suffixes);
146+ if (*++argv)
147+ skip2 = PARSE_FUNC(*argv, suffixes);
148+ }
149+#endif
150 }
151 fp2 = cmp_xfopen_input(filename2);
152
153@@ -98,6 +170,11 @@
154 return 0;
155 }
156
157+#ifdef CONFIG_FEATURE_CMP_SKIP
158+ skip_input(fp1, skip1, filename1);
159+ skip_input(fp2, skip2, filename2);
160+#endif
161+
162 fmt = fmt_differ;
163 if (opt_flags == OPT_l) {
164 fmt = fmt_l_opt;
165@@ -106,6 +183,10 @@
166 char_pos = 0;
167 line_pos = 1;
168 do {
169+#ifdef CONFIG_FEATURE_CMP_LIMIT
170+ if (limit-- == 0)
171+ break;
172+#endif
173 c1 = getc(fp1);
174 c2 = getc(fp2);
175 ++char_pos;
176Index: include/usage.h
177===================================================================
178RCS file: /var/cvs/busybox/include/usage.h,v
179retrieving revision 1.198
180diff -u -r1.198 usage.h
181--- a/include/usage.h 29 Mar 2004 08:20:08 -0000 1.198
182+++ b/include/usage.h 31 Mar 2004 11:51:17 -0000
183@@ -186,14 +186,29 @@
184 #define clear_full_usage \
185 "Clear screen."
186
187+#ifdef CONFIG_FEATURE_CMP_SKIP
188+#define USAGE_CMP_SKIP(a) a
189+#else
190+#define USAGE_CMP_SKIP(a)
191+#endif
192+
193+#ifdef CONFIG_FEATURE_CMP_LIMIT
194+#define USAGE_CMP_LIMIT(a) a
195+#else
196+#define USAGE_CMP_LIMIT(a)
197+#endif
198+
199 #define cmp_trivial_usage \
200- "[OPTION]... FILE1 [FILE2]"
201+ "[OPTION]... FILE1 [FILE2" USAGE_CMP_SKIP(" [SKIP1 [SKIP2]]") "]"
202 #define cmp_full_usage \
203- "Compare files.\n\n" \
204+ "Compare files.\n" \
205+ USAGE_CMP_SKIP("SKIP1 and SKIP2 are the number of bytes to skip in each file.\n") \
206+ "\n" \
207 "Options:\n" \
208- "\t-l\tWrite the byte numbers (decimal) and values (octal)\n" \
209- "\t\t for all differing bytes.\n" \
210- "\t-s\tquiet mode - do not print"
211+ "\t-l\t\tWrite the byte numbers (decimal) and values (octal)\n" \
212+ "\t\t\t for all differing bytes.\n" \
213+ USAGE_CMP_LIMIT("\t-n LIMIT\tCompare at most LIMIT bytes.\n") \
214+ "\t-s\t\tquiet mode - do not print"
215
216 #define cp_trivial_usage \
217 "[OPTION]... SOURCE DEST"
218Index: include/libbb.h
219===================================================================
220RCS file: /var/cvs/busybox/include/libbb.h,v
221retrieving revision 1.129
222diff -u -r1.129 libbb.h
223--- a/include/libbb.h 15 Mar 2004 08:28:38 -0000 1.129
224+++ b/include/libbb.h 31 Mar 2004 11:51:17 -0000
225@@ -217,6 +217,21 @@
226 const struct suffix_mult *suffixes);
227 extern long bb_xgetlarg10_sfx(const char *arg, const struct suffix_mult *suffixes);
228
229+struct suffix_mult64 {
230+ const char *suffix;
231+ unsigned long long mult;
232+};
233+
234+extern unsigned long long bb_xgetullarg_bnd_sfx(const char *arg, int base,
235+ unsigned long long lower,
236+ unsigned long long upper,
237+ const struct suffix_mult64 *suffixes);
238+
239+extern long long bb_xgetllarg_bnd_sfx(const char *arg, int base,
240+ long long lower,
241+ long long upper,
242+ const struct suffix_mult64 *suffixes);
243+extern long long bb_xgetllarg10_sfx(const char *arg, const struct suffix_mult64 *suffixes);
244
245 //#warning pitchable now?
246 extern unsigned long bb_xparse_number(const char *numstr,
247Index: libbb/Makefile.in
248===================================================================
249RCS file: /var/cvs/busybox/libbb/Makefile.in,v
250retrieving revision 1.34
251diff -u -r1.34 Makefile.in
252--- a/libbb/Makefile.in 6 Mar 2004 22:11:45 -0000 1.34
253+++ b/libbb/Makefile.in 31 Mar 2004 11:51:17 -0000
254@@ -70,7 +70,8 @@
255
256 LIBBB_MSRC3:=$(LIBBB_DIR)xgetularg.c
257 LIBBB_MOBJ3:=xgetularg_bnd_sfx.o xgetlarg_bnd_sfx.o getlarg10_sfx.o \
258- xgetularg_bnd.o xgetularg10_bnd.o xgetularg10.o
259+ xgetularg_bnd.o xgetularg10_bnd.o xgetularg10.o \
260+ xgetullarg_bnd_sfx.o xgetllarg_bnd_sfx.o xgetllarg10_sfx.o
261
262 LIBBB_MSRC4:=$(LIBBB_DIR)/safe_strtol.c
263 LIBBB_MOBJ4:=safe_strtoi.o safe_strtod.o safe_strtol.o safe_strtoul.o
264Index: libbb/xgetularg.c
265===================================================================
266RCS file: /var/cvs/busybox/libbb/xgetularg.c,v
267retrieving revision 1.2
268diff -u -r1.2 xgetularg.c
269--- a/libbb/xgetularg.c 15 Mar 2004 08:28:44 -0000 1.2
270+++ b/libbb/xgetularg.c 31 Mar 2004 11:51:17 -0000
271@@ -158,3 +158,106 @@
272 return bb_xgetularg10_bnd(arg, 0, ULONG_MAX);
273 }
274 #endif
275+
276+#ifdef L_xgetullarg_bnd_sfx
277+extern
278+unsigned long long bb_xgetullarg_bnd_sfx(const char *arg, int base,
279+ unsigned long long lower,
280+ unsigned long long upper,
281+ const struct suffix_mult64 *suffixes)
282+{
283+ unsigned long long r;
284+ int old_errno;
285+ char *e;
286+
287+ assert(arg);
288+
289+ /* Disallow '-' and any leading whitespace. Speed isn't critical here
290+ * since we're parsing commandline args. So make sure we get the
291+ * actual isspace function rather than a larger macro implementaion. */
292+ if ((*arg == '-') || (isspace)(*arg)) {
293+ bb_show_usage();
294+ }
295+
296+ /* Since this is a lib function, we're not allowed to reset errno to 0.
297+ * Doing so could break an app that is deferring checking of errno.
298+ * So, save the old value so that we can restore it if successful. */
299+ old_errno = errno;
300+ errno = 0;
301+ r = strtoull(arg, &e, base);
302+ /* Do the initial validity check. Note: The standards do not
303+ * guarantee that errno is set if no digits were found. So we
304+ * must test for this explicitly. */
305+ if (errno || (arg == e)) { /* error or no digits */
306+ bb_show_usage();
307+ }
308+ errno = old_errno; /* Ok. So restore errno. */
309+
310+ /* Do optional suffix parsing. Allow 'empty' suffix tables.
311+ * Note that we also all nul suffixes with associated multipliers,
312+ * to allow for scaling of the arg by some default multiplier. */
313+
314+ if (suffixes) {
315+ while (suffixes->suffix) {
316+ if (strcmp(suffixes->suffix, e) == 0) {
317+ if (ULONG_LONG_MAX / suffixes->mult < r) { /* Overflow! */
318+ bb_show_usage();
319+ }
320+ ++e;
321+ r *= suffixes->mult;
322+ break;
323+ }
324+ ++suffixes;
325+ }
326+ }
327+
328+ /* Finally, check for illegal trailing chars and range limits. */
329+ /* Note: although we allow leading space (via stroul), trailing space
330+ * is an error. It would be easy enough to allow though if desired. */
331+ if (*e || (r < lower) || (r > upper)) {
332+ bb_show_usage();
333+ }
334+
335+ return r;
336+}
337+#endif
338+
339+#ifdef L_xgetllarg_bnd_sfx
340+extern
341+long long bb_xgetllarg_bnd_sfx(const char *arg, int base,
342+ long long lower,
343+ long long upper,
344+ const struct suffix_mult64 *suffixes)
345+{
346+ unsigned long long u = LONG_LONG_MAX;
347+ long long r;
348+ const char *p = arg;
349+
350+ if ((*p == '-') && (p[1] != '+')) {
351+ ++p;
352+#if LONG_LONG_MAX == (-(LONG_LONG_MIN + 1))
353+ ++u; /* two's complement */
354+#endif
355+ }
356+
357+ r = bb_xgetullarg_bnd_sfx(p, base, 0, u, suffixes);
358+
359+ if (*arg == '-') {
360+ r = -r;
361+ }
362+
363+ if ((r < lower) || (r > upper)) {
364+ bb_show_usage();
365+ }
366+
367+ return r;
368+}
369+#endif
370+
371+#ifdef L_xgetllarg10_sfx
372+extern
373+long long bb_xgetllarg10_sfx(const char *arg, const struct suffix_mult64 *suffixes)
374+{
375+ return bb_xgetllarg_bnd_sfx(arg, 10, LONG_LONG_MIN, LONG_LONG_MAX, suffixes);
376+}
377+#endif
diff --git a/busybox/patches/dd_ibs_and_obs.diff b/busybox/patches/dd_ibs_and_obs.diff
deleted file mode 100644
index 3bbf4b989..000000000
--- a/busybox/patches/dd_ibs_and_obs.diff
+++ /dev/null
@@ -1,252 +0,0 @@
1This patch adds support of ibs= and obs= to dd.
2----
3Hideki IWAMOTO h-iwamoto@kit.hi-ho.ne.jp
4
5
6--- a/include/usage.h 29 Mar 2004 08:20:08 -0000 1.198
7+++ b/include/usage.h 4 Apr 2004 07:15:21 -0000
8@@ -309,13 +309,15 @@
9 "64\n"
10
11 #define dd_trivial_usage \
12- "[if=FILE] [of=FILE] [bs=N] [count=N] [skip=N]\n" \
13- "\t [seek=N] [conv=notrunc|noerror|sync]"
14+ "[if=FILE] [of=FILE] [ibs=N] [obs=N] [bs=N] [count=N]\n" \
15+ "\t [skip=N] [seek=N] [conv=notrunc|noerror|sync]"
16 #define dd_full_usage \
17 "Copy a file, converting and formatting according to options\n\n" \
18 "\tif=FILE\t\tread from FILE instead of stdin\n" \
19 "\tof=FILE\t\twrite to FILE instead of stdout\n" \
20- "\tbs=N\t\tread and write N bytes at a time\n" \
21+ "\tibs=N\t\tread N bytes at a time\n" \
22+ "\tobs=N\t\twrite N bytes at a time\n" \
23+ "\tbs=N\t\tforce ibs=N and obs=N\n" \
24 "\tcount=N\t\tcopy only N input blocks\n" \
25 "\tskip=N\t\tskip N input blocks\n" \
26 "\tseek=N\t\tskip N output blocks\n" \
27@@ -323,6 +325,8 @@
28 "\tconv=noerror\tcontinue after read errors\n" \
29 "\tconv=sync\tpad blocks with zeros\n" \
30 "\n" \
31+ "If the bs= expr operand is not specified, the input is processed and collected\n" \
32+ "into full-sized output blocks until the end of the input is reached.\n" \
33 "Numbers may be suffixed by c (x1), w (x2), b (x512), kD (x1000), k (x1024),\n" \
34 "MD (x1000000), M (x1048576), GD (x1000000000) or G (x1073741824)."
35 #define dd_example_usage \
36--- a/coreutils/dd.c 30 Jan 2004 22:24:32 -0000 1.55
37+++ b/coreutils/dd.c 4 Apr 2004 07:15:21 -0000
38@@ -30,6 +30,10 @@
39 #include <fcntl.h>
40 #include "busybox.h"
41
42+#define C_NOERROR 0x0001
43+#define C_TRUNC 0x0002
44+#define C_SYNC 0x0004
45+#define C_TWOBUFS 0x0008
46
47 static const struct suffix_mult dd_suffixes[] = {
48 { "c", 1 },
49@@ -51,13 +55,13 @@
50 size_t in_full = 0;
51 size_t in_part = 0;
52 size_t count = -1;
53- size_t bs = 512;
54+ size_t ibs = 512;
55+ size_t obs = 512;
56+ size_t oc = 0;
57 ssize_t n;
58 off_t seek = 0;
59 off_t skip = 0;
60- int sync_flag = FALSE;
61- int noerror = FALSE;
62- int trunc_flag = TRUE;
63+ unsigned int dd_flags = C_TWOBUFS | C_TRUNC;
64 int oflag;
65 int ifd;
66 int ofd;
67@@ -65,11 +69,18 @@
68 const char *infile = NULL;
69 const char *outfile = NULL;
70 char *buf;
71+ char *ibuf;
72+ char *obuf;
73
74 for (i = 1; i < argc; i++) {
75- if (strncmp("bs=", argv[i], 3) == 0)
76- bs = bb_xparse_number(argv[i]+3, dd_suffixes);
77- else if (strncmp("count=", argv[i], 6) == 0)
78+ if (strncmp("ibs=", argv[i], 4) == 0)
79+ ibs = bb_xparse_number(argv[i]+4, dd_suffixes);
80+ else if (strncmp("obs=", argv[i], 4) == 0)
81+ obs = bb_xparse_number(argv[i]+4, dd_suffixes);
82+ else if (strncmp("bs=", argv[i], 3) == 0) {
83+ ibs = obs = bb_xparse_number(argv[i]+3, dd_suffixes);
84+ dd_flags &= ~C_TWOBUFS;
85+ } else if (strncmp("count=", argv[i], 6) == 0)
86 count = bb_xparse_number(argv[i]+6, dd_suffixes);
87 else if (strncmp("seek=", argv[i], 5) == 0)
88 seek = bb_xparse_number(argv[i]+5, dd_suffixes);
89@@ -83,13 +94,13 @@
90 buf = argv[i]+5;
91 while (1) {
92 if (strncmp("notrunc", buf, 7) == 0) {
93- trunc_flag = FALSE;
94+ dd_flags &= ~C_TRUNC;
95 buf += 7;
96 } else if (strncmp("sync", buf, 4) == 0) {
97- sync_flag = TRUE;
98+ dd_flags |= C_SYNC;
99 buf += 4;
100 } else if (strncmp("noerror", buf, 7) == 0) {
101- noerror = TRUE;
102+ dd_flags |= C_NOERROR;
103 buf += 7;
104 } else {
105 bb_error_msg_and_die("invalid conversion `%s'", argv[i]+5);
106@@ -103,7 +114,12 @@
107 bb_show_usage();
108 }
109
110- buf = xmalloc(bs);
111+ ibuf = xmalloc(ibs);
112+
113+ if (dd_flags & C_TWOBUFS)
114+ obuf = xmalloc(obs);
115+ else
116+ obuf = ibuf;
117
118 if (infile != NULL) {
119 ifd = bb_xopen(infile, O_RDONLY);
120@@ -115,7 +131,7 @@
121 if (outfile != NULL) {
122 oflag = O_WRONLY | O_CREAT;
123
124- if (!seek && trunc_flag) {
125+ if (!seek && (dd_flags & C_TRUNC)) {
126 oflag |= O_TRUNC;
127 }
128
129@@ -123,8 +139,8 @@
130 bb_perror_msg_and_die("%s", outfile);
131 }
132
133- if (seek && trunc_flag) {
134- if (ftruncate(ofd, seek * bs) < 0) {
135+ if (seek && (dd_flags & C_TRUNC)) {
136+ if (ftruncate(ofd, seek * obs) < 0) {
137 struct stat st;
138
139 if (fstat (ofd, &st) < 0 || S_ISREG (st.st_mode) ||
140@@ -139,52 +155,88 @@
141 }
142
143 if (skip) {
144- if (lseek(ifd, skip * bs, SEEK_CUR) < 0) {
145- bb_perror_msg_and_die("%s", infile);
146+ if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) {
147+ while (skip-- > 0) {
148+ n = safe_read(ifd, ibuf, ibs);
149+ if (n < 0)
150+ bb_perror_msg_and_die("%s", infile);
151+ if (n == 0)
152+ break;
153+ }
154 }
155 }
156
157 if (seek) {
158- if (lseek(ofd, seek * bs, SEEK_CUR) < 0) {
159+ if (lseek(ofd, seek * obs, SEEK_CUR) < 0) {
160 bb_perror_msg_and_die("%s", outfile);
161 }
162 }
163
164 while (in_full + in_part != count) {
165- if (noerror) {
166+ if (dd_flags & C_NOERROR) {
167 /* Pre-zero the buffer when doing the noerror thing */
168- memset(buf, '\0', bs);
169+ memset(ibuf, '\0', ibs);
170+ }
171+
172+ n = safe_read(ifd, ibuf, ibs);
173+ if (n == 0) {
174+ break;
175 }
176- n = safe_read(ifd, buf, bs);
177 if (n < 0) {
178- if (noerror) {
179- n = bs;
180+ if (dd_flags & C_NOERROR) {
181+ n = ibs;
182 bb_perror_msg("%s", infile);
183 } else {
184 bb_perror_msg_and_die("%s", infile);
185 }
186 }
187- if (n == 0) {
188- break;
189- }
190- if (n == bs) {
191+ if (n == ibs) {
192 in_full++;
193 } else {
194 in_part++;
195+ if (dd_flags & C_SYNC) {
196+ memset(ibuf + n, '\0', ibs - n);
197+ n = ibs;
198+ }
199 }
200- if (sync_flag) {
201- memset(buf + n, '\0', bs - n);
202- n = bs;
203+
204+ if (dd_flags & C_TWOBUFS) {
205+ size_t d;
206+ char *tmp = ibuf;
207+
208+ while (n) {
209+ d = obs - oc;
210+ if (d > n)
211+ d = n;
212+ memcpy(obuf + oc, tmp, d);
213+ n -= d;
214+ tmp += d;
215+ oc += d;
216+ if (oc == obs) {
217+ if (bb_full_write(ofd, obuf, obs) < 0) {
218+ bb_perror_msg_and_die("%s", outfile);
219+ }
220+ out_full++;
221+ oc = 0;
222+ }
223+ }
224+ } else {
225+ if (bb_full_write(ofd, ibuf, n) < 0) {
226+ bb_perror_msg_and_die("%s", outfile);
227+ }
228+ if (n == ibs) {
229+ out_full++;
230+ } else {
231+ out_part++;
232+ }
233 }
234- n = bb_full_write(ofd, buf, n);
235- if (n < 0) {
236+ }
237+
238+ if (oc) {
239+ if (bb_full_write(ofd, obuf, oc) < 0) {
240 bb_perror_msg_and_die("%s", outfile);
241 }
242- if (n == bs) {
243- out_full++;
244- } else {
245- out_part++;
246- }
247+ out_part++;
248 }
249
250 if (close (ifd) < 0) {
251
252
diff --git a/busybox/patches/eject.diff b/busybox/patches/eject.diff
deleted file mode 100644
index fcc234d02..000000000
--- a/busybox/patches/eject.diff
+++ /dev/null
@@ -1,164 +0,0 @@
1Index: AUTHORS
2===================================================================
3RCS file: /var/cvs/busybox/AUTHORS,v
4retrieving revision 1.40
5diff -u -r1.40 AUTHORS
6--- a/AUTHORS 9 Oct 2003 21:19:21 -0000 1.40
7+++ b/AUTHORS 5 Mar 2004 07:23:17 -0000
8@@ -8,6 +8,9 @@
9
10 -----------
11
12+Peter Willis <psyphreak@phreaker.net>
13+ eject
14+
15 Emanuele Aina <emanuele.aina@tiscali.it>
16 run-parts
17
18Index: coreutils/Config.in
19===================================================================
20RCS file: /var/cvs/busybox/coreutils/Config.in,v
21retrieving revision 1.23
22diff -u -r1.23 Config.in
23--- a/coreutils/Config.in 5 Mar 2004 06:47:25 -0000 1.23
24+++ b/coreutils/Config.in 5 Mar 2004 07:23:18 -0000
25@@ -164,6 +164,13 @@
26 a command; without options it displays the current
27 environment.
28
29+config CONFIG_EJECT
30+ bool "eject"
31+ default n
32+ help
33+ ejects a cdrom drive.
34+ defaults to /dev/cdrom
35+
36 config CONFIG_EXPR
37 bool "expr"
38 default n
39Index: coreutils/Makefile.in
40===================================================================
41RCS file: /var/cvs/busybox/coreutils/Makefile.in,v
42retrieving revision 1.8
43diff -u -r1.8 Makefile.in
44--- a/coreutils/Makefile.in 27 Jan 2004 09:22:20 -0000 1.8
45+++ b/coreutils/Makefile.in 5 Mar 2004 07:23:18 -0000
46@@ -41,6 +41,7 @@
47 COREUTILS-$(CONFIG_DU) += du.o
48 COREUTILS-$(CONFIG_ECHO) += echo.o
49 COREUTILS-$(CONFIG_ENV) += env.o
50+COREUTILS-$(CONFIG_EJECT) += eject.o
51 COREUTILS-$(CONFIG_EXPR) += expr.o
52 COREUTILS-$(CONFIG_FALSE) += false.o
53 COREUTILS-$(CONFIG_FOLD) += fold.o
54Index: coreutils/eject.c
55===================================================================
56RCS file: coreutils/eject.c
57diff -N coreutils/eject.c
58--- /dev/null 1 Jan 1970 00:00:00 -0000
59+++ b/coreutils/eject.c 5 Mar 2004 07:23:21 -0000
60@@ -0,0 +1,66 @@
61+/*
62+ * eject implementation for busybox
63+ *
64+ * Copyright (C) 2004 Peter Willis <psyphreak@phreaker.net>
65+ *
66+ * This program is free software; you can redistribute it and/or modify
67+ * it under the terms of the GNU General Public License as published by
68+ * the Free Software Foundation; either version 2 of the License, or
69+ * (at your option) any later version.
70+ *
71+ * This program is distributed in the hope that it will be useful,
72+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
73+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74+ * General Public License for more details.
75+ *
76+ * You should have received a copy of the GNU General Public License
77+ * along with this program; if not, write to the Free Software
78+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
79+ *
80+ */
81+
82+/*
83+ * This is a simple hack of eject based on something Erik posted in #uclibc.
84+ * Most of the dirty work blatantly ripped off from cat.c =)
85+ */
86+
87+#include <stdio.h>
88+#include <string.h>
89+#include <sys/types.h>
90+#include <sys/stat.h>
91+#include <fcntl.h>
92+#include <sys/ioctl.h>
93+#include "busybox.h"
94+#include <linux/cdrom.h> // needs to be after busybox.h or compile problems arise
95+
96+#define DEFAULT_CDROM "/dev/cdrom"
97+
98+extern int eject_main(int argc, char **argv)
99+{
100+ int fd;
101+ int flag = CDROMEJECT;
102+ int i = 1;
103+ char *device = NULL;
104+
105+ /*
106+ * i'm too lazy to learn bb_getopt_ulflags and this is obscenely large
107+ * for just some argument parsing so mjn3 can clean it up later.
108+ * sorry, but PlumpOS 7.0-pre2 needs this asap :-/
109+ */
110+ while (++i <= argc) {
111+ if ( (! strncmp(argv[i-1],"-t",2)) || (! strncmp(argv[i-1],"--trayclose",11)) ) {
112+ flag = CDROMCLOSETRAY;
113+ } else {
114+ device = argv[i-1];
115+ }
116+ }
117+ if ( (fd = open(device == NULL ? DEFAULT_CDROM : device, O_RDONLY | O_NONBLOCK) ) < 0 ) {
118+ perror("eject: Can't open device");
119+ return(EXIT_FAILURE);
120+ }
121+ if (ioctl(fd, flag)) {
122+ perror("eject: Can't eject cdrom");
123+ return(EXIT_FAILURE);
124+ }
125+ return EXIT_SUCCESS;
126+}
127Index: include/applets.h
128===================================================================
129RCS file: /var/cvs/busybox/include/applets.h,v
130retrieving revision 1.111
131diff -u -r1.111 applets.h
132--- a/include/applets.h 27 Jan 2004 09:22:20 -0000 1.111
133+++ b/include/applets.h 5 Mar 2004 07:23:21 -0000
134@@ -178,6 +178,9 @@
135 #if defined(CONFIG_FEATURE_GREP_EGREP_ALIAS)
136 APPLET_NOUSAGE("egrep", grep_main, _BB_DIR_BIN, _BB_SUID_NEVER)
137 #endif
138+#ifdef CONFIG_EJECT
139+ APPLET(eject, eject_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
140+#endif
141 #ifdef CONFIG_ENV
142 APPLET(env, env_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
143 #endif
144Index: include/usage.h
145===================================================================
146RCS file: /var/cvs/busybox/include/usage.h,v
147retrieving revision 1.191
148diff -u -r1.191 usage.h
149--- a/include/usage.h 25 Feb 2004 10:35:55 -0000 1.191
150+++ b/include/usage.h 5 Mar 2004 07:23:29 -0000
151@@ -537,6 +537,13 @@
152 "\t-, -i\tstart with an empty environment\n" \
153 "\t-u\tremove variable from the environment\n"
154
155+#define eject_trivial_usage \
156+ "[-t] [FILE]"
157+#define eject_full_usage \
158+ "Ejects the specified FILE or /dev/cdrom if FILE is unspecified.\n\n" \
159+ "Options:\n" \
160+ "\t-t, --trayclose \tclose tray\n"
161+
162 #define expr_trivial_usage \
163 "EXPRESSION"
164 #define expr_full_usage \
diff --git a/busybox/patches/makdevs_table.diff b/busybox/patches/makdevs_table.diff
deleted file mode 100644
index 1041608b7..000000000
--- a/busybox/patches/makdevs_table.diff
+++ /dev/null
@@ -1,294 +0,0 @@
1Index: include/usage.h
2===================================================================
3RCS file: /var/cvs/busybox/include/usage.h,v
4retrieving revision 1.211
5diff -u -r1.211 usage.h
6--- a/include/usage.h 26 May 2004 22:09:37 -0000 1.211
7+++ b/include/usage.h 5 Jun 2004 07:51:26 -0000
8@@ -1536,6 +1536,7 @@
9 #define lsmod_full_usage \
10 "List the currently loaded kernel modules."
11
12+#ifdef CONFIG_FEATURE_MAKEDEVS_LEAF
13 #define makedevs_trivial_usage \
14 "NAME TYPE MAJOR MINOR FIRST LAST [s]"
15 #define makedevs_full_usage \
16@@ -1555,6 +1556,18 @@
17 "[creates ttyS2-ttyS63]\n" \
18 "# makedevs /dev/hda b 3 0 0 8 s\n" \
19 "[creates hda,hda1-hda8]\n"
20+#endif
21+
22+#ifdef CONFIG_FEATURE_MAKEDEVS_TABLE
23+#define makedevs_trivial_usage \
24+ "[-r rootdir] [device_table]"
25+#define makedevs_full_usage \
26+ "Creates a batch of special files as specified in a device table\n" \
27+ "The device table has one line per device group, each group is of\n" \
28+ "the format\n" \
29+ "\ttype mode user group major minor start increment count\n" \
30+ "a '-' may be used for blank entries\n"
31+#endif
32
33 #ifdef CONFIG_FEATURE_MD5_SHA1_SUM_CHECK
34 #define USAGE_MD5_SHA1_SUM_CHECK(a) a
35Index: miscutils/Config.in
36===================================================================
37RCS file: /var/cvs/busybox/miscutils/Config.in,v
38retrieving revision 1.14
39diff -u -r1.14 Config.in
40--- a/miscutils/Config.in 15 Mar 2004 08:28:46 -0000 1.14
41+++ b/miscutils/Config.in 5 Jun 2004 07:51:26 -0000
42@@ -143,10 +143,32 @@
43 bool "makedevs"
44 default n
45 help
46- 'makedevs' is a utility used and created by the Linux Router Project.
47- It creates a large number of device special files (/dev devices)
48- rather quickly, and can be considerably faster then running mknod a
49- zillion times.
50+ 'makedevs' is a utility used to create a batch of devices with
51+ one command.
52+ .
53+ There are two choices for command line behaviour, the interface
54+ as used by LEAF/Linux Router Project, or a device table file.
55+ .
56+ 'leaf' is traditionally what busybox follows, it allows multiple
57+ devices of a particluar type to be created per command.
58+ e.g. /dev/hda[0-9]
59+ Device properties are passed as command line arguments.
60+ .
61+ 'table' reads device properties from a file or stdin, allowing
62+ a batch of unrelated devices to be makde with one command.
63+ User/group names are allowed as an alternative to uid/gid.
64+
65+choice
66+ prompt "Choose makedevs behaviour"
67+ default CONFIG_FEATURE_MAKDEVS_TABLE
68+
69+config CONFIG_FEATURE_MAKEDEVS_LEAF
70+ bool "leaf"
71+
72+config CONFIG_FEATURE_MAKEDEVS_TABLE
73+ bool "table"
74+
75+endchoice
76
77 config CONFIG_MT
78 bool "mt"
79Index: miscutils/makedevs.c
80===================================================================
81RCS file: /var/cvs/busybox/miscutils/makedevs.c,v
82retrieving revision 1.16
83diff -u -r1.16 makedevs.c
84--- a/miscutils/makedevs.c 15 Mar 2004 08:28:46 -0000 1.16
85+++ b/miscutils/makedevs.c 5 Jun 2004 07:51:26 -0000
86@@ -1,20 +1,27 @@
87 /* vi: set sw=4 ts=4: */
88-/*
89- * public domain -- Dave 'Kill a Cop' Cinege <dcinege@psychosis.com>
90- *
91- * makedevs
92- * Make ranges of device files quickly.
93- * known bugs: can't deal with alpha ranges
94- */
95
96+#include <sys/types.h>
97+
98+#include <fcntl.h>
99+#include <getopt.h>
100 #include <stdio.h>
101 #include <stdlib.h>
102 #include <string.h>
103-#include <fcntl.h>
104+#include <time.h>
105 #include <unistd.h>
106-#include <sys/types.h>
107+
108 #include "busybox.h"
109
110+#ifdef CONFIG_FEATURE_MAKEDEVS_LEAF
111+
112+/*
113+ * public domain -- Dave 'Kill a Cop' Cinege <dcinege@psychosis.com>
114+ *
115+ * makedevs
116+ * Make ranges of device files quickly.
117+ * known bugs: can't deal with alpha ranges
118+ */
119+
120 int makedevs_main(int argc, char **argv)
121 {
122 mode_t mode;
123@@ -69,24 +76,153 @@
124 return 0;
125 }
126
127+#elif defined CONFIG_FEATURE_MAKEDEVS_TABLE
128+
129 /*
130-And this is what this program replaces. The shell is too slow!
131+ * This program is free software; you can redistribute it and/or modify
132+ * it under the terms of the GNU General Public License version 2 as
133+ * published by the Free Software Foundation.
134+ *
135+ * This program is distributed in the hope that it will be useful,
136+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
137+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
138+ * GNU Library General Public License for more details.
139+ *
140+ * You should have received a copy of the GNU General Public License
141+ * along with this program; if not, write to the Free Software
142+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
143+ *
144+ */
145+
146+static const struct option makedevs_long_options[] = {
147+ {"root", 1, NULL, 'r'},
148+ {0, 0, 0, 0}
149+};
150
151-makedev () {
152-local basedev=$1; local S=$2; local E=$3
153-local major=$4; local Sminor=$5; local type=$6
154-local sbase=$7
155-
156- if [ ! "$sbase" = "" ]; then
157- mknod "$basedev" $type $major $Sminor
158- S=`expr $S + 1`
159- Sminor=`expr $Sminor + 1`
160- fi
161-
162- while [ $S -le $E ]; do
163- mknod "$basedev$S" $type $major $Sminor
164- S=`expr $S + 1`
165- Sminor=`expr $Sminor + 1`
166- done
167+extern int makedevs_main(int argc, char **argv)
168+{
169+ FILE *table;
170+ int opt;
171+ char *rootdir = "./";
172+ char *line;
173+ int ret = EXIT_SUCCESS;
174+
175+ bb_opt_complementaly = "d~r";
176+ bb_applet_long_options = makedevs_long_options;
177+ opt = bb_getopt_ulflags(argc, argv, "d:r:", &rootdir, &rootdir);
178+
179+ if (optind + 1 == argc) {
180+ table = bb_xfopen(argv[optind], "r");
181+ } else {
182+ table = stdin;
183+ }
184+
185+ if (chdir(rootdir) == -1) {
186+ bb_perror_msg_and_die("Couldnt chdor to %s", rootdir);
187+ }
188+
189+ umask(0);
190+
191+ while ((line = bb_get_chomped_line_from_file(table))) {
192+ char type;
193+ unsigned int mode = 0755;
194+ unsigned int major = 0;
195+ unsigned int minor = 0;
196+ unsigned int count = 0;
197+ unsigned int increment = 0;
198+ unsigned int start = 0;
199+ char name[41];
200+ char user[41];
201+ char group[41];
202+ char *full_name;
203+ uid_t uid;
204+ gid_t gid;
205+
206+ if ((2 > sscanf(line, "%40s %c %o %40s %40s %u %u %u %u %u", name,
207+ &type, &mode, user, group, &major,
208+ &minor, &start, &increment, &count)) ||
209+ ((major | minor | start | count | increment) > 255)) {
210+ bb_error_msg("Ignoring invalid line\n%s\n", line);
211+ ret = EXIT_FAILURE;
212+ continue;
213+ }
214+ if (name[0] == '#') {
215+ continue;
216+ }
217+ if (group) {
218+ gid = get_ug_id(group, my_getgrnam);
219+ } else {
220+ gid = getgid();
221+ }
222+ if (user) {
223+ uid = get_ug_id(user, my_getpwnam);
224+ } else {
225+ uid = getuid();
226+ }
227+ full_name = concat_path_file(rootdir, name);
228+
229+ if (type == 'd') {
230+ bb_make_directory(full_name, mode | S_IFDIR, 0);
231+ if (chown(full_name, uid, gid) == -1) {
232+ bb_perror_msg("chown failed for %s", full_name);
233+ ret = EXIT_FAILURE;
234+ goto loop;
235+ }
236+ } else {
237+ dev_t rdev;
238+
239+ if (type == 'p') {
240+ mode |= S_IFIFO;
241+ }
242+ else if (type == 'c') {
243+ mode |= S_IFCHR;
244+ }
245+ else if (type == 'b') {
246+ mode |= S_IFBLK;
247+ } else {
248+ bb_error_msg("Unsupported file type %c", type);
249+ ret = EXIT_FAILURE;
250+ goto loop;
251+ }
252+
253+ if (count > 0) {
254+ int i;
255+ char *full_name_inc;
256+
257+ full_name_inc = xmalloc(strlen(full_name) + 4);
258+ for (i = start; i < count; i++) {
259+ sprintf(full_name_inc, "%s%d", full_name, i);
260+ rdev = (major << 8) + minor + (i * increment - start);
261+ if (mknod(full_name_inc, mode, rdev) == -1) {
262+ bb_perror_msg("Couldnt create node %s", full_name_inc);
263+ ret = EXIT_FAILURE;
264+ }
265+ else if (chown(full_name_inc, uid, gid) == -1) {
266+ bb_perror_msg("chown failed for %s", full_name_inc);
267+ ret = EXIT_FAILURE;
268+ }
269+ }
270+ free(full_name_inc);
271+ } else {
272+ rdev = (major << 8) + minor;
273+ if (mknod(full_name, mode, rdev) == -1) {
274+ bb_perror_msg("Couldnt create node %s", full_name);
275+ ret = EXIT_FAILURE;
276+ }
277+ else if (chown(full_name, uid, gid) == -1) {
278+ bb_perror_msg("chown failed for %s", full_name);
279+ ret = EXIT_FAILURE;
280+ }
281+ }
282+ }
283+loop:
284+ free(line);
285+ free(full_name);
286+ }
287+ fclose(table);
288+
289+ return 0;
290 }
291-*/
292+#else
293+# error makdedevs configuration error, either leaf or table must be selected
294+#endif
diff --git a/busybox/patches/rpm2cpio_bzip2.patch b/busybox/patches/rpm2cpio_bzip2.patch
deleted file mode 100644
index 151dd9fb4..000000000
--- a/busybox/patches/rpm2cpio_bzip2.patch
+++ /dev/null
@@ -1,63 +0,0 @@
1diff -ur busybox/archival/Config.in busybox/archival/Config.in
2--- busybox/archival/Config.in Sun May 23 09:15:37 2004
3+++ busybox/archival/Config.in Sun May 23 09:15:58 2004
4@@ -127,6 +127,14 @@
5 help
6 Converts an RPM file into a CPIO archive.
7
8+config CONFIG_FEATURE_RPM2CPIO_BZIP2
9+ bool " Support bzip2 decompression"
10+ default n
11+ depends on CONFIG_RPM2CPIO
12+ help
13+ If you enable this option you'll be able to extract
14+ rpms compressed with bzip2.
15+
16 config CONFIG_RPM
17 bool "rpm"
18 default n
19diff -ur busybox/archival/libunarchive/Makefile.in busybox/archival/libunarchive/Makefile.in
20--- busybox/archival/libunarchive/Makefile.in Sun May 23 09:15:04 2004
21+++ busybox/archival/libunarchive/Makefile.in Sun May 23 09:16:42 2004
22@@ -65,6 +65,7 @@
23 LIBUNARCHIVE-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
24 LIBUNARCHIVE-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
25 LIBUNARCHIVE-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
26+LIBUNARCHIVE-$(CONFIG_FEATURE_RPM2CPIO_BZIP2) += decompress_bunzip2.o
27 LIBUNARCHIVE-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
28 LIBUNARCHIVE-$(CONFIG_TAR) += get_header_tar.o
29 LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
30diff -ur busybox/archival/rpm2cpio.c busybox/archival/rpm2cpio.c
31--- busybox/archival/rpm2cpio.c Sun May 23 09:15:04 2004
32+++ busybox/archival/rpm2cpio.c Sun May 23 09:19:03 2004
33@@ -91,14 +91,26 @@
34 skip_header(rpm_fd);
35
36 bb_xread_all(rpm_fd, &magic, 2);
37- if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
38- bb_error_msg_and_die("Invalid gzip magic");
39+ if ((magic[0] == 0x1f) || (magic[1] == 0x8b)) {
40+ check_header_gzip(rpm_fd);
41+ if (inflate_gunzip(rpm_fd, fileno(stdout)) != 0)
42+ bb_error_msg("Error inflating (gzip)");
43 }
44
45- check_header_gzip(rpm_fd);
46- if (inflate_gunzip(rpm_fd, STDOUT_FILENO) != 0) {
47- bb_error_msg("Error inflating");
48+ if ((magic[0] == 'B') && (magic[1] == 'Z')) {
49+#ifdef CONFIG_FEATURE_RPM2CPIO_BZIP2
50+ /* return to position before magic (eek..!) */
51+ lseek(rpm_fd, -2, SEEK_CUR);
52+ if(uncompressStream(rpm_fd, fileno(stdout)) != 0)
53+ bb_error_msg("Error inflating (bzip2)");
54+#else
55+ bb_error_msg_and_die("bzip2 not supported");
56+#endif
57 }
58+
59+ else
60+ bb_error_msg_and_die("not gzip or bzip2 compressed");
61+
62
63 close(rpm_fd);
diff --git a/busybox/patches/tftp_timeout_multicast.diff b/busybox/patches/tftp_timeout_multicast.diff
deleted file mode 100644
index ca431fc60..000000000
--- a/busybox/patches/tftp_timeout_multicast.diff
+++ /dev/null
@@ -1,1053 +0,0 @@
1Index: AUTHORS
2===================================================================
3RCS file: /var/cvs/busybox/AUTHORS,v
4retrieving revision 1.40
5diff -u -r1.40 AUTHORS
6--- a/AUTHORS 9 Oct 2003 21:19:21 -0000 1.40
7+++ b/AUTHORS 5 Mar 2004 15:45:47 -0000
8@@ -92,6 +92,9 @@
9 Original author of BusyBox in 1995, 1996. Some of his code can
10 still be found hiding here and there...
11
12+John Powers <jpp@ti.com>
13+ Added multicast option (rfc2090) and timeout option (rfc2349) to tftp.
14+
15 Tim Riker <Tim@Rikers.org>
16 bug fixes, member of fan club
17
18Index: include/usage.h
19===================================================================
20RCS file: /var/cvs/busybox/include/usage.h,v
21retrieving revision 1.191
22diff -u -r1.191 usage.h
23--- a/include/usage.h 25 Feb 2004 10:35:55 -0000 1.191
24+++ b/include/usage.h 5 Mar 2004 15:45:59 -0000
25@@ -2492,6 +2492,21 @@
26 #else
27 #define USAGE_TFTP_BS(a)
28 #endif
29+#ifdef CONFIG_FEATURE_TFTP_TIMEOUT
30+ #define USAGE_TFTP_TIMEOUT(a) a
31+#else
32+ #define USAGE_TFTP_TIMEOUT(a)
33+#endif
34+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
35+ #define USAGE_TFTP_MULTICAST(a) a
36+#else
37+ #define USAGE_TFTP_MULTICAST(a)
38+#endif
39+#ifdef CONFIG_FEATURE_TFTP_DEBUG
40+ #define USAGE_TFTP_DEBUG(a) a
41+#else
42+ #define USAGE_TFTP_DEBUG(a)
43+#endif
44
45 #define tftp_trivial_usage \
46 "[OPTION]... HOST [PORT]"
47@@ -2508,6 +2523,16 @@
48 ) \
49 USAGE_TFTP_BS( \
50 "\t-b SIZE\tTransfer blocks of SIZE octets.\n" \
51+ ) \
52+ USAGE_TFTP_TIMEOUT( \
53+ "\t-T SEC\tClient timeout SEC seconds (default: 5).\n" \
54+ "\t-t SEC\tServer timeout SEC seconds\n" \
55+ ) \
56+ USAGE_TFTP_MULTICAST( \
57+ "\t-m\tMulticast get file.\n" \
58+ ) \
59+ USAGE_TFTP_DEBUG( \
60+ "\t-D\tPrint debug messages.\n" \
61 )
62 #define time_trivial_usage \
63 "[OPTION]... COMMAND [ARGS...]"
64Index: networking/Config.in
65===================================================================
66RCS file: /var/cvs/busybox/networking/Config.in,v
67retrieving revision 1.27
68diff -u -r1.27 Config.in
69--- a/networking/Config.in 22 Feb 2004 12:25:47 -0000 1.27
70+++ b/networking/Config.in 5 Mar 2004 15:45:59 -0000
71@@ -522,6 +522,13 @@
72 Add support for the GET command within the TFTP client. This allows
73 a client to retrieve a file from a TFTP server.
74
75+config CONFIG_FEATURE_TFTP_MULTICAST
76+ bool " Enable \"multicast\" option"
77+ default n
78+ depends on CONFIG_FEATURE_TFTP_GET
79+ help
80+ Allow the client to receive multicast file transfers.
81+
82 config CONFIG_FEATURE_TFTP_PUT
83 bool " Enable \"put\" command"
84 default y
85@@ -531,12 +538,19 @@
86 a client to transfer a file to a TFTP server.
87
88 config CONFIG_FEATURE_TFTP_BLOCKSIZE
89- bool " Enable \"blocksize\" command"
90+ bool " Enable \"blksize\" option"
91 default n
92 depends on CONFIG_TFTP
93 help
94 Allow the client to specify the desired block size for transfers.
95
96+config CONFIG_FEATURE_TFTP_TIMEOUT
97+ bool " Enable \"timeout\" option"
98+ default n
99+ depends on CONFIG_TFTP
100+ help
101+ Allow the client to negotiate timeout option with server.
102+
103 config CONFIG_FEATURE_TFTP_DEBUG
104 bool " Enable debug"
105 default n
106Index: networking/tftp.c
107===================================================================
108RCS file: /var/cvs/busybox/networking/tftp.c,v
109retrieving revision 1.25
110diff -u -r1.25 tftp.c
111--- a/networking/tftp.c 5 Mar 2004 13:04:39 -0000 1.25
112+++ b/networking/tftp.c 5 Mar 2004 15:46:00 -0000
113@@ -1,11 +1,26 @@
114+/* vi: set sw=4 ts=4: */
115 /* ------------------------------------------------------------------------- */
116 /* tftp.c */
117+/* Copyright (c) 2003, 2004 Texas Instruments */
118+/* */
119+/* This package is free software; you can redistribute it and/or */
120+/* modify it under the terms of the license found in the file */
121+/* named COPYING that should have accompanied this file. */
122+/* */
123+/* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
124+/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
125+/* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
126 /* */
127 /* A simple tftp client for busybox. */
128 /* Tries to follow RFC1350. */
129 /* Only "octet" mode supported. */
130 /* Optional blocksize negotiation (RFC2347 + RFC2348) */
131 /* */
132+/* New features added at Texas Instruments, October 2003 */
133+/* Author: John Powers */
134+/* Multicast option: rfc2090 */
135+/* Timeout option: rfc2349 */
136+/* */
137 /* Copyright (C) 2001 Magnus Damm <damm@opensource.se> */
138 /* */
139 /* Parts of the code based on: */
140@@ -46,8 +61,20 @@
141
142 #include "busybox.h"
143
144+#if defined(CONFIG_FEATURE_TFTP_BLOCKSIZE) || defined(CONFIG_FEATURE_TFTP_MULTICAST) || defined(CONFIG_FEATURE_TFTP_TIMEOUT)
145+ #define TFTP_OPTIONS
146+#endif
147+
148 //#define CONFIG_FEATURE_TFTP_DEBUG
149
150+#ifdef CONFIG_FEATURE_TFTP_DEBUG
151+ static void printtime(void);
152+ #define dprintf(fmt...) if (debug) {printtime(); printf(fmt);}
153+ int debug = 0;
154+#else
155+ #define dprintf(fmt...)
156+#endif
157+
158 #define TFTP_BLOCKSIZE_DEFAULT 512 /* according to RFC 1350, don't change */
159 #define TFTP_TIMEOUT 5 /* seconds */
160
161@@ -68,12 +95,24 @@
162 "Illegal TFTP operation",
163 "Unknown transfer ID",
164 "File already exists",
165- "No such user"
166+ "No such user",
167+#ifdef TFTP_OPTIONS
168+ "Unsupported option",
169+#endif
170 };
171
172 const int tftp_cmd_get = 1;
173 const int tftp_cmd_put = 2;
174
175+
176+struct tftp_option {
177+ int multicast;
178+ int blksize;
179+ int client_timeout;
180+ int server_timeout;
181+};
182+
183+
184 #ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
185
186 static int tftp_blocksize_check(int blocksize, int bufsize)
187@@ -93,16 +132,158 @@
188 return blocksize;
189 }
190
191+#endif
192+
193+#ifdef CONFIG_FEATURE_TFTP_TIMEOUT
194+
195+static int
196+tftp_timeout_check(int timeout)
197+{
198+ /* Check if timeout seconds is valid:
199+ * RFC2349 says between 1 and 255.
200+ */
201+
202+ if (timeout < 1 || timeout > 255) {
203+ bb_error_msg("bad timeout value");
204+ return 0;
205+ }
206+ return timeout;
207+}
208+
209+#endif
210+
211+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
212+static int
213+tftp_multicast_check(const char *opt, char **phost, unsigned short *pport, int *pactive)
214+{
215+ /* Option string contains comma delimited addr,port,active.
216+ * addr = multicast IP address
217+ * port = port number
218+ * active = 1 if active client
219+ * 0 if passive client
220+ *
221+ * Addr and port will be empty fields when the server notifies a
222+ * passive client that it is now the active client.
223+ *
224+ * The host address string must be freed by the caller. Neither host
225+ * nor port will be set/changed if the input fields are empty.
226+ *
227+ * If any tokenization errors occur in the opt string, the host
228+ * address string is automatically freed.
229+ *
230+ * Return 0 if any tokenization error, 1 if all parameters are good.
231+ */
232+
233+ char *token = NULL;
234+ char *parse_buf = NULL;
235+ char *tokenv = NULL;
236+ char *host = NULL;
237+ int port;
238+ int active;
239+
240+ parse_buf = bb_xstrdup(opt);
241+
242+ dprintf("multicast option=%s\n", opt);
243+
244+ /* IP address */
245+ if ((token = strtok_r(parse_buf, ",", &tokenv)) == NULL) {
246+ dprintf("tftp_multicast_check: cannot parse IP address from %s\n", parse_buf);
247+ free(parse_buf);
248+ return 0;
249+ }
250+ if (strlen(token) > 0)
251+ *phost = host = bb_xstrdup(token);
252+
253+ /* Port */
254+ if ((token = strtok_r(NULL, ",", &tokenv)) == NULL) {
255+ dprintf("tftp_multicast_check: cannot parse port number from %s\n", tokenv);
256+ goto token_error;
257+ }
258+ if (strlen(token) > 0) {
259+ port = atoi(token);
260+ if (port < 0 || port > 0xFFFF) {
261+ dprintf("tftp_multicast_check: bad port number (%d)\n", port);
262+ goto token_error;
263+ }
264+ *pport = htons(port);
265+ }
266+
267+ /* Active/passive */
268+ if ((token = strtok_r(NULL, ",", &tokenv)) == NULL) {
269+ dprintf("tftp_multicast_check: cannot parse active/passive from %s\n", tokenv);
270+ goto token_error;
271+ }
272+ active = atoi(token);
273+ if (active != 0 && active != 1) {
274+ dprintf("tftp_multicast_check: bad active/passive flag (%d)\n", active);
275+ goto token_error;
276+ }
277+ *pactive = active;
278+
279+ free(parse_buf);
280+ return 1;
281+
282+token_error:
283+ free(parse_buf);
284+ if (host != NULL)
285+ free(host);
286+ *phost = NULL;
287+ return 0;
288+
289+}
290+
291+#define VECTOR_QUANTUM_WIDTH 8
292+#define VECTOR_QUANTUM_ALL_ONES ((1<<VECTOR_QUANTUM_WIDTH)-1)
293+
294+static void inline
295+bit_set(int bit, unsigned char *vector)
296+{
297+ int offset = bit / VECTOR_QUANTUM_WIDTH;
298+ int mask = 1 << (bit % VECTOR_QUANTUM_WIDTH);
299+ vector[offset] |= mask;
300+}
301+
302+static int inline
303+bit_isset(int bit, const unsigned char *vector)
304+{
305+ int offset = bit / VECTOR_QUANTUM_WIDTH;
306+ int mask = 1 << (bit % VECTOR_QUANTUM_WIDTH);
307+ return vector[offset] & mask ? 1 : 0;
308+}
309+
310+static int inline
311+bit_lmz(const unsigned char *vector)
312+{
313+ /* Return number of left-most zero in bit vector */
314+ const unsigned char *vp = vector;
315+ int i;
316+ unsigned char velem;
317+
318+ while (*vp == VECTOR_QUANTUM_ALL_ONES)
319+ vp++;
320+ velem = *vp;
321+ for (i = 0; i < VECTOR_QUANTUM_WIDTH; i++) {
322+ if ((velem & (1 << i)) == 0)
323+ break;
324+ }
325+ dprintf("bit_lmz: block=%d\n", (vp - vector)*VECTOR_QUANTUM_WIDTH + i);
326+ return (vp - vector)*VECTOR_QUANTUM_WIDTH + i;
327+}
328+
329+#endif
330+
331+
332+
333+#ifdef TFTP_OPTIONS
334+
335 static char *tftp_option_get(char *buf, int len, char *option)
336 {
337- int opt_val = 0;
338+ int opt_val = 0;
339 int opt_found = 0;
340 int k;
341-
342- while (len > 0) {
343
344+ while (len > 0) {
345 /* Make sure the options are terminated correctly */
346-
347 for (k = 0; k < len; k++) {
348 if (buf[k] == '\0') {
349 break;
350@@ -117,9 +298,8 @@
351 if (strcasecmp(buf, option) == 0) {
352 opt_found = 1;
353 }
354- }
355- else {
356- if (opt_found) {
357+ } else {
358+ if (opt_found) {
359 return buf;
360 }
361 }
362@@ -138,7 +318,8 @@
363 #endif
364
365 static inline int tftp(const int cmd, const struct hostent *host,
366- const char *remotefile, int localfd, const unsigned short port, int tftp_bufsize)
367+ const char *remotefile, int localfd, const unsigned short port,
368+ struct tftp_option *option)
369 {
370 const int cmd_get = cmd & tftp_cmd_get;
371 const int cmd_put = cmd & tftp_cmd_put;
372@@ -155,18 +336,29 @@
373 int len;
374 int opcode = 0;
375 int finished = 0;
376- int timeout = bb_tftp_num_retries;
377+ int retry = bb_tftp_num_retries;
378 unsigned short block_nr = 1;
379
380-#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
381- int want_option_ack = 0;
382+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
383+ struct hostent *mchost;
384+ struct sockaddr_in mcsa;
385+ char *mchostname;
386+ unsigned short mcport;
387+ unsigned char *mcblockmap = NULL;
388+ int master_client = 1;
389+ int mcfd = -1;
390+ int mcmaxblock = 0x10000;
391+ int ack_oack = 0;
392+#else
393+ #define master_client 1
394+ #define ack_oack 0
395 #endif
396
397 /* Can't use RESERVE_CONFIG_BUFFER here since the allocation
398 * size varies meaning BUFFERS_GO_ON_STACK would fail */
399- char *buf=xmalloc(tftp_bufsize + 4);
400+ char *buf=xmalloc(option->blksize + 4);
401
402- tftp_bufsize += 4;
403+ int tftp_bufsize = option->blksize + 4;
404
405 if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
406 bb_perror_msg("socket");
407@@ -183,15 +375,21 @@
408 memcpy(&sa.sin_addr, (struct in_addr *) host->h_addr,
409 sizeof(sa.sin_addr));
410
411- /* build opcode */
412-
413- if (cmd_get) {
414- opcode = TFTP_RRQ;
415+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
416+ if (option->multicast) {
417+ const int bmsize = 0x10000 / VECTOR_QUANTUM_WIDTH;
418+ if ((mcfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
419+ bb_perror_msg("multicast socket");
420+ return EXIT_FAILURE;
421+ }
422+ mcblockmap = xmalloc(bmsize+1);
423+ memset(mcblockmap, 0, bmsize+1);
424 }
425+#endif
426
427- if (cmd_put) {
428- opcode = TFTP_WRQ;
429- }
430+ /* build opcode */
431+
432+ opcode = cmd_get ? TFTP_RRQ : TFTP_WRQ;
433
434 while (1) {
435
436@@ -203,7 +401,7 @@
437
438 cp += 2;
439
440- /* add filename and mode */
441+ /* First packet of file transfer includes file name, mode, and options */
442
443 if ((cmd_get && (opcode == TFTP_RRQ)) ||
444 (cmd_put && (opcode == TFTP_WRQ))) {
445@@ -223,7 +421,7 @@
446 }
447
448 if (too_long || ((&buf[tftp_bufsize - 1] - cp) < 6)) {
449- bb_error_msg("too long remote-filename");
450+ bb_error_msg("too long: remote filename");
451 break;
452 }
453
454@@ -238,8 +436,8 @@
455
456 if (len != TFTP_BLOCKSIZE_DEFAULT) {
457
458- if ((&buf[tftp_bufsize - 1] - cp) < 15) {
459- bb_error_msg("too long remote-filename");
460+ if ((&buf[tftp_bufsize - 1] - cp) < 15) {
461+ bb_error_msg("buffer too small for blksize option");
462 break;
463 }
464
465@@ -249,16 +447,65 @@
466 cp += 8;
467
468 cp += snprintf(cp, 6, "%d", len) + 1;
469+ }
470+#endif
471+
472+
473+
474+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
475+
476+ if (option->multicast) {
477+ if ((&buf[tftp_bufsize - 1] - cp) < 12) {
478+ bb_error_msg("buffer too small for multicast option");
479+ break;
480+ }
481+
482+ /* add "multicast" option */
483
484- want_option_ack = 1;
485+ memcpy(cp, "multicast\0", 11);
486+ cp += 11;
487+
488+ option->multicast = 0; /* turn back on when server accepts option */
489+ ack_oack = 1; /* acknowledge OACK */
490 }
491+
492 #endif
493+
494+#ifdef CONFIG_FEATURE_TFTP_TIMEOUT
495+
496+ if (option->server_timeout != TFTP_TIMEOUT) {
497+ if ((&buf[tftp_bufsize - 1] - cp) < 12) {
498+ bb_error_msg("buffer too small for timeout option");
499+ break;
500+ }
501+
502+ /* add "timeout" option */
503+
504+ memcpy(cp, "timeout", 8);
505+ cp += 8;
506+
507+ cp += snprintf(cp, 4, "%d", option->server_timeout) + 1;
508+ }
509+#endif
510+
511 }
512
513 /* add ack and data */
514
515- if ((cmd_get && (opcode == TFTP_ACK)) ||
516- (cmd_put && (opcode == TFTP_DATA))) {
517+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
518+ else if (option->multicast && opcode == TFTP_ACK) {
519+ if (master_client || ack_oack) {
520+ int blocknum = bit_lmz(mcblockmap);
521+ *((unsigned short *) cp) = htons(blocknum);
522+ cp += 2;
523+ if (blocknum >= mcmaxblock)
524+ finished = 1;
525+ dprintf("ack block %d/%d %s\n", blocknum, mcmaxblock, finished? "finished": "");
526+ }
527+ }
528+#endif
529+ else if ((cmd_get && opcode == TFTP_ACK) ||
530+ (cmd_put && opcode == TFTP_DATA)) {
531
532 *((unsigned short *) cp) = htons(block_nr);
533
534@@ -275,7 +522,7 @@
535 }
536
537 if (len != (tftp_bufsize - 4)) {
538- finished++;
539+ finished = 1;
540 }
541
542 cp += len;
543@@ -283,82 +530,119 @@
544 }
545
546
547- /* send packet */
548+ /* send packet and receive reply */
549
550
551- timeout = bb_tftp_num_retries; /* re-initialize */
552+ retry = bb_tftp_num_retries; /* re-initialize */
553 do {
554-
555+ int selectrc;
556 len = cp - buf;
557
558-#ifdef CONFIG_FEATURE_TFTP_DEBUG
559- fprintf(stderr, "sending %u bytes\n", len);
560- for (cp = buf; cp < &buf[len]; cp++)
561- fprintf(stderr, "%02x ", (unsigned char)*cp);
562- fprintf(stderr, "\n");
563-#endif
564- if (sendto(socketfd, buf, len, 0,
565- (struct sockaddr *) &sa, sizeof(sa)) < 0) {
566- bb_perror_msg("send");
567- len = -1;
568- break;
569- }
570-
571+ /* send packet */
572+ if ((len > 2) && (! option->multicast || master_client || ack_oack)) {
573
574- if (finished && (opcode == TFTP_ACK)) {
575- break;
576+#ifdef CONFIG_FEATURE_TFTP_DEBUG
577+ dprintf("sending %u bytes\n", len);
578+ for (cp = buf; cp < &buf[len]; cp++)
579+ if (debug)
580+ printf("%02x ", *(unsigned char *)cp);
581+ if (debug)
582+ printf("\n");
583+#endif
584+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
585+ ack_oack = 0;
586+#endif
587+ if (sendto(socketfd, buf, len, 0, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
588+ bb_perror_msg("send");
589+ len = -1;
590+ break;
591+ }
592+ if (finished && opcode == TFTP_ACK) {
593+ break;
594+ }
595 }
596
597- /* receive packet */
598+ /* receive reply packet */
599
600 memset(&from, 0, sizeof(from));
601 fromlen = sizeof(from);
602
603- tv.tv_sec = TFTP_TIMEOUT;
604+ tv.tv_sec = option->client_timeout;
605 tv.tv_usec = 0;
606
607 FD_ZERO(&rfds);
608 FD_SET(socketfd, &rfds);
609+ dprintf("set to receive from socketfd (%d)\n", socketfd);
610+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
611+ if (option->multicast) {
612+ FD_SET(mcfd, &rfds);
613+ dprintf("set to receive from mcfd (%d)\n", mcfd);
614+ }
615+#endif
616
617- switch (select(FD_SETSIZE, &rfds, NULL, NULL, &tv)) {
618- case 1:
619- len = recvfrom(socketfd, buf, tftp_bufsize, 0,
620- (struct sockaddr *) &from, &fromlen);
621-
622- if (len < 0) {
623- bb_perror_msg("recvfrom");
624- break;
625+ dprintf("select\n");
626+ selectrc = select(FD_SETSIZE, &rfds, NULL, NULL, &tv);
627+ if (selectrc > 0) {
628+ /* A packet was received */
629+ if (FD_ISSET(socketfd, &rfds)) { /* Unicast packet */
630+ dprintf("from socketfd\n");
631+ len = recvfrom(socketfd, buf, tftp_bufsize, 0, (struct sockaddr *) &from, &fromlen);
632+
633+ if (len < 0) {
634+ bb_perror_msg("recvfrom");
635+ } else {
636+ if (sa.sin_port == port) {
637+ sa.sin_port = from.sin_port;
638+ }
639+ if (sa.sin_port == from.sin_port) {
640+ retry = 0;
641+ } else {
642+ /* bad packet */
643+ /* discard the packet - treat as timeout */
644+ retry = bb_tftp_num_retries;
645+ bb_error_msg("timeout");
646+ }
647+ }
648 }
649
650- timeout = 0;
651-
652- if (sa.sin_port == port) {
653- sa.sin_port = from.sin_port;
654+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
655+ else if (option->multicast && FD_ISSET(mcfd, &rfds)) { /* Multicast packet */
656+ dprintf("from mcfd\n");
657+ len = recvfrom(mcfd, buf, tftp_bufsize, 0, (struct sockaddr *) &from, &fromlen);
658+ if (len < 0) {
659+ bb_perror_msg("multicast recvfrom");
660+ } else {
661+ if (mcsa.sin_port == mcport) {
662+ mcsa.sin_port = from.sin_port;
663+ }
664+ if (mcsa.sin_port == from.sin_port) {
665+ retry = 0;
666+ } else {
667+ retry = bb_tftp_num_retries;
668+ bb_error_msg("multicast timeout");
669+ }
670+ }
671 }
672- if (sa.sin_port == from.sin_port) {
673- break;
674- }
675-
676- /* fall-through for bad packets! */
677- /* discard the packet - treat as timeout */
678- timeout = bb_tftp_num_retries;
679+#endif
680
681- case 0:
682+ } else if (selectrc == 0) {
683+ /* Time out */
684+ dprintf("timeout\n");
685 bb_error_msg("timeout");
686
687- timeout--;
688- if (timeout == 0) {
689+ retry--;
690+ if (retry == 0) {
691 len = -1;
692 bb_error_msg("last timeout");
693 }
694- break;
695-
696- default:
697+ } else {
698+ /* Error condition */
699+ dprintf("error\n");
700 bb_perror_msg("select");
701 len = -1;
702 }
703
704- } while (timeout && (len >= 0));
705+ } while (retry && len >= 0);
706
707 if ((finished) || (len < 0)) {
708 break;
709@@ -370,9 +654,8 @@
710 opcode = ntohs(*((unsigned short *) buf));
711 tmp = ntohs(*((unsigned short *) &buf[2]));
712
713-#ifdef CONFIG_FEATURE_TFTP_DEBUG
714- fprintf(stderr, "received %d bytes: %04x %04x\n", len, opcode, tmp);
715-#endif
716+ dprintf("received %d bytes: %04x %04x\n", len, opcode, tmp);
717+ dprintf("master_client=%d\n", master_client);
718
719 if (opcode == TFTP_ERROR) {
720 char *msg = NULL;
721@@ -393,55 +676,116 @@
722 break;
723 }
724
725-#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
726- if (want_option_ack) {
727+#ifdef TFTP_OPTIONS
728
729- want_option_ack = 0;
730+ if (opcode == TFTP_OACK) {
731
732- if (opcode == TFTP_OACK) {
733+ /* server seems to support options */
734
735- /* server seems to support options */
736+ char *res;
737+
738+ block_nr = 0; /* acknowledge option packet with block number 0 */
739+ opcode = cmd_put ? TFTP_DATA : TFTP_ACK;
740
741- char *res;
742
743- res = tftp_option_get(&buf[2], len-2,
744- "blksize");
745+#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
746+ res = tftp_option_get(&buf[2], len-2, "blksize");
747
748- if (res) {
749- int blksize = atoi(res);
750-
751- if (tftp_blocksize_check(blksize,
752- tftp_bufsize - 4)) {
753+ if (res) {
754+ int blksize = atoi(res);
755
756- if (cmd_put) {
757- opcode = TFTP_DATA;
758- }
759- else {
760- opcode = TFTP_ACK;
761- }
762-#ifdef CONFIG_FEATURE_TFTP_DEBUG
763- fprintf(stderr, "using blksize %u\n", blksize);
764+ if (tftp_blocksize_check(blksize, tftp_bufsize - 4)) {
765+ dprintf("using blksize %d\n", blksize);
766+ tftp_bufsize = blksize + 4;
767+ free(buf);
768+ buf = xmalloc(tftp_bufsize);
769+ } else {
770+ bb_error_msg("bad blksize %d", blksize);
771+ break;
772+ }
773+ }
774 #endif
775- tftp_bufsize = blksize + 4;
776- block_nr = 0;
777- continue;
778- }
779- }
780- /* FIXME:
781- * we should send ERROR 8 */
782- bb_error_msg("bad server option");
783- break;
784- }
785
786- bb_error_msg("warning: blksize not supported by server"
787- " - reverting to 512");
788
789- tftp_bufsize = TFTP_BLOCKSIZE_DEFAULT + 4;
790+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
791+ res = tftp_option_get(&buf[2], len-2, "multicast");
792+
793+ if (res) {
794+ ack_oack = 1;
795+ if (tftp_multicast_check(res, &mchostname, &mcport, &master_client)) {
796+ struct ip_mreq mreq;
797+ struct in_addr mcaddr;
798+
799+ dprintf("using multicast\n");
800+
801+ mchost = xgethostbyname(mchostname);
802+ if (mchost) {
803+ memcpy(&mcaddr, mchost->h_addr, mchost->h_length);
804+ if (! IN_MULTICAST(ntohl(mcaddr.s_addr))) {
805+ bb_error_msg("bad multicast address: %s", mchostname);
806+ break;
807+ }
808+ } else {
809+ bb_error_msg("bad multicast address: %s", mchostname);
810+ break;
811+ }
812+
813+ memset(&mcsa, 0, sizeof(mcsa));
814+ mcsa.sin_family = AF_INET;
815+ mcsa.sin_addr.s_addr = htonl(INADDR_ANY);
816+ mcsa.sin_port = mcport;
817+
818+ bind(mcfd, (struct sockaddr *)&mcsa, sizeof(mcsa));
819+
820+ mreq.imr_multiaddr.s_addr = mcaddr.s_addr;
821+ mreq.imr_interface.s_addr = htonl(INADDR_ANY);
822+
823+ if (setsockopt(mcfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0)
824+ {
825+ bb_error_msg("setsockopt");
826+ break;
827+ }
828+
829+ option->multicast = 1;
830+ } else {
831+ bb_error_msg("bad multicast option value: %s", res);
832+ break;
833+ }
834+ }
835+#endif
836+
837 }
838+ else
839 #endif
840
841 if (cmd_get && (opcode == TFTP_DATA)) {
842
843+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
844+ if (option->multicast) {
845+ int bn = tmp - 1;
846+ /* Do I need this block? */
847+ if (! bit_isset(bn, mcblockmap)) {
848+ lseek(localfd, bn*(tftp_bufsize-4), SEEK_SET);
849+ len = write(localfd, &buf[4], len-4);
850+ if (len < 0) {
851+ bb_perror_msg("write");
852+ break;
853+ }
854+ bit_set(bn, mcblockmap);
855+ if (len != (tftp_bufsize-4)) {
856+ mcmaxblock = tmp;
857+ dprintf("mcmaxblock=%d, (len(%d) != tftp_bufsize-4(%d))\n", mcmaxblock, len, tftp_bufsize-4);
858+ }
859+ opcode = TFTP_ACK;
860+ }
861+ /* Do not acknowledge block if I already have a copy of the block. A situation can arise when the server
862+ * and client timeout nearly simultaneously. The server retransmits the block at the same time the client
863+ * re-requests the block. From then on out, each block is transmitted twice--not a good use of bandwidth.
864+ */
865+ }
866+ else
867+#endif
868+
869 if (tmp == block_nr) {
870
871 len = write(localfd, &buf[4], len - 4);
872@@ -452,15 +796,14 @@
873 }
874
875 if (len != (tftp_bufsize - 4)) {
876- finished++;
877+ finished = 1;
878 }
879
880 opcode = TFTP_ACK;
881- continue;
882 }
883 }
884
885- if (cmd_put && (opcode == TFTP_ACK)) {
886+ else if (cmd_put && opcode == TFTP_ACK) {
887
888 if (tmp == (unsigned short)(block_nr - 1)) {
889 if (finished) {
890@@ -468,15 +811,19 @@
891 }
892
893 opcode = TFTP_DATA;
894- continue;
895 }
896 }
897 }
898
899 #ifdef CONFIG_FEATURE_CLEAN_UP
900 close(socketfd);
901+ free(buf);
902+
903+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
904+ if (mcblockmap != NULL)
905+ free(mcblockmap);
906+#endif
907
908- free(buf);
909 #endif
910
911 return finished ? EXIT_SUCCESS : EXIT_FAILURE;
912@@ -487,13 +834,18 @@
913 struct hostent *host = NULL;
914 char *localfile = NULL;
915 char *remotefile = NULL;
916- int port;
917+ unsigned short port;
918 int cmd = 0;
919 int fd = -1;
920 int flags = 0;
921 int opt;
922 int result;
923- int blocksize = TFTP_BLOCKSIZE_DEFAULT;
924+ struct tftp_option option = {
925+ .multicast = 0,
926+ .blksize = TFTP_BLOCKSIZE_DEFAULT,
927+ .client_timeout = TFTP_TIMEOUT,
928+ .server_timeout = TFTP_TIMEOUT,
929+ };
930
931 /* figure out what to pass to getopt */
932
933@@ -515,13 +867,45 @@
934 #define PUT
935 #endif
936
937- while ((opt = getopt(argc, argv, BS GET PUT "l:r:")) != -1) {
938+#ifdef CONFIG_FEATURE_TFTP_TIMEOUT
939+#define TO "T:t:"
940+#else
941+#define TO
942+#endif
943+
944+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
945+#define MC "m"
946+#else
947+#define MC
948+#endif
949+
950+#ifdef CONFIG_FEATURE_TFTP_DEBUG
951+#define DB "D"
952+#else
953+#define DB
954+#endif
955+
956+ while ((opt = getopt(argc, argv, BS GET PUT TO MC DB "l:r:")) != -1) {
957 switch (opt) {
958 #ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
959 case 'b':
960- blocksize = atoi(optarg);
961- if (!tftp_blocksize_check(blocksize, 0)) {
962- return EXIT_FAILURE;
963+ option.blksize = atoi(optarg);
964+ if (!tftp_blocksize_check(option.blksize, 0)) {
965+ return EXIT_FAILURE;
966+ }
967+ break;
968+#endif
969+#ifdef CONFIG_FEATURE_TFTP_TIMEOUT
970+ case 'T':
971+ option.client_timeout = atoi(optarg);
972+ if (!tftp_timeout_check(option.client_timeout)) {
973+ return EXIT_FAILURE;
974+ }
975+ break;
976+ case 't':
977+ option.server_timeout = atoi(optarg);
978+ if (!tftp_timeout_check(option.server_timeout)) {
979+ return EXIT_FAILURE;
980 }
981 break;
982 #endif
983@@ -537,18 +921,34 @@
984 flags = O_RDONLY;
985 break;
986 #endif
987+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
988+ case 'm':
989+ option.multicast = 1; /* receive multicast file */
990+ break;
991+#endif
992+#ifdef CONFIG_FEATURE_TFTP_DEBUG
993+ case 'D':
994+ debug = 1;
995+ break;
996+#endif
997 case 'l':
998 localfile = bb_xstrdup(optarg);
999 break;
1000 case 'r':
1001 remotefile = bb_xstrdup(optarg);
1002 break;
1003+ default:
1004+ bb_show_usage();
1005 }
1006 }
1007
1008 if ((cmd == 0) || (optind == argc)) {
1009 bb_show_usage();
1010 }
1011+ if (cmd == tftp_cmd_put && option.multicast) {
1012+ fprintf(stderr, "Multicast (-m) invalid option with put (-p) command\n");
1013+ exit(EXIT_FAILURE);
1014+ }
1015 if(localfile && strcmp(localfile, "-") == 0) {
1016 fd = fileno((cmd==tftp_cmd_get)? stdout : stdin);
1017 }
1018@@ -566,14 +966,12 @@
1019 host = xgethostbyname(argv[optind]);
1020 port = bb_lookup_port(argv[optind + 1], "udp", 69);
1021
1022-#ifdef CONFIG_FEATURE_TFTP_DEBUG
1023- fprintf(stderr, "using server \"%s\", remotefile \"%s\", "
1024+ dprintf("using server \"%s\", remotefile \"%s\", "
1025 "localfile \"%s\".\n",
1026 inet_ntoa(*((struct in_addr *) host->h_addr)),
1027 remotefile, localfile);
1028-#endif
1029
1030- result = tftp(cmd, host, remotefile, fd, port, blocksize);
1031+ result = tftp(cmd, host, remotefile, fd, port, &option);
1032
1033 #ifdef CONFIG_FEATURE_CLEAN_UP
1034 if (!(fd == STDOUT_FILENO || fd == STDIN_FILENO)) {
1035@@ -582,3 +980,18 @@
1036 #endif
1037 return(result);
1038 }
1039+
1040+
1041+#ifdef CONFIG_FEATURE_TFTP_DEBUG
1042+
1043+#include <sys/time.h>
1044+
1045+static void
1046+printtime(void)
1047+{
1048+ struct timeval tv;
1049+ gettimeofday(&tv, NULL);
1050+ printf("%11lu.%06lu ", tv.tv_sec, tv.tv_usec);
1051+}
1052+
1053+#endif
diff --git a/busybox/patches/top_system_cpu.diff b/busybox/patches/top_system_cpu.diff
deleted file mode 100644
index 5d213e76a..000000000
--- a/busybox/patches/top_system_cpu.diff
+++ /dev/null
@@ -1,51 +0,0 @@
1diff -purN busybox.ori/include/libbb.h busybox/include/libbb.h
2--- busybox.ori/include/libbb.h 2004-03-21 14:39:35.000000000 +0100
3+++ busybox-1.0/include/libbb.h 2004-03-21 14:45:35.000000000 +0100
4@@ -447,6 +447,7 @@ typedef struct {
5 int ppid;
6 #ifdef FEATURE_CPU_USAGE_PERCENTAGE
7 unsigned pcpu;
8+ unsigned pscpu;
9 unsigned long stime, utime;
10 #endif
11 char *cmd;
12diff -purN busybox.ori/procps/top.c busybox/procps/top.c
13--- busybox.ori/procps/top.c 2004-03-21 14:40:09.000000000 +0100
14+++ busybox-1.0/procps/top.c 2004-03-21 17:27:52.961951448 +0100
15@@ -289,6 +289,15 @@ static void do_stats(void)
16 i = 999;
17 cur->pcpu = i;
18
19+ /*
20+ * Calculate percent of system time from cpu time
21+ */
22+ if (systime != 0) {
23+ cur->pscpu = 100 * total_time / systime;
24+ } else {
25+ cur->pscpu = 0;
26+ }
27+
28 }
29
30 /*
31@@ -393,7 +402,7 @@ static void display_status(int count, in
32
33 #ifdef FEATURE_CPU_USAGE_PERCENTAGE
34 /* what info of the processes is shown */
35- printf("\n\e[7m PID USER STATUS RSS PPID %%CPU %%MEM COMMAND\e[0m\n");
36+ printf("\n\e[7m PID USER STATUS RSS PPID %%CPU %%SCPU %%MEM COMMAND\e[0m\n");
37 #else
38 printf("\n\e[7m PID USER STATUS RSS PPID %%MEM COMMAND\e[0m\n");
39 #endif
40@@ -410,9 +419,9 @@ static void display_status(int count, in
41 else
42 sprintf(rss_str_buf, "%7ld", s->rss);
43 #ifdef FEATURE_CPU_USAGE_PERCENTAGE
44- printf("%5d %-8s %s %s %5d %2d.%d %2u.%u ",
45+ printf("%5d %-8s %s %s %5d %2d.%d %2d.%d %2u.%u ",
46 s->pid, s->user, s->state, rss_str_buf, s->ppid,
47- s->pcpu/10, s->pcpu%10, pmem/10, pmem%10);
48+ s->pcpu/10, s->pcpu%10,s->pscpu/10, s->pscpu%10, pmem/10, pmem%10);
49 #else
50 printf("%5d %-8s %s %s %5d %2u.%u ",
51 s->pid, s->user, s->state, rss_str_buf, s->ppid,
diff --git a/busybox/patches/udhcp_additional_items.diff b/busybox/patches/udhcp_additional_items.diff
deleted file mode 100644
index 933be2ad4..000000000
--- a/busybox/patches/udhcp_additional_items.diff
+++ /dev/null
@@ -1,126 +0,0 @@
1Index: include/usage.h
2===================================================================
3RCS file: /var/cvs/busybox/include/usage.h,v
4retrieving revision 1.191
5diff -u -r1.191 usage.h
6--- a/include/usage.h 25 Feb 2004 10:35:55 -0000 1.191
7+++ b/include/usage.h 5 Mar 2004 14:32:45 -0000
8@@ -2606,6 +2606,7 @@
9 "\t-p,\t--pidfile=file\tStore process ID of daemon in file\n" \
10 "\t-q,\t--quit\tQuit after obtaining lease\n" \
11 "\t-r,\t--request=IP\tIP address to request (default: none)\n" \
12+ "\t-R,\t--require=NAME\tAdd NAME to request\n" \
13 "\t-s,\t--script=file\tRun file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \
14 "\t-v,\t--version\tDisplay version"
15
16Index: networking/udhcp/README.udhcpc
17===================================================================
18RCS file: /var/cvs/busybox/networking/udhcp/README.udhcpc,v
19retrieving revision 1.3
20diff -u -r1.3 README.udhcpc
21--- a/networking/udhcp/README.udhcpc 11 Dec 2002 21:12:44 -0000 1.3
22+++ b/networking/udhcp/README.udhcpc 5 Mar 2004 14:32:46 -0000
23@@ -22,6 +22,7 @@
24 -p, --pidfile=file Store process ID of daemon in file
25 -q, --quit Quit after obtaining lease
26 -r, --request=IP IP address to request (default: none)
27+-R, --require=NAME Add NAME to request
28 -s, --script=file Run file at dhcp events (default:
29 /usr/share/udhcpc/default.script)
30 -v, --version Display version
31@@ -101,6 +102,8 @@
32
33 additional options are easily added in options.c.
34
35+By default, only a few basic items are requested. To request additional
36+items use the -R option. Example: "-R rootpath"
37
38 note on udhcpc's random seed
39 ---------------------------
40Index: networking/udhcp/dhcpc.c
41===================================================================
42RCS file: /var/cvs/busybox/networking/udhcp/dhcpc.c,v
43retrieving revision 1.16
44diff -u -r1.16 dhcpc.c
45--- a/networking/udhcp/dhcpc.c 30 Jan 2004 23:45:12 -0000 1.16
46+++ b/networking/udhcp/dhcpc.c 5 Mar 2004 14:32:46 -0000
47@@ -88,6 +88,7 @@
48 " -p, --pidfile=file Store process ID of daemon in file\n"
49 " -q, --quit Quit after obtaining lease\n"
50 " -r, --request=IP IP address to request (default: none)\n"
51+" -R, --require=NAME Add NAME to the request\n"
52 " -s, --script=file Run file at dhcp events (default:\n"
53 " " DEFAULT_SCRIPT ")\n"
54 " -v, --version Display version\n"
55@@ -203,6 +204,7 @@
56 {"pidfile", required_argument, 0, 'p'},
57 {"quit", no_argument, 0, 'q'},
58 {"request", required_argument, 0, 'r'},
59+ {"require", required_argument, 0, 'R'},
60 {"script", required_argument, 0, 's'},
61 {"version", no_argument, 0, 'v'},
62 {0, 0, 0, 0}
63@@ -211,7 +213,7 @@
64 /* get options */
65 while (1) {
66 int option_index = 0;
67- c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v", arg_options, &option_index);
68+ c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:R:s:v", arg_options, &option_index);
69 if (c == -1) break;
70
71 switch (c) {
72@@ -254,6 +256,11 @@
73 case 'r':
74 requested_ip = inet_addr(optarg);
75 break;
76+ case 'R':
77+ if (require_option(optarg)) {
78+ fprintf(stderr,"WARNING: %s unknown/not-supported (Ignored)\n", optarg );
79+ }
80+ break;
81 case 's':
82 client_config.script = optarg;
83 break;
84Index: networking/udhcp/options.c
85===================================================================
86RCS file: /var/cvs/busybox/networking/udhcp/options.c,v
87retrieving revision 1.7
88diff -u -r1.7 options.c
89--- a/networking/udhcp/options.c 30 Jan 2004 23:45:12 -0000 1.7
90+++ b/networking/udhcp/options.c 5 Mar 2004 14:32:46 -0000
91@@ -57,7 +57,19 @@
92 [OPTION_S32] = 4
93 };
94
95-
96+/* find and mark requested item as required */
97+int require_option(char *name)
98+{
99+ int i;
100+ for (i = 0; dhcp_options[i].code; i++) {
101+ if (strcmp(name, dhcp_options[i].name) == 0 ){
102+ dhcp_options[i].flags |= OPTION_REQ;
103+ return 0;
104+ }
105+ }
106+ return 1;
107+}
108+
109 /* get an option with bounds checking (warning, not aligned). */
110 uint8_t *get_option(struct dhcpMessage *packet, int code)
111 {
112Index: networking/udhcp/options.h
113===================================================================
114RCS file: /var/cvs/busybox/networking/udhcp/options.h,v
115retrieving revision 1.5
116diff -u -r1.5 options.h
117--- a/networking/udhcp/options.h 30 Jan 2004 23:45:12 -0000 1.5
118+++ b/networking/udhcp/options.h 5 Mar 2004 14:32:46 -0000
119@@ -30,6 +30,7 @@
120 extern struct dhcp_option dhcp_options[];
121 extern int option_lengths[];
122
123+int require_option(char *name);
124 uint8_t *get_option(struct dhcpMessage *packet, int code);
125 int end_option(uint8_t *optionptr);
126 int add_option_string(uint8_t *optionptr, uint8_t *string);
diff --git a/busybox/patches/udhcp_config_paths.diff b/busybox/patches/udhcp_config_paths.diff
deleted file mode 100644
index 1d3a6b4b0..000000000
--- a/busybox/patches/udhcp_config_paths.diff
+++ /dev/null
@@ -1,333 +0,0 @@
1Index: include/usage.h
2===================================================================
3RCS file: /var/cvs/busybox/include/usage.h,v
4retrieving revision 1.191
5diff -u -r1.191 usage.h
6--- a/include/usage.h 25 Feb 2004 10:35:55 -0000 1.191
7+++ b/include/usage.h 5 Mar 2004 13:20:11 -0000
8@@ -2606,7 +2606,8 @@
9 "\t-p,\t--pidfile=file\tStore process ID of daemon in file\n" \
10 "\t-q,\t--quit\tQuit after obtaining lease\n" \
11 "\t-r,\t--request=IP\tIP address to request (default: none)\n" \
12- "\t-s,\t--script=file\tRun file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \
13+ "\t-s,\t--script=file\tRun file at dhcp events (default: " \
14+ CONFIG_UDHCPC_SCRIPT_PATH ")\n" \
15 "\t-v,\t--version\tDisplay version"
16
17 #define udhcpd_trivial_usage \
18Index: networking/udhcp/AUTHORS
19===================================================================
20RCS file: /var/cvs/busybox/networking/udhcp/AUTHORS,v
21retrieving revision 1.3
22diff -u -r1.3 AUTHORS
23--- a/networking/udhcp/AUTHORS 18 Dec 2003 22:25:38 -0000 1.3
24+++ b/networking/udhcp/AUTHORS 5 Mar 2004 13:20:11 -0000
25@@ -10,5 +10,5 @@
26 Moreton Bay (http://www.moretonbay.com/)
27 Vladimir Oleynik <dzo@simtrea.ru> Size optimizations
28
29-
30+Tony J. White <tjw@tjw.org> additional busybox build options
31
32Index: networking/udhcp/Config.in
33===================================================================
34RCS file: /var/cvs/busybox/networking/udhcp/Config.in,v
35retrieving revision 1.5
36diff -u -r1.5 Config.in
37--- a/networking/udhcp/Config.in 22 Oct 2003 09:58:38 -0000 1.5
38+++ b/networking/udhcp/Config.in 5 Mar 2004 13:20:11 -0000
39@@ -58,5 +58,62 @@
40
41 See http://udhcp.busybox.net for further details.
42
43+menu "udhcpd Configuration Options"
44+ depends on CONFIG_UDHCPD
45+
46+config CONFIG_UDHCPD_CONF_PATH
47+ string "Path to default udhcpd.conf"
48+ default "/etc/udhcpd.conf"
49+ depends on CONFIG_UDHCPD
50+ help
51+ The full path to udhcpd's default configuration file.
52+ (default is: /etc/udhcpd.conf)
53+
54+config CONFIG_UDHCPD_LEASE_PATH
55+ string "Path to default udhcpd.leases"
56+ default "/var/lib/misc/udhcpd.leases"
57+ depends on CONFIG_UDHCPD
58+ help
59+ The full path to udhcpd's default leases file.
60+ (default is: /var/lib/misc/udhcpd.leases)
61+
62+config CONFIG_UDHCPD_PID_PATH
63+ string "Path to default udhcpd PID file"
64+ default "/var/run/udhcpd.pid"
65+ depends on CONFIG_UDHCPD
66+ help
67+ The full path to udhcpd's default pid file.
68+ (default is: /var/run/udhcpd.pid)
69+
70+endmenu
71+
72+menu "udhcpc Configuration Options"
73+ depends on CONFIG_UDHCPC
74+
75+config CONFIG_UDHCPC_SCRIPT_PATH
76+ string "Path to default udhcpc event script"
77+ depends on CONFIG_UDHCPC
78+ help
79+ The full path to udhcpc's default event script file.
80+ (default is: /usr/share/udhcpc/default.script OR
81+ /share/udhcpc/default.script if CONFIG_INSTALL_NO_USR is set)
82+
83+ When udhcpc is started it executes this script to take care
84+ of system tasks after it completes DHCP communication. Such
85+ tasks include putting network interfaces up or down, setting
86+ DNS info, adding routing information, etc.
87+
88+if CONFIG_INSTALL_NO_USR
89+config CONFIG_UDHCPC_SCRIPT_PATH
90+ default "/share/udhcpc/default.script"
91+endif
92+
93+if !CONFIG_INSTALL_NO_USR
94+config CONFIG_UDHCPC_SCRIPT_PATH
95+ default "/usr/share/udhcpc/default.script"
96+endif
97+
98+endmenu
99+
100 endmenu
101
102Index: networking/udhcp/README
103===================================================================
104RCS file: /var/cvs/busybox/networking/udhcp/README,v
105retrieving revision 1.3
106diff -u -r1.3 README
107--- a/networking/udhcp/README 18 Dec 2003 22:25:38 -0000 1.3
108+++ b/networking/udhcp/README 5 Mar 2004 13:20:11 -0000
109@@ -9,27 +9,42 @@
110 compile time options
111 -------------------
112
113-The Makefile contains three of the compile time options:
114+The following options can be adjusted when configuring busybox:
115
116- UDHCP_DEBUG: If UDHCP_DEBUG is defined, udhcpd will output extra
117- debugging output, compile with -g, and not fork to the background when
118- run.
119- UDHCP_SYSLOG: If UDHCP_SYSLOG is defined, udhcpd will log all its
120- messages syslog, otherwise, it will attempt to log them to stdout.
121-
122- COMBINED_BINARY: If COMBINED_BINARY is define, one binary, udhcpd,
123- is created. If called as udhcpd, the dhcp server will be started.
124- If called as udhcpc, the dhcp client will be started.
125-
126-dhcpd.h contains the other three compile time options:
127-
128- LEASE_TIME: The default lease time if not specified in the config
129- file.
130+ CONFIG_FEATURE_UDHCP_DEBUG:
131+ If this is defined, udhcpd will output extra debugging output,
132+ compile with -g, and not fork to the background when run.
133
134- LEASES_FILE: The default file for storing leases.
135-
136- DHCPD_CONFIG_FILE: The defualt config file to use.
137+ CONFIG_FEATURE_UDHCP_SYSLOG:
138+ If this is defined, udhcpd will log all its messages syslog,
139+ otherwise, it will attempt to log them to stdout.
140+
141+ CONFIG_UDHCPD_CONF_PATH:
142+ The full path to udhcpd's default configuration file.
143+
144+ CONFIG_UDHCPD_LEASE_PATH:
145+ The full path to udhcpd's default leases file.
146+
147+ CONFIG_UDHCPD_PID_PATH:
148+ The full path to udhcpd's default pid file.
149+
150+ CONFIG_UDHCPC_SCRIPT_PATH:
151+ The full path to udhcpc's default event script file.
152+ (default is: /usr/share/udhcpc/default.script)
153+
154+ When udhcpc is started it executes this script to take care
155+ of system tasks after it completes DHCP communication. Such
156+ tasks include putting network interfaces up or down, setting
157+ DNS info, adding routing information, etc.
158+
159+
160+dhcpd.h contains the another compile time option:
161
162+ LEASE_TIME:
163+ The default lease time if not specified in the config file.
164+ This option can also be changed at runtime with the 'lease'
165+ configuration option.
166+
167 options.c contains a set of dhcp options for the client:
168
169 name[10]: The name of the option as it will appear in scripts
170Index: networking/udhcp/README.udhcpc
171===================================================================
172RCS file: /var/cvs/busybox/networking/udhcp/README.udhcpc,v
173retrieving revision 1.3
174diff -u -r1.3 README.udhcpc
175--- a/networking/udhcp/README.udhcpc 11 Dec 2002 21:12:44 -0000 1.3
176+++ b/networking/udhcp/README.udhcpc 5 Mar 2004 13:20:11 -0000
177@@ -23,7 +23,8 @@
178 -q, --quit Quit after obtaining lease
179 -r, --request=IP IP address to request (default: none)
180 -s, --script=file Run file at dhcp events (default:
181- /usr/share/udhcpc/default.script)
182+ /usr/share/udhcpc/default.script or
183+ CONFIG_UDHCPC_SCRIPT_PATH at build time)
184 -v, --version Display version
185
186
187Index: networking/udhcp/README.udhcpd
188===================================================================
189RCS file: /var/cvs/busybox/networking/udhcp/README.udhcpd,v
190retrieving revision 1.1
191diff -u -r1.1 README.udhcpd
192--- a/networking/udhcp/README.udhcpd 31 Oct 2002 19:21:27 -0000 1.1
193+++ b/networking/udhcp/README.udhcpd 5 Mar 2004 13:20:11 -0000
194@@ -50,10 +50,14 @@
195
196 compile time options
197 -------------------
198+
199+During busybox configuration, you can change the default paths for
200+udhcpd.conf, udhcpd.leases, and udhcpd.pid files. See README for
201+more details.
202
203-dhcpd.h contains the other two compile time options:
204+dhcpd.h contains the compile time option:
205
206 LEASE_TIME: The default lease time if not specified in the config
207 file.
208+
209
210- DHCPD_CONFIG_FILE: The defualt config file to use.
211Index: networking/udhcp/dhcpc.h
212===================================================================
213RCS file: /var/cvs/busybox/networking/udhcp/dhcpc.h,v
214retrieving revision 1.4
215diff -u -r1.4 dhcpc.h
216--- a/networking/udhcp/dhcpc.h 30 Jan 2004 23:45:12 -0000 1.4
217+++ b/networking/udhcp/dhcpc.h 5 Mar 2004 13:20:11 -0000
218@@ -2,7 +2,11 @@
219 #ifndef _DHCPC_H
220 #define _DHCPC_H
221
222-#define DEFAULT_SCRIPT "/usr/share/udhcpc/default.script"
223+#ifdef CONFIG_UDHCPC_SCRIPT_PATH
224+ #define DEFAULT_SCRIPT CONFIG_UDHCPC_SCRIPT_PATH
225+#else
226+ #define DEFAULT_SCRIPT "/usr/share/udhcpc/default.script"
227+#endif
228
229 /* allow libbb_udhcp.h to redefine DEFAULT_SCRIPT */
230 #include "libbb_udhcp.h"
231Index: networking/udhcp/dhcpd.c
232===================================================================
233RCS file: /var/cvs/busybox/networking/udhcp/dhcpd.c,v
234retrieving revision 1.5
235diff -u -r1.5 dhcpd.c
236--- a/networking/udhcp/dhcpd.c 30 Jan 2004 23:45:12 -0000 1.5
237+++ b/networking/udhcp/dhcpd.c 5 Mar 2004 13:20:11 -0000
238@@ -70,6 +70,13 @@
239 struct dhcpOfferedAddr *lease;
240 int max_sock;
241 unsigned long num_ips;
242+ int daemonize = 1;
243+
244+ while (strcmp(argv[1],"-f")==0 || strcmp(argv[1],"--foreground")==0) {
245+ daemonize = 0;
246+ argv++;
247+ argc--;
248+ }
249
250 memset(&server_config, 0, sizeof(struct server_config_t));
251 read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]);
252@@ -99,9 +106,8 @@
253 &server_config.server, server_config.arp) < 0)
254 return 1;
255
256-#ifndef UDHCP_DEBUG
257- background(server_config.pidfile); /* hold lock during fork. */
258-#endif
259+ if(daemonize)
260+ background(server_config.pidfile); /* hold lock during fork. */
261
262 /* Setup the signal pipe */
263 udhcp_sp_setup();
264Index: networking/udhcp/dhcpd.h
265===================================================================
266RCS file: /var/cvs/busybox/networking/udhcp/dhcpd.h,v
267retrieving revision 1.5
268diff -u -r1.5 dhcpd.h
269--- a/networking/udhcp/dhcpd.h 30 Jan 2004 23:45:12 -0000 1.5
270+++ b/networking/udhcp/dhcpd.h 5 Mar 2004 13:20:12 -0000
271@@ -15,11 +15,25 @@
272
273 /* the period of time the client is allowed to use that address */
274 #define LEASE_TIME (60*60*24*10) /* 10 days of seconds */
275-#define LEASES_FILE "/var/lib/misc/udhcpd.leases"
276+
277+#ifdef CONFIG_UDHCPD_LEASE_PATH
278+ #define LEASES_FILE CONFIG_UDHCPD_LEASE_PATH
279+#else
280+ #define LEASES_FILE "/var/lib/misc/udhcpd.leases"
281+#endif
282
283 /* where to find the DHCP server configuration file */
284-#define DHCPD_CONF_FILE "/etc/udhcpd.conf"
285+#ifdef CONFIG_UDHCPD_CONF_PATH
286+ #define DHCPD_CONF_FILE CONFIG_UDHCPD_CONF_PATH
287+#else
288+ #define DHCPD_CONF_FILE "/etc/udhcpd.conf"
289+#endif
290
291+#ifdef CONFIG_UDHCPD_PID_PATH
292+ #define DHCPD_PID_FILE CONFIG_UDHCPD_PID_PATH
293+#else
294+ #define DHCPD_PID_FILE "/var/run/udhcpd.pid"
295+#endif
296 /*****************************************************************/
297 /* Do not modify below here unless you know what you are doing!! */
298 /*****************************************************************/
299Index: networking/udhcp/files.c
300===================================================================
301RCS file: /var/cvs/busybox/networking/udhcp/files.c,v
302retrieving revision 1.13
303diff -u -r1.13 files.c
304--- a/networking/udhcp/files.c 30 Jan 2004 23:45:12 -0000 1.13
305+++ b/networking/udhcp/files.c 5 Mar 2004 13:20:13 -0000
306@@ -166,7 +166,7 @@
307 {"offer_time", read_u32, &(server_config.offer_time), "60"},
308 {"min_lease", read_u32, &(server_config.min_lease), "60"},
309 {"lease_file", read_str, &(server_config.lease_file), LEASES_FILE},
310- {"pidfile", read_str, &(server_config.pidfile), "/var/run/udhcpd.pid"},
311+ {"pidfile", read_str, &(server_config.pidfile), DHCPD_PID_FILE},
312 {"notify_file", read_str, &(server_config.notify_file), ""},
313 {"siaddr", read_ip, &(server_config.siaddr), "0.0.0.0"},
314 {"sname", read_str, &(server_config.sname), ""},
315Index: networking/udhcp/libbb_udhcp.h
316===================================================================
317RCS file: /var/cvs/busybox/networking/udhcp/libbb_udhcp.h,v
318retrieving revision 1.5
319diff -u -r1.5 libbb_udhcp.h
320--- a/networking/udhcp/libbb_udhcp.h 18 Dec 2003 22:25:38 -0000 1.5
321+++ b/networking/udhcp/libbb_udhcp.h 5 Mar 2004 13:20:13 -0000
322@@ -3,11 +3,6 @@
323 /* bit of a hack, do this no matter what the order of the includes.
324 * (for busybox) */
325
326-#ifdef CONFIG_INSTALL_NO_USR
327-#undef DEFUALT_SCRIPT
328-#define DEFAULT_SCRIPT "/share/udhcpc/default.script"
329-#endif
330-
331 #ifndef _LIBBB_UDHCP_H
332 #define _LIBBB_UDHCP_H
333
diff --git a/busybox/patches/udhcpd_foreground.diff b/busybox/patches/udhcpd_foreground.diff
deleted file mode 100644
index 3b8c7eb0c..000000000
--- a/busybox/patches/udhcpd_foreground.diff
+++ /dev/null
@@ -1,33 +0,0 @@
1Index: ./networking/udhcp/dhcpd.c
2===================================================================
3RCS file: /var/cvs/busybox/networking/udhcp/dhcpd.c,v
4retrieving revision 1.5
5diff -u -r1.5 dhcpd.c
6--- a/./networking/udhcp/dhcpd.c 30 Jan 2004 23:45:12 -0000 1.5
7+++ b/./networking/udhcp/dhcpd.c 5 Mar 2004 13:09:05 -0000
8@@ -70,6 +70,13 @@
9 struct dhcpOfferedAddr *lease;
10 int max_sock;
11 unsigned long num_ips;
12+ int daemonize = 1;
13+
14+ while (strcmp(argv[1],"-f")==0 || strcmp(argv[1],"--foreground")==0) {
15+ daemonize = 0;
16+ argv++;
17+ argc--;
18+ }
19
20 memset(&server_config, 0, sizeof(struct server_config_t));
21 read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]);
22@@ -99,9 +106,8 @@
23 &server_config.server, server_config.arp) < 0)
24 return 1;
25
26-#ifndef UDHCP_DEBUG
27- background(server_config.pidfile); /* hold lock during fork. */
28-#endif
29+ if(daemonize)
30+ background(server_config.pidfile); /* hold lock during fork. */
31
32 /* Setup the signal pipe */
33 udhcp_sp_setup();