diff options
author | Erik Andersen | 2000-02-07 05:29:42 +0000 |
---|---|---|
committer | Erik Andersen | 2000-02-07 05:29:42 +0000 |
commit | fac10d7c59f7db0facd5fb94de273310b9ec86e6 (patch) | |
tree | dccf8f905fc5807239883da9fca6597037d487fc /coreutils/mkdir.c | |
parent | 50bc101b7d6e847a9a0621ca3eb28c7117d095e5 (diff) | |
download | busybox-fac10d7c59f7db0facd5fb94de273310b9ec86e6.zip busybox-fac10d7c59f7db0facd5fb94de273310b9ec86e6.tar.gz |
A few minor updates. ;-)
Seriously though, read the Changelog for busybox 0.42,
which this is about to become...
-Erik
Diffstat (limited to 'coreutils/mkdir.c')
-rw-r--r-- | coreutils/mkdir.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c index 017ef9b..8e3f51b 100644 --- a/coreutils/mkdir.c +++ b/coreutils/mkdir.c @@ -22,9 +22,13 @@ */ #include "internal.h" +#define bb_need_name_too_long +#define BB_DECLARE_EXTERN +#include "messages.c" + #include <stdio.h> #include <errno.h> -#include <sys/param.h> +#include <sys/param.h> /* for PATH_MAX */ static const char mkdir_usage[] = "mkdir [OPTION] DIRECTORY...\n\n" @@ -40,27 +44,27 @@ static mode_t mode = 0777; extern int mkdir_main(int argc, char **argv) { - int i=FALSE; + int i = FALSE; argc--; argv++; /* Parse any options */ while (argc > 0 && **argv == '-') { - while (i==FALSE && *++(*argv)) { + while (i == FALSE && *++(*argv)) { switch (**argv) { case 'm': if (--argc == 0) usage( mkdir_usage); /* Find the specified modes */ mode = 0; - if ( parse_mode(*(++argv), &mode) == FALSE ) { + if (parse_mode(*(++argv), &mode) == FALSE ) { fprintf(stderr, "Unknown mode: %s\n", *argv); - exit( FALSE); + exit FALSE; } /* Set the umask for this process so it doesn't * screw up whatever the user just entered. */ umask(0); - i=TRUE; + i = TRUE; break; case 'p': parentFlag = TRUE; @@ -73,7 +77,6 @@ extern int mkdir_main(int argc, char **argv) argv++; } - if (argc < 1) { usage( mkdir_usage); } @@ -81,13 +84,16 @@ extern int mkdir_main(int argc, char **argv) while (argc > 0) { int status; struct stat statBuf; - char buf[NAME_MAX]; - + char buf[PATH_MAX + 1]; + if (strlen(*argv) > PATH_MAX - 1) { + fprintf(stderr, name_too_long, "mkdir"); + exit FALSE; + } strcpy (buf, *argv); - status=stat(buf, &statBuf); - if (parentFlag == FALSE && status != -1 && status != ENOENT ) { + status = stat(buf, &statBuf); + if (parentFlag == FALSE && status != -1 && errno != ENOENT) { fprintf(stderr, "%s: File exists\n", buf); - exit( FALSE); + exit FALSE; } if (parentFlag == TRUE) { strcat( buf, "/"); @@ -96,13 +102,13 @@ extern int mkdir_main(int argc, char **argv) else { if (mkdir (buf, mode) != 0 && parentFlag == FALSE) { perror(buf); - exit( FALSE); + exit FALSE; } } argc--; argv++; } - exit( TRUE); + exit TRUE; } |