Some updates for the day,

-Erik
This commit is contained in:
Erik Andersen 2000-02-18 21:34:17 +00:00
parent bf5f009862
commit e272915e1f
19 changed files with 128 additions and 53 deletions

View File

@ -1,3 +1,17 @@
0.43
* Wrote basename
* tar wouldn't create directory entries that don't end in '/',
now it does (fix thanks to Avery Pennarun <apenwarr@worldvisions.ca>)
* Several fixes from Pavel Roskin <pavel_roskin@geocities.com>:
- When `tail' fails to open a file it now exits.
- When `syslogd' is given the `-n' option it should still use
fork() for running klogd.
* nslookup types are now changed to u_int32_t (instead of uint32_t)
changed per a patch from Pascal Bellard <pascal.bellard@ascend.com>
-Erik Andersen
0.42 0.42
* Fairly massive restructuring of umount.c to deal with remounting * Fairly massive restructuring of umount.c to deal with remounting

View File

@ -19,7 +19,7 @@
# #
# PROG := busybox # PROG := busybox
VERSION := 0.42 VERSION := 0.43
BUILDTIME := $(shell TZ=GMT date "+%Y%m%d-%H%M") BUILDTIME := $(shell TZ=GMT date "+%Y%m%d-%H%M")
# Set the following to `true' to make a debuggable build. # Set the following to `true' to make a debuggable build.
@ -89,7 +89,7 @@ ifndef $(PREFIX)
endif endif
LIBRARIES = LIBRARIES =
OBJECTS = $(shell ./busybox.sh) messages.o utility.o OBJECTS = $(shell ./busybox.sh) busybox.o messages.o utility.o
CFLAGS += -DBB_VER='"$(VERSION)"' CFLAGS += -DBB_VER='"$(VERSION)"'
CFLAGS += -DBB_BT='"$(BUILDTIME)"' CFLAGS += -DBB_BT='"$(BUILDTIME)"'
ifdef BB_INIT_SCRIPT ifdef BB_INIT_SCRIPT

38
TODO
View File

@ -24,10 +24,29 @@ around to it some time. If you have any good ideas, please let me know.
* killall * killall
* stty * stty
* tr * tr
* cut
* expr (maybe?) (ash builtin?) * expr (maybe?) (ash builtin?)
-----------------------
busybox.defs.h is too big and hard to follow.
I either need to add a better build system (like the Linux kernel?)
or I need to split up busybox.defs.h into coherent chunks (i.e.
busybox.defs.h just has a bunch of:
#include "fileutils.h"
#include "shellutils.h"
which would then have smaller sets of #defines...
Hmm. Needs to be carefully thought out.
-----------------------
Some known bugs, todo items, etc... Some known bugs, todo items, etc...
@ -67,3 +86,22 @@ think???)
There is no exclude file(s) option to tar. LRP's packaging system can not There is no exclude file(s) option to tar. LRP's packaging system can not
function without this. Will you have the time to add this soon? function without this. Will you have the time to add this soon?
-----------------------
/bin/busybox --install -s which makes all links to commands that it
can support (an optionnal -s should be used for symbolic links instead
of hard links).
-----------------------
cd /mnt
mkdir BACKUP
mv * BACKUP
Today, "mv" behaved as a cp -a and my disk becomed full. It does not
work properly either when renaming a directory into something else
(it produces a lot of disk activity when doing this).

View File

@ -37,6 +37,9 @@ void *__libc_stack_end;
static const struct Applet applets[] = { static const struct Applet applets[] = {
#ifdef BB_BASENAME //usr/bin/basename
{"basename", basename_main},
#endif
#ifdef BB_BUSYBOX //bin #ifdef BB_BUSYBOX //bin
{"busybox", busybox_main}, {"busybox", busybox_main},
#endif #endif

View File

@ -596,6 +596,12 @@ readHeader(const TarHeader * hp, int fileCount, char **fileTable)
*/ */
if (S_ISDIR(mode)) { if (S_ISDIR(mode)) {
if (createPath(outName, mode) == TRUE) { if (createPath(outName, mode) == TRUE) {
/* make the final component, just in case it was
* omitted by createPath() (which will skip the
* directory if it doesn't have a terminating '/')
*/
mkdir(outName, mode);
/* Set the file time */ /* Set the file time */
utb.actime = mtime; utb.actime = mtime;
utb.modtime = mtime; utb.modtime = mtime;

View File

@ -37,6 +37,9 @@ void *__libc_stack_end;
static const struct Applet applets[] = { static const struct Applet applets[] = {
#ifdef BB_BASENAME //usr/bin/basename
{"basename", basename_main},
#endif
#ifdef BB_BUSYBOX //bin #ifdef BB_BUSYBOX //bin
{"busybox", busybox_main}, {"busybox", busybox_main},
#endif #endif

View File

@ -7,7 +7,7 @@
// //
// //
// BusyBox Applications // BusyBox Applications
#define BB_BUSYBOX //#define BB_BASENAME
#define BB_CAT #define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP #define BB_CHMOD_CHOWN_CHGRP
#define BB_CHROOT #define BB_CHROOT

View File

@ -1,5 +1,5 @@
Name: busybox Name: busybox
Version: 0.42 Version: 0.43
Release: 1 Release: 1
Group: System/Utilities Group: System/Utilities
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary. Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.

View File

@ -330,7 +330,7 @@ static int tail_file(const char *filename, off_t n_units)
/* Not standard input. */ /* Not standard input. */
fd = open(filename, O_RDONLY); fd = open(filename, O_RDONLY);
if (fd == -1) if (fd == -1)
errorMsg("open error"); fatalError("open error");
errors = tail_lines(filename, fd, (long) n_units); errors = tail_lines(filename, fd, (long) n_units);
close(fd); close(fd);

View File

@ -1,5 +1,5 @@
Name: busybox Name: busybox
Version: 0.42 Version: 0.43
Release: 1 Release: 1
Group: System/Utilities Group: System/Utilities
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary. Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.

10
init.c
View File

@ -118,7 +118,7 @@ initAction *initActionList = NULL;
static char *secondConsole = VT_SECONDARY; static char *secondConsole = VT_SECONDARY;
static char *log = VT_LOG; static char *log = VT_LOG;
static int kernelVersion = 0; static int kernelVersion = 0;
static char termType[32] = "TERM=ansi"; static char termType[32] = "TERM=linux";
static char console[32] = _PATH_CONSOLE; static char console[32] = _PATH_CONSOLE;
static void delete_initAction(initAction * action); static void delete_initAction(initAction * action);
@ -314,6 +314,8 @@ static void console_init()
if (ioctl(0, TIOCGSERIAL, &sr) == 0) { if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
log = NULL; log = NULL;
secondConsole = NULL; secondConsole = NULL;
/* Force the TERM setting to vt102 for serial console */
snprintf(termType, sizeof(termType) - 1, "TERM=vt102");
message(LOG | CONSOLE, message(LOG | CONSOLE,
"serial console detected. Disabling virtual terminals.\r\n"); "serial console detected. Disabling virtual terminals.\r\n");
} }
@ -839,11 +841,11 @@ extern int init_main(int argc, char **argv)
/* Hello world */ /* Hello world */
#ifndef DEBUG_INIT #ifndef DEBUG_INIT
message(LOG | CONSOLE, message(LOG,
"init started: BusyBox v%s (%s) multi-call binary\r\n", "init started: BusyBox v%s (%s) multi-call binary\r\n",
BB_VER, BB_BT); BB_VER, BB_BT);
#else #else
message(LOG | CONSOLE, message(LOG,
"init(%d) started: BusyBox v%s (%s) multi-call binary\r\n", "init(%d) started: BusyBox v%s (%s) multi-call binary\r\n",
getpid(), BB_VER, BB_BT); getpid(), BB_VER, BB_BT);
#endif #endif
@ -851,7 +853,7 @@ extern int init_main(int argc, char **argv)
/* Mount /proc */ /* Mount /proc */
if (mount("proc", "/proc", "proc", 0, 0) == 0) { if (mount("proc", "/proc", "proc", 0, 0) == 0) {
message(LOG | CONSOLE, "Mounting /proc: done.\n"); message(LOG, "Mounting /proc: done.\n");
kernelVersion = get_kernel_revision(); kernelVersion = get_kernel_revision();
} else } else
message(LOG | CONSOLE, "Mounting /proc: failed!\n"); message(LOG | CONSOLE, "Mounting /proc: failed!\n");

View File

@ -118,7 +118,7 @@ initAction *initActionList = NULL;
static char *secondConsole = VT_SECONDARY; static char *secondConsole = VT_SECONDARY;
static char *log = VT_LOG; static char *log = VT_LOG;
static int kernelVersion = 0; static int kernelVersion = 0;
static char termType[32] = "TERM=ansi"; static char termType[32] = "TERM=linux";
static char console[32] = _PATH_CONSOLE; static char console[32] = _PATH_CONSOLE;
static void delete_initAction(initAction * action); static void delete_initAction(initAction * action);
@ -314,6 +314,8 @@ static void console_init()
if (ioctl(0, TIOCGSERIAL, &sr) == 0) { if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
log = NULL; log = NULL;
secondConsole = NULL; secondConsole = NULL;
/* Force the TERM setting to vt102 for serial console */
snprintf(termType, sizeof(termType) - 1, "TERM=vt102");
message(LOG | CONSOLE, message(LOG | CONSOLE,
"serial console detected. Disabling virtual terminals.\r\n"); "serial console detected. Disabling virtual terminals.\r\n");
} }
@ -839,11 +841,11 @@ extern int init_main(int argc, char **argv)
/* Hello world */ /* Hello world */
#ifndef DEBUG_INIT #ifndef DEBUG_INIT
message(LOG | CONSOLE, message(LOG,
"init started: BusyBox v%s (%s) multi-call binary\r\n", "init started: BusyBox v%s (%s) multi-call binary\r\n",
BB_VER, BB_BT); BB_VER, BB_BT);
#else #else
message(LOG | CONSOLE, message(LOG,
"init(%d) started: BusyBox v%s (%s) multi-call binary\r\n", "init(%d) started: BusyBox v%s (%s) multi-call binary\r\n",
getpid(), BB_VER, BB_BT); getpid(), BB_VER, BB_BT);
#endif #endif
@ -851,7 +853,7 @@ extern int init_main(int argc, char **argv)
/* Mount /proc */ /* Mount /proc */
if (mount("proc", "/proc", "proc", 0, 0) == 0) { if (mount("proc", "/proc", "proc", 0, 0) == 0) {
message(LOG | CONSOLE, "Mounting /proc: done.\n"); message(LOG, "Mounting /proc: done.\n");
kernelVersion = get_kernel_revision(); kernelVersion = get_kernel_revision();
} else } else
message(LOG | CONSOLE, "Mounting /proc: failed!\n"); message(LOG | CONSOLE, "Mounting /proc: failed!\n");

View File

@ -57,6 +57,7 @@ struct Applet {
int (*main)(int argc, char** argv); int (*main)(int argc, char** argv);
}; };
extern int basename_main(int argc, char **argv);
extern int busybox_main(int argc, char** argv); extern int busybox_main(int argc, char** argv);
extern int block_device_main(int argc, char** argv); extern int block_device_main(int argc, char** argv);
extern int cat_main(int argc, char** argv); extern int cat_main(int argc, char** argv);

View File

@ -58,9 +58,9 @@ static void server_fprint(FILE * dst)
/* only works for IPv4 */ /* only works for IPv4 */
static int addr_fprint(char *addr, FILE * dst) static int addr_fprint(char *addr, FILE * dst)
{ {
uint8_t split[4]; u_int8_t split[4];
uint32_t ip; u_int32_t ip;
uint32_t *x = (uint32_t *) addr; u_int32_t *x = (u_int32_t *) addr;
ip = ntohl(*x); ip = ntohl(*x);
split[0] = (ip & 0xff000000) >> 24; split[0] = (ip & 0xff000000) >> 24;
@ -73,12 +73,12 @@ static int addr_fprint(char *addr, FILE * dst)
} }
/* changes a c-string matching the perl regex \d+\.\d+\.\d+\.\d+ /* changes a c-string matching the perl regex \d+\.\d+\.\d+\.\d+
* into a uint32_t * into a u_int32_t
*/ */
static uint32_t str_to_addr(const char *addr) static u_int32_t str_to_addr(const char *addr)
{ {
uint32_t split[4]; u_int32_t split[4];
uint32_t ip; u_int32_t ip;
sscanf(addr, "%d.%d.%d.%d", sscanf(addr, "%d.%d.%d.%d",
&split[0], &split[1], &split[2], &split[3]); &split[0], &split[1], &split[2], &split[3]);
@ -174,4 +174,4 @@ int nslookup_main(int argc, char **argv)
return 0; return 0;
} }
/* $Id: nslookup.c,v 1.4 2000/02/08 19:58:47 erik Exp $ */ /* $Id: nslookup.c,v 1.5 2000/02/18 21:34:17 erik Exp $ */

View File

@ -58,9 +58,9 @@ static void server_fprint(FILE * dst)
/* only works for IPv4 */ /* only works for IPv4 */
static int addr_fprint(char *addr, FILE * dst) static int addr_fprint(char *addr, FILE * dst)
{ {
uint8_t split[4]; u_int8_t split[4];
uint32_t ip; u_int32_t ip;
uint32_t *x = (uint32_t *) addr; u_int32_t *x = (u_int32_t *) addr;
ip = ntohl(*x); ip = ntohl(*x);
split[0] = (ip & 0xff000000) >> 24; split[0] = (ip & 0xff000000) >> 24;
@ -73,12 +73,12 @@ static int addr_fprint(char *addr, FILE * dst)
} }
/* changes a c-string matching the perl regex \d+\.\d+\.\d+\.\d+ /* changes a c-string matching the perl regex \d+\.\d+\.\d+\.\d+
* into a uint32_t * into a u_int32_t
*/ */
static uint32_t str_to_addr(const char *addr) static u_int32_t str_to_addr(const char *addr)
{ {
uint32_t split[4]; u_int32_t split[4];
uint32_t ip; u_int32_t ip;
sscanf(addr, "%d.%d.%d.%d", sscanf(addr, "%d.%d.%d.%d",
&split[0], &split[1], &split[2], &split[3]); &split[0], &split[1], &split[2], &split[3]);
@ -174,4 +174,4 @@ int nslookup_main(int argc, char **argv)
return 0; return 0;
} }
/* $Id: nslookup.c,v 1.4 2000/02/08 19:58:47 erik Exp $ */ /* $Id: nslookup.c,v 1.5 2000/02/18 21:34:17 erik Exp $ */

View File

@ -365,6 +365,17 @@ extern int syslogd_main(int argc, char **argv)
*p++ = '\0'; *p++ = '\0';
} }
#ifdef BB_KLOGD
/* Start up the klogd process */
if (startKlogd == TRUE) {
klogd_pid = fork();
if (klogd_pid == 0) {
strncpy(argv[0], "klogd", strlen(argv[0]));
doKlogd();
}
}
#endif
if (doFork == TRUE) { if (doFork == TRUE) {
pid = fork(); pid = fork();
if (pid < 0) if (pid < 0)
@ -377,16 +388,5 @@ extern int syslogd_main(int argc, char **argv)
doSyslogd(); doSyslogd();
} }
#ifdef BB_KLOGD
/* Start up the klogd process */
if (startKlogd == TRUE) {
klogd_pid = fork();
if (klogd_pid == 0) {
strncpy(argv[0], "klogd", strlen(argv[0]));
doKlogd();
}
}
#endif
exit(TRUE); exit(TRUE);
} }

View File

@ -365,6 +365,17 @@ extern int syslogd_main(int argc, char **argv)
*p++ = '\0'; *p++ = '\0';
} }
#ifdef BB_KLOGD
/* Start up the klogd process */
if (startKlogd == TRUE) {
klogd_pid = fork();
if (klogd_pid == 0) {
strncpy(argv[0], "klogd", strlen(argv[0]));
doKlogd();
}
}
#endif
if (doFork == TRUE) { if (doFork == TRUE) {
pid = fork(); pid = fork();
if (pid < 0) if (pid < 0)
@ -377,16 +388,5 @@ extern int syslogd_main(int argc, char **argv)
doSyslogd(); doSyslogd();
} }
#ifdef BB_KLOGD
/* Start up the klogd process */
if (startKlogd == TRUE) {
klogd_pid = fork();
if (klogd_pid == 0) {
strncpy(argv[0], "klogd", strlen(argv[0]));
doKlogd();
}
}
#endif
exit(TRUE); exit(TRUE);
} }

2
tail.c
View File

@ -330,7 +330,7 @@ static int tail_file(const char *filename, off_t n_units)
/* Not standard input. */ /* Not standard input. */
fd = open(filename, O_RDONLY); fd = open(filename, O_RDONLY);
if (fd == -1) if (fd == -1)
errorMsg("open error"); fatalError("open error");
errors = tail_lines(filename, fd, (long) n_units); errors = tail_lines(filename, fd, (long) n_units);
close(fd); close(fd);

6
tar.c
View File

@ -596,6 +596,12 @@ readHeader(const TarHeader * hp, int fileCount, char **fileTable)
*/ */
if (S_ISDIR(mode)) { if (S_ISDIR(mode)) {
if (createPath(outName, mode) == TRUE) { if (createPath(outName, mode) == TRUE) {
/* make the final component, just in case it was
* omitted by createPath() (which will skip the
* directory if it doesn't have a terminating '/')
*/
mkdir(outName, mode);
/* Set the file time */ /* Set the file time */
utb.actime = mtime; utb.actime = mtime;
utb.modtime = mtime; utb.modtime = mtime;