diff options
-rw-r--r-- | Changelog | 4 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rwxr-xr-x | applets/install.sh | 11 | ||||
-rw-r--r-- | busybox.def.h | 3 | ||||
-rw-r--r-- | coreutils/rm.c | 13 | ||||
-rw-r--r-- | init.c | 4 | ||||
-rw-r--r-- | init/init.c | 4 | ||||
-rwxr-xr-x | install.sh | 11 | ||||
-rw-r--r-- | internal.h | 4 | ||||
-rw-r--r-- | mount.c | 35 | ||||
-rw-r--r-- | rm.c | 13 | ||||
-rw-r--r-- | util-linux/mount.c | 35 |
12 files changed, 98 insertions, 43 deletions
@@ -7,6 +7,10 @@ * 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 @@ -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 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 diff --git a/applets/install.sh b/applets/install.sh index 4a0b83254..29c9e26d9 100755 --- a/applets/install.sh +++ b/applets/install.sh @@ -1,16 +1,21 @@ #!/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 diff --git a/busybox.def.h b/busybox.def.h index 6e2b818d6..657ce4383 100644 --- a/busybox.def.h +++ b/busybox.def.h @@ -34,9 +34,10 @@ #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 diff --git a/coreutils/rm.c b/coreutils/rm.c index e6132ab35..ba5d30e92 100644 --- a/coreutils/rm.c +++ b/coreutils/rm.c @@ -26,6 +26,7 @@ #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" @@ -59,6 +60,7 @@ static int dirAction(const char *fileName, struct stat* statbuf) extern int rm_main(int argc, char **argv) { + struct stat statbuf; if (argc < 2) { usage( rm_usage); @@ -85,9 +87,14 @@ extern int rm_main(int argc, char **argv) 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); @@ -538,3 +538,7 @@ extern int init_main(int argc, char **argv) sleep(1); } } + +#if defined FOO + #error Ack! +#endif diff --git a/init/init.c b/init/init.c index a3e8d6700..980150ff5 100644 --- a/init/init.c +++ b/init/init.c @@ -538,3 +538,7 @@ extern int init_main(int argc, char **argv) sleep(1); } } + +#if defined FOO + #error Ack! +#endif diff --git a/install.sh b/install.sh index 4a0b83254..29c9e26d9 100755 --- a/install.sh +++ b/install.sh @@ -1,16 +1,21 @@ #!/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 diff --git a/internal.h b/internal.h index 0e7054f14..32a21ce5b 100644 --- a/internal.h +++ b/internal.h @@ -158,6 +158,10 @@ extern void erase_mtab(const char * name); 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) @@ -92,12 +92,12 @@ static const struct mount_options mount_options[] = { }; #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; @@ -106,7 +106,7 @@ do_mount(char* specialfile, char* dir, char* filesystemtype, 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 @@ -157,7 +157,7 @@ parse_mount_options ( char *options, unsigned long *flags, char *strflags) 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; @@ -182,7 +182,8 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, 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; } @@ -190,7 +191,8 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, 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) { @@ -203,7 +205,9 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, 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; @@ -245,14 +249,13 @@ extern int mount_main (int argc, char **argv) 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; @@ -262,8 +265,6 @@ extern int mount_main (int argc, char **argv) goto goodbye; } filesystemType = *(++argv); - --i; - ++argv; break; case 'w': flags &= ~MS_RDONLY; @@ -317,14 +318,20 @@ extern int mount_main (int argc, char **argv) *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; } @@ -26,6 +26,7 @@ #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" @@ -59,6 +60,7 @@ static int dirAction(const char *fileName, struct stat* statbuf) extern int rm_main(int argc, char **argv) { + struct stat statbuf; if (argc < 2) { usage( rm_usage); @@ -85,9 +87,14 @@ extern int rm_main(int argc, char **argv) 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); diff --git a/util-linux/mount.c b/util-linux/mount.c index 827a56f0a..a9463afba 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -92,12 +92,12 @@ static const struct mount_options mount_options[] = { }; #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; @@ -106,7 +106,7 @@ do_mount(char* specialfile, char* dir, char* filesystemtype, 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 @@ -157,7 +157,7 @@ parse_mount_options ( char *options, unsigned long *flags, char *strflags) 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; @@ -182,7 +182,8 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, 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; } @@ -190,7 +191,8 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, 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) { @@ -203,7 +205,9 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, 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; @@ -245,14 +249,13 @@ extern int mount_main (int argc, char **argv) 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; @@ -262,8 +265,6 @@ extern int mount_main (int argc, char **argv) goto goodbye; } filesystemType = *(++argv); - --i; - ++argv; break; case 'w': flags &= ~MS_RDONLY; @@ -317,14 +318,20 @@ extern int mount_main (int argc, char **argv) *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; } |