summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/loadb.c13
-rw-r--r--commands/loadxy.c13
2 files changed, 4 insertions, 22 deletions
diff --git a/commands/loadb.c b/commands/loadb.c
index 8c3906c..37c272f 100644
--- a/commands/loadb.c
+++ b/commands/loadb.c
@@ -33,6 +33,7 @@
#include <command.h>
#include <console.h>
#include <errno.h>
+#include <libfile.h>
#include <environment.h>
#include <cache.h>
#include <getopt.h>
@@ -661,21 +662,11 @@ static int do_load_serial_bin(int argc, char *argv[])
output_file = DEF_FILE;
/* File should exist */
- ofd = open(output_file, O_WRONLY | O_CREAT);
+ ofd = open_and_lseek(output_file, O_WRONLY | O_CREAT, offset);
if (ofd < 0) {
perror(argv[0]);
return 3;
}
- /* Seek to the right offset */
- if (offset) {
- int seek = lseek(ofd, offset, SEEK_SET);
- if (seek != offset) {
- close(ofd);
- ofd = 0;
- perror(argv[0]);
- return 4;
- }
- }
printf("## Ready for binary (kermit) download "
"to 0x%08lX offset on %s device at %d bps...\n", offset,
diff --git a/commands/loadxy.c b/commands/loadxy.c
index 2bfe482..85efad6 100644
--- a/commands/loadxy.c
+++ b/commands/loadxy.c
@@ -37,6 +37,7 @@
#include <fcntl.h>
#include <fs.h>
#include <malloc.h>
+#include <libfile.h>
#define DEF_FILE "image.bin"
@@ -176,21 +177,11 @@ static int do_loadx(int argc, char *argv[])
output_file = DEF_FILE;
/* File should exist */
- ofd = open(output_file, O_WRONLY | O_CREAT);
+ ofd = open_and_lseek(output_file, O_WRONLY | O_CREAT, offset);
if (ofd < 0) {
perror(argv[0]);
return 3;
}
- /* Seek to the right offset */
- if (offset) {
- int seek = lseek(ofd, offset, SEEK_SET);
- if (seek != offset) {
- close(ofd);
- ofd = 0;
- perror(argv[0]);
- return 4;
- }
- }
current_baudrate = console_get_baudrate(cdev);