From: Erik Andersen Date: Thu, 13 Jan 2000 04:43:48 +0000 (-0000) Subject: Bug fixes. X-Git-Tag: 0_41~3 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=05df239ed90584156b820dbf3ede638208eb440f;p=oweals%2Fbusybox.git Bug fixes. -Erik --- diff --git a/Changelog b/Changelog index 823598033..d0878bc9c 100644 --- a/Changelog +++ b/Changelog @@ -1,12 +1,17 @@ 0.41 + * New App: wc -- contributed by Edward Betts * Fixed a bug in both cp and mv preventing 'cp foo/README bar' type commands (file in a directory to another directory) from working. * Fixed a logger bug that caused garbage to be written to the syslog (unless you used busybox syslog, which hid the bug). Thanks to Alex Holden for the fix. + * /bin/true and /bin/false were echoing a blank line when run. Now fixed. + * mkdir -p would print an error when asked to mkdir an existing dir + with no interveining subdirectories. + * Fixed "syslogd -O" so that it works. - -Erik Andersen, + -Erik Andersen 0.40 * New Apps: sort, uniq. -beppu diff --git a/Makefile b/Makefile index f1f25cd43..d0779c5c0 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ PROG=busybox -VERSION=0.40 +VERSION=0.41 BUILDTIME=$(shell date "+%Y%m%d-%H%M") # Comment out the following to make a debuggable build diff --git a/TODO b/TODO index 24df1cf9f..4d209bb46 100644 --- a/TODO +++ b/TODO @@ -18,7 +18,6 @@ around to it some time. If you have any good ideas, please let me know. * hwclock * killall * stty -* wc * tr * expr (maybe?) (ash builtin?) diff --git a/applets/busybox.c b/applets/busybox.c index 4a7feefd2..a00f90be0 100644 --- a/applets/busybox.c +++ b/applets/busybox.c @@ -5,6 +5,16 @@ static int been_there_done_that = 0; +#if 0 +void exit (int status) __attribute__ ((noreturn)); +void exit (int status) { _exit(status); }; +void abort (void) __attribute__ ((__noreturn__)); +void abort (void) { _exit(0); }; +int atexit (void (*__func) (void)) { _exit(0); }; +void *__libc_stack_end; +#endif + + static const struct Applet applets[] = { #ifdef BB_BUSYBOX //bin @@ -219,6 +229,9 @@ static const struct Applet applets[] = { {"true", true_main}, {"false", false_main}, #endif +#ifdef BB_WC //usr/bin + {"wc", wc_main}, +#endif #ifdef BB_UNAME //bin {"uname", uname_main}, #endif @@ -241,6 +254,8 @@ static const struct Applet applets[] = { {0} }; + + int main(int argc, char **argv) { char *s = argv[0]; diff --git a/busybox.c b/busybox.c index 4a7feefd2..a00f90be0 100644 --- a/busybox.c +++ b/busybox.c @@ -5,6 +5,16 @@ static int been_there_done_that = 0; +#if 0 +void exit (int status) __attribute__ ((noreturn)); +void exit (int status) { _exit(status); }; +void abort (void) __attribute__ ((__noreturn__)); +void abort (void) { _exit(0); }; +int atexit (void (*__func) (void)) { _exit(0); }; +void *__libc_stack_end; +#endif + + static const struct Applet applets[] = { #ifdef BB_BUSYBOX //bin @@ -219,6 +229,9 @@ static const struct Applet applets[] = { {"true", true_main}, {"false", false_main}, #endif +#ifdef BB_WC //usr/bin + {"wc", wc_main}, +#endif #ifdef BB_UNAME //bin {"uname", uname_main}, #endif @@ -241,6 +254,8 @@ static const struct Applet applets[] = { {0} }; + + int main(int argc, char **argv) { char *s = argv[0]; diff --git a/busybox.def.h b/busybox.def.h index 834555302..65ed365a5 100644 --- a/busybox.def.h +++ b/busybox.def.h @@ -72,12 +72,13 @@ #define BB_SORT #define BB_SWAPONOFF #define BB_SYNC -//#define BB_SYSLOGD +#define BB_SYSLOGD #define BB_TAIL #define BB_TAR #define BB_TEE #define BB_TOUCH #define BB_TRUE_FALSE +#define BB_WC #define BB_UMOUNT #define BB_UNIQ #define BB_UPDATE diff --git a/busybox.spec b/busybox.spec index d1a702642..ae7010186 100644 --- a/busybox.spec +++ b/busybox.spec @@ -1,5 +1,5 @@ Name: busybox -Version: 0.40 +Version: 0.41 Release: 1 Group: System/Utilities Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary. @@ -21,7 +21,7 @@ embedded system. %setup -q -n %{Name}-%{Version} %Build -BB_INIT_SCRIPT='\"/etc/rc.d/init.d/rcS\"' make +make %Install rm -rf $RPM_BUILD_ROOT diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c index 9ea3b4ea0..dc245a18e 100644 --- a/coreutils/mkdir.c +++ b/coreutils/mkdir.c @@ -84,7 +84,7 @@ extern int mkdir_main(int argc, char **argv) strcpy (buf, *argv); status=stat(buf, &statBuf); - if (status != -1 && status != ENOENT ) { + if (parentFlag == FALSE && status != -1 && status != ENOENT ) { fprintf(stderr, "%s: File exists\n", buf); exit( FALSE); } @@ -93,7 +93,7 @@ extern int mkdir_main(int argc, char **argv) createPath(buf, mode); } else { - if (mkdir (buf, mode) != 0) { + if (mkdir (buf, mode) != 0 && parentFlag == FALSE) { perror(buf); exit( FALSE); } diff --git a/docs/CommandList b/docs/CommandList index 39c72a17a..8c0a01e23 100644 --- a/docs/CommandList +++ b/docs/CommandList @@ -12,6 +12,9 @@ ________________________________________________________________________________ BusyBox 0.38, Functions and the Arguments they Support +New Apps that have been added to BusyBox since this document was written: + ping, hostname, mkfifo, free, tail, du, tee, head, sort, uniq, lsmod, rmmod, fbset, and loadacm. + ______________________________________________________________________________________________________ @@ -154,7 +157,7 @@ cp [option] fileA fileB attributes group permissions and time information. - -R recursive Copy to the current location and all subdirectories in the tree. + -R recursive Copies directories recursively @@ -321,7 +324,7 @@ fsck.minix [-larvsmf] /dev/name -r Perform interactive repairs. - -q Perform automatic repairs + -a Perform automatic repairs -v Verbose @@ -712,29 +715,30 @@ ________________________________________________________________________________ - sed + Usage: sed [-n] -e script [file...] - Sed scripts are subject to the following format: 's/regexp/replacement/[gp]' which attempts to - - to match regexp against the pattern space and if successful, replaces the matched portion with - - replacement -r or -R Remove contents of directories recursively. - - - - -________________________________________________________________________________________________________ - - - - + Allowed sed scripts come in the following form: + 'ADDR [!] COMMAND' -rmdir [OPTION] ... directory + where address ADDR can be: + NUMBER Match specified line number + $ Match last line + /REGEXP/ Match specified regexp + (! inverts the meaning of the match) - Remove directories if they are empty. + and COMMAND can be: + s/regexp/replacement/[igp] + which attempt to match regexp against the pattern space + and if successful replaces the matched portion with replacement. + aTEXT + which appends TEXT after the pattern space + Options: + -e add the script to the commands to be executed + -n suppress automatic printing of pattern space + This version of sed matches full regular expresions. @@ -744,51 +748,6 @@ ________________________________________________________________________________ -rmdir [OPTION] ... directory - - Remove directories if they are empty. - - - - -________________________________________________________________________________________________________ - - - - - -sed - - Sed scripts are subject to the following format: 's/regexp/replacement/[gp]' which attempts to - - match regexp against the pattern space and if successful, replaces the matched portion with - - replacement. This version of sed matches - - full regular expressions. - - -e Add the script to the commands to be executed. - - -n Suppress automatic printing of pattern space.. - - -e Add the script to the commands to be executed. - - -n Suppress automatic printing of pattern space.. - - -e Add the script to the commands to be executed. - - -n Suppress automatic printing of pattern space. - - - - - -________________________________________________________________________________________________________ - - - - - sleep N Pause for N seconds. @@ -977,10 +936,14 @@ ________________________________________________________________________________ zcat [options] files - Uncompress file from gzip, gunzip or compress command or standard input if file is '-'. + Usage: zcat [OPTION]... FILE - -c Write output to standard output. + Uncompress FILE (or standard input if FILE is '-'). + (When invoked as zcat, defaults to having -c turned on) + Options: + -c Write output to standard output + -t Test compressed file integrity @@ -991,7 +954,7 @@ ________________________________________________________________________________ -gunzip (Same as zcat) +gunzip (Same as zcat, but without the "-c" option.) @@ -1003,10 +966,13 @@ ________________________________________________________________________________ +gzip [OPTION]... FILE -gzip (Same as zcat) - + Compress FILE with maximum compression. + When FILE is -, reads standard input. Implies -c. + Options: + -c Write output to standard output instead of FILE.gz diff --git a/examples/busybox.spec b/examples/busybox.spec index d1a702642..ae7010186 100644 --- a/examples/busybox.spec +++ b/examples/busybox.spec @@ -1,5 +1,5 @@ Name: busybox -Version: 0.40 +Version: 0.41 Release: 1 Group: System/Utilities Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary. @@ -21,7 +21,7 @@ embedded system. %setup -q -n %{Name}-%{Version} %Build -BB_INIT_SCRIPT='\"/etc/rc.d/init.d/rcS\"' make +make %Install rm -rf $RPM_BUILD_ROOT diff --git a/init.c b/init.c index 8a48380e9..b4ab1c751 100644 --- a/init.c +++ b/init.c @@ -331,7 +331,7 @@ static void console_init() static pid_t run(char* command, char *terminal, int get_enter) { - int i; + int i, fd; pid_t pid; char* tmpCmd; char* cmd[255]; @@ -357,21 +357,20 @@ static pid_t run(char* command, close(2); setsid(); - if (device_open(terminal, O_RDWR) < 0) { - message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal); - exit(1); - } - dup(0); - dup(0); - tcsetpgrp (0, getpgrp()); - set_term(0); - /* Reset signal handlers set for parent process */ signal(SIGUSR1, SIG_DFL); signal(SIGUSR2, SIG_DFL); signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); + if ((fd = device_open(terminal, O_RDWR)) < 0) { + message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal); + exit(1); + } + dup(fd); + dup(fd); + tcsetpgrp (0, getpgrp()); + set_term(0); if (get_enter==TRUE) { /* @@ -389,19 +388,21 @@ static pid_t run(char* command, read(fileno(stdin), &c, 1); } + /* Log the process name and args */ + message(LOG|CONSOLE, "Starting pid %d, console %s: '", + shell_pgid, terminal, command); + /* Convert command (char*) into cmd (char**, one word per string) */ for (tmpCmd=command, i=0; (tmpCmd=strsep(&command, " \t")) != NULL;) { if (*tmpCmd != '\0') { cmd[i] = tmpCmd; + message(LOG|CONSOLE, "%s ", tmpCmd); tmpCmd++; i++; } } cmd[i] = NULL; - - /* Log the process name and args */ - message(LOG, "Starting pid %d, console %s: '%s'\r\n", - shell_pgid, terminal, cmd[0]); + message(LOG|CONSOLE, "'\r\n"); /* Now run it. The new program will take over this PID, * so nothing further in init.c should be run. */ @@ -540,8 +541,8 @@ void new_initAction (initActionEnum action, } else strncpy(newAction->console, console, 255); newAction->pid = 0; -// message(LOG|CONSOLE, "process='%s' action='%d' console='%s'\n", -// newAction->process, newAction->action, newAction->console); + message(LOG|CONSOLE, "process='%s' action='%d' console='%s'\n", + newAction->process, newAction->action, newAction->console); } void delete_initAction (initAction *action) @@ -672,11 +673,8 @@ extern int init_main(int argc, char **argv) usage( "init\n\nInit is the parent of all processes.\n\n" "This version of init is designed to be run only by the kernel\n"); } - - /* from the controlling terminal */ - setsid(); - - /* Set up sig handlers -- be sure to clear all of these in run() */ + /* Set up sig handlers -- be sure to + * clear all of these in run() */ signal(SIGUSR1, halt_signal); signal(SIGUSR2, reboot_signal); signal(SIGINT, reboot_signal); @@ -686,7 +684,7 @@ extern int init_main(int argc, char **argv) * SIGINT on CAD so we can shut things down gracefully... */ reboot(RB_DISABLE_CAD); #endif - + /* Figure out where the default console should be */ console_init(); @@ -695,11 +693,11 @@ extern int init_main(int argc, char **argv) close(1); close(2); set_term(0); + setsid(); /* Make sure PATH is set to something sane */ putenv(_PATH_STDPATH); - /* Hello world */ #ifndef DEBUG_INIT message(LOG|CONSOLE, diff --git a/init/init.c b/init/init.c index 8a48380e9..b4ab1c751 100644 --- a/init/init.c +++ b/init/init.c @@ -331,7 +331,7 @@ static void console_init() static pid_t run(char* command, char *terminal, int get_enter) { - int i; + int i, fd; pid_t pid; char* tmpCmd; char* cmd[255]; @@ -357,21 +357,20 @@ static pid_t run(char* command, close(2); setsid(); - if (device_open(terminal, O_RDWR) < 0) { - message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal); - exit(1); - } - dup(0); - dup(0); - tcsetpgrp (0, getpgrp()); - set_term(0); - /* Reset signal handlers set for parent process */ signal(SIGUSR1, SIG_DFL); signal(SIGUSR2, SIG_DFL); signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); + if ((fd = device_open(terminal, O_RDWR)) < 0) { + message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal); + exit(1); + } + dup(fd); + dup(fd); + tcsetpgrp (0, getpgrp()); + set_term(0); if (get_enter==TRUE) { /* @@ -389,19 +388,21 @@ static pid_t run(char* command, read(fileno(stdin), &c, 1); } + /* Log the process name and args */ + message(LOG|CONSOLE, "Starting pid %d, console %s: '", + shell_pgid, terminal, command); + /* Convert command (char*) into cmd (char**, one word per string) */ for (tmpCmd=command, i=0; (tmpCmd=strsep(&command, " \t")) != NULL;) { if (*tmpCmd != '\0') { cmd[i] = tmpCmd; + message(LOG|CONSOLE, "%s ", tmpCmd); tmpCmd++; i++; } } cmd[i] = NULL; - - /* Log the process name and args */ - message(LOG, "Starting pid %d, console %s: '%s'\r\n", - shell_pgid, terminal, cmd[0]); + message(LOG|CONSOLE, "'\r\n"); /* Now run it. The new program will take over this PID, * so nothing further in init.c should be run. */ @@ -540,8 +541,8 @@ void new_initAction (initActionEnum action, } else strncpy(newAction->console, console, 255); newAction->pid = 0; -// message(LOG|CONSOLE, "process='%s' action='%d' console='%s'\n", -// newAction->process, newAction->action, newAction->console); + message(LOG|CONSOLE, "process='%s' action='%d' console='%s'\n", + newAction->process, newAction->action, newAction->console); } void delete_initAction (initAction *action) @@ -672,11 +673,8 @@ extern int init_main(int argc, char **argv) usage( "init\n\nInit is the parent of all processes.\n\n" "This version of init is designed to be run only by the kernel\n"); } - - /* from the controlling terminal */ - setsid(); - - /* Set up sig handlers -- be sure to clear all of these in run() */ + /* Set up sig handlers -- be sure to + * clear all of these in run() */ signal(SIGUSR1, halt_signal); signal(SIGUSR2, reboot_signal); signal(SIGINT, reboot_signal); @@ -686,7 +684,7 @@ extern int init_main(int argc, char **argv) * SIGINT on CAD so we can shut things down gracefully... */ reboot(RB_DISABLE_CAD); #endif - + /* Figure out where the default console should be */ console_init(); @@ -695,11 +693,11 @@ extern int init_main(int argc, char **argv) close(1); close(2); set_term(0); + setsid(); /* Make sure PATH is set to something sane */ putenv(_PATH_STDPATH); - /* Hello world */ #ifndef DEBUG_INIT message(LOG|CONSOLE, diff --git a/internal.h b/internal.h index 1b5c0bc92..49cfcf05c 100644 --- a/internal.h +++ b/internal.h @@ -125,6 +125,7 @@ extern int touch_main(int argc, char** argv); extern int tput_main(int argc, char** argv); extern int true_main(int argc, char** argv); extern int tryopen_main(int argc, char** argv); +extern int wc_main(int argc, char** argv); extern int umount_main(int argc, char** argv); extern int uniq_main(int argc, char** argv); extern int update_main(int argc, char** argv); diff --git a/mkdir.c b/mkdir.c index 9ea3b4ea0..dc245a18e 100644 --- a/mkdir.c +++ b/mkdir.c @@ -84,7 +84,7 @@ extern int mkdir_main(int argc, char **argv) strcpy (buf, *argv); status=stat(buf, &statBuf); - if (status != -1 && status != ENOENT ) { + if (parentFlag == FALSE && status != -1 && status != ENOENT ) { fprintf(stderr, "%s: File exists\n", buf); exit( FALSE); } @@ -93,7 +93,7 @@ extern int mkdir_main(int argc, char **argv) createPath(buf, mode); } else { - if (mkdir (buf, mode) != 0) { + if (mkdir (buf, mode) != 0 && parentFlag == FALSE) { perror(buf); exit( FALSE); } diff --git a/reg_test.sh b/reg_test.sh index 2a73fc511..8177096a8 100755 --- a/reg_test.sh +++ b/reg_test.sh @@ -9,7 +9,7 @@ if ! eval diff -u tar.c testdir ; then echo "Bummer. File copy failed." exit 0 else - echo "Cool. File copy is ok." + echo "Cool. 'cp tar.c testdir' is ok." fi rm -rf testdir @@ -20,7 +20,7 @@ if ! eval diff -u tar.c testdir/foo/tar.c ; then echo "Bummer. File copy to a directory failed." exit 0 else - echo "Cool. File copy to a directory is ok." + echo "Cool. 'cp tar.c testdir/foo' is ok." fi @@ -32,7 +32,7 @@ if ! eval diff -u tar.c testdir/foo/tar.c ; then echo "Bummer. File copy to a directory w/ a '/' failed." exit 0 else - echo "Cool. File copy to a directory w/ a '/' is ok." + echo "Cool. 'cp tar.c testdir/foo/' is ok." fi @@ -44,7 +44,7 @@ if ! eval diff -ur X11 testdir ; then echo "Bummer. Local dir copy failed." exit 0 else - echo "Cool. Local dir copy is ok." + echo "Cool. 'cp -a X11 testdir' is ok." fi rm -rf testdir X11 @@ -55,7 +55,7 @@ if ! eval diff -ur X11 testdir ; then echo "Bummer. Local dir copy w/ a '/' failed." exit 0 else - echo "Cool. Local dir copy w/ a '/' is ok." + echo "Cool. 'cp -a X11 testdir/' is ok." fi rm -rf testdir X11 @@ -66,7 +66,7 @@ if ! eval diff -ur X11 testdir ; then echo "Bummer. Local dir copy w/ a src '/' failed." exit 0 else - echo "Cool. Local dir copy w/ a src '/' is ok." + echo "Cool. 'cp -a X11/ testdir' is ok." fi rm -rf testdir X11 @@ -77,7 +77,7 @@ if ! eval diff -ur X11 testdir ; then echo "Bummer. Local dir copy w/ 2x '/'s failed." exit 0 else - echo "Cool. Local dir copy w/ 2x '/'s is ok." + echo "Cool. 'cp -a X11/ testdir/' is ok." fi rm -rf testdir X11 @@ -86,7 +86,7 @@ if ! eval diff -ur /etc/X11 testdir ; then echo "Bummer. Remote dir copy failed." exit 0 else - echo "Cool. Remote dir copy is ok." + echo "Cool. 'cp -a /etc/X11 testdir' is ok." fi @@ -98,7 +98,7 @@ if ! eval diff -ur /etc/X11 testdir/foo ; then echo "Bummer. Remote dir copy to a directory failed." exit 0 else - echo "Cool. Remote dir copy to a directory is ok." + echo "Cool. 'cp -a /etc/X11 testdir/foo' is ok." fi @@ -110,7 +110,7 @@ if ! eval diff -ur /etc/X11 testdir/foo ; then echo "Bummer. Remote dir copy to a directory w/ a '/' failed." exit 0 else - echo "Cool. Remote dir copy to a directory w/ a '/' is ok." + echo "Cool. 'cp -a /etc/X11 testdir/foo/' is ok." fi rm -rf testdir @@ -124,14 +124,24 @@ if ! eval ./busybox cp README foo ; then echo "Bummer. cp README foo failed." exit 0 else - echo "Cool. cp README foo is ok." + echo "Cool. 'cp README foo' is ok." fi if ! eval ./busybox cp foo/README bar ; then echo "Bummer. cp foo/README bar failed." exit 0 else - echo "Cool. cp foo/README bar is ok." + echo "Cool. 'cp foo/README bar' is ok." +fi + +rm -f bar/README +ENVVAR1=foo +ENVVAR2=bar +if ! eval ./busybox cp $ENVVAR1/README $ENVVAR2 ; then + echo "Bummer. cp foo/README bar failed." + exit 0 +else + echo "Cool. 'cp \$ENVVAR1/README \$ENVVAR2' is ok." fi rm -rf foo bar diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 43e83b191..0be9ded06 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c @@ -337,11 +337,13 @@ extern int syslogd_main(int argc, char **argv) #ifdef BB_KLOGD int startKlogd = TRUE; #endif + int stopDoingThat = FALSE; char *p; char **argv1=argv; while (--argc > 0 && **(++argv1) == '-') { - while (*(++(*argv1))) { + stopDoingThat = FALSE; + while (stopDoingThat == FALSE && *(++(*argv1))) { switch (**argv1) { case 'm': if (--argc == 0) { @@ -362,6 +364,7 @@ extern int syslogd_main(int argc, char **argv) usage(syslogd_usage); } logFilePath = *(++argv1); + stopDoingThat = TRUE; break; default: usage(syslogd_usage); diff --git a/syslogd.c b/syslogd.c index 43e83b191..0be9ded06 100644 --- a/syslogd.c +++ b/syslogd.c @@ -337,11 +337,13 @@ extern int syslogd_main(int argc, char **argv) #ifdef BB_KLOGD int startKlogd = TRUE; #endif + int stopDoingThat = FALSE; char *p; char **argv1=argv; while (--argc > 0 && **(++argv1) == '-') { - while (*(++(*argv1))) { + stopDoingThat = FALSE; + while (stopDoingThat == FALSE && *(++(*argv1))) { switch (**argv1) { case 'm': if (--argc == 0) { @@ -362,6 +364,7 @@ extern int syslogd_main(int argc, char **argv) usage(syslogd_usage); } logFilePath = *(++argv1); + stopDoingThat = TRUE; break; default: usage(syslogd_usage); diff --git a/true_false.c b/true_false.c index feaa9297d..eb9466b7b 100644 --- a/true_false.c +++ b/true_false.c @@ -27,12 +27,12 @@ extern int true_main(int argc, char** argv) { - return( TRUE); + exit( TRUE); } extern int false_main(int argc, char** argv) { - return( FALSE); + exit( FALSE); } diff --git a/utility.c b/utility.c index c1bd82e8b..c18cb4b27 100644 --- a/utility.c +++ b/utility.c @@ -396,7 +396,7 @@ recursiveAction(const char *fileName, int recurse, int followLinks, int depthFir int (*dirAction) (const char *fileName, struct stat* statbuf)) { int status; - struct stat statbuf; + struct stat statbuf, statbuf1; struct dirent *next; if (followLinks == TRUE) @@ -404,6 +404,7 @@ recursiveAction(const char *fileName, int recurse, int followLinks, int depthFir else status = lstat(fileName, &statbuf); + status = lstat(fileName, &statbuf); if (status < 0) { perror(fileName); return (FALSE); @@ -424,8 +425,14 @@ recursiveAction(const char *fileName, int recurse, int followLinks, int depthFir return (TRUE); } } + + status = lstat(fileName, &statbuf1); + if (status < 0) { + perror(fileName); + return (FALSE); + } - if (S_ISDIR(statbuf.st_mode)) { + if (S_ISDIR(statbuf.st_mode) && S_ISDIR(statbuf1.st_mode)) { DIR *dir; dir = opendir(fileName); if (!dir) {