diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-15 22:05:07 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-15 22:05:07 +0100 |
commit | a40f0624db4c9490d46f116c4c4635dfa68e070c (patch) | |
tree | 6495c54fab2be22802c6befc9d5c8ea01807a60c /coreutils/cp.c | |
parent | 662078f9fd41efe422d7abc0aea1395c27c61ddd (diff) | |
download | busybox-w32-a40f0624db4c9490d46f116c4c4635dfa68e070c.tar.gz busybox-w32-a40f0624db4c9490d46f116c4c4635dfa68e070c.tar.bz2 busybox-w32-a40f0624db4c9490d46f116c4c4635dfa68e070c.zip |
cp: fix -H handling
function old new delta
copy_file 1495 1518 +23
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/cp.c')
-rw-r--r-- | coreutils/cp.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/coreutils/cp.c b/coreutils/cp.c index 9f6c12367..d7c8d91cc 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c | |||
@@ -35,10 +35,9 @@ int cp_main(int argc, char **argv) | |||
35 | OPT_a = 1 << (sizeof(FILEUTILS_CP_OPTSTR)-1), | 35 | OPT_a = 1 << (sizeof(FILEUTILS_CP_OPTSTR)-1), |
36 | OPT_r = 1 << (sizeof(FILEUTILS_CP_OPTSTR)), | 36 | OPT_r = 1 << (sizeof(FILEUTILS_CP_OPTSTR)), |
37 | OPT_P = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+1), | 37 | OPT_P = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+1), |
38 | OPT_H = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+2), | 38 | OPT_v = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+2), |
39 | OPT_v = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+3), | ||
40 | #if ENABLE_FEATURE_CP_LONG_OPTIONS | 39 | #if ENABLE_FEATURE_CP_LONG_OPTIONS |
41 | OPT_parents = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+4), | 40 | OPT_parents = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+3), |
42 | #endif | 41 | #endif |
43 | }; | 42 | }; |
44 | 43 | ||
@@ -48,7 +47,7 @@ int cp_main(int argc, char **argv) | |||
48 | // -r and -R are the same | 47 | // -r and -R are the same |
49 | // -R (and therefore -r) turns on -d (coreutils does this) | 48 | // -R (and therefore -r) turns on -d (coreutils does this) |
50 | // -a = -pdR | 49 | // -a = -pdR |
51 | opt_complementary = "-2:l--s:s--l:Pd:rRd:Rd:apdR:HL"; | 50 | opt_complementary = "-2:l--s:s--l:Pd:rRd:Rd:apdR"; |
52 | #if ENABLE_FEATURE_CP_LONG_OPTIONS | 51 | #if ENABLE_FEATURE_CP_LONG_OPTIONS |
53 | applet_long_options = | 52 | applet_long_options = |
54 | "archive\0" No_argument "a" | 53 | "archive\0" No_argument "a" |
@@ -64,7 +63,7 @@ int cp_main(int argc, char **argv) | |||
64 | ; | 63 | ; |
65 | #endif | 64 | #endif |
66 | // -v (--verbose) is ignored | 65 | // -v (--verbose) is ignored |
67 | flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPHv"); | 66 | flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPv"); |
68 | /* Options of cp from GNU coreutils 6.10: | 67 | /* Options of cp from GNU coreutils 6.10: |
69 | * -a, --archive | 68 | * -a, --archive |
70 | * -f, --force | 69 | * -f, --force |
@@ -113,17 +112,14 @@ int cp_main(int argc, char **argv) | |||
113 | */ | 112 | */ |
114 | argc -= optind; | 113 | argc -= optind; |
115 | argv += optind; | 114 | argv += optind; |
116 | flags ^= FILEUTILS_DEREFERENCE; /* the sense of this flag was reversed */ | 115 | /* Reverse this bit. If there is -d, bit is not set: */ |
116 | flags ^= FILEUTILS_DEREFERENCE; | ||
117 | /* coreutils 6.9 compat: | 117 | /* coreutils 6.9 compat: |
118 | * by default, "cp" derefs symlinks (creates regular dest files), | 118 | * by default, "cp" derefs symlinks (creates regular dest files), |
119 | * but "cp -R" does not. We switch off deref if -r or -R (see above). | 119 | * but "cp -R" does not. We switch off deref if -r or -R (see above). |
120 | * However, "cp -RL" must still deref symlinks: */ | 120 | * However, "cp -RL" must still deref symlinks: */ |
121 | if (flags & FILEUTILS_DEREF_SOFTLINK) /* -L */ | 121 | if (flags & FILEUTILS_DEREF_SOFTLINK) /* -L */ |
122 | flags |= FILEUTILS_DEREFERENCE; | 122 | flags |= FILEUTILS_DEREFERENCE; |
123 | /* The behavior of -H is *almost* like -L, but not quite, so let's | ||
124 | * just ignore it too for fun. TODO. | ||
125 | if (flags & OPT_H) ... // deref command-line params only | ||
126 | */ | ||
127 | 123 | ||
128 | #if ENABLE_SELINUX | 124 | #if ENABLE_SELINUX |
129 | if (flags & FILEUTILS_PRESERVE_SECURITY_CONTEXT) { | 125 | if (flags & FILEUTILS_PRESERVE_SECURITY_CONTEXT) { |