summaryrefslogtreecommitdiffstats
path: root/toolbox
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-12-16 15:18:56 -0800
committerElliott Hughes <enh@google.com>2014-12-16 15:18:56 -0800
commitde4fd83e0b3e085acce005ef0a14250eb1fbcc01 (patch)
tree6aae109bd14faef7c9a2226879218c37d82ea081 /toolbox
parent8641daeea1c9990934562593828b85d8dceb5a04 (diff)
downloadsystem_core-de4fd83e0b3e085acce005ef0a14250eb1fbcc01.zip
system_core-de4fd83e0b3e085acce005ef0a14250eb1fbcc01.tar.gz
system_core-de4fd83e0b3e085acce005ef0a14250eb1fbcc01.tar.bz2
Lose mkdir to toybox.
Change-Id: Ie2ad916893ba36e7cee6d5a4533e60732871c8dd
Diffstat (limited to 'toolbox')
-rw-r--r--toolbox/Android.mk1
-rw-r--r--toolbox/mkdir.c77
2 files changed, 0 insertions, 78 deletions
diff --git a/toolbox/Android.mk b/toolbox/Android.mk
index c6769d7..23b61e9 100644
--- a/toolbox/Android.mk
+++ b/toolbox/Android.mk
@@ -127,7 +127,6 @@ OUR_TOOLS := \
log \
ls \
lsof \
- mkdir \
mount \
nandread \
netstat \
diff --git a/toolbox/mkdir.c b/toolbox/mkdir.c
deleted file mode 100644
index 398d350..0000000
--- a/toolbox/mkdir.c
+++ /dev/null
@@ -1,77 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/limits.h>
-#include <sys/stat.h>
-
-static int usage()
-{
- fprintf(stderr,"mkdir [OPTION] <target>\n");
- fprintf(stderr," --help display usage and exit\n");
- fprintf(stderr," -p, --parents create parent directories as needed\n");
- return -1;
-}
-
-int mkdir_main(int argc, char *argv[])
-{
- int ret;
- if(argc < 2 || strcmp(argv[1], "--help") == 0) {
- return usage();
- }
-
- int recursive = (strcmp(argv[1], "-p") == 0 ||
- strcmp(argv[1], "--parents") == 0) ? 1 : 0;
-
- if(recursive && argc < 3) {
- // -p specified without a path
- return usage();
- }
-
- if(recursive) {
- argc--;
- argv++;
- }
-
- char currpath[PATH_MAX], *pathpiece;
- struct stat st;
-
- while(argc > 1) {
- argc--;
- argv++;
- if(recursive) {
- // reset path
- strcpy(currpath, "");
- // create the pieces of the path along the way
- pathpiece = strtok(argv[0], "/");
- if(argv[0][0] == '/') {
- // prepend / if needed
- strcat(currpath, "/");
- }
- while(pathpiece != NULL) {
- if(strlen(currpath) + strlen(pathpiece) + 2/*NUL and slash*/ > PATH_MAX) {
- fprintf(stderr, "Invalid path specified: too long\n");
- return 1;
- }
- strcat(currpath, pathpiece);
- strcat(currpath, "/");
- if(stat(currpath, &st) != 0) {
- ret = mkdir(currpath, 0777);
- if(ret < 0) {
- fprintf(stderr, "mkdir failed for %s, %s\n", currpath, strerror(errno));
- return ret;
- }
- }
- pathpiece = strtok(NULL, "/");
- }
- } else {
- ret = mkdir(argv[0], 0777);
- if(ret < 0) {
- fprintf(stderr, "mkdir failed for %s, %s\n", argv[0], strerror(errno));
- return ret;
- }
- }
- }
-
- return 0;
-}