from http://www-128.ibm.com/developerworks/cn/linux/l-busybox/index.html
int main( int argc, char *argv[] )
// test.c #include < stdio.h> int main( int argc, char *argv[] ) { int i; for (i = 0 ; i < argc ; i++) { printf("argv[%d] = %s\n", i, argv[i]); } return 0; }
$ gcc -Wall -o test test.c $ ./test arg1 arg2 argv[0] = ./test argv[1] = arg1 argv[2] = arg2 $ mv test newtest $ ./newtest arg1 argv[0] = ./newtest argv[1] = arg1 $ ln -s newtest linktest $ ./linktest arg argv[0] = ./linktest argv[1] = arg
$ tar xvfz busybox-1.1.1.tar.gz $
$ cd busybox-1.1.1 $ make defconfig $ make $
$ ./busybox pwd /usr/local/src/busybox-1.1.1 $ ./busybox ash /usr/local/src/busybox-1.1.1 $ pwd /usr/local/src/busybox-1.1.1 /usr/local/src/busybox-1.1.1 $ exit $
$ make menuconfig $ make $
$ make install $
$ make PREFIX=/tmp/newtarget install $
$ ./busybox --install -s $
$ make allyesconfig $ make $
$ ./busybox wc --help BusyBox v1.1.1 (2006.04.09-15:27+0000) multi-call binary Usage: wc [OPTION]... [FILE]... Print line, word, and byte counts for each FILE, and a total line if more than one FILE is specified. With no FILE, read standard input. Options: -c print the byte counts -l print the newline counts -L print the length of the longest line -w print the word counts $
#include "busybox.h " int newcmd_main( int argc, char *argv[] ) { int i; printf("newcmd called:\n"); for (i = 0 ; i < argc ; i++) { printf("arg[%d] = %s\n", i, argv[i]); } return 0; }
MISCUTILS-$(CONFIG_MT) += mt.o MISCUTILS-$(CONFIG_NEWCMD) += newcmd.o MISCUTILS-$(CONFIG_RUNLEVEL) += runlevel.o
config CONFIG_NEWCMD bool "newcmd" default n help newcmd is a new test command.
USE_NEWCMD(APPLET(newcmd, newcmd_main, _BB_DIR_USER_BIN, _BB_SUID_NEVER))
#define newcmd_trivial_usage "None" #define newcmd_full_usage "None"
$ ./busybox newcmd arg1 newcmd called: arg[0] = newcmd arg[1] = arg1 $ ./busybox newcmd --help BusyBox v1.1.1 (2006.04.12-13:47+0000) multi-call binary Usage: newcmd None None