diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-12 11:22:19 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-12 11:22:19 +0000 |
commit | 13afb2acdae8a63c0d7851e97de592f9a4996eea (patch) | |
tree | 773e168def38b9ae7f3364e14ff8d31a0f7c788b /coreutils | |
parent | a87045ce37e01971bd40219293afdacd4c2317e2 (diff) | |
download | busybox-w32-13afb2acdae8a63c0d7851e97de592f9a4996eea.tar.gz busybox-w32-13afb2acdae8a63c0d7851e97de592f9a4996eea.tar.bz2 busybox-w32-13afb2acdae8a63c0d7851e97de592f9a4996eea.zip |
mv: fix a case when we move dangling symlink
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/mv.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/coreutils/mv.c b/coreutils/mv.c index 5611ecd01..be10b030a 100644 --- a/coreutils/mv.c +++ b/coreutils/mv.c | |||
@@ -26,16 +26,13 @@ static const char mv_longopts[] ALIGN1 = | |||
26 | #define OPT_FILEUTILS_FORCE 1 | 26 | #define OPT_FILEUTILS_FORCE 1 |
27 | #define OPT_FILEUTILS_INTERACTIVE 2 | 27 | #define OPT_FILEUTILS_INTERACTIVE 2 |
28 | 28 | ||
29 | static const char fmt[] ALIGN1 = | ||
30 | "cannot overwrite %sdirectory with %sdirectory"; | ||
31 | |||
32 | int mv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 29 | int mv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
33 | int mv_main(int argc, char **argv) | 30 | int mv_main(int argc, char **argv) |
34 | { | 31 | { |
35 | struct stat dest_stat; | 32 | struct stat dest_stat; |
36 | const char *last; | 33 | const char *last; |
37 | const char *dest; | 34 | const char *dest; |
38 | unsigned long flags; | 35 | unsigned flags; |
39 | int dest_exists; | 36 | int dest_exists; |
40 | int status = 0; | 37 | int status = 0; |
41 | int copy_flag = 0; | 38 | int copy_flag = 0; |
@@ -57,7 +54,7 @@ int mv_main(int argc, char **argv) | |||
57 | return EXIT_FAILURE; | 54 | return EXIT_FAILURE; |
58 | } | 55 | } |
59 | 56 | ||
60 | if (!(dest_exists & 2)) { | 57 | if (!(dest_exists & 2)) { /* last is not a directory */ |
61 | dest = last; | 58 | dest = last; |
62 | goto DO_MOVE; | 59 | goto DO_MOVE; |
63 | } | 60 | } |
@@ -88,10 +85,13 @@ int mv_main(int argc, char **argv) | |||
88 | int source_exists; | 85 | int source_exists; |
89 | 86 | ||
90 | if (errno != EXDEV | 87 | if (errno != EXDEV |
91 | || (source_exists = cp_mv_stat(*argv, &source_stat)) < 1 | 88 | || (source_exists = cp_mv_stat2(*argv, &source_stat, lstat)) < 1 |
92 | ) { | 89 | ) { |
93 | bb_perror_msg("cannot rename '%s'", *argv); | 90 | bb_perror_msg("cannot rename '%s'", *argv); |
94 | } else { | 91 | } else { |
92 | static const char fmt[] ALIGN1 = | ||
93 | "cannot overwrite %sdirectory with %sdirectory"; | ||
94 | |||
95 | if (dest_exists) { | 95 | if (dest_exists) { |
96 | if (dest_exists == 3) { | 96 | if (dest_exists == 3) { |
97 | if (source_exists != 3) { | 97 | if (source_exists != 3) { |