fake out support for POSIX -H and -L options since busybox cp dereferences everything by default

This commit is contained in:
Mike Frysinger 2005-04-14 02:52:50 +00:00
parent 75ac42b1ae
commit 2ed05ab146
3 changed files with 19 additions and 9 deletions

View File

@ -42,7 +42,7 @@
#include "libcoreutils/coreutils.h" #include "libcoreutils/coreutils.h"
/* WARNING!! ORDER IS IMPORTANT!! */ /* WARNING!! ORDER IS IMPORTANT!! */
static const char cp_opts[] = "pdRfiarP"; static const char cp_opts[] = "pdRfiarPHL";
extern int cp_main(int argc, char **argv) extern int cp_main(int argc, char **argv)
{ {
@ -79,6 +79,14 @@ extern int cp_main(int argc, char **argv)
*/ */
flags |= FILEUTILS_DEREFERENCE; flags |= FILEUTILS_DEREFERENCE;
} }
/* Default behavior of cp is to dereference, so we don't have to do
* anything special when we are given -L.
* The behavior of -H is *almost* like -L, but not quite, so let's
* just ignore it too for fun.
if (flags & 256 || flags & 512) {
;
}
*/
flags ^= FILEUTILS_DEREFERENCE; /* The sense of this flag was reversed. */ flags ^= FILEUTILS_DEREFERENCE; /* The sense of this flag was reversed. */

View File

@ -205,6 +205,7 @@
"\n" \ "\n" \
"\t-a\tSame as -dpR\n" \ "\t-a\tSame as -dpR\n" \
"\t-d,-P\tPreserves links\n" \ "\t-d,-P\tPreserves links\n" \
"\t-H,-L\tDereference all symlinks (implied by default)\n" \
"\t-p\tPreserves file attributes if possible\n" \ "\t-p\tPreserves file attributes if possible\n" \
"\t-f\tforce (implied; ignored) - always set\n" \ "\t-f\tforce (implied; ignored) - always set\n" \
"\t-i\tinteractive, prompt before overwrite\n" \ "\t-i\tinteractive, prompt before overwrite\n" \

View File

@ -54,7 +54,8 @@ int copy_file(const char *source, const char *dest, int flags)
} }
} else { } else {
if (source_stat.st_dev == dest_stat.st_dev && if (source_stat.st_dev == dest_stat.st_dev &&
source_stat.st_ino == dest_stat.st_ino) { source_stat.st_ino == dest_stat.st_ino)
{
bb_error_msg("`%s' and `%s' are the same file", source, dest); bb_error_msg("`%s' and `%s' are the same file", source, dest);
return -1; return -1;
} }