* 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.
* 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
# -D_GNU_SOURCE is needed because environ is used in init.c
ifeq ($(DODEBUG),true)
- CFLAGS=-Wall -g -D_GNU_SOURCE -DDEBUG_INIT
+ CFLAGS+=-Wall -g -D_GNU_SOURCE -DDEBUG_INIT
STRIP=
LDFLAGS=
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
STRIP= strip --remove-section=.note --remove-section=.comment $(PROG)
#Only staticly link when _not_ debugging
#!/bin/sh
+set -e
+
if [ "$1" == "" ]; then
- echo "No installation directory. aborting."
+ echo "No installation directory, aborting."
exit 1;
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
for i in $h ; do
+ [ ${verbose} ] && echo " making link to $i"
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
rm -f $1/bin/busybox
install -m 755 busybox $1/bin/busybox
#define BB_MKDIR
#define BB_MKNOD
#define BB_MKSWAP
-#define BB_MNC
+//#define BB_MNC
#define BB_MORE
#define BB_MOUNT
+#define BB_NFSMOUNT
//#define BB_MT
//#define BB_MTAB
#define BB_MV
#include <time.h>
#include <utime.h>
#include <dirent.h>
+#include <errno.h>
static const char* rm_usage = "rm [OPTION]... FILE...\n\n"
"Remove (unlink) the FILE(s).\n\n"
extern int rm_main(int argc, char **argv)
{
+ struct stat statbuf;
if (argc < 2) {
usage( rm_usage);
while (argc-- > 0) {
srcName = *(argv++);
- if (recursiveAction( srcName, recursiveFlag, FALSE, TRUE,
- fileAction, dirAction) == FALSE) {
- exit( FALSE);
+ if (forceFlag == TRUE && lstat(srcName, &statbuf) != 0 && errno == ENOENT) {
+ /* do not reports errors for non-existent files if -f, just skip them */
+ }
+ else {
+ if (recursiveAction( srcName, recursiveFlag, FALSE,
+ TRUE, fileAction, dirAction) == FALSE) {
+ exit( FALSE);
+ }
}
}
exit( TRUE);
sleep(1);
}
}
+
+#if defined FOO
+ #error Ack!
+#endif
sleep(1);
}
}
+
+#if defined FOO
+ #error Ack!
+#endif
#!/bin/sh
+set -e
+
if [ "$1" == "" ]; then
- echo "No installation directory. aborting."
+ echo "No installation directory, aborting."
exit 1;
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
for i in $h ; do
+ [ ${verbose} ] && echo " making link to $i"
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
rm -f $1/bin/busybox
install -m 755 busybox $1/bin/busybox
extern void whine_if_fstab_is_missing();
#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_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)
#else
static int
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;
if ( status == 0 ) {
if ( useMtab==TRUE )
- write_mtab(specialfile, dir, filesystemtype, flags, string_flags);
+ write_mtab(specialfile, dir, filesystemtype, flags, mtab_opts);
return 0;
}
else
int
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;
filesystemType++; // hop past tab
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)
break;
}
fclose (f);
} else {
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) {
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;
char *filesystemType = "auto";
char *device = NULL;
argv++;
while (i > 0 && **argv) {
if (**argv == '-') {
- while (i>0 && *++(*argv)) switch (**argv) {
+ char *opt = *argv;
+ while (i>0 && *++opt) switch (*opt) {
case 'o':
if (--i == 0) {
goto goodbye;
}
parse_mount_options (*(++argv), &flags, string_flags);
- --i;
- ++argv;
break;
case 'r':
flags |= MS_RDONLY;
goto goodbye;
}
filesystemType = *(++argv);
- --i;
- ++argv;
break;
case 'w':
flags &= ~MS_RDONLY;
*string_flags = '\0';
parse_mount_options(m->mnt_opts, &flags, string_flags);
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);
} else {
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,
- flags, string_flags, useMtab, fakeIt));
+ flags, string_flags, useMtab, fakeIt, extra_opts));
} else {
goto goodbye;
}
#include <time.h>
#include <utime.h>
#include <dirent.h>
+#include <errno.h>
static const char* rm_usage = "rm [OPTION]... FILE...\n\n"
"Remove (unlink) the FILE(s).\n\n"
extern int rm_main(int argc, char **argv)
{
+ struct stat statbuf;
if (argc < 2) {
usage( rm_usage);
while (argc-- > 0) {
srcName = *(argv++);
- if (recursiveAction( srcName, recursiveFlag, FALSE, TRUE,
- fileAction, dirAction) == FALSE) {
- exit( FALSE);
+ if (forceFlag == TRUE && lstat(srcName, &statbuf) != 0 && errno == ENOENT) {
+ /* do not reports errors for non-existent files if -f, just skip them */
+ }
+ else {
+ if (recursiveAction( srcName, recursiveFlag, FALSE,
+ TRUE, fileAction, dirAction) == FALSE) {
+ exit( FALSE);
+ }
}
}
exit( TRUE);
};
#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)
#else
static int
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;
if ( status == 0 ) {
if ( useMtab==TRUE )
- write_mtab(specialfile, dir, filesystemtype, flags, string_flags);
+ write_mtab(specialfile, dir, filesystemtype, flags, mtab_opts);
return 0;
}
else
int
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;
filesystemType++; // hop past tab
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)
break;
}
fclose (f);
} else {
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) {
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;
char *filesystemType = "auto";
char *device = NULL;
argv++;
while (i > 0 && **argv) {
if (**argv == '-') {
- while (i>0 && *++(*argv)) switch (**argv) {
+ char *opt = *argv;
+ while (i>0 && *++opt) switch (*opt) {
case 'o':
if (--i == 0) {
goto goodbye;
}
parse_mount_options (*(++argv), &flags, string_flags);
- --i;
- ++argv;
break;
case 'r':
flags |= MS_RDONLY;
goto goodbye;
}
filesystemType = *(++argv);
- --i;
- ++argv;
break;
case 'w':
flags &= ~MS_RDONLY;
*string_flags = '\0';
parse_mount_options(m->mnt_opts, &flags, string_flags);
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);
} else {
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,
- flags, string_flags, useMtab, fakeIt));
+ flags, string_flags, useMtab, fakeIt, extra_opts));
} else {
goto goodbye;
}