[BusyBox-cvs] CVS busybox/debianutils

CVS User solar solar at codepoet.org
Wed Dec 8 16:47:30 UTC 2004


Update of /var/cvs/busybox/debianutils
In directory nail:/tmp/cvs-serv31942/debianutils

Modified Files:
	Config.in readlink.c 
Log Message:
- CONFIG_FEATURE_READLINK_FOLLOW readlink -f patch from Colin Watson <cjwatson at debian.org> on busybox mailing list 08/11/04

--- /var/cvs/busybox/debianutils/Config.in	2004/03/15 08:28:24	1.7
+++ /var/cvs/busybox/debianutils/Config.in	2004/12/08 16:47:28	1.8
@@ -24,6 +24,13 @@
 	  This program reads a symbolic link and returns the name
 	  of the file it points to
 
+config CONFIG_FEATURE_READLINK_FOLLOW
+	bool "  Enable canonicalization by following all symlinks (-f)"
+	default n
+	depends on CONFIG_READLINK
+	help
+	  Enable the readlink option (-f).
+
 config CONFIG_RUN_PARTS
 	bool "run-parts"
 	default n
--- /var/cvs/busybox/debianutils/readlink.c	2003/03/19 09:11:41	1.2
+++ /var/cvs/busybox/debianutils/readlink.c	2004/12/08 16:47:28	1.3
@@ -23,18 +23,38 @@
 #include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
+#include <getopt.h>
 #include "busybox.h"
 
+#ifdef CONFIG_FEATURE_READLINK_FOLLOW
+# define READLINK_FOLLOW	"f"
+# define READLINK_FLAG_f	(1 << 0)
+#else
+# define READLINK_FOLLOW	""
+#endif
+
+static const char readlink_options[] = READLINK_FOLLOW;
+
 int readlink_main(int argc, char **argv)
 {
 	char *buf = NULL;
+	unsigned long opt = bb_getopt_ulflags(argc, argv, readlink_options);
+#ifdef CONFIG_FEATURE_READLINK_FOLLOW
+	RESERVE_CONFIG_BUFFER(resolved_path, PATH_MAX);
+#endif
 
 	/* no options, no getopt */
 
-	if (argc != 2)
+	if (optind + 1 != argc)
 		bb_show_usage();
 
-	buf = xreadlink(argv[1]);
+#ifdef CONFIG_FEATURE_READLINK_FOLLOW
+	if (opt & READLINK_FLAG_f) {
+		buf = realpath(argv[optind], resolved_path);
+	} else
+#endif
+		buf = xreadlink(argv[optind]);
+
 	if (!buf)
 		return EXIT_FAILURE;
 	puts(buf);



More information about the busybox-cvs mailing list