aboutsummaryrefslogtreecommitdiff
path: root/toys/cp.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/cp.c')
-rw-r--r--toys/cp.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/toys/cp.c b/toys/cp.c
index c3153e0a..a53d5fe0 100644
--- a/toys/cp.c
+++ b/toys/cp.c
@@ -10,8 +10,8 @@
USE_CP(NEWTOY(cp, "<2vslrR+rdpa+d+p+rHLPif", TOYFLAG_BIN))
config CP
- bool "cp"
- default y
+ bool "cp (broken by dirtree changes)"
+ default n
help
usage: cp -fiprdal SOURCE... DEST
@@ -128,8 +128,9 @@ void cp_file(char *src, char *dst, struct stat *srcst)
// Callback from dirtree_read() for each file/directory under a source dir.
-int cp_node(char *path, struct dirtree *node)
+int cp_node(struct dirtree *node)
{
+ char *path = dirtree_path(node, 0); // TODO: use openat() instead
char *s = path+strlen(path);
struct dirtree *n;
@@ -148,6 +149,7 @@ int cp_node(char *path, struct dirtree *node)
s = xmsprintf("%s/%s", TT.destname, s);
cp_file(path, s, &(node->st));
free(s);
+ free(path); // redo this whole darn function.
return 0;
}
@@ -209,7 +211,7 @@ void cp_main(void)
TT.keep_symlinks++;
strncpy(toybuf, src, sizeof(toybuf)-1);
toybuf[sizeof(toybuf)-1]=0;
- dirtree_read(toybuf, NULL, cp_node);
+ dirtree_read(toybuf, cp_node);
} else error_msg("Skipped dir '%s'", src);
} else cp_file(src, dst, &st);
if (TT.destisdir) free(dst);