arm start.c: Make runtime function address calculation tolerant for more compilers
[barebox-mini2440.git] / commands / cd.c
bloba842f4dc20861bf5dec06b972dfb322d9bbb8f77
1 /*
2 * cd.c - change working directory
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 /**
24 * @file
25 * @brief Change working directory
28 #include <common.h>
29 #include <command.h>
30 #include <fs.h>
31 #include <errno.h>
33 static int do_cd(struct command *cmdtp, int argc, char *argv[])
35 int ret;
37 if (argc == 1)
38 ret = chdir("/");
39 else
40 ret = chdir(argv[1]);
42 if (ret) {
43 perror("chdir");
44 return 1;
47 return 0;
50 static const __maybe_unused char cmd_cd_help[] =
51 "Usage: cd [directory]\n"
52 "change to directory. If called without argument, change to /\n";
54 BAREBOX_CMD_START(cd)
55 .cmd = do_cd,
56 .usage = "change working directory",
57 BAREBOX_CMD_HELP(cmd_cd_help)
58 BAREBOX_CMD_END
60 /**
61 * @page cd_command cd (change working directory)
63 * Usage is: cd [\<directory name>]
65 * Change to \<directory name>. If called without argument, change to \b /
66 * (root)