aboutsummaryrefslogtreecommitdiff
path: root/coreutils
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 /coreutils
parent8b8d32ea56d443c754f9230e2284ed65a2552df4 (diff)
downloadbusybox-w32-31416d589ebb34eeab1af151dd50015105e3db98.tar.gz
busybox-w32-31416d589ebb34eeab1af151dd50015105e3db98.tar.bz2
busybox-w32-31416d589ebb34eeab1af151dd50015105e3db98.zip
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>
Diffstat (limited to 'coreutils')
-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
52 chown is used to change the user and/or group ownership 52 chown is used to change the user and/or group ownership
53 of files. 53 of files.
54 54
55config FEATURE_CHOWN_LONG_OPTIONS
56 bool "Enable long options"
57 default n
58 depends on CHOWN && LONG_OPTS
59 help
60 Enable use of long options
61
55config CHROOT 62config CHROOT
56 bool "chroot" 63 bool "chroot"
57 default n 64 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 @@
8 */ 8 */
9 9
10/* BB_AUDIT SUSv3 defects - none? */ 10/* BB_AUDIT SUSv3 defects - none? */
11/* BB_AUDIT GNU defects - unsupported long options. */
12/* http://www.opengroup.org/onlinepubs/007904975/utilities/chown.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/chown.html */
13 12
14#include "libbb.h" 13#include "libbb.h"
@@ -37,6 +36,20 @@
37#define BIT_TRAVERSE_TOP (0x20|0x40) 36#define BIT_TRAVERSE_TOP (0x20|0x40)
38#define OPT_TRAVERSE_TOP (IF_DESKTOP(opt & BIT_TRAVERSE_TOP) IF_NOT_DESKTOP(0)) 37#define OPT_TRAVERSE_TOP (IF_DESKTOP(opt & BIT_TRAVERSE_TOP) IF_NOT_DESKTOP(0))
39 38
39#if ENABLE_FEATURE_CHOWN_LONG_OPTIONS
40static const char chown_longopts[] ALIGN1 =
41 "recursive\0" No_argument "R"
42 "dereference\0" No_argument "\xff"
43 "no-dereference\0" No_argument "h"
44# if ENABLE_DESKTOP
45 "changes\0" No_argument "c"
46 "silent\0" No_argument "f"
47 "quiet\0" No_argument "f"
48 "verbose\0" No_argument "v"
49# endif
50 ;
51#endif
52
40typedef int (*chown_fptr)(const char *, uid_t, gid_t); 53typedef int (*chown_fptr)(const char *, uid_t, gid_t);
41 54
42struct param_t { 55struct param_t {
@@ -78,6 +91,9 @@ int chown_main(int argc UNUSED_PARAM, char **argv)
78 param.ugid.gid = -1; 91 param.ugid.gid = -1;
79 param.chown_func = chown; 92 param.chown_func = chown;
80 93
94#if ENABLE_FEATURE_CHOWN_LONG_OPTIONS
95 applet_long_options = chown_longopts;
96#endif
81 opt_complementary = "-2"; 97 opt_complementary = "-2";
82 opt = getopt32(argv, OPT_STR); 98 opt = getopt32(argv, OPT_STR);
83 argv += optind; 99 argv += optind;