aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debianutils/readlink.c40
1 files changed, 8 insertions, 32 deletions
diff --git a/debianutils/readlink.c b/debianutils/readlink.c
index dd5612052..3042b83ec 100644
--- a/debianutils/readlink.c
+++ b/debianutils/readlink.c
@@ -4,20 +4,7 @@
4 * 4 *
5 * Copyright (C) 2000,2001 Matt Kraai <kraai@alumni.carnegiemellon.edu> 5 * Copyright (C) 2000,2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * Licensed under GPL v2, see file LICENSE in this tarball for details.
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */ 8 */
22 9
23#include <errno.h> 10#include <errno.h>
@@ -26,31 +13,20 @@
26#include <getopt.h> 13#include <getopt.h>
27#include "busybox.h" 14#include "busybox.h"
28 15
29#ifdef CONFIG_FEATURE_READLINK_FOLLOW 16#define READLINK_FLAG_f (1 << 0)
30# define READLINK_FOLLOW "f"
31# define READLINK_FLAG_f (1 << 0)
32#else
33# define READLINK_FOLLOW ""
34#endif
35
36static const char readlink_options[] = READLINK_FOLLOW;
37 17
38int readlink_main(int argc, char **argv) 18int readlink_main(int argc, char **argv)
39{ 19{
40 char *buf = NULL; 20 char *buf;
41 unsigned long opt = bb_getopt_ulflags(argc, argv, readlink_options); 21 unsigned long opt = bb_getopt_ulflags(argc, argv,
42#ifdef CONFIG_FEATURE_READLINK_FOLLOW 22 ENABLE_FEATURE_READLINK_FOLLOW ? "f" : "");
43 RESERVE_CONFIG_BUFFER(resolved_path, PATH_MAX);
44#endif
45 23
46 if (optind + 1 != argc) 24 if (optind + 1 != argc)
47 bb_show_usage(); 25 bb_show_usage();
48 26
49#ifdef CONFIG_FEATURE_READLINK_FOLLOW 27 if (ENABLE_FEATURE_READLINK_FOLLOW && (opt & READLINK_FLAG_f))
50 if (opt & READLINK_FLAG_f) { 28 buf = realpath(argv[optind], NULL);
51 buf = realpath(argv[optind], resolved_path); 29 else
52 } else
53#endif
54 buf = xreadlink(argv[optind]); 30 buf = xreadlink(argv[optind]);
55 31
56 if (!buf) 32 if (!buf)