summaryrefslogtreecommitdiffstats
path: root/commands/cd.c
blob: 0a45cbb63d5ccc796086993d5d84e6594592a641 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <common.h>
#include <command.h>
#include <fs.h>
#include <errno.h>

static int do_cd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	int ret;

	if (argc == 1)
		ret = chdir("/");
	else
		ret = chdir(argv[1]);

	if (ret) {
		perror("chdir");
		return 1;
	}

	return 0;
}

static __maybe_unused char cmd_cd_help[] =
"Usage: cd [directory]\n"
"change to directory. If called without argument, change to /\n";

U_BOOT_CMD_START(cd)
	.maxargs	= 2,
	.cmd		= do_cd,
	.usage		= "change working directory",
	U_BOOT_CMD_HELP(cmd_cd_help)
U_BOOT_CMD_END