diff options
author | Mike Frysinger <vapier@gentoo.org> | 2005-04-14 02:52:50 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2005-04-14 02:52:50 +0000 |
commit | 2ed05ab1464a442e8fd13815abf43575c7910aad (patch) | |
tree | 44fae62c20b02fe54fb141c3312958842893873e /coreutils/cp.c | |
parent | 75ac42b1aea14abbd8633003a6c56fa28c27a6c9 (diff) | |
download | busybox-w32-2ed05ab1464a442e8fd13815abf43575c7910aad.tar.gz busybox-w32-2ed05ab1464a442e8fd13815abf43575c7910aad.tar.bz2 busybox-w32-2ed05ab1464a442e8fd13815abf43575c7910aad.zip |
fake out support for POSIX -H and -L options since busybox cp dereferences everything by default
Diffstat (limited to 'coreutils/cp.c')
-rw-r--r-- | coreutils/cp.c | 18 |
1 files changed, 13 insertions, 5 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 | ||