aboutsummaryrefslogtreecommitdiff
path: root/coreutils/mv.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2005-07-20 00:45:40 +0000
committerRob Landley <rob@landley.net>2005-07-20 00:45:40 +0000
commit3c12ff7c894d930b1c431954f645087724017995 (patch)
treef03892cf7bdd37148841e4b4caa3720f67da38d1 /coreutils/mv.c
parentc337d29550162e4130fe74a1f2c7118da3110343 (diff)
downloadbusybox-3c12ff7c894d930b1c431954f645087724017995.tar.gz
If /tmp and /home were different partitions, then "mv /tmp/file /home/file"
would delete /home/file even if /tmp/file didn't exist. This fixes that, although the logic of both mv and cp is a bit tangled and should probably be untangled.
Diffstat (limited to 'coreutils/mv.c')
-rw-r--r--coreutils/mv.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/coreutils/mv.c b/coreutils/mv.c
index 4f08dedc0..e1c4529ad 100644
--- a/coreutils/mv.c
+++ b/coreutils/mv.c
@@ -99,10 +99,10 @@ DO_MOVE:
struct stat source_stat;
int source_exists;
- if (errno != EXDEV) {
+ if (errno != EXDEV ||
+ (source_exists = cp_mv_stat(*argv, &source_stat)) < 1) {
bb_perror_msg("unable to rename `%s'", *argv);
- }
- else if ((source_exists = cp_mv_stat(*argv, &source_stat)) >= 0) {
+ } else {
if (dest_exists) {
if (dest_exists == 3) {
if (source_exists != 3) {