diff options
author | Nishanth Menon <x0nishan@ti.com> | 2008-08-15 19:31:56 -0500 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2008-08-19 09:38:57 +0200 |
commit | c63e66ed7e582c81f6a371d4058ebca87f129fee (patch) | |
tree | fa3ea86b317d507f6513d241488841f8917434df /commands/loadb.c | |
parent | 1252331f68710539993dbcfaf4ed91df473c5be8 (diff) | |
download | barebox-c63e66ed7e582c81f6a371d4058ebca87f129fee.tar.gz barebox-c63e66ed7e582c81f6a371d4058ebca87f129fee.tar.xz |
loadb: create file
Allow loadb and loady to create file if file not
present. This will allow for downloading a file
to filesystem and cp or doing other operations on
the same. Making this as an option instead of a
default behavior ensures that users intend to
create file when they use -c option
Signed-off-by: Nishanth Menon <x0nishan@ti.com>
Diffstat (limited to 'commands/loadb.c')
-rw-r--r-- | commands/loadb.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/commands/loadb.c b/commands/loadb.c index d81afcee02..9c7819ef89 100644 --- a/commands/loadb.c +++ b/commands/loadb.c @@ -651,12 +651,13 @@ static int do_load_serial_bin(cmd_tbl_t *cmdtp, int argc, char *argv[]) int load_baudrate = 0, current_baudrate; int rcode = 0; int opt; + int open_mode = O_WRONLY; char *output_file = NULL; struct console_device *cdev = NULL; getopt_reset(); - while ((opt = getopt(argc, argv, "d:b:o:")) > 0) { + while ((opt = getopt(argc, argv, "d:b:o:c")) > 0) { switch (opt) { case 'd': output_file = optarg; @@ -667,6 +668,9 @@ static int do_load_serial_bin(cmd_tbl_t *cmdtp, int argc, char *argv[]) case 'o': offset = (int)simple_strtoul(optarg, NULL, 10); break; + case 'c': + open_mode |= O_CREAT; + break; default: perror(argv[0]); return 1; @@ -687,7 +691,7 @@ static int do_load_serial_bin(cmd_tbl_t *cmdtp, int argc, char *argv[]) output_file = DEF_FILE; /* File should exist */ - ofd = open(output_file, O_WRONLY); + ofd = open(output_file, open_mode); if (ofd < 0) { perror(argv[0]); return 3; @@ -757,10 +761,11 @@ static const __maybe_unused char cmd_loadb_help[] = " -d device - which device to download - defaults to " DEF_FILE "\n" " -o offset - what offset to download - defaults to 0\n" " -b baud - baudrate at which to download - defaults to " - "console baudrate\n"; + "console baudrate" + " -c - Create file if it is not present - default disabled"; #ifdef CONFIG_CMD_LOADB U_BOOT_CMD_START(loadb) - .maxargs = 7, + .maxargs = 8, .cmd = do_load_serial_bin, .usage = "Load binary file over serial line (kermit mode)", U_BOOT_CMD_HELP(cmd_loadb_help) @@ -768,7 +773,7 @@ U_BOOT_CMD_END #endif #ifdef CONFIG_CMD_LOADY U_BOOT_CMD_START(loady) - .maxargs = 7, + .maxargs = 8, .cmd = do_load_serial_bin, .usage = "Load binary file over serial line (ymodem mode)", U_BOOT_CMD_HELP(cmd_loadb_help) |