svn commit: trunk/busybox: coreutils include

vda at busybox.net vda at busybox.net
Fri Oct 27 23:28:39 UTC 2006


Author: vda
Date: 2006-10-27 16:28:38 -0700 (Fri, 27 Oct 2006)
New Revision: 16461

Log:
chgrp: just call chown! :)


Modified:
   trunk/busybox/coreutils/Kbuild
   trunk/busybox/coreutils/chgrp.c
   trunk/busybox/include/usage.h


Changeset:
Modified: trunk/busybox/coreutils/Kbuild
===================================================================
--- trunk/busybox/coreutils/Kbuild	2006-10-27 17:59:14 UTC (rev 16460)
+++ trunk/busybox/coreutils/Kbuild	2006-10-27 23:28:38 UTC (rev 16461)
@@ -11,7 +11,7 @@
 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

Modified: trunk/busybox/coreutils/chgrp.c
===================================================================
--- trunk/busybox/coreutils/chgrp.c	2006-10-27 17:59:14 UTC (rev 16460)
+++ trunk/busybox/coreutils/chgrp.c	2006-10-27 23:28:38 UTC (rev 16461)
@@ -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);
 }

Modified: trunk/busybox/include/usage.h
===================================================================
--- trunk/busybox/include/usage.h	2006-10-27 17:59:14 UTC (rev 16460)
+++ trunk/busybox/include/usage.h	2006-10-27 23:28:38 UTC (rev 16461)
@@ -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" \




More information about the busybox-cvs mailing list