summaryrefslogtreecommitdiffstats
path: root/commands/cp.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-09-25 12:19:37 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2009-09-25 13:33:52 +0200
commita205b87fa241ebe165da059617007c9263f33d2e (patch)
treead265642f07dea51b60208c93dc3b0ba22fe98b5 /commands/cp.c
parentde14570aea49fcd7a3e0071d37d0ef93a980c4fd (diff)
downloadbarebox-a205b87fa241ebe165da059617007c9263f33d2e.tar.gz
barebox-a205b87fa241ebe165da059617007c9263f33d2e.tar.xz
make copy_file() globally available
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/cp.c')
-rw-r--r--commands/cp.c59
1 files changed, 2 insertions, 57 deletions
diff --git a/commands/cp.c b/commands/cp.c
index af03615f5d..0a90c163b0 100644
--- a/commands/cp.c
+++ b/commands/cp.c
@@ -26,66 +26,11 @@
*/
#include <common.h>
#include <command.h>
-#include <fs.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <malloc.h>
#include <xfuncs.h>
#include <linux/stat.h>
#include <libbb.h>
-
-#define RW_BUF_SIZE (ulong)4096
-
-/**
- * @param[in] src FIXME
- * @param[out] dst FIXME
- */
-static int copy_file(const char *src, const char *dst)
-{
- char *rw_buf = NULL;
- int srcfd = 0, dstfd = 0;
- int r, w;
- int ret = 1;
-
- rw_buf = xmalloc(RW_BUF_SIZE);
-
- srcfd = open(src, O_RDONLY);
- if (srcfd < 0) {
- printf("could not open %s: %s\n", src, errno_str());
- goto out;
- }
-
- dstfd = open(dst, O_WRONLY | O_CREAT);
- if (dstfd < 0) {
- printf("could not open %s: %s\n", dst, errno_str());
- goto out;
- }
-
- while(1) {
- r = read(srcfd, rw_buf, RW_BUF_SIZE);
- if (r < 0) {
- perror("read");
- goto out;
- }
- if (!r)
- break;
- w = write(dstfd, rw_buf, r);
- if (w < 0) {
- perror("write");
- goto out;
- }
- }
-
- ret = 0;
-out:
- free(rw_buf);
- if (srcfd > 0)
- close(srcfd);
- if (dstfd > 0)
- close(dstfd);
-
- return ret;
-}
+#include <fs.h>
+#include <malloc.h>
/**
* @param[in] cmdtp FIXME