From cb41c2e83b9e9997b9737d7061d53f7c11a463a8 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Mon, 22 Nov 1999 07:41:00 +0000 Subject: [PATCH] Bug fixes --- applets/install.sh | 6 +++--- coreutils/dd.c | 5 +++++ coreutils/mkdir.c | 14 +++++++++----- dd.c | 5 +++++ install.sh | 6 +++--- mkdir.c | 14 +++++++++----- utility.c | 8 +------- 7 files changed, 35 insertions(+), 23 deletions(-) diff --git a/applets/install.sh b/applets/install.sh index 4c2a4f1b8..458e65ce9 100755 --- a/applets/install.sh +++ b/applets/install.sh @@ -12,11 +12,11 @@ h=`sort busybox.links | uniq` for i in $h ; do mypath=`echo $i | sed -e 's/\(^.*\/\)\(.*\)/\1/g' `; myapp=`echo $i | sed -e 's/\(^.*\/\)\(.*\)/\2/g' `; - mkdir -p $1$mypath echo " $1$mypath$myapp -> /bin/busybox" - (cd $1$mypath ; rm -f $1$mypath$myapp ; ln -s /bin/busybox $1$mypath$myapp ) + mkdir -p $1$mypath + (cd $1$mypath && rm -f $1$mypath$myapp && ln -s /bin/busybox $1$mypath$myapp ) done rm -f $1/bin/busybox install -m 755 busybox $1/bin/busybox - +exit 0 diff --git a/coreutils/dd.c b/coreutils/dd.c index 64948571c..a2dc1c396 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c @@ -29,10 +29,15 @@ #include "internal.h" +#include #include #include #include +#if (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1) #include +#else +typedef unsigned long long int uintmax_t; +#endif static const char dd_usage[] = "dd [if=name] [of=name] [bs=n] [count=n]\n\n" diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c index 2cd178805..9ea3b4ea0 100644 --- a/coreutils/mkdir.c +++ b/coreutils/mkdir.c @@ -80,17 +80,21 @@ extern int mkdir_main(int argc, char **argv) while (argc > 0) { int status; struct stat statBuf; - status=stat(*argv, &statBuf); + char buf[NAME_MAX]; + + strcpy (buf, *argv); + status=stat(buf, &statBuf); if (status != -1 && status != ENOENT ) { - fprintf(stderr, "%s: File exists\n", *argv); + fprintf(stderr, "%s: File exists\n", buf); exit( FALSE); } if (parentFlag == TRUE) { - createPath(*argv, mode); + strcat( buf, "/"); + createPath(buf, mode); } else { - if (mkdir (*argv, mode) != 0) { - perror(*argv); + if (mkdir (buf, mode) != 0) { + perror(buf); exit( FALSE); } } diff --git a/dd.c b/dd.c index 64948571c..a2dc1c396 100644 --- a/dd.c +++ b/dd.c @@ -29,10 +29,15 @@ #include "internal.h" +#include #include #include #include +#if (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1) #include +#else +typedef unsigned long long int uintmax_t; +#endif static const char dd_usage[] = "dd [if=name] [of=name] [bs=n] [count=n]\n\n" diff --git a/install.sh b/install.sh index 4c2a4f1b8..458e65ce9 100755 --- a/install.sh +++ b/install.sh @@ -12,11 +12,11 @@ h=`sort busybox.links | uniq` for i in $h ; do mypath=`echo $i | sed -e 's/\(^.*\/\)\(.*\)/\1/g' `; myapp=`echo $i | sed -e 's/\(^.*\/\)\(.*\)/\2/g' `; - mkdir -p $1$mypath echo " $1$mypath$myapp -> /bin/busybox" - (cd $1$mypath ; rm -f $1$mypath$myapp ; ln -s /bin/busybox $1$mypath$myapp ) + mkdir -p $1$mypath + (cd $1$mypath && rm -f $1$mypath$myapp && ln -s /bin/busybox $1$mypath$myapp ) done rm -f $1/bin/busybox install -m 755 busybox $1/bin/busybox - +exit 0 diff --git a/mkdir.c b/mkdir.c index 2cd178805..9ea3b4ea0 100644 --- a/mkdir.c +++ b/mkdir.c @@ -80,17 +80,21 @@ extern int mkdir_main(int argc, char **argv) while (argc > 0) { int status; struct stat statBuf; - status=stat(*argv, &statBuf); + char buf[NAME_MAX]; + + strcpy (buf, *argv); + status=stat(buf, &statBuf); if (status != -1 && status != ENOENT ) { - fprintf(stderr, "%s: File exists\n", *argv); + fprintf(stderr, "%s: File exists\n", buf); exit( FALSE); } if (parentFlag == TRUE) { - createPath(*argv, mode); + strcat( buf, "/"); + createPath(buf, mode); } else { - if (mkdir (*argv, mode) != 0) { - perror(*argv); + if (mkdir (buf, mode) != 0) { + perror(buf); exit( FALSE); } } diff --git a/utility.c b/utility.c index 004864a18..011c0cf41 100644 --- a/utility.c +++ b/utility.c @@ -481,14 +481,8 @@ extern void createPath (const char *name, int mode) char *cpOld; char buf[NAME_MAX]; - strcpy (buf, name); - if (buf[strlen(buf)]!='/') { - buf[strlen(buf)] = '/'; - buf[strlen(buf)+1] = '\0'; - } - + strcpy( buf, name); cp = strchr (buf, '/'); - while (cp) { cpOld = cp; cp = strchr (cp + 1, '/'); -- 2.25.1