1 /* vi: set sw=4 ts=4: */
3 * Mini readlink implementation for busybox
5 * Copyright (C) 2000,2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
7 * Licensed under GPL v2 or later, see file LICENSE in this tarball for details.
16 #define READLINK_FLAG_f (1 << 0)
18 int readlink_main(int argc, char **argv)
21 unsigned opt = ENABLE_FEATURE_READLINK_FOLLOW ?
22 getopt32(argc, argv, "f") : 0;
24 if (argc != (ENABLE_FEATURE_READLINK_FOLLOW ? optind + 1 : 2))
27 if (opt & READLINK_FLAG_f)
28 buf = realpath(argv[optind], bb_common_bufsiz1);
30 buf = xreadlink(argv[ENABLE_FEATURE_READLINK_FOLLOW ? optind : 1]);
36 if (ENABLE_FEATURE_CLEAN_UP && buf != bb_common_bufsiz1)