[Toybox] [HACK] hackfixing cp for compilation
Roy Tam
roytam at gmail.com
Sun Oct 28 20:42:32 PDT 2012
It is broken for months, so I hackfixed it.
diff -U8 toys/posix/cp.c toys/posix/cp.c_hf
--- toys/posix/cp.c 2012-10-27 10:15:31.000000000 +0800
+++ toys/posix/cp.c_hf 2012-10-29 11:41:01.000000000 +0800
@@ -171,37 +171,37 @@
// Loop through sources
for (i=0; i<toys.optc; i++) {
char *dst, *src = toys.optargs[i];
// Skip src==dest (TODO check inodes to catch "cp blah ./blah").
- if (!strncmp(src, TT.destname)) continue;
+ if (!strcmp(src, TT.destname)) continue;
// Skip nonexistent sources.
TT.keep_symlinks = toys.optflags & (FLAG_d|FLAG_a);
if (TT.keep_symlinks ? lstat(src, &st) : stat(src, &st)
- || (st.st_dev = dst.st_dev && st.st_ino == dst.dst_ino))
+ /*|| (st.st_dev = dst.st_dev && st.st_ino ==
dst.dst_ino)*/)
{
objection:
perror_msg("bad '%s'", src);
toys.exitval = 1;
continue;
}
// Copy directory or file.
if (TT.destisdir) {
char *s;
// Catch "cp -R .. ." and friends that would
go on forever
- if (dpath && (s = realpath(src, NULL)) {
+ if (dpath && (s = realpath(src, NULL))) {
int i = strlen(s);
i = (!strncmp(s, dst, i) && (!s[i] ||
s[i]=='/'));
free(s);
if (i) goto objection;
}
// Create destination filename within directory
More information about the Toybox
mailing list