summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-04-08 10:17:15 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-04-08 10:17:15 +0200
commitd44e3d642171fa506dcc5a6c1b2babe6b4b813bf (patch)
treef07ca08305b99b0c01ddd4775fd15b38ed7d0a67 /commands
parentc239b65fc2bc779343d7b8f0afd1c4cac1dd0beb (diff)
parent14ad13bfc3e83e7b9befb78b837d28427d8eacdf (diff)
downloadbarebox-d44e3d642171fa506dcc5a6c1b2babe6b4b813bf.tar.gz
barebox-d44e3d642171fa506dcc5a6c1b2babe6b4b813bf.tar.xz
Merge branch 'for-next/lseek'
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 8c3906ca42..37c272f6c7 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 2bfe482fc5..85efad67c7 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);