summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-04-11 11:06:07 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-04-15 12:21:45 +0200
commit4f17444eccebeeadeaed212568a202ef97f4e71f (patch)
treeb006ce0f54caf425510289408ed771c1276ac42f /commands
parentdb33f32842973245f0adcae2fb7fd23ec4325630 (diff)
downloadbarebox-4f17444eccebeeadeaed212568a202ef97f4e71f.tar.gz
barebox-4f17444eccebeeadeaed212568a202ef97f4e71f.tar.xz
libfile: move open_and_lseek() to libfile
libfile is a collection of helpers for handling files. open_and_lseek() is a perfect match for this, so move it there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/md.c1
-rw-r--r--commands/mem.c23
-rw-r--r--commands/memcmp.c1
-rw-r--r--commands/memcpy.c1
-rw-r--r--commands/memset.c1
-rw-r--r--commands/mm.c1
-rw-r--r--commands/mw.c1
7 files changed, 6 insertions, 23 deletions
diff --git a/commands/md.c b/commands/md.c
index c88259a3f8..3e83c723a3 100644
--- a/commands/md.c
+++ b/commands/md.c
@@ -28,6 +28,7 @@
#include <malloc.h>
#include <errno.h>
#include <fs.h>
+#include <libfile.h>
#include <fcntl.h>
#include <getopt.h>
#include <linux/stat.h>
diff --git a/commands/mem.c b/commands/mem.c
index 23c703f0b5..907f1f76a8 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -41,29 +41,6 @@
char *mem_rw_buf;
-int open_and_lseek(const char *filename, int mode, loff_t pos)
-{
- int fd, ret;
-
- fd = open(filename, mode | O_RDONLY);
- if (fd < 0) {
- perror("open");
- return fd;
- }
-
- if (!pos)
- return fd;
-
- ret = lseek(fd, pos, SEEK_SET);
- if (ret == -1) {
- perror("lseek");
- close(fd);
- return -errno;
- }
-
- return fd;
-}
-
/*
* Common function for parsing options for the 'md', 'mw', 'memcpy', 'memcmp'
* commands.
diff --git a/commands/memcmp.c b/commands/memcmp.c
index e079d5f78e..ce044df0d9 100644
--- a/commands/memcmp.c
+++ b/commands/memcmp.c
@@ -28,6 +28,7 @@
#include <malloc.h>
#include <errno.h>
#include <fs.h>
+#include <libfile.h>
#include <fcntl.h>
#include <getopt.h>
#include <linux/stat.h>
diff --git a/commands/memcpy.c b/commands/memcpy.c
index 9c8b64525c..168ef3b4fc 100644
--- a/commands/memcpy.c
+++ b/commands/memcpy.c
@@ -28,6 +28,7 @@
#include <malloc.h>
#include <errno.h>
#include <fs.h>
+#include <libfile.h>
#include <fcntl.h>
#include <getopt.h>
#include <linux/stat.h>
diff --git a/commands/memset.c b/commands/memset.c
index fc5b659b9b..f871e07c95 100644
--- a/commands/memset.c
+++ b/commands/memset.c
@@ -28,6 +28,7 @@
#include <malloc.h>
#include <errno.h>
#include <fs.h>
+#include <libfile.h>
#include <fcntl.h>
#include <getopt.h>
#include <linux/stat.h>
diff --git a/commands/mm.c b/commands/mm.c
index 7c890a6696..6d2a887892 100644
--- a/commands/mm.c
+++ b/commands/mm.c
@@ -22,6 +22,7 @@
#include <malloc.h>
#include <errno.h>
#include <fs.h>
+#include <libfile.h>
#include <fcntl.h>
#include <getopt.h>
#include <linux/stat.h>
diff --git a/commands/mw.c b/commands/mw.c
index 8ca3c61d7f..bb6a16ef3d 100644
--- a/commands/mw.c
+++ b/commands/mw.c
@@ -28,6 +28,7 @@
#include <malloc.h>
#include <errno.h>
#include <fs.h>
+#include <libfile.h>
#include <fcntl.h>
#include <getopt.h>
#include <linux/stat.h>