update busybox support
[nestedvm.git] / upstream / patches / busybox.patch
1 diff -Bubr ../busybox-1.00+/archival/libunarchive/decompress_bunzip2.c ./archival/libunarchive/decompress_bunzip2.c
2 --- ../busybox-1.00+/archival/libunarchive/decompress_bunzip2.c 2004-08-27 17:43:05.000000000 -0700
3 +++ ./archival/libunarchive/decompress_bunzip2.c        2009-06-07 15:10:37.000000000 -0700
4 @@ -136,7 +136,7 @@
5  {
6         /* Note: Ignore the warning about hufGroup, base and limit being used uninitialized.
7          * They will be initialized on the fist pass of the loop. */
8 -       struct group_data *hufGroup;
9 +       struct group_data *hufGroup=NULL;
10         int dbufCount,nextSym,dbufSize,groupCount,*base,*limit,selector,
11                 i,j,k,t,runPos,symCount,symTotal,nSelectors,byteCount[256];
12         unsigned char uc, symToByte[256], mtfSymbol[256], *selectors;
13 Only in ./archival/libunarchive: decompress_bunzip2.c.orig
14 diff -Bubr ../busybox-1.00+/archival/tar.c ./archival/tar.c
15 --- ../busybox-1.00+/archival/tar.c     2004-08-26 15:18:56.000000000 -0700
16 +++ ./archival/tar.c    2009-06-07 15:19:14.000000000 -0700
17 @@ -48,8 +48,10 @@
18  #include <errno.h>
19  #include <signal.h>
20  #include <sys/wait.h>
21 +#ifndef NESTEDVM
22  #include <sys/socket.h>
23  #include <sys/sysmacros.h>     /* major() and minor() */
24 +#endif
25  #include "unarchive.h"
26  #include "busybox.h"
27  
28 Only in ./archival: tar.c.orig
29 Only in .: busybox-1.00-pre9
30 Only in .: .config
31 Only in .: .config.cmd
32 Only in .: .config.old
33 diff -Bubr ../busybox-1.00+/coreutils/cal.c ./coreutils/cal.c
34 --- ../busybox-1.00+/coreutils/cal.c    2004-04-14 10:51:09.000000000 -0700
35 +++ ./coreutils/cal.c   2009-06-07 15:08:50.000000000 -0700
36 @@ -31,7 +31,9 @@
37  
38  #include <sys/types.h>
39  #include <ctype.h>
40 +#ifndef NESTEDVM
41  #include <err.h>
42 +#endif
43  #include <stdio.h>
44  #include <stdlib.h>
45  #include <string.h>
46 diff -Bubr ../busybox-1.00+/coreutils/date.c ./coreutils/date.c
47 --- ../busybox-1.00+/coreutils/date.c   2004-10-11 13:52:16.000000000 -0700
48 +++ ./coreutils/date.c  2009-06-07 15:08:50.000000000 -0700
49 @@ -236,7 +236,11 @@
50                 }
51  
52                 /* if setting time, set it */
53 +#ifndef NESTEDVM
54                 if (set_time && (stime(&tm) < 0)) {
55 +#else
56 +        if(0) {
57 +#endif
58                         bb_perror_msg("cannot set date");
59                 }
60         }
61 Only in ./coreutils: date.c.orig
62 diff -Bubr ../busybox-1.00+/coreutils/df.c ./coreutils/df.c
63 --- ../busybox-1.00+/coreutils/df.c     2004-08-02 17:14:01.000000000 -0700
64 +++ ./coreutils/df.c    2009-06-07 15:20:57.000000000 -0700
65 @@ -35,8 +35,10 @@
66  #include <stdlib.h>
67  #include <string.h>
68  #include <unistd.h>
69 +#ifndef NESTEDVM
70  #include <mntent.h>
71  #include <sys/vfs.h>
72 +#endif
73  #include "busybox.h"
74  
75  #ifndef CONFIG_FEATURE_HUMAN_READABLE
76 @@ -46,6 +48,7 @@
77  }
78  #endif
79  
80 +#ifndef NESTEDVM
81  extern int df_main(int argc, char **argv)
82  {
83         long blocks_used;
84 @@ -160,6 +163,7 @@
85  
86         bb_fflush_stdout_and_exit(status);
87  }
88 +#endif
89  
90  /*
91  Local Variables:
92 diff -Bubr ../busybox-1.00+/coreutils/dos2unix.c ./coreutils/dos2unix.c
93 --- ../busybox-1.00+/coreutils/dos2unix.c       2004-05-05 12:39:21.000000000 -0700
94 +++ ./coreutils/dos2unix.c      2009-06-07 15:08:50.000000000 -0700
95 @@ -30,7 +30,9 @@
96  #include <string.h>
97  #include <getopt.h>
98  #include <unistd.h>
99 +#ifndef NESTEDVM
100  #include <stdint.h>
101 +#endif
102  #include <fcntl.h>
103  #include <sys/time.h>
104  #include "busybox.h"
105 diff -Bubr ../busybox-1.00+/coreutils/env.c ./coreutils/env.c
106 --- ../busybox-1.00+/coreutils/env.c    2004-04-16 08:02:10.000000000 -0700
107 +++ ./coreutils/env.c   2009-06-07 15:08:50.000000000 -0700
108 @@ -50,12 +50,13 @@
109  #include <getopt.h>
110  #include "busybox.h"
111  
112 -
113 +#ifdef NESTEDVM
114  static const struct option env_long_options[] = {
115         { "ignore-environment", 0, NULL, 'i' },
116         { "unset", 1, NULL, 'u' },
117         { 0, 0, 0, 0 }
118  };
119 +#endif
120  
121  extern int env_main(int argc, char** argv)
122  {
123 diff -Bubr ../busybox-1.00+/coreutils/expr.c ./coreutils/expr.c
124 --- ../busybox-1.00+/coreutils/expr.c   2004-04-14 10:51:09.000000000 -0700
125 +++ ./coreutils/expr.c  2009-06-07 15:22:16.000000000 -0700
126 @@ -244,6 +244,7 @@
127  
128  static VALUE *docolon (VALUE *sv, VALUE *pv)
129  {
130 +#ifndef NESTEDVM
131         VALUE *v;
132         const char *errmsg;
133         struct re_pattern_buffer re_buffer;
134 @@ -291,6 +292,9 @@
135         }
136         free (re_buffer.buffer);
137         return v;
138 +#else
139 +        return NULL;
140 +#endif
141  }
142  
143  /* Handle bare operands and ( expr ) syntax.  */
144 diff -Bubr ../busybox-1.00+/coreutils/ls.c ./coreutils/ls.c
145 --- ../busybox-1.00+/coreutils/ls.c     2004-09-23 19:04:13.000000000 -0700
146 +++ ./coreutils/ls.c    2009-06-07 15:22:37.000000000 -0700
147 @@ -59,9 +59,11 @@
148  #include <stdlib.h>
149  #include <fcntl.h>
150  #include <signal.h>
151 +#ifndef NESTEDVM
152  #include <termios.h>
153  #include <sys/ioctl.h>
154  #include <sys/sysmacros.h>     /* major() and minor() */
155 +#endif
156  #include "busybox.h"
157  #ifdef CONFIG_SELINUX
158  #include <fs_secure.h>
159 @@ -984,8 +986,11 @@
160  #endif
161  
162  #ifdef CONFIG_FEATURE_LS_COLOR
163 -       if (isatty(STDOUT_FILENO))
164 +    {
165 +        char *term = getenv("TERM");
166 +        if (isatty(STDOUT_FILENO) && term && *term)
167                 show_color = 1;
168 +    }
169  #endif
170  
171         /* process options */
172 Only in ./coreutils: ls.c.orig
173 diff -Bubr ../busybox-1.00+/coreutils/md5_sha1_sum.c ./coreutils/md5_sha1_sum.c
174 --- ../busybox-1.00+/coreutils/md5_sha1_sum.c   2004-04-14 10:51:09.000000000 -0700
175 +++ ./coreutils/md5_sha1_sum.c  2009-06-07 15:08:50.000000000 -0700
176 @@ -20,7 +20,9 @@
177  #include <fcntl.h>
178  #include <limits.h>
179  #include <stdio.h>
180 +#ifndef NESTEDVM
181  #include <stdint.h>
182 +#endif
183  #include <stdlib.h>
184  #include <string.h>
185  #include <unistd.h>
186 diff -Bubr ../busybox-1.00+/coreutils/rmdir.c ./coreutils/rmdir.c
187 --- ../busybox-1.00+/coreutils/rmdir.c  2004-03-15 00:28:21.000000000 -0800
188 +++ ./coreutils/rmdir.c 2009-06-07 15:08:50.000000000 -0700
189 @@ -25,7 +25,9 @@
190  
191  #include <stdlib.h>
192  #include <unistd.h>
193 +#ifndef NESTEDVM
194  #include <libgen.h>
195 +#endif
196  #include "busybox.h"
197  
198  extern int rmdir_main(int argc, char **argv)
199 diff -Bubr ../busybox-1.00+/editors/vi.c ./editors/vi.c
200 --- ../busybox-1.00+/editors/vi.c       2004-08-19 12:15:06.000000000 -0700
201 +++ ./editors/vi.c      2009-06-07 15:24:23.000000000 -0700
202 @@ -68,7 +68,9 @@
203  #include <stdio.h>
204  #include <stdlib.h>
205  #include <string.h>
206 +#ifndef NESTEDVM
207  #include <termios.h>
208 +#endif
209  #include <unistd.h>
210  #include <sys/ioctl.h>
211  #include <sys/time.h>
212 @@ -183,7 +185,9 @@
213  static Byte *screenbegin;      // index into text[], of top line on the screen
214  static Byte *dot;              // where all the action takes place
215  static int tabstop;
216 +#ifndef NESTEDVM
217  static struct termios term_orig, term_vi;      // remember what the cooked mode was
218 +#endif
219  static Byte erase_char;         // the users erase character
220  static Byte last_input_char;    // last char read from user
221  static Byte last_forward_char;  // last char searched for with 'f'
222 @@ -2113,6 +2117,7 @@
223  //----- Set terminal attributes --------------------------------
224  static void rawmode(void)
225  {
226 +#ifndef NESTEDVM
227         tcgetattr(0, &term_orig);
228         term_vi = term_orig;
229         term_vi.c_lflag &= (~ICANON & ~ECHO);   // leave ISIG ON- allow intr's
230 @@ -2122,12 +2127,15 @@
231         term_vi.c_cc[VTIME] = 0;
232         erase_char = term_vi.c_cc[VERASE];
233         tcsetattr(0, TCSANOW, &term_vi);
234 +#endif
235  }
236  
237  static void cookmode(void)
238  {
239         fflush(stdout);
240 +#ifndef NESTEDVM
241         tcsetattr(0, TCSANOW, &term_orig);
242 +#endif
243  }
244  
245  //----- Come here when we get a window resize signal ---------
246 diff -Bubr ../busybox-1.00+/include/busybox.h ./include/busybox.h
247 --- ../busybox-1.00+/include/busybox.h  2004-03-15 00:28:38.000000000 -0800
248 +++ ./include/busybox.h 2009-06-07 15:08:50.000000000 -0700
249 @@ -33,7 +33,7 @@
250  #include <sys/types.h>
251  
252  #if __GNU_LIBRARY__ < 5
253 -#ifndef __dietlibc__
254 +#if !defined(__dietlibc__) && !defined(NESTEDVM)
255  #error "Sorry, libc5 is not supported"
256  #endif
257  #endif
258 @@ -48,7 +48,9 @@
259  #include <dmalloc.h>
260  #endif
261  
262 +#ifndef NESTEDVM
263  #include <features.h>
264 +#endif
265  
266  /* Pull in the utility routines from libbb */
267  #include "libbb.h"
268 diff -Bubr ../busybox-1.00+/include/grp_.h ./include/grp_.h
269 --- ../busybox-1.00+/include/grp_.h     2004-07-15 05:53:49.000000000 -0700
270 +++ ./include/grp_.h    2009-06-07 15:08:50.000000000 -0700
271 @@ -31,7 +31,9 @@
272  
273  
274  #include <sys/types.h>
275 +#ifndef NESTEDVM
276  #include <features.h>
277 +#endif
278  #include <stdio.h>
279  
280  
281 Only in ./include: grp_.h.orig
282 diff -Bubr ../busybox-1.00+/include/libbb.h ./include/libbb.h
283 --- ../busybox-1.00+/include/libbb.h    2004-09-14 20:04:07.000000000 -0700
284 +++ ./include/libbb.h   2009-06-07 15:08:50.000000000 -0700
285 @@ -24,22 +24,68 @@
286  #ifndef        __LIBCONFIG_H__
287  #define        __LIBCONFIG_H__    1
288  
289 +
290 +#ifdef NESTEDVM
291 +#include <sys/cdefs.h>
292 +#include <sys/fcntl.h>
293 +#include <stdio.h>
294 +#include <string.h>
295 +#include <unistd.h>
296 +
297 +#define WCOREDUMP(x) 0
298 +
299 +typedef char int8_t;
300 +typedef unsigned char uint8_t;
301 +typedef short int16_t;
302 +typedef unsigned short uint16_t;
303 +typedef int int32_t;
304 +typedef unsigned int uint32_t;
305 +typedef long long int64_t;
306 +typedef unsigned long long uint64_t;
307 +
308 +struct option {
309 +       const char *name;
310 +       int has_arg;
311 +       int *flag;
312 +       int val;
313 +};
314 +
315 +#include <stdarg.h>
316 +
317 +static char *strchrnul(const char *s, int c) {
318 +    char *ret;
319 +    ret = strchr(s,c);
320 +    return ret ? ret : (char*)s + strlen(s);
321 +}
322 +
323 +static char *stpcpy(char *dest, const char *src) {
324 +    while((*dest = *src) != '\0') { dest++; src++; }
325 +    return dest;
326 +}
327 +
328 +#endif
329 +
330  #include <stdio.h>
331  #include <stdlib.h>
332  #include <stdarg.h>
333  #include <sys/stat.h>
334  #include <sys/types.h>
335  #include <regex.h>
336 +#ifndef NESTEDVM
337  #include <termios.h>
338  #include <stdint.h>
339 +#endif
340  
341  #include <netdb.h>
342 +#include <netinet/in.h>
343  
344  #ifdef DMALLOC
345  #include <dmalloc.h>
346  #endif
347  
348 +#ifndef NESTEDVM
349  #include <features.h>
350 +#endif
351  
352  #include "config.h"
353  #ifdef CONFIG_SELINUX
354 @@ -123,8 +169,10 @@
355  extern int bb_parse_mode( const char* s, mode_t* theMode);
356  extern long bb_xgetlarg(const char *arg, int base, long lower, long upper);
357  
358 +#ifndef NESTEDVM
359  extern unsigned long bb_baud_to_value(speed_t speed);
360  extern speed_t bb_value_to_baud(unsigned long value);
361 +#endif
362  
363  extern int get_kernel_revision(void);
364  
365 diff -Bubr ../busybox-1.00+/include/pwd_.h ./include/pwd_.h
366 --- ../busybox-1.00+/include/pwd_.h     2004-07-15 05:53:49.000000000 -0700
367 +++ ./include/pwd_.h    2009-06-07 15:08:50.000000000 -0700
368 @@ -29,7 +29,9 @@
369  #define        _PWD_H  1
370  
371  #include <sys/types.h>
372 +#ifndef NESTEDVM
373  #include <features.h>
374 +#endif
375  #include <stdio.h>
376  
377  /* The passwd structure.  */
378 Only in ./include: pwd_.h.orig
379 diff -Bubr ../busybox-1.00+/init/halt.c ./init/halt.c
380 --- ../busybox-1.00+/init/halt.c        2004-03-15 00:28:40.000000000 -0800
381 +++ ./init/halt.c       2009-06-07 15:24:41.000000000 -0700
382 @@ -24,7 +24,9 @@
383  #include <stdlib.h>
384  #include <unistd.h>
385  #include <getopt.h>
386 +#ifndef NESTEDVM
387  #include <sys/reboot.h>
388 +#endif
389  #include "busybox.h"
390  #include "init_shared.h"
391  
392 Only in ./init: .#init.c
393 diff -Bubr ../busybox-1.00+/init/init.c ./init/init.c
394 --- ../busybox-1.00+/init/init.c        2004-10-08 01:21:54.000000000 -0700
395 +++ ./init/init.c       2009-06-07 15:26:03.000000000 -0700
396 @@ -34,23 +34,31 @@
397  #include <signal.h>
398  #include <stdarg.h>
399  #include <string.h>
400 +#ifndef NESTEDVM
401  #include <termios.h>
402 +#endif
403  #include <unistd.h>
404  #include <limits.h>
405  #include <sys/fcntl.h>
406  #include <sys/ioctl.h>
407 +#ifndef NESTEDVM
408  #include <sys/mount.h>
409 +#endif
410  #include <sys/types.h>
411  #include <sys/wait.h>
412 +#ifndef NESTEDVM
413  #include <sys/reboot.h>
414 +#endif
415  #include "busybox.h"
416  
417  #include "init_shared.h"
418  
419  
420 +#ifndef NESTEDVM
421  #ifdef CONFIG_SYSLOGD
422  # include <sys/syslog.h>
423  #endif
424 +#endif
425  
426  
427  #define INIT_BUFFS_SIZE 256
428 @@ -675,7 +683,9 @@
429          * linux/kernel/sys.c, which can cause the machine to panic when
430          * the init process is killed.... */
431         if ((pid = fork()) == 0) {
432 +#ifndef NESTEDVM
433                 reboot(magic);
434 +#endif
435                 _exit(0);
436         }
437         waitpid (pid, NULL, 0);
438 diff -Bubr ../busybox-1.00+/libbb/getopt_ulflags.c ./libbb/getopt_ulflags.c
439 --- ../busybox-1.00+/libbb/getopt_ulflags.c     2004-02-05 05:49:29.000000000 -0800
440 +++ ./libbb/getopt_ulflags.c    2009-06-07 15:08:50.000000000 -0700
441 @@ -150,8 +150,14 @@
442      s--;
443    }
444  
445 -  while ((c = getopt_long (argc, argv, applet_opts,
446 -                           bb_applet_long_options, NULL)) > 0) {
447 +    
448 +  while ((c = 
449 +#ifdef NESTEDVM
450 +          getopt(argc,argv,applet_opts)
451 +#else
452 +          getopt_long (argc, argv, applet_opts,bb_applet_long_options, NULL) 
453 +#endif
454 +  ) > 0) {
455         for (on_off = complementaly; on_off->opt != c; on_off++) {
456             if(!on_off->opt)
457                         bb_show_usage ();
458 diff -Bubr ../busybox-1.00+/libbb/get_terminal_width_height.c ./libbb/get_terminal_width_height.c
459 --- ../busybox-1.00+/libbb/get_terminal_width_height.c  2004-03-23 15:15:35.000000000 -0800
460 +++ ./libbb/get_terminal_width_height.c 2009-06-07 15:08:50.000000000 -0700
461 @@ -24,8 +24,10 @@
462  #include <fcntl.h>
463  #include <unistd.h>
464  #include <unistd.h>
465 +#ifndef NESTEDVM
466  #include <termios.h>
467  #include <sys/ioctl.h>
468 +#endif
469  #include "busybox.h"
470  
471  /* It is perfectly ok to pass in a NULL for either width or for
472 @@ -34,7 +36,11 @@
473   * which case you will always get 80x24 */
474  void get_terminal_width_height(int fd, int *width, int *height)
475  {
476 +#ifdef NESTEDVM
477 +    struct { int ws_row; int ws_col; } win = { 0, 0};
478 +#else
479         struct winsize win = { 0, 0, 0, 0 };
480 +#endif
481  #ifdef CONFIG_FEATURE_AUTOWIDTH
482         if (ioctl(fd, TIOCGWINSZ, &win) != 0) {
483                 win.ws_row = 24;
484 diff -Bubr ../busybox-1.00+/libbb/hash_fd.c ./libbb/hash_fd.c
485 --- ../busybox-1.00+/libbb/hash_fd.c    2004-03-15 00:28:42.000000000 -0800
486 +++ ./libbb/hash_fd.c   2009-06-07 15:08:50.000000000 -0700
487 @@ -20,18 +20,27 @@
488   *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
489   */
490  
491 +#ifndef NESTEDVM
492  #include <byteswap.h>
493  #include <endian.h>
494 +#endif
495  #include <fcntl.h>
496  #include <limits.h>
497  #include <stdio.h>
498 +#ifndef NESTEDVM
499  #include <stdint.h>
500 +#endif
501  #include <stdlib.h>
502  #include <string.h>
503  #include <unistd.h>
504  
505  #include "busybox.h"
506  
507 +#ifdef NESTEDVM
508 +#define __BYTE_ORDER BYTE_ORDER
509 +#define __LITTLE_ENDIAN LITTLE_ENDIAN
510 +#define __BIG_ENDIAN BIG_ENDIAN
511 +#endif
512  
513  #ifdef CONFIG_SHA1SUM
514  /*
515 Only in ./libbb: Makefile.in.orig
516 diff -Bubr ../busybox-1.00+/libbb/procps.c ./libbb/procps.c
517 --- ../busybox-1.00+/libbb/procps.c     2004-08-26 15:18:58.000000000 -0700
518 +++ ./libbb/procps.c    2009-06-07 15:08:50.000000000 -0700
519 @@ -12,7 +12,9 @@
520  #include <string.h>
521  #include <stdlib.h>
522  #include <unistd.h>
523 +#ifndef NESTEDVM
524  #include <asm/page.h>
525 +#endif
526  
527  #include "libbb.h"
528  
529 diff -Bubr ../busybox-1.00+/libbb/run_shell.c ./libbb/run_shell.c
530 --- ../busybox-1.00+/libbb/run_shell.c  2004-03-15 00:28:43.000000000 -0800
531 +++ ./libbb/run_shell.c 2009-06-07 15:08:50.000000000 -0700
532 @@ -33,7 +33,9 @@
533  #include <unistd.h>
534  #include <string.h>
535  #include <stdlib.h>
536 +#ifndef NESTEDVM
537  #include <syslog.h>
538 +#endif
539  #include <ctype.h>
540  #include "libbb.h"
541  #ifdef CONFIG_SELINUX
542 diff -Bubr ../busybox-1.00+/libbb/u_signal_names.c ./libbb/u_signal_names.c
543 --- ../busybox-1.00+/libbb/u_signal_names.c     2004-03-15 00:28:43.000000000 -0800
544 +++ ./libbb/u_signal_names.c    2009-06-07 15:08:50.000000000 -0700
545 @@ -21,6 +21,7 @@
546   * USA
547   */
548  
549 +#include <sys/types.h>
550  #include <signal.h>
551  #include <ctype.h>
552  #include <string.h>
553 diff -Bubr ../busybox-1.00+/libbb/vdprintf.c ./libbb/vdprintf.c
554 --- ../busybox-1.00+/libbb/vdprintf.c   2004-03-15 00:28:43.000000000 -0800
555 +++ ./libbb/vdprintf.c  2009-06-07 15:08:50.000000000 -0700
556 @@ -26,7 +26,17 @@
557  
558  
559  #if (__GLIBC__ < 2)
560 -extern int vdprintf(int d, const char *format, va_list ap)
561 +int dprintf(int d, const char *fmt, ...) {
562 +    int ret;
563 +    va_list ap;
564 +    
565 +    va_start (ap, fmt);
566 +    ret = vdprintf (d, fmt, ap);
567 +    va_end (ap);
568 +    return ret;
569 +}
570 +
571 +int vdprintf(int d, const char *format, va_list ap)
572  {
573         char buf[BUF_SIZE];
574         int len;
575 diff -Bubr ../busybox-1.00+/libbb/xconnect.c ./libbb/xconnect.c
576 --- ../busybox-1.00+/libbb/xconnect.c   2004-04-14 10:51:16.000000000 -0700
577 +++ ./libbb/xconnect.c  2009-06-07 15:08:50.000000000 -0700
578 @@ -62,7 +62,7 @@
579  int xconnect(struct sockaddr_in *s_addr)
580  {
581         int s = socket(AF_INET, SOCK_STREAM, 0);
582 -       if (connect(s, (struct sockaddr_in *)s_addr, sizeof(struct sockaddr_in)) < 0)
583 +       if (connect(s, (struct sockaddr *)s_addr, sizeof(struct sockaddr_in)) < 0)
584         {
585                 bb_perror_msg_and_die("Unable to connect to remote host (%s)",
586                                 inet_ntoa(s_addr->sin_addr));
587 diff -Bubr ../busybox-1.00+/libbb/xgetcwd.c ./libbb/xgetcwd.c
588 --- ../busybox-1.00+/libbb/xgetcwd.c    2003-05-26 07:06:00.000000000 -0700
589 +++ ./libbb/xgetcwd.c   2009-06-07 15:08:50.000000000 -0700
590 @@ -11,6 +11,7 @@
591  #include <unistd.h>
592  #include <limits.h>
593  #include <sys/param.h>
594 +#include <sys/syslimits.h>
595  #include "libbb.h"
596  
597  /* Amount to increase buffer size by in each try. */
598 diff -Bubr ../busybox-1.00+/networking/httpd.c ./networking/httpd.c
599 --- ../busybox-1.00+/networking/httpd.c 2004-10-08 01:03:29.000000000 -0700
600 +++ ./networking/httpd.c        2009-06-07 15:11:28.000000000 -0700
601 @@ -1789,11 +1789,15 @@
602    FD_ZERO (&s_fd) ;
603    FD_SET (a_c_w, &s_fd) ;
604  
605 +#ifdef NESTEDVM
606 +  //while(read(a_c_w, buf, sizeof(config->buf) > 0));
607 +#else
608    do {
609      tv.tv_sec = 2 ;
610      tv.tv_usec = 0 ;
611      retval = select (a_c_w + 1, &s_fd, NULL, NULL, &tv);
612    } while (retval > 0 && (read (a_c_w, buf, sizeof (config->buf)) > 0));
613 +#endif
614  
615    shutdown(a_c_r, SHUT_RD);
616    close(config->accepted_socket);
617 @@ -1818,18 +1822,22 @@
618  #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
619  static int miniHttpd(int server)
620  {
621 +#ifndef NESTEDVM
622    fd_set readfd, portfd;
623  
624    FD_ZERO(&portfd);
625    FD_SET(server, &portfd);
626 +#endif
627  
628    /* copy the ports we are watching to the readfd set */
629    while (1) {
630 +#ifndef NESTEDVM
631      readfd = portfd;
632  
633      /* Now wait INDEFINITELY on the set of sockets! */
634      if (select(server + 1, &readfd, 0, 0, 0) > 0) {
635        if (FD_ISSET(server, &readfd)) {
636 +#endif
637         int on;
638         struct sockaddr_in fromAddr;
639  
640 @@ -1838,7 +1846,7 @@
641                        (struct sockaddr *)&fromAddr, &fromAddrLen);
642  
643         if (s < 0) {
644 -           continue;
645 +           break;
646         }
647         config->accepted_socket = s;
648         config->rmt_ip = ntohl(fromAddr.sin_addr.s_addr);
649 @@ -1872,8 +1880,10 @@
650                 exit(0);
651         }
652         close(s);
653 +#ifndef NESTEDVM
654        }
655      }
656 +#endif
657    } // while (1)
658    return 0;
659  }
660 Only in ./networking: httpd.c.orig
661 diff -Bubr ../busybox-1.00+/networking/tftp.c ./networking/tftp.c
662 --- ../busybox-1.00+/networking/tftp.c  2004-09-14 10:24:58.000000000 -0700
663 +++ ./networking/tftp.c 2009-06-07 15:09:40.000000000 -0700
664 @@ -320,7 +320,11 @@
665                         FD_ZERO(&rfds);
666                         FD_SET(socketfd, &rfds);
667  
668 +#ifdef NESTEDVM
669 +                       switch(1) {
670 +#else
671                         switch (select(FD_SETSIZE, &rfds, NULL, NULL, &tv)) {
672 +#endif
673                         case 1:
674                                 len = recvfrom(socketfd, buf, tftp_bufsize, 0,
675                                                 (struct sockaddr *) &from, &fromlen);
676 diff -Bubr ../busybox-1.00+/procps/ps.c ./procps/ps.c
677 --- ../busybox-1.00+/procps/ps.c        2004-03-15 00:29:03.000000000 -0800
678 +++ ./procps/ps.c       2009-06-07 15:08:54.000000000 -0700
679 @@ -27,8 +27,10 @@
680  #include <fcntl.h>
681  #include <ctype.h>
682  #include <string.h>
683 +#ifndef NESTEDVM
684  #include <termios.h>
685  #include <sys/ioctl.h>
686 +#endif
687  #include "busybox.h"
688  #ifdef CONFIG_SELINUX
689  #include <fs_secure.h>
690 diff -Bubr ../busybox-1.00+/Rules.mak ./Rules.mak
691 --- ../busybox-1.00+/Rules.mak  2004-10-08 03:52:33.000000000 -0700
692 +++ ./Rules.mak 2009-06-07 15:08:50.000000000 -0700
693 @@ -158,8 +158,8 @@
694      STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging
695  else
696      CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG
697 -    LDFLAGS += -s -Wl,-warn-common
698 -    STRIPCMD:=$(STRIP) --remove-section=.note --remove-section=.comment
699 +    LDFLAGS += -Wl,-warn-common
700 +    STRIPCMD:= true
701  endif
702  ifeq ($(strip $(CONFIG_STATIC)),y)
703      LDFLAGS += --static
704 Only in .: Rules.mak.orig
705 diff -Bubr ../busybox-1.00+/shell/ash.c ./shell/ash.c
706 --- ../busybox-1.00+/shell/ash.c        2004-10-08 02:43:34.000000000 -0700
707 +++ ./shell/ash.c       2009-06-07 15:08:54.000000000 -0700
708 @@ -67,7 +67,9 @@
709  
710  #include <sys/types.h>
711  #include <sys/cdefs.h>
712 +#ifndef NESTEDVM
713  #include <sys/ioctl.h>
714 +#endif
715  #include <sys/param.h>
716  #include <sys/resource.h>
717  #include <sys/stat.h>
718 @@ -90,8 +92,10 @@
719  #include <paths.h>
720  #include <setjmp.h>
721  #include <signal.h>
722 +#ifndef NESTEDVM
723  #include <stdint.h>
724  #include <sysexits.h>
725 +#endif
726  #include <time.h>
727  #include <fnmatch.h>
728  
729 @@ -1403,7 +1407,9 @@
730         { BUILTIN_SPEC_REG      "trap", trapcmd },
731         { BUILTIN_REGULAR       "true", truecmd },
732         { BUILTIN_NOSPEC        "type", typecmd },
733 +#ifndef NESTEDVM
734         { BUILTIN_NOSPEC        "ulimit", ulimitcmd },
735 +#endif
736         { BUILTIN_REGULAR       "umask", umaskcmd },
737  #ifdef CONFIG_ASH_ALIAS
738         { BUILTIN_REGULAR       "unalias", unaliascmd },
739 @@ -2563,7 +2569,9 @@
740         int i;
741  
742         intpending = 0;
743 +#ifndef NESTEDVM
744         sigsetmask(0);
745 +#endif
746         i = EXSIG;
747         if (gotsig[SIGINT - 1] && !trap[SIGINT]) {
748                 if (!(rootshell && iflag)) {
749 @@ -6716,7 +6724,11 @@
750  #endif
751                 }
752                 st &= 0x7f;
753 +#ifdef NESTEDVM
754 +               col = fmtstr(s, 32, "signal %d",st);
755 +#else
756                 col = fmtstr(s, 32, strsignal(st));
757 +#endif
758                 if (WCOREDUMP(status)) {
759                         col += fmtstr(s + col, 16, " (core dumped)");
760                 }
761 @@ -7323,7 +7335,7 @@
762  #endif
763         if (block == 0)
764                 flags |= WNOHANG;
765 -       return wait3(status, flags, (struct rusage *)NULL);
766 +    return waitpid((pid_t)-1,status,flags);
767  }
768  
769  /*
770 @@ -12717,6 +12729,8 @@
771         return 0;
772  }
773  
774 +#ifndef NESTEDVM
775 +
776  /*
777   * ulimit builtin
778   *
779 @@ -12898,7 +12912,7 @@
780         }
781         return 0;
782  }
783 -
784 +#endif /* NESTEDVM */
785  
786  #ifdef CONFIG_ASH_MATH_SUPPORT
787  
788 Only in ./shell: ash.c.orig
789 diff -Bubr ../busybox-1.00+/util-linux/more.c ./util-linux/more.c
790 --- ../busybox-1.00+/util-linux/more.c  2004-03-27 02:02:48.000000000 -0800
791 +++ ./util-linux/more.c 2009-06-07 15:08:54.000000000 -0700
792 @@ -32,7 +32,9 @@
793  #include <signal.h>
794  #include <stdlib.h>
795  #include <unistd.h>
796 +#ifndef NESTEDVM
797  #include <sys/ioctl.h>
798 +#endif
799  #include "busybox.h"
800  
801