cp: fix --sparse to have mandatory argument, fix --remove-destination bit position
No binary (build failed)
gcc -Wp,-MD,applets/.usage.d -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -Iinclude -Iinclude -o applets/usage applets/usage.c
(log yok)
| @@ -113,6 +113,8 @@ | |
| #include "libbb.h" | |
| #include "libcoreutils/coreutils.h" | |
| + | #define DBG_OPTION_PARSING 0 |
| + | |
| /* This is a NOEXEC applet. Be very careful! */ | |
| int cp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | |
| @@ -168,7 +170,7 @@ int cp_main(int argc, char **argv) | |
| "reflink\0" Optional_argument "\xfd" | |
| # endif | |
| # if ENABLE_FEATURE_CP_SPARSE | |
| - | "sparse\0" Optional_argument "\xfc" |
| + | "sparse\0" Required_argument "\xfc" |
| # endif | |
| , &last | |
| # if ENABLE_FEATURE_CP_REFLINK | |
| @@ -179,6 +181,7 @@ int cp_main(int argc, char **argv) | |
| , &sparse | |
| # endif | |
| ); | |
| + | |
| # if ENABLE_FEATURE_CP_REFLINK | |
| BUILD_BUG_ON((int)OPT_reflink != (int)FILEUTILS_REFLINK); | |
| if (flags & FILEUTILS_REFLINK) { | |
| @@ -190,6 +193,16 @@ int cp_main(int argc, char **argv) | |
| bb_show_usage(); | |
| } | |
| # endif | |
| + | # if DBG_OPTION_PARSING |
| + | bb_error_msg("flags: 0x%08x", flags); |
| + | # define showopt(o) bb_error_msg("flags & %s(%x):\t%x", #o, o, flags & o); |
| + | showopt(FILEUTILS_RMDEST ); |
| + | showopt(OPT_parents ); |
| + | showopt(OPT_reflink ); |
| + | showopt(FILEUTILS_REFLINK_ALWAYS); |
| + | return 0; |
| + | # undef showopt |
| + | # endif |
| #else | |
| flags = getopt32(argv, "^" | |
| FILEUTILS_CP_OPTSTR | |
| @@ -505,16 +505,17 @@ enum { /* cp.c, mv.c, install.c depend on these values. CAREFUL when changing th | |
| #endif | |
| #define FILEUTILS_CP_OPTSTR "pdRfinlsLHarPvuTt:" IF_SELINUX("c") | |
| /* How many bits in FILEUTILS_CP_OPTSTR? */ | |
| - | FILEUTILS_CP_OPTBITS = 18 - !ENABLE_SELINUX, |
| + | FILEUTILS_CP_OPTBITS = (18 - !ENABLE_SELINUX), |
| - | FILEUTILS_RMDEST = 1 << (19 - !ENABLE_SELINUX), /* cp --remove-destination */ |
| - | /* bit 18 skipped for "cp --parents" */ |
| + | FILEUTILS_RMDEST = 1 << (18 - !ENABLE_SELINUX), /* cp --remove-destination */ |
| + | /* bit 19 is used in cp for "cp --parents" */ |
| FILEUTILS_REFLINK = 1 << (20 - !ENABLE_SELINUX), /* cp --reflink=auto */ | |
| - | FILEUTILS_REFLINK_ALWAYS = 1 << (21 - !ENABLE_SELINUX), /* cp --reflink[=always] */ |
| + | /* bit 21 is used in cp for "cp --sparse=... */ |
| /* | |
| * Hole. cp may have some bits set here, | |
| * they should not affect remove_file()/copy_file() | |
| */ | |
| + | FILEUTILS_REFLINK_ALWAYS = 1 << 29, /* cp --reflink, --reflink=always */ |
| #if ENABLE_SELINUX | |
| FILEUTILS_SET_SECURITY_CONTEXT = 1 << 30, | |
| #endif | |