diff options
author | Denys Vlasenko | 2018-07-13 20:30:02 +0200 |
---|---|---|
committer | Denys Vlasenko | 2018-07-13 20:30:02 +0200 |
commit | 79fb6ac7a5acc4178b66314c573aeada1d387ed9 (patch) | |
tree | 421fd899e9dfcc5533b3107af6eba3de0f153044 /coreutils | |
parent | 253f555f01fa380083a7436a569397a4e7f997b0 (diff) | |
download | busybox-79fb6ac7a5acc4178b66314c573aeada1d387ed9.zip busybox-79fb6ac7a5acc4178b66314c573aeada1d387ed9.tar.gz |
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.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/coreutils/cp.c b/coreutils/cp.c index 455bffb..b623aaf 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c @@ -24,6 +24,11 @@ //config: help //config: Enable long options. //config: Also add support for --parents option. +//config: +//config:config FEATURE_CP_REFLINK +//config: bool "Enable --reflink[=auto] +//config: default y +//config: depends on FEATURE_CP_LONG_OPTIONS //applet:IF_CP(APPLET_NOEXEC(cp, cp, BB_DIR_BIN, BB_SUID_DROP, cp)) /* 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) #if ENABLE_FEATURE_CP_LONG_OPTIONS /*OPT_rmdest = FILEUTILS_RMDEST = 1 << FILEUTILS_CP_OPTNUM */ OPT_parents = 1 << (FILEUTILS_CP_OPTNUM+1), + OPT_reflink = 1 << (FILEUTILS_CP_OPTNUM+2), #endif }; #if ENABLE_FEATURE_CP_LONG_OPTIONS +# if ENABLE_FEATURE_CP_REFLINK + char *reflink = NULL; +# endif flags = getopt32long(argv, "^" FILEUTILS_CP_OPTSTR "\0" @@ -99,7 +108,22 @@ int cp_main(int argc, char **argv) "update\0" No_argument "u" "remove-destination\0" No_argument "\xff" "parents\0" No_argument "\xfe" +# if ENABLE_FEATURE_CP_REFLINK + "reflink\0" Optional_argument "\xfd" + , &reflink +# endif ); +# if ENABLE_FEATURE_CP_REFLINK + BUILD_BUG_ON(OPT_reflink != FILEUTILS_REFLINK); + if (flags & FILEUTILS_REFLINK) { + if (!reflink) + flags |= FILEUTILS_REFLINK_ALWAYS; + else if (strcmp(reflink, "always") == 0) + flags |= FILEUTILS_REFLINK_ALWAYS; + else if (strcmp(reflink, "auto") != 0) + bb_show_usage(); + } +# endif #else flags = getopt32(argv, "^" FILEUTILS_CP_OPTSTR |