diff options
-rw-r--r-- | coreutils/Kbuild | 2 | ||||
-rw-r--r-- | coreutils/chgrp.c | 48 | ||||
-rw-r--r-- | include/usage.h | 10 |
3 files changed, 19 insertions, 41 deletions
diff --git a/coreutils/Kbuild b/coreutils/Kbuild index cf1718419..cfb508d81 100644 --- a/coreutils/Kbuild +++ b/coreutils/Kbuild @@ -11,7 +11,7 @@ lib-$(CONFIG_BASENAME) += basename.o lib-$(CONFIG_CAL) += cal.o lib-$(CONFIG_CAT) += cat.o lib-$(CONFIG_CATV) += catv.o -lib-$(CONFIG_CHGRP) += chgrp.o +lib-$(CONFIG_CHGRP) += chgrp.o chown.o lib-$(CONFIG_CHMOD) += chmod.o lib-$(CONFIG_CHOWN) += chown.o lib-$(CONFIG_CHROOT) += chroot.o diff --git a/coreutils/chgrp.c b/coreutils/chgrp.c index e62bd16f0..da5b12964 100644 --- a/coreutils/chgrp.c +++ b/coreutils/chgrp.c @@ -7,49 +7,21 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -/* BB_AUDIT SUSv3 defects - unsupported options -h, -H, -L, and -P. */ -/* BB_AUDIT GNU defects - unsupported options -h, -c, -f, -v, and long options. */ -/* BB_AUDIT Note: gnu chgrp does not support -H, -L, or -P. */ +/* BB_AUDIT SUSv3 defects - unsupported options -H, -L, and -P. */ +/* BB_AUDIT GNU defects - unsupported long options. */ /* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */ -#include <stdlib.h> -#include <unistd.h> #include "busybox.h" -static int fileAction(const char *fileName, struct stat *statbuf, void* junk) -{ - if (lchown(fileName, statbuf->st_uid, *((long *) junk)) == 0) { - return (TRUE); - } - bb_perror_msg("%s", fileName); /* Avoid multibyte problems. */ - return (FALSE); -} - int chgrp_main(int argc, char **argv) { - long gid; - int recursiveFlag; - int retval = EXIT_SUCCESS; - - recursiveFlag = getopt32(argc, argv, "R"); - - if (argc - optind < 2) { - bb_show_usage(); - } - - argv += optind; - - /* Find the selected group */ - gid = get_ug_id(*argv, bb_xgetgrnam); - ++argv; - - /* Ok, ready to do the deed now */ - do { - if (! recursive_action (*argv, recursiveFlag, FALSE, FALSE, - fileAction, fileAction, &gid)) { - retval = EXIT_FAILURE; + /* "chgrp [opts] abc file(s)" == "chown [opts] :abc file(s)" */ + char **p = argv; + while (*++p) { + if (p[0][0] != '-') { + p[0] = xasprintf(":%s", p[0]); + break; } - } while (*++argv); - - return retval; + } + return chown_main(argc, argv); } diff --git a/include/usage.h b/include/usage.h index 8d61c2907..46bb9eca4 100644 --- a/include/usage.h +++ b/include/usage.h @@ -169,11 +169,17 @@ "\t-v\tset the file's version/generation number" #define chgrp_trivial_usage \ - "[OPTION]... GROUP FILE..." + "[-Rh"USE_DESKTOP("cvf")"]... GROUP FILE..." #define chgrp_full_usage \ "Change the group membership of each FILE to GROUP.\n" \ "\nOptions:\n" \ - "\t-R\tChanges files and directories recursively" + "\t-R\tChanges files and directories recursively\n" \ + "\t-h\tDo not dereference symbolic links" \ + USE_DESKTOP( \ + "\n\t-c\tList changed files" \ + "\n\t-v\tList all files" \ + "\n\t-f\tHide errors" \ + ) #define chgrp_example_usage \ "$ ls -l /tmp/foo\n" \ "-r--r--r-- 1 andersen andersen 0 Apr 12 18:25 /tmp/foo\n" \ |