This commit is contained in:
Eric Andersen 1999-11-15 17:33:30 +00:00
parent 80974fad03
commit a9c95ea655
12 changed files with 98 additions and 43 deletions

View File

@ -7,6 +7,10 @@
* If BB_CONSOLE_CMD_IF_RC_SCRIPT_EXITS is defined, then whatever * If BB_CONSOLE_CMD_IF_RC_SCRIPT_EXITS is defined, then whatever
command you define it as will be run if the init script exits. command you define it as will be run if the init script exits.
* Made createPath be quiet (again thanks to Eric Delaunay). * Made createPath be quiet (again thanks to Eric Delaunay).
* Updated to install.sh to make it more robust (thanks to Adam Di Carlo)
* NFS support added to mount by Eric Delaunay. It costs 10k when compiled
in, but that is still a big win for those that use NFS.
* Made 'rm -f' be silent for non-existant files (thanks to Eric Delaunay).
-Erik Andersen -Erik Andersen

View File

@ -34,11 +34,11 @@ ARCH=`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'`
# -D_GNU_SOURCE is needed because environ is used in init.c # -D_GNU_SOURCE is needed because environ is used in init.c
ifeq ($(DODEBUG),true) ifeq ($(DODEBUG),true)
CFLAGS=-Wall -g -D_GNU_SOURCE -DDEBUG_INIT CFLAGS+=-Wall -g -D_GNU_SOURCE -DDEBUG_INIT
STRIP= STRIP=
LDFLAGS= LDFLAGS=
else else
CFLAGS=-Wall -Os -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE CFLAGS+=-Wall -Os -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
LDFLAGS= -s LDFLAGS= -s
STRIP= strip --remove-section=.note --remove-section=.comment $(PROG) STRIP= strip --remove-section=.note --remove-section=.comment $(PROG)
#Only staticly link when _not_ debugging #Only staticly link when _not_ debugging

View File

@ -1,16 +1,21 @@
#!/bin/sh #!/bin/sh
set -e
if [ "$1" == "" ]; then if [ "$1" == "" ]; then
echo "No installation directory. aborting." echo "No installation directory, aborting."
exit 1; exit 1;
fi fi
h=`cat busybox.links` # can't just use cat, rmdir is not unique
#h=`cat busybox.links`
h=`sort busybox.links | uniq`
mkdir -p $1/bin mkdir -p $1/bin
for i in $h ; do for i in $h ; do
[ ${verbose} ] && echo " making link to $i"
mkdir -p $1/`echo $i | sed -e 's/\(^.*\/\)\(.*\)/\1/g' ` mkdir -p $1/`echo $i | sed -e 's/\(^.*\/\)\(.*\)/\1/g' `
(cd $1/bin ; ln -s busybox `echo $i | sed -e 's/\(^.*\/\)\(.*\)/\2/g' ` ) ln -s busybox $1/bin/`echo $i | sed -e 's/\(^.*\/\)\(.*\)/\2/g' `
done done
rm -f $1/bin/busybox rm -f $1/bin/busybox
install -m 755 busybox $1/bin/busybox install -m 755 busybox $1/bin/busybox

View File

@ -34,9 +34,10 @@
#define BB_MKDIR #define BB_MKDIR
#define BB_MKNOD #define BB_MKNOD
#define BB_MKSWAP #define BB_MKSWAP
#define BB_MNC //#define BB_MNC
#define BB_MORE #define BB_MORE
#define BB_MOUNT #define BB_MOUNT
#define BB_NFSMOUNT
//#define BB_MT //#define BB_MT
//#define BB_MTAB //#define BB_MTAB
#define BB_MV #define BB_MV

View File

@ -26,6 +26,7 @@
#include <time.h> #include <time.h>
#include <utime.h> #include <utime.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h>
static const char* rm_usage = "rm [OPTION]... FILE...\n\n" static const char* rm_usage = "rm [OPTION]... FILE...\n\n"
"Remove (unlink) the FILE(s).\n\n" "Remove (unlink) the FILE(s).\n\n"
@ -59,6 +60,7 @@ static int dirAction(const char *fileName, struct stat* statbuf)
extern int rm_main(int argc, char **argv) extern int rm_main(int argc, char **argv)
{ {
struct stat statbuf;
if (argc < 2) { if (argc < 2) {
usage( rm_usage); usage( rm_usage);
@ -85,9 +87,14 @@ extern int rm_main(int argc, char **argv)
while (argc-- > 0) { while (argc-- > 0) {
srcName = *(argv++); srcName = *(argv++);
if (recursiveAction( srcName, recursiveFlag, FALSE, TRUE, if (forceFlag == TRUE && lstat(srcName, &statbuf) != 0 && errno == ENOENT) {
fileAction, dirAction) == FALSE) { /* do not reports errors for non-existent files if -f, just skip them */
exit( FALSE); }
else {
if (recursiveAction( srcName, recursiveFlag, FALSE,
TRUE, fileAction, dirAction) == FALSE) {
exit( FALSE);
}
} }
} }
exit( TRUE); exit( TRUE);

4
init.c
View File

@ -538,3 +538,7 @@ extern int init_main(int argc, char **argv)
sleep(1); sleep(1);
} }
} }
#if defined FOO
#error Ack!
#endif

View File

@ -538,3 +538,7 @@ extern int init_main(int argc, char **argv)
sleep(1); sleep(1);
} }
} }
#if defined FOO
#error Ack!
#endif

View File

@ -1,16 +1,21 @@
#!/bin/sh #!/bin/sh
set -e
if [ "$1" == "" ]; then if [ "$1" == "" ]; then
echo "No installation directory. aborting." echo "No installation directory, aborting."
exit 1; exit 1;
fi fi
h=`cat busybox.links` # can't just use cat, rmdir is not unique
#h=`cat busybox.links`
h=`sort busybox.links | uniq`
mkdir -p $1/bin mkdir -p $1/bin
for i in $h ; do for i in $h ; do
[ ${verbose} ] && echo " making link to $i"
mkdir -p $1/`echo $i | sed -e 's/\(^.*\/\)\(.*\)/\1/g' ` mkdir -p $1/`echo $i | sed -e 's/\(^.*\/\)\(.*\)/\1/g' `
(cd $1/bin ; ln -s busybox `echo $i | sed -e 's/\(^.*\/\)\(.*\)/\2/g' ` ) ln -s busybox $1/bin/`echo $i | sed -e 's/\(^.*\/\)\(.*\)/\2/g' `
done done
rm -f $1/bin/busybox rm -f $1/bin/busybox
install -m 755 busybox $1/bin/busybox install -m 755 busybox $1/bin/busybox

View File

@ -158,6 +158,10 @@ extern void erase_mtab(const char * name);
extern void whine_if_fstab_is_missing(); extern void whine_if_fstab_is_missing();
#endif #endif
#if defined BB_NFSMOUNT
int nfsmount(const char *spec, const char *node, unsigned long *flags,
char **extra_opts, char **mount_opts, int running_bg);
#endif
#if defined (BB_FSCK_MINIX) || defined (BB_MKFS_MINIX) #if defined (BB_FSCK_MINIX) || defined (BB_MKFS_MINIX)

35
mount.c
View File

@ -92,12 +92,12 @@ static const struct mount_options mount_options[] = {
}; };
#if ! defined BB_MTAB #if ! defined BB_MTAB
#define do_mount(specialfile, dir, filesystemtype, flags, string_flags, useMtab, fakeIt) \ #define do_mount(specialfile, dir, filesystemtype, flags, string_flags, useMtab, fakeIt, mtab_opts) \
mount(specialfile, dir, filesystemtype, flags, string_flags) mount(specialfile, dir, filesystemtype, flags, string_flags)
#else #else
static int static int
do_mount(char* specialfile, char* dir, char* filesystemtype, do_mount(char* specialfile, char* dir, char* filesystemtype,
long flags, void* string_flags, int useMtab, int fakeIt) long flags, void* string_flags, int useMtab, int fakeIt, char* mtab_opts)
{ {
int status=0; int status=0;
@ -106,7 +106,7 @@ do_mount(char* specialfile, char* dir, char* filesystemtype,
if ( status == 0 ) { if ( status == 0 ) {
if ( useMtab==TRUE ) if ( useMtab==TRUE )
write_mtab(specialfile, dir, filesystemtype, flags, string_flags); write_mtab(specialfile, dir, filesystemtype, flags, mtab_opts);
return 0; return 0;
} }
else else
@ -157,7 +157,7 @@ parse_mount_options ( char *options, unsigned long *flags, char *strflags)
int int
mount_one(char *blockDevice, char *directory, char *filesystemType, mount_one(char *blockDevice, char *directory, char *filesystemType,
unsigned long flags, char *string_flags, int useMtab, int fakeIt) unsigned long flags, char *string_flags, int useMtab, int fakeIt, char *mtab_opts)
{ {
int status = 0; int status = 0;
@ -182,7 +182,8 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
filesystemType++; // hop past tab filesystemType++; // hop past tab
status = do_mount (blockDevice, directory, filesystemType, status = do_mount (blockDevice, directory, filesystemType,
flags | MS_MGC_VAL, string_flags, useMtab, fakeIt); flags | MS_MGC_VAL, string_flags, useMtab,
fakeIt, mtab_opts);
if (status == 0) if (status == 0)
break; break;
} }
@ -190,7 +191,8 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
fclose (f); fclose (f);
} else { } else {
status = do_mount (blockDevice, directory, filesystemType, status = do_mount (blockDevice, directory, filesystemType,
flags | MS_MGC_VAL, string_flags, useMtab, fakeIt); flags | MS_MGC_VAL, string_flags, useMtab,
fakeIt, mtab_opts);
} }
if (status) { if (status) {
@ -203,7 +205,9 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
extern int mount_main (int argc, char **argv) extern int mount_main (int argc, char **argv)
{ {
char string_flags[1024]=""; char string_flags_buf[1024]="";
char *string_flags = string_flags_buf;
char *extra_opts = string_flags_buf;
unsigned long flags = 0; unsigned long flags = 0;
char *filesystemType = "auto"; char *filesystemType = "auto";
char *device = NULL; char *device = NULL;
@ -245,14 +249,13 @@ extern int mount_main (int argc, char **argv)
argv++; argv++;
while (i > 0 && **argv) { while (i > 0 && **argv) {
if (**argv == '-') { if (**argv == '-') {
while (i>0 && *++(*argv)) switch (**argv) { char *opt = *argv;
while (i>0 && *++opt) switch (*opt) {
case 'o': case 'o':
if (--i == 0) { if (--i == 0) {
goto goodbye; goto goodbye;
} }
parse_mount_options (*(++argv), &flags, string_flags); parse_mount_options (*(++argv), &flags, string_flags);
--i;
++argv;
break; break;
case 'r': case 'r':
flags |= MS_RDONLY; flags |= MS_RDONLY;
@ -262,8 +265,6 @@ extern int mount_main (int argc, char **argv)
goto goodbye; goto goodbye;
} }
filesystemType = *(++argv); filesystemType = *(++argv);
--i;
++argv;
break; break;
case 'w': case 'w':
flags &= ~MS_RDONLY; flags &= ~MS_RDONLY;
@ -317,14 +318,20 @@ extern int mount_main (int argc, char **argv)
*string_flags = '\0'; *string_flags = '\0';
parse_mount_options(m->mnt_opts, &flags, string_flags); parse_mount_options(m->mnt_opts, &flags, string_flags);
mount_one (m->mnt_fsname, m->mnt_dir, m->mnt_type, mount_one (m->mnt_fsname, m->mnt_dir, m->mnt_type,
flags, string_flags, useMtab, fakeIt); flags, string_flags, useMtab, fakeIt, extra_opts);
} }
} }
endmntent (f); endmntent (f);
} else { } else {
if (device && directory) { if (device && directory) {
#ifdef BB_NFSMOUNT
if (strcmp(filesystemType, "nfs") == 0) {
if (nfsmount(device, directory, &flags, &extra_opts, &string_flags, 1) != 0)
exit(FALSE);
}
#endif
exit (mount_one (device, directory, filesystemType, exit (mount_one (device, directory, filesystemType,
flags, string_flags, useMtab, fakeIt)); flags, string_flags, useMtab, fakeIt, extra_opts));
} else { } else {
goto goodbye; goto goodbye;
} }

13
rm.c
View File

@ -26,6 +26,7 @@
#include <time.h> #include <time.h>
#include <utime.h> #include <utime.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h>
static const char* rm_usage = "rm [OPTION]... FILE...\n\n" static const char* rm_usage = "rm [OPTION]... FILE...\n\n"
"Remove (unlink) the FILE(s).\n\n" "Remove (unlink) the FILE(s).\n\n"
@ -59,6 +60,7 @@ static int dirAction(const char *fileName, struct stat* statbuf)
extern int rm_main(int argc, char **argv) extern int rm_main(int argc, char **argv)
{ {
struct stat statbuf;
if (argc < 2) { if (argc < 2) {
usage( rm_usage); usage( rm_usage);
@ -85,9 +87,14 @@ extern int rm_main(int argc, char **argv)
while (argc-- > 0) { while (argc-- > 0) {
srcName = *(argv++); srcName = *(argv++);
if (recursiveAction( srcName, recursiveFlag, FALSE, TRUE, if (forceFlag == TRUE && lstat(srcName, &statbuf) != 0 && errno == ENOENT) {
fileAction, dirAction) == FALSE) { /* do not reports errors for non-existent files if -f, just skip them */
exit( FALSE); }
else {
if (recursiveAction( srcName, recursiveFlag, FALSE,
TRUE, fileAction, dirAction) == FALSE) {
exit( FALSE);
}
} }
} }
exit( TRUE); exit( TRUE);

View File

@ -92,12 +92,12 @@ static const struct mount_options mount_options[] = {
}; };
#if ! defined BB_MTAB #if ! defined BB_MTAB
#define do_mount(specialfile, dir, filesystemtype, flags, string_flags, useMtab, fakeIt) \ #define do_mount(specialfile, dir, filesystemtype, flags, string_flags, useMtab, fakeIt, mtab_opts) \
mount(specialfile, dir, filesystemtype, flags, string_flags) mount(specialfile, dir, filesystemtype, flags, string_flags)
#else #else
static int static int
do_mount(char* specialfile, char* dir, char* filesystemtype, do_mount(char* specialfile, char* dir, char* filesystemtype,
long flags, void* string_flags, int useMtab, int fakeIt) long flags, void* string_flags, int useMtab, int fakeIt, char* mtab_opts)
{ {
int status=0; int status=0;
@ -106,7 +106,7 @@ do_mount(char* specialfile, char* dir, char* filesystemtype,
if ( status == 0 ) { if ( status == 0 ) {
if ( useMtab==TRUE ) if ( useMtab==TRUE )
write_mtab(specialfile, dir, filesystemtype, flags, string_flags); write_mtab(specialfile, dir, filesystemtype, flags, mtab_opts);
return 0; return 0;
} }
else else
@ -157,7 +157,7 @@ parse_mount_options ( char *options, unsigned long *flags, char *strflags)
int int
mount_one(char *blockDevice, char *directory, char *filesystemType, mount_one(char *blockDevice, char *directory, char *filesystemType,
unsigned long flags, char *string_flags, int useMtab, int fakeIt) unsigned long flags, char *string_flags, int useMtab, int fakeIt, char *mtab_opts)
{ {
int status = 0; int status = 0;
@ -182,7 +182,8 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
filesystemType++; // hop past tab filesystemType++; // hop past tab
status = do_mount (blockDevice, directory, filesystemType, status = do_mount (blockDevice, directory, filesystemType,
flags | MS_MGC_VAL, string_flags, useMtab, fakeIt); flags | MS_MGC_VAL, string_flags, useMtab,
fakeIt, mtab_opts);
if (status == 0) if (status == 0)
break; break;
} }
@ -190,7 +191,8 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
fclose (f); fclose (f);
} else { } else {
status = do_mount (blockDevice, directory, filesystemType, status = do_mount (blockDevice, directory, filesystemType,
flags | MS_MGC_VAL, string_flags, useMtab, fakeIt); flags | MS_MGC_VAL, string_flags, useMtab,
fakeIt, mtab_opts);
} }
if (status) { if (status) {
@ -203,7 +205,9 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
extern int mount_main (int argc, char **argv) extern int mount_main (int argc, char **argv)
{ {
char string_flags[1024]=""; char string_flags_buf[1024]="";
char *string_flags = string_flags_buf;
char *extra_opts = string_flags_buf;
unsigned long flags = 0; unsigned long flags = 0;
char *filesystemType = "auto"; char *filesystemType = "auto";
char *device = NULL; char *device = NULL;
@ -245,14 +249,13 @@ extern int mount_main (int argc, char **argv)
argv++; argv++;
while (i > 0 && **argv) { while (i > 0 && **argv) {
if (**argv == '-') { if (**argv == '-') {
while (i>0 && *++(*argv)) switch (**argv) { char *opt = *argv;
while (i>0 && *++opt) switch (*opt) {
case 'o': case 'o':
if (--i == 0) { if (--i == 0) {
goto goodbye; goto goodbye;
} }
parse_mount_options (*(++argv), &flags, string_flags); parse_mount_options (*(++argv), &flags, string_flags);
--i;
++argv;
break; break;
case 'r': case 'r':
flags |= MS_RDONLY; flags |= MS_RDONLY;
@ -262,8 +265,6 @@ extern int mount_main (int argc, char **argv)
goto goodbye; goto goodbye;
} }
filesystemType = *(++argv); filesystemType = *(++argv);
--i;
++argv;
break; break;
case 'w': case 'w':
flags &= ~MS_RDONLY; flags &= ~MS_RDONLY;
@ -317,14 +318,20 @@ extern int mount_main (int argc, char **argv)
*string_flags = '\0'; *string_flags = '\0';
parse_mount_options(m->mnt_opts, &flags, string_flags); parse_mount_options(m->mnt_opts, &flags, string_flags);
mount_one (m->mnt_fsname, m->mnt_dir, m->mnt_type, mount_one (m->mnt_fsname, m->mnt_dir, m->mnt_type,
flags, string_flags, useMtab, fakeIt); flags, string_flags, useMtab, fakeIt, extra_opts);
} }
} }
endmntent (f); endmntent (f);
} else { } else {
if (device && directory) { if (device && directory) {
#ifdef BB_NFSMOUNT
if (strcmp(filesystemType, "nfs") == 0) {
if (nfsmount(device, directory, &flags, &extra_opts, &string_flags, 1) != 0)
exit(FALSE);
}
#endif
exit (mount_one (device, directory, filesystemType, exit (mount_one (device, directory, filesystemType,
flags, string_flags, useMtab, fakeIt)); flags, string_flags, useMtab, fakeIt, extra_opts));
} else { } else {
goto goodbye; goto goodbye;
} }