aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-07-13 20:30:02 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-07-13 20:30:02 +0200
commit79fb6ac7a5acc4178b66314c573aeada1d387ed9 (patch)
tree421fd899e9dfcc5533b3107af6eba3de0f153044 /coreutils
parent253f555f01fa380083a7436a569397a4e7f997b0 (diff)
downloadbusybox-w32-79fb6ac7a5acc4178b66314c573aeada1d387ed9.tar.gz
busybox-w32-79fb6ac7a5acc4178b66314c573aeada1d387ed9.tar.bz2
busybox-w32-79fb6ac7a5acc4178b66314c573aeada1d387ed9.zip
cp: optional --reflink support
function old new delta cp_main 428 512 +84 copy_file 1676 1742 +66 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/cp.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/coreutils/cp.c b/coreutils/cp.c
index 455bffbba..b623aaf33 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -24,6 +24,11 @@
24//config: help 24//config: help
25//config: Enable long options. 25//config: Enable long options.
26//config: Also add support for --parents option. 26//config: Also add support for --parents option.
27//config:
28//config:config FEATURE_CP_REFLINK
29//config: bool "Enable --reflink[=auto]
30//config: default y
31//config: depends on FEATURE_CP_LONG_OPTIONS
27 32
28//applet:IF_CP(APPLET_NOEXEC(cp, cp, BB_DIR_BIN, BB_SUID_DROP, cp)) 33//applet:IF_CP(APPLET_NOEXEC(cp, cp, BB_DIR_BIN, BB_SUID_DROP, cp))
29/* NOEXEC despite cases when it can be a "runner" (cp -r LARGE_DIR NEW_DIR) */ 34/* NOEXEC despite cases when it can be a "runner" (cp -r LARGE_DIR NEW_DIR) */
@@ -72,10 +77,14 @@ int cp_main(int argc, char **argv)
72#if ENABLE_FEATURE_CP_LONG_OPTIONS 77#if ENABLE_FEATURE_CP_LONG_OPTIONS
73 /*OPT_rmdest = FILEUTILS_RMDEST = 1 << FILEUTILS_CP_OPTNUM */ 78 /*OPT_rmdest = FILEUTILS_RMDEST = 1 << FILEUTILS_CP_OPTNUM */
74 OPT_parents = 1 << (FILEUTILS_CP_OPTNUM+1), 79 OPT_parents = 1 << (FILEUTILS_CP_OPTNUM+1),
80 OPT_reflink = 1 << (FILEUTILS_CP_OPTNUM+2),
75#endif 81#endif
76 }; 82 };
77 83
78#if ENABLE_FEATURE_CP_LONG_OPTIONS 84#if ENABLE_FEATURE_CP_LONG_OPTIONS
85# if ENABLE_FEATURE_CP_REFLINK
86 char *reflink = NULL;
87# endif
79 flags = getopt32long(argv, "^" 88 flags = getopt32long(argv, "^"
80 FILEUTILS_CP_OPTSTR 89 FILEUTILS_CP_OPTSTR
81 "\0" 90 "\0"
@@ -99,7 +108,22 @@ int cp_main(int argc, char **argv)
99 "update\0" No_argument "u" 108 "update\0" No_argument "u"
100 "remove-destination\0" No_argument "\xff" 109 "remove-destination\0" No_argument "\xff"
101 "parents\0" No_argument "\xfe" 110 "parents\0" No_argument "\xfe"
111# if ENABLE_FEATURE_CP_REFLINK
112 "reflink\0" Optional_argument "\xfd"
113 , &reflink
114# endif
102 ); 115 );
116# if ENABLE_FEATURE_CP_REFLINK
117 BUILD_BUG_ON(OPT_reflink != FILEUTILS_REFLINK);
118 if (flags & FILEUTILS_REFLINK) {
119 if (!reflink)
120 flags |= FILEUTILS_REFLINK_ALWAYS;
121 else if (strcmp(reflink, "always") == 0)
122 flags |= FILEUTILS_REFLINK_ALWAYS;
123 else if (strcmp(reflink, "auto") != 0)
124 bb_show_usage();
125 }
126# endif
103#else 127#else
104 flags = getopt32(argv, "^" 128 flags = getopt32(argv, "^"
105 FILEUTILS_CP_OPTSTR 129 FILEUTILS_CP_OPTSTR