+ // Need at least two arguments
+ // Soft- and hardlinking doesn't mix
+ // -P and -d are the same (-P is POSIX, -d is GNU)
+ // -r and -R are the same
+ // -R (and therefore -r) turns on -d (coreutils does this)
+ // -a = -pdR
+ opt_complementary = "-2:l--s:s--l:Pd:rRd:Rd:apdR";
+#if ENABLE_FEATURE_CP_LONG_OPTIONS
+ applet_long_options =
+ "archive\0" No_argument "a"
+ "force\0" No_argument "f"
+ "interactive\0" No_argument "i"
+ "link\0" No_argument "l"
+ "dereference\0" No_argument "L"
+ "no-dereference\0" No_argument "P"
+ "recursive\0" No_argument "R"
+ "symbolic-link\0" No_argument "s"
+ "verbose\0" No_argument "v"
+ "parents\0" No_argument "\xff"
+ ;
+#endif
+ // -v (--verbose) is ignored
+ flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPv");
+ /* Options of cp from GNU coreutils 6.10:
+ * -a, --archive
+ * -f, --force
+ * -i, --interactive
+ * -l, --link
+ * -L, --dereference
+ * -P, --no-dereference
+ * -R, -r, --recursive
+ * -s, --symbolic-link
+ * -v, --verbose
+ * -H follow command-line symbolic links in SOURCE
+ * -d same as --no-dereference --preserve=links
+ * -p same as --preserve=mode,ownership,timestamps
+ * -c same as --preserve=context
+ * --parents
+ * use full source file name under DIRECTORY
+ * NOT SUPPORTED IN BBOX:
+ * --backup[=CONTROL]
+ * make a backup of each existing destination file
+ * -b like --backup but does not accept an argument
+ * --copy-contents
+ * copy contents of special files when recursive
+ * --preserve[=ATTR_LIST]
+ * preserve attributes (default: mode,ownership,timestamps),
+ * if possible additional attributes: security context,links,all
+ * --no-preserve=ATTR_LIST
+ * --remove-destination
+ * remove each existing destination file before attempting to open
+ * --sparse=WHEN
+ * control creation of sparse files
+ * --strip-trailing-slashes
+ * remove any trailing slashes from each SOURCE argument
+ * -S, --suffix=SUFFIX
+ * override the usual backup suffix
+ * -t, --target-directory=DIRECTORY
+ * copy all SOURCE arguments into DIRECTORY
+ * -T, --no-target-directory
+ * treat DEST as a normal file
+ * -u, --update
+ * copy only when the SOURCE file is newer than the destination
+ * file or when the destination file is missing
+ * -x, --one-file-system
+ * stay on this file system
+ * -Z, --context=CONTEXT
+ * (SELinux) set SELinux security context of copy to CONTEXT
+ */
+ argc -= optind;
+ argv += optind;
+ /* Reverse this bit. If there is -d, bit is not set: */
+ flags ^= FILEUTILS_DEREFERENCE;
+ /* coreutils 6.9 compat:
+ * by default, "cp" derefs symlinks (creates regular dest files),
+ * but "cp -R" does not. We switch off deref if -r or -R (see above).
+ * However, "cp -RL" must still deref symlinks: */
+ if (flags & FILEUTILS_DEREF_SOFTLINK) /* -L */
+ flags |= FILEUTILS_DEREFERENCE;
+
+#if ENABLE_SELINUX
+ if (flags & FILEUTILS_PRESERVE_SECURITY_CONTEXT) {
+ selinux_or_die();
+ }
+#endif