aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2002-12-10 00:14:33 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2002-12-10 00:14:33 +0000
commit62fae308a3d92d987711d08f3d36b0ad753c2e18 (patch)
treef51bbc4b9c66bbcc3db041727a2b097e7bb4faac
parent9bf9f1edbec05edbf566c3220835440e1b18fcc8 (diff)
downloadbusybox-w32-62fae308a3d92d987711d08f3d36b0ad753c2e18.tar.gz
busybox-w32-62fae308a3d92d987711d08f3d36b0ad753c2e18.tar.bz2
busybox-w32-62fae308a3d92d987711d08f3d36b0ad753c2e18.zip
Realpath applet
-rw-r--r--coreutils/realpath.c44
-rw-r--r--include/applets.h3
-rw-r--r--include/usage.h5
3 files changed, 52 insertions, 0 deletions
diff --git a/coreutils/realpath.c b/coreutils/realpath.c
new file mode 100644
index 000000000..7ef935ee0
--- /dev/null
+++ b/coreutils/realpath.c
@@ -0,0 +1,44 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 */
16
17#include <limits.h>
18#include <stdlib.h>
19
20#include "busybox.h"
21
22int realpath_main(int argc, char **argv)
23{
24 char *resolved_path;
25 int count;
26
27 if (argc == 1) {
28 show_usage();
29 }
30
31 resolved_path = malloc(PATH_MAX);
32
33 for (count = 1; count < argc; count++) {
34 resolved_path = realpath(argv[count], resolved_path);
35 if (resolved_path) {
36 puts(resolved_path);
37 } else {
38 perror_msg("%s", argv[count]);
39 }
40 }
41 free(resolved_path);
42
43 return(EXIT_SUCCESS);
44} \ No newline at end of file
diff --git a/include/applets.h b/include/applets.h
index d8c4b38a0..b7171f7a1 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -416,6 +416,9 @@
416#ifdef CONFIG_READLINK 416#ifdef CONFIG_READLINK
417 APPLET(readlink, readlink_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) 417 APPLET(readlink, readlink_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
418#endif 418#endif
419#ifdef CONFIG_REALPATH
420 APPLET(realpath, realpath_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
421#endif
419#ifdef CONFIG_REBOOT 422#ifdef CONFIG_REBOOT
420 APPLET(reboot, reboot_main, _BB_DIR_SBIN, _BB_SUID_NEVER) 423 APPLET(reboot, reboot_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
421#endif 424#endif
diff --git a/include/usage.h b/include/usage.h
index 2e8720e94..17fd4073a 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -1638,6 +1638,11 @@
1638#define readlink_full_usage \ 1638#define readlink_full_usage \
1639 "Read a symbolic link." 1639 "Read a symbolic link."
1640 1640
1641#define realpath_trivial_usage \
1642 "pathname ..."
1643#define realpath_full_usage \
1644 "return the canonicalized absolute pathnames of given arguments\n\n"
1645
1641#define reboot_trivial_usage \ 1646#define reboot_trivial_usage \
1642 "" 1647 ""
1643#define reboot_full_usage \ 1648#define reboot_full_usage \