Magellan Linux

Contents of /trunk/mkinitrd-magellan/busybox/coreutils/realpath.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 532 - (show annotations) (download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 1011 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd

1 /* vi: set sw=4 ts=4: */
2
3 /* BB_AUDIT SUSv3 N/A -- Apparently a busybox extension. */
4
5 /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
6 *
7 * Now does proper error checking on output and returns a failure exit code
8 * if one or more paths cannot be resolved.
9 *
10 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
11 */
12
13 #include "busybox.h"
14
15 int realpath_main(int argc, char **argv)
16 {
17 int retval = EXIT_SUCCESS;
18
19 #if PATH_MAX > (BUFSIZ+1)
20 RESERVE_CONFIG_BUFFER(resolved_path, PATH_MAX);
21 # define resolved_path_MUST_FREE 1
22 #else
23 #define resolved_path bb_common_bufsiz1
24 # define resolved_path_MUST_FREE 0
25 #endif
26
27 if (--argc == 0) {
28 bb_show_usage();
29 }
30
31 do {
32 argv++;
33 if (realpath(*argv, resolved_path) != NULL) {
34 puts(resolved_path);
35 } else {
36 retval = EXIT_FAILURE;
37 bb_perror_msg("%s", *argv);
38 }
39 } while (--argc);
40
41 #if ENABLE_FEATURE_CLEAN_UP && resolved_path_MUST_FREE
42 RELEASE_CONFIG_BUFFER(resolved_path);
43 #endif
44
45 fflush_stdout_and_exit(retval);
46 }