aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coreutils/cp.c8
-rw-r--r--coreutils/mv.c4
-rw-r--r--cp.c8
-rw-r--r--include/libbb.h2
-rw-r--r--libbb/copy_file.c4
-rw-r--r--libbb/libbb.h2
-rw-r--r--mv.c4
7 files changed, 16 insertions, 16 deletions
diff --git a/coreutils/cp.c b/coreutils/cp.c
index 82d43adff..8f8fe5ed3 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -36,7 +36,7 @@ extern int cp_main(int argc, char **argv)
{
int status = 0;
int opt;
- int flags = 0;
+ int flags = FILEUTILS_DEREFERENCE;
int i;
while ((opt = getopt(argc, argv, "adfipR")) != -1)
@@ -45,7 +45,7 @@ extern int cp_main(int argc, char **argv)
flags |= FILEUTILS_PRESERVE_STATUS | FILEUTILS_RECUR;
/* fallthrough */
case 'd':
- flags |= FILEUTILS_PRESERVE_SYMLINKS;
+ flags &= ~FILEUTILS_DEREFERENCE;
break;
case 'f':
flags |= FILEUTILS_FORCE;
@@ -73,9 +73,9 @@ extern int cp_main(int argc, char **argv)
int source_exists = 1;
int dest_exists = 1;
- if (((flags & FILEUTILS_PRESERVE_SYMLINKS) &&
+ if ((!(flags & FILEUTILS_DEREFERENCE) &&
lstat(argv[optind], &source_stat) < 0) ||
- (!(flags & FILEUTILS_PRESERVE_SYMLINKS) &&
+ ((flags & FILEUTILS_DEREFERENCE) &&
stat(argv[optind], &source_stat))) {
if (errno != ENOENT)
perror_msg_and_die("unable to stat `%s'", argv[optind]);
diff --git a/coreutils/mv.c b/coreutils/mv.c
index b890abf6e..1c4a34788 100644
--- a/coreutils/mv.c
+++ b/coreutils/mv.c
@@ -74,8 +74,8 @@ static int manual_rename(const char *source, const char *dest)
}
}
- if (copy_file(source, dest, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS |
- FILEUTILS_PRESERVE_SYMLINKS) < 0)
+ if (copy_file(source, dest,
+ FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS) < 0)
return -1;
if (remove_file(source, FILEUTILS_RECUR | FILEUTILS_FORCE) < 0)
diff --git a/cp.c b/cp.c
index 82d43adff..8f8fe5ed3 100644
--- a/cp.c
+++ b/cp.c
@@ -36,7 +36,7 @@ extern int cp_main(int argc, char **argv)
{
int status = 0;
int opt;
- int flags = 0;
+ int flags = FILEUTILS_DEREFERENCE;
int i;
while ((opt = getopt(argc, argv, "adfipR")) != -1)
@@ -45,7 +45,7 @@ extern int cp_main(int argc, char **argv)
flags |= FILEUTILS_PRESERVE_STATUS | FILEUTILS_RECUR;
/* fallthrough */
case 'd':
- flags |= FILEUTILS_PRESERVE_SYMLINKS;
+ flags &= ~FILEUTILS_DEREFERENCE;
break;
case 'f':
flags |= FILEUTILS_FORCE;
@@ -73,9 +73,9 @@ extern int cp_main(int argc, char **argv)
int source_exists = 1;
int dest_exists = 1;
- if (((flags & FILEUTILS_PRESERVE_SYMLINKS) &&
+ if ((!(flags & FILEUTILS_DEREFERENCE) &&
lstat(argv[optind], &source_stat) < 0) ||
- (!(flags & FILEUTILS_PRESERVE_SYMLINKS) &&
+ ((flags & FILEUTILS_DEREFERENCE) &&
stat(argv[optind], &source_stat))) {
if (errno != ENOENT)
perror_msg_and_die("unable to stat `%s'", argv[optind]);
diff --git a/include/libbb.h b/include/libbb.h
index 30f0bb9a7..bbdbc6c86 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -273,7 +273,7 @@ char *simplify_path(const char *path);
enum {
FILEUTILS_PRESERVE_STATUS = 1,
- FILEUTILS_PRESERVE_SYMLINKS = 2,
+ FILEUTILS_DEREFERENCE = 2,
FILEUTILS_RECUR = 4,
FILEUTILS_FORCE = 8,
FILEUTILS_INTERACTIVE = 16
diff --git a/libbb/copy_file.c b/libbb/copy_file.c
index 9c1bba689..d3902ffbe 100644
--- a/libbb/copy_file.c
+++ b/libbb/copy_file.c
@@ -40,9 +40,9 @@ int copy_file(const char *source, const char *dest, int flags)
int dest_exists = 1;
int status = 0;
- if (((flags & FILEUTILS_PRESERVE_SYMLINKS) &&
+ if ((!(flags & FILEUTILS_DEREFERENCE) &&
lstat(source, &source_stat) < 0) ||
- (!(flags & FILEUTILS_PRESERVE_SYMLINKS) &&
+ ((flags & FILEUTILS_DEREFERENCE) &&
stat(source, &source_stat) < 0)) {
perror_msg("%s", source);
return -1;
diff --git a/libbb/libbb.h b/libbb/libbb.h
index 30f0bb9a7..bbdbc6c86 100644
--- a/libbb/libbb.h
+++ b/libbb/libbb.h
@@ -273,7 +273,7 @@ char *simplify_path(const char *path);
enum {
FILEUTILS_PRESERVE_STATUS = 1,
- FILEUTILS_PRESERVE_SYMLINKS = 2,
+ FILEUTILS_DEREFERENCE = 2,
FILEUTILS_RECUR = 4,
FILEUTILS_FORCE = 8,
FILEUTILS_INTERACTIVE = 16
diff --git a/mv.c b/mv.c
index b890abf6e..1c4a34788 100644
--- a/mv.c
+++ b/mv.c
@@ -74,8 +74,8 @@ static int manual_rename(const char *source, const char *dest)
}
}
- if (copy_file(source, dest, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS |
- FILEUTILS_PRESERVE_SYMLINKS) < 0)
+ if (copy_file(source, dest,
+ FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS) < 0)
return -1;
if (remove_file(source, FILEUTILS_RECUR | FILEUTILS_FORCE) < 0)