diff options
author | vapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-04-14 02:52:50 +0000 |
---|---|---|
committer | vapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-04-14 02:52:50 +0000 |
commit | 3edf63036a9bcd25a4027ddf3d159f04fb42f575 (patch) | |
tree | 44fae62c20b02fe54fb141c3312958842893873e | |
parent | c524ced560ab34a8421306506e7c6ff585db6bb6 (diff) | |
download | busybox-w32-3edf63036a9bcd25a4027ddf3d159f04fb42f575.tar.gz busybox-w32-3edf63036a9bcd25a4027ddf3d159f04fb42f575.tar.bz2 busybox-w32-3edf63036a9bcd25a4027ddf3d159f04fb42f575.zip |
fake out support for POSIX -H and -L options since busybox cp dereferences everything by default
git-svn-id: svn://busybox.net/trunk/busybox@10097 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | coreutils/cp.c | 18 | ||||
-rw-r--r-- | include/usage.h | 1 | ||||
-rw-r--r-- | libbb/copy_file.c | 9 |
3 files changed, 19 insertions, 9 deletions
diff --git a/coreutils/cp.c b/coreutils/cp.c index 97731e83f..eaabee4f4 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c | |||
@@ -42,7 +42,7 @@ | |||
42 | #include "libcoreutils/coreutils.h" | 42 | #include "libcoreutils/coreutils.h" |
43 | 43 | ||
44 | /* WARNING!! ORDER IS IMPORTANT!! */ | 44 | /* WARNING!! ORDER IS IMPORTANT!! */ |
45 | static const char cp_opts[] = "pdRfiarP"; | 45 | static const char cp_opts[] = "pdRfiarPHL"; |
46 | 46 | ||
47 | extern int cp_main(int argc, char **argv) | 47 | extern int cp_main(int argc, char **argv) |
48 | { | 48 | { |
@@ -70,7 +70,7 @@ extern int cp_main(int argc, char **argv) | |||
70 | if (flags & 64) { | 70 | if (flags & 64) { |
71 | /* Make -r a synonym for -R, | 71 | /* Make -r a synonym for -R, |
72 | * -r was marked as obsolete in SUSv3, but is included for compatability | 72 | * -r was marked as obsolete in SUSv3, but is included for compatability |
73 | */ | 73 | */ |
74 | flags |= FILEUTILS_RECUR; | 74 | flags |= FILEUTILS_RECUR; |
75 | } | 75 | } |
76 | if (flags & 128) { | 76 | if (flags & 128) { |
@@ -79,6 +79,14 @@ extern int cp_main(int argc, char **argv) | |||
79 | */ | 79 | */ |
80 | flags |= FILEUTILS_DEREFERENCE; | 80 | flags |= FILEUTILS_DEREFERENCE; |
81 | } | 81 | } |
82 | /* Default behavior of cp is to dereference, so we don't have to do | ||
83 | * anything special when we are given -L. | ||
84 | * The behavior of -H is *almost* like -L, but not quite, so let's | ||
85 | * just ignore it too for fun. | ||
86 | if (flags & 256 || flags & 512) { | ||
87 | ; | ||
88 | } | ||
89 | */ | ||
82 | 90 | ||
83 | flags ^= FILEUTILS_DEREFERENCE; /* The sense of this flag was reversed. */ | 91 | flags ^= FILEUTILS_DEREFERENCE; /* The sense of this flag was reversed. */ |
84 | 92 | ||
@@ -92,7 +100,7 @@ extern int cp_main(int argc, char **argv) | |||
92 | /* If there are only two arguments and... */ | 100 | /* If there are only two arguments and... */ |
93 | if (optind + 2 == argc) { | 101 | if (optind + 2 == argc) { |
94 | s_flags = cp_mv_stat2(*argv, &source_stat, | 102 | s_flags = cp_mv_stat2(*argv, &source_stat, |
95 | (flags & FILEUTILS_DEREFERENCE) ? stat : lstat); | 103 | (flags & FILEUTILS_DEREFERENCE) ? stat : lstat); |
96 | if ((s_flags < 0) || ((d_flags = cp_mv_stat(last, &dest_stat)) < 0)) { | 104 | if ((s_flags < 0) || ((d_flags = cp_mv_stat(last, &dest_stat)) < 0)) { |
97 | exit(EXIT_FAILURE); | 105 | exit(EXIT_FAILURE); |
98 | } | 106 | } |
@@ -104,8 +112,8 @@ extern int cp_main(int argc, char **argv) | |||
104 | ((((flags & FILEUTILS_RECUR) >> 1) & s_flags) && !d_flags) | 112 | ((((flags & FILEUTILS_RECUR) >> 1) & s_flags) && !d_flags) |
105 | ) { | 113 | ) { |
106 | /* ...do a simple copy. */ | 114 | /* ...do a simple copy. */ |
107 | dest = last; | 115 | dest = last; |
108 | goto DO_COPY; /* Note: optind+2==argc implies argv[1]==last below. */ | 116 | goto DO_COPY; /* Note: optind+2==argc implies argv[1]==last below. */ |
109 | } | 117 | } |
110 | } | 118 | } |
111 | 119 | ||
diff --git a/include/usage.h b/include/usage.h index fd0f68166..940d0deff 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -205,6 +205,7 @@ | |||
205 | "\n" \ | 205 | "\n" \ |
206 | "\t-a\tSame as -dpR\n" \ | 206 | "\t-a\tSame as -dpR\n" \ |
207 | "\t-d,-P\tPreserves links\n" \ | 207 | "\t-d,-P\tPreserves links\n" \ |
208 | "\t-H,-L\tDereference all symlinks (implied by default)\n" \ | ||
208 | "\t-p\tPreserves file attributes if possible\n" \ | 209 | "\t-p\tPreserves file attributes if possible\n" \ |
209 | "\t-f\tforce (implied; ignored) - always set\n" \ | 210 | "\t-f\tforce (implied; ignored) - always set\n" \ |
210 | "\t-i\tinteractive, prompt before overwrite\n" \ | 211 | "\t-i\tinteractive, prompt before overwrite\n" \ |
diff --git a/libbb/copy_file.c b/libbb/copy_file.c index 68a1ded04..0120d0b16 100644 --- a/libbb/copy_file.c +++ b/libbb/copy_file.c | |||
@@ -54,10 +54,11 @@ int copy_file(const char *source, const char *dest, int flags) | |||
54 | } | 54 | } |
55 | } else { | 55 | } else { |
56 | if (source_stat.st_dev == dest_stat.st_dev && | 56 | if (source_stat.st_dev == dest_stat.st_dev && |
57 | source_stat.st_ino == dest_stat.st_ino) { | 57 | source_stat.st_ino == dest_stat.st_ino) |
58 | bb_error_msg("`%s' and `%s' are the same file", source, dest); | 58 | { |
59 | return -1; | 59 | bb_error_msg("`%s' and `%s' are the same file", source, dest); |
60 | } | 60 | return -1; |
61 | } | ||
61 | dest_exists = 1; | 62 | dest_exists = 1; |
62 | } | 63 | } |
63 | 64 | ||