[git commit] cp: accept --sparse=ANYTHING

Denys Vlasenko vda.linux at googlemail.com
Tue Jul 14 17:00:02 UTC 2026


commit: https://git.busybox.net/busybox/commit/?id=17908bf760caa0a65d3254f252456dabebe0c877
branch: https://git.busybox.net/busybox/log/?h=master

function                                             old     new   delta
cp_main                                              514     527     +13
.rodata                                           107332  107341      +9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 22/0)               Total: 22 bytes

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 coreutils/cp.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/coreutils/cp.c b/coreutils/cp.c
index 961de5b42..3ddf90088 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -29,6 +29,11 @@
 //config:	bool "Enable --reflink[=auto]"
 //config:	default y
 //config:	depends on FEATURE_CP_LONG_OPTIONS
+//config:
+//config:config FEATURE_CP_SPARSE
+//config:	bool "Enable --sparse=WHEN"
+//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) */
@@ -129,6 +134,9 @@ int cp_main(int argc, char **argv)
 	};
 # if ENABLE_FEATURE_CP_REFLINK
 	char *reflink = NULL;
+# endif
+# if ENABLE_FEATURE_CP_SPARSE
+	char *sparse = NULL;
 # endif
 	flags = getopt32long(argv, "^"
 		FILEUTILS_CP_OPTSTR
@@ -158,10 +166,17 @@ int cp_main(int argc, char **argv)
 		"parents\0"        No_argument "\xfe"
 # if ENABLE_FEATURE_CP_REFLINK
 		"reflink\0"        Optional_argument "\xfd"
+# endif
+# if ENABLE_FEATURE_CP_SPARSE
+		"sparse\0"         Optional_argument "\xfc"
 # endif
 		, &last
 # if ENABLE_FEATURE_CP_REFLINK
 		, &reflink
+# endif
+# if ENABLE_FEATURE_CP_SPARSE
+		// NOP for now
+		, &sparse
 # endif
 	);
 # if ENABLE_FEATURE_CP_REFLINK


More information about the busybox-cvs mailing list