Close IMG tag.
[oweals/busybox.git] / mkdir.c
diff --git a/mkdir.c b/mkdir.c
index f6e08cadc076dae316354da7eeedc3bded56d37c..2345d88314dec8e51ca51cc2cf525e49e7082570 100644 (file)
--- a/mkdir.c
+++ b/mkdir.c
@@ -2,7 +2,7 @@
 /*
  * Mini mkdir implementation for busybox
  *
- * Copyright (C) 1999,2000 by Lineo, inc.
+ * Copyright (C) 1999,2000,2001 by Lineo, inc.
  * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
  *
  * This program is free software; you can redistribute it and/or modify
  *
  */
 
-#include "internal.h"
+#include "busybox.h"
 #define bb_need_name_too_long
 #define BB_DECLARE_EXTERN
 #include "messages.c"
 
 #include <stdio.h>
 #include <errno.h>
-
-static const char mkdir_usage[] =
-       "mkdir [OPTION] DIRECTORY...\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
-       "\nCreate the DIRECTORY(ies), if they do not already exist\n\n"
-       "Options:\n"
-
-       "\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n"
-       "\t-p\tno error if existing, make parent directories as needed\n"
-#endif
-       ;
-
+#include <string.h>
+#include <stdlib.h>
 
 static int parentFlag = FALSE;
 static mode_t mode = 0777;
@@ -62,8 +52,8 @@ extern int mkdir_main(int argc, char **argv)
                                /* Find the specified modes */
                                mode = 0;
                                if (parse_mode(*(++argv), &mode) == FALSE) {
-                                       errorMsg("Unknown mode: %s\n", *argv);
-                                       exit FALSE;
+                                       error_msg("Unknown mode: %s\n", *argv);
+                                       return EXIT_FAILURE;
                                }
                                /* Set the umask for this process so it doesn't 
                                 * screw up whatever the user just entered. */
@@ -91,26 +81,26 @@ extern int mkdir_main(int argc, char **argv)
                char buf[BUFSIZ + 1];
 
                if (strlen(*argv) > BUFSIZ - 1) {
-                       errorMsg(name_too_long);
-                       exit FALSE;
+                       error_msg(name_too_long);
+                       return EXIT_FAILURE;
                }
                strcpy(buf, *argv);
                status = stat(buf, &statBuf);
                if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
-                       errorMsg("%s: File exists\n", buf);
-                       exit FALSE;
+                       error_msg("%s: File exists\n", buf);
+                       return EXIT_FAILURE;
                }
                if (parentFlag == TRUE) {
                        strcat(buf, "/");
-                       createPath(buf, mode);
+                       create_path(buf, mode);
                } else {
                        if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
                                perror(buf);
-                               exit FALSE;
+                               return EXIT_FAILURE;
                        }
                }
                argc--;
                argv++;
        }
-       return( TRUE);
+       return EXIT_SUCCESS;
 }