aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatheus Izvekov <mizvekov@gmail.com>2010-01-21 19:30:25 -0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-01-23 00:10:40 +0100
commit31416d589ebb34eeab1af151dd50015105e3db98 (patch)
tree4012bdc30abd9ce17374706280344861829ce46e
parent8b8d32ea56d443c754f9230e2284ed65a2552df4 (diff)
downloadbusybox-31416d589ebb34eeab1af151dd50015105e3db98.tar.gz
chown: support long options
function old new delta chown_longopts - 81 +81 chown_main 182 192 +10 Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/Config.in7
-rw-r--r--coreutils/chown.c18
2 files changed, 24 insertions, 1 deletions
diff --git a/coreutils/Config.in b/coreutils/Config.in
index 49e285982..1e32e2664 100644
--- a/coreutils/Config.in
+++ b/coreutils/Config.in
@@ -52,6 +52,13 @@ config CHOWN
chown is used to change the user and/or group ownership
of files.
+config FEATURE_CHOWN_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on CHOWN && LONG_OPTS
+ help
+ Enable use of long options
+
config CHROOT
bool "chroot"
default n
diff --git a/coreutils/chown.c b/coreutils/chown.c
index 2d8e556f0..d29f8252a 100644
--- a/coreutils/chown.c
+++ b/coreutils/chown.c
@@ -8,7 +8,6 @@
*/
/* BB_AUDIT SUSv3 defects - none? */
-/* BB_AUDIT GNU defects - unsupported long options. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chown.html */
#include "libbb.h"
@@ -37,6 +36,20 @@
#define BIT_TRAVERSE_TOP (0x20|0x40)
#define OPT_TRAVERSE_TOP (IF_DESKTOP(opt & BIT_TRAVERSE_TOP) IF_NOT_DESKTOP(0))
+#if ENABLE_FEATURE_CHOWN_LONG_OPTIONS
+static const char chown_longopts[] ALIGN1 =
+ "recursive\0" No_argument "R"
+ "dereference\0" No_argument "\xff"
+ "no-dereference\0" No_argument "h"
+# if ENABLE_DESKTOP
+ "changes\0" No_argument "c"
+ "silent\0" No_argument "f"
+ "quiet\0" No_argument "f"
+ "verbose\0" No_argument "v"
+# endif
+ ;
+#endif
+
typedef int (*chown_fptr)(const char *, uid_t, gid_t);
struct param_t {
@@ -78,6 +91,9 @@ int chown_main(int argc UNUSED_PARAM, char **argv)
param.ugid.gid = -1;
param.chown_func = chown;
+#if ENABLE_FEATURE_CHOWN_LONG_OPTIONS
+ applet_long_options = chown_longopts;
+#endif
opt_complementary = "-2";
opt = getopt32(argv, OPT_STR);
argv += optind;