arm start.c: Make runtime function address calculation tolerant for more compilers
[barebox-mini2440.git] / commands / mkdir.c
blobb66795b6e2ab3ed3bccdef4523d5c62e1eb7b372
1 /*
2 * mkdir.c - create directories
4 * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
6 * See file CREDITS for list of people who contributed to this
7 * project.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <common.h>
24 #include <command.h>
25 #include <fs.h>
26 #include <errno.h>
27 #include <getopt.h>
29 static int do_mkdir(struct command *cmdtp, int argc, char *argv[])
31 int opt, parent = 0, ret;
33 while((opt = getopt(argc, argv, "p")) > 0) {
34 switch(opt) {
35 case 'p':
36 parent = 1;
37 break;
38 default:
39 return 1;
44 if (optind == argc)
45 return COMMAND_ERROR_USAGE;
47 while (optind < argc) {
48 if (parent)
49 ret = make_directory(argv[optind]);
50 else
51 ret = mkdir(argv[optind], 0);
52 if (ret) {
53 printf("could not create %s: %s\n", argv[optind], errno_str());
54 return 1;
56 optind++;
59 return 0;
62 static const __maybe_unused char cmd_mkdir_help[] =
63 "Usage: mkdir [directories]\n"
64 "Create new directories\n";
66 BAREBOX_CMD_START(mkdir)
67 .cmd = do_mkdir,
68 .usage = "make directories",
69 BAREBOX_CMD_HELP(cmd_mkdir_help)
70 BAREBOX_CMD_END