aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-03-23 12:12:03 +0000
committerRon Yorston <rmy@pobox.com>2012-03-23 12:12:03 +0000
commitb0f54743e36af163ae2530c381c485bb29df13dc (patch)
treecda4cfeaae6e47fe4f14c1b566092be4da9affc4 /coreutils
parent40514a0309939f2446f0d4ed9600cad5de396e7f (diff)
parentba88826c66411affc1da3614742b454654f7298a (diff)
downloadbusybox-w32-b0f54743e36af163ae2530c381c485bb29df13dc.tar.gz
busybox-w32-b0f54743e36af163ae2530c381c485bb29df13dc.tar.bz2
busybox-w32-b0f54743e36af163ae2530c381c485bb29df13dc.zip
Merge branch 'busybox' into merge
Conflicts: Makefile.flags
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/chroot.c1
-rw-r--r--coreutils/cp.c4
-rw-r--r--coreutils/date.c3
-rw-r--r--coreutils/du.c24
-rw-r--r--coreutils/ln.c4
-rw-r--r--coreutils/mkdir.c7
-rw-r--r--coreutils/printf.c26
-rw-r--r--coreutils/test.c15
-rw-r--r--coreutils/touch.c26
-rw-r--r--coreutils/uudecode.c2
-rw-r--r--coreutils/uuencode.c4
11 files changed, 70 insertions, 46 deletions
diff --git a/coreutils/chroot.c b/coreutils/chroot.c
index ab8beb023..633e66b38 100644
--- a/coreutils/chroot.c
+++ b/coreutils/chroot.c
@@ -31,7 +31,6 @@ int chroot_main(int argc UNUSED_PARAM, char **argv)
31 if (!*argv) 31 if (!*argv)
32 bb_show_usage(); 32 bb_show_usage();
33 xchroot(*argv); 33 xchroot(*argv);
34 xchdir("/");
35 34
36 ++argv; 35 ++argv;
37 if (!*argv) { /* no 2nd param (PROG), use shell */ 36 if (!*argv) { /* no 2nd param (PROG), use shell */
diff --git a/coreutils/cp.c b/coreutils/cp.c
index f276d25d7..45efaba72 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -16,9 +16,9 @@
16 */ 16 */
17 17
18//usage:#define cp_trivial_usage 18//usage:#define cp_trivial_usage
19//usage: "[OPTIONS] SOURCE DEST" 19//usage: "[OPTIONS] SOURCE... DEST"
20//usage:#define cp_full_usage "\n\n" 20//usage:#define cp_full_usage "\n\n"
21//usage: "Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY\n" 21//usage: "Copy SOURCE(s) to DEST\n"
22//usage: "\n -a Same as -dpR" 22//usage: "\n -a Same as -dpR"
23//usage: IF_SELINUX( 23//usage: IF_SELINUX(
24//usage: "\n -c Preserve security context" 24//usage: "\n -c Preserve security context"
diff --git a/coreutils/date.c b/coreutils/date.c
index d90e620a0..62cceff9c 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -129,6 +129,9 @@
129//usage: "\n [YYYY.]MM.DD-hh:mm[:ss]" 129//usage: "\n [YYYY.]MM.DD-hh:mm[:ss]"
130//usage: "\n YYYY-MM-DD hh:mm[:ss]" 130//usage: "\n YYYY-MM-DD hh:mm[:ss]"
131//usage: "\n [[[[[YY]YY]MM]DD]hh]mm[.ss]" 131//usage: "\n [[[[[YY]YY]MM]DD]hh]mm[.ss]"
132//usage: IF_FEATURE_DATE_COMPAT(
133//usage: "\n 'date TIME' form accepts MMDDhhmm[[YY]YY][.ss] instead"
134//usage: )
132//usage: 135//usage:
133//usage:#define date_example_usage 136//usage:#define date_example_usage
134//usage: "$ date\n" 137//usage: "$ date\n"
diff --git a/coreutils/du.c b/coreutils/du.c
index 34a549f02..19a0319f1 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -26,11 +26,7 @@
26//usage:#define du_trivial_usage 26//usage:#define du_trivial_usage
27//usage: "[-aHLdclsx" IF_FEATURE_HUMAN_READABLE("hm") "k] [FILE]..." 27//usage: "[-aHLdclsx" IF_FEATURE_HUMAN_READABLE("hm") "k] [FILE]..."
28//usage:#define du_full_usage "\n\n" 28//usage:#define du_full_usage "\n\n"
29//usage: "Summarize disk space used for each FILE and/or directory.\n" 29//usage: "Summarize disk space used for each FILE and/or directory\n"
30//usage: "Disk space is printed in units of "
31//usage: IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K("1024")
32//usage: IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K("512")
33//usage: " bytes.\n"
34//usage: "\n -a Show file sizes too" 30//usage: "\n -a Show file sizes too"
35//usage: "\n -L Follow all symlinks" 31//usage: "\n -L Follow all symlinks"
36//usage: "\n -H Follow symlinks on command line" 32//usage: "\n -H Follow symlinks on command line"
@@ -40,11 +36,13 @@
40//usage: "\n -s Display only a total for each argument" 36//usage: "\n -s Display only a total for each argument"
41//usage: "\n -x Skip directories on different filesystems" 37//usage: "\n -x Skip directories on different filesystems"
42//usage: IF_FEATURE_HUMAN_READABLE( 38//usage: IF_FEATURE_HUMAN_READABLE(
43//usage: "\n -h Sizes in human readable format (e.g., 1K 243M 2G )" 39//usage: "\n -h Sizes in human readable format (e.g., 1K 243M 2G)"
44//usage: "\n -m Sizes in megabytes" 40//usage: "\n -m Sizes in megabytes"
45//usage: ) 41//usage: )
46//usage: "\n -k Sizes in kilobytes" 42//usage: "\n -k Sizes in kilobytes" IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(" (default)")
47//usage: IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(" (default)") 43//usage: IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(
44//usage: "\n Default unit is 512 bytes"
45//usage: )
48//usage: 46//usage:
49//usage:#define du_example_usage 47//usage:#define du_example_usage
50//usage: "$ du\n" 48//usage: "$ du\n"
@@ -91,7 +89,7 @@ struct globals {
91#define INIT_G() do { } while (0) 89#define INIT_G() do { } while (0)
92 90
93 91
94static void print(unsigned long size, const char *filename) 92static void print(unsigned long long size, const char *filename)
95{ 93{
96 /* TODO - May not want to defer error checking here. */ 94 /* TODO - May not want to defer error checking here. */
97#if ENABLE_FEATURE_HUMAN_READABLE 95#if ENABLE_FEATURE_HUMAN_READABLE
@@ -105,15 +103,15 @@ static void print(unsigned long size, const char *filename)
105 size++; 103 size++;
106 size >>= 1; 104 size >>= 1;
107 } 105 }
108 printf("%lu\t%s\n", size, filename); 106 printf("%llu\t%s\n", size, filename);
109#endif 107#endif
110} 108}
111 109
112/* tiny recursive du */ 110/* tiny recursive du */
113static unsigned long du(const char *filename) 111static unsigned long long du(const char *filename)
114{ 112{
115 struct stat statbuf; 113 struct stat statbuf;
116 unsigned long sum; 114 unsigned long long sum;
117 115
118 if (lstat(filename, &statbuf) != 0) { 116 if (lstat(filename, &statbuf) != 0) {
119 bb_simple_perror_msg(filename); 117 bb_simple_perror_msg(filename);
@@ -190,7 +188,7 @@ static unsigned long du(const char *filename)
190int du_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 188int du_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
191int du_main(int argc UNUSED_PARAM, char **argv) 189int du_main(int argc UNUSED_PARAM, char **argv)
192{ 190{
193 unsigned long total; 191 unsigned long long total;
194 int slink_depth_save; 192 int slink_depth_save;
195 unsigned opt; 193 unsigned opt;
196 194
diff --git a/coreutils/ln.c b/coreutils/ln.c
index 88a9a8f91..0eb3e6579 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -69,8 +69,8 @@ int ln_main(int argc, char **argv)
69 src = last; 69 src = last;
70 70
71 if (is_directory(src, 71 if (is_directory(src,
72 (opts & LN_NODEREFERENCE) ^ LN_NODEREFERENCE, 72 (opts & LN_NODEREFERENCE) ^ LN_NODEREFERENCE
73 NULL) 73 )
74 ) { 74 ) {
75 src_name = xstrdup(*argv); 75 src_name = xstrdup(*argv);
76 src = concat_path_file(src, bb_get_last_path_component_strip(src_name)); 76 src = concat_path_file(src, bb_get_last_path_component_strip(src_name));
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index a4429b1cb..b33b6bba3 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -54,7 +54,7 @@ static const char mkdir_longopts[] ALIGN1 =
54int mkdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 54int mkdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
55int mkdir_main(int argc UNUSED_PARAM, char **argv) 55int mkdir_main(int argc UNUSED_PARAM, char **argv)
56{ 56{
57 mode_t mode = (mode_t)(-1); 57 long mode = -1;
58 int status = EXIT_SUCCESS; 58 int status = EXIT_SUCCESS;
59 int flags = 0; 59 int flags = 0;
60 unsigned opt; 60 unsigned opt;
@@ -68,10 +68,11 @@ int mkdir_main(int argc UNUSED_PARAM, char **argv)
68#endif 68#endif
69 opt = getopt32(argv, "m:p" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext)); 69 opt = getopt32(argv, "m:p" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext));
70 if (opt & 1) { 70 if (opt & 1) {
71 mode = 0777; 71 mode_t mmode = 0777;
72 if (!bb_parse_mode(smode, &mode)) { 72 if (!bb_parse_mode(smode, &mmode)) {
73 bb_error_msg_and_die("invalid mode '%s'", smode); 73 bb_error_msg_and_die("invalid mode '%s'", smode);
74 } 74 }
75 mode = mmode;
75 } 76 }
76 if (opt & 2) 77 if (opt & 2)
77 flags |= FILEUTILS_RECUR; 78 flags |= FILEUTILS_RECUR;
diff --git a/coreutils/printf.c b/coreutils/printf.c
index f53aa4787..3dd43a978 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -36,13 +36,12 @@
36 David MacKenzie <djm@gnu.ai.mit.edu> 36 David MacKenzie <djm@gnu.ai.mit.edu>
37*/ 37*/
38 38
39// 19990508 Busy Boxed! Dave Cinege 39/* 19990508 Busy Boxed! Dave Cinege */
40 40
41//usage:#define printf_trivial_usage 41//usage:#define printf_trivial_usage
42//usage: "FORMAT [ARGUMENT]..." 42//usage: "FORMAT [ARG]..."
43//usage:#define printf_full_usage "\n\n" 43//usage:#define printf_full_usage "\n\n"
44//usage: "Format and print ARGUMENT(s) according to FORMAT,\n" 44//usage: "Format and print ARG(s) according to FORMAT (a-la C printf)"
45//usage: "where FORMAT controls the output exactly as in C printf"
46//usage: 45//usage:
47//usage:#define printf_example_usage 46//usage:#define printf_example_usage
48//usage: "$ printf \"Val=%d\\n\" 5\n" 47//usage: "$ printf \"Val=%d\\n\" 5\n"
@@ -132,13 +131,28 @@ static double my_xstrtod(const char *arg)
132 return result; 131 return result;
133} 132}
134 133
134/* Handles %b */
135static void print_esc_string(const char *str) 135static void print_esc_string(const char *str)
136{ 136{
137 char c; 137 char c;
138 while ((c = *str) != '\0') { 138 while ((c = *str) != '\0') {
139 str++; 139 str++;
140 if (c == '\\') 140 if (c == '\\') {
141 c = bb_process_escape_sequence(&str); 141 /* %b also accepts 4-digit octals of the form \0### */
142 if (*str == '0') {
143 if ((unsigned char)(str[1] - '0') < 8) {
144 /* 2nd char is 0..7: skip leading '0' */
145 str++;
146 }
147 }
148 {
149 /* optimization: don't force arg to be on-stack,
150 * use another variable for that. */
151 const char *z = str;
152 c = bb_process_escape_sequence(&z);
153 str = z;
154 }
155 }
142 putchar(c); 156 putchar(c);
143 } 157 }
144} 158}
diff --git a/coreutils/test.c b/coreutils/test.c
index 2e896f4c7..ccfa923da 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -737,7 +737,8 @@ static number_t nexpr(enum token n)
737 if (n == EOI) { 737 if (n == EOI) {
738 /* special case: [ ! ], [ a -a ! ] are valid */ 738 /* special case: [ ! ], [ a -a ! ] are valid */
739 /* IOW, "! ARG" may miss ARG */ 739 /* IOW, "! ARG" may miss ARG */
740 unnest_msg("<nexpr:1 (!EOI)\n"); 740 args--;
741 unnest_msg("<nexpr:1 (!EOI), args:%s(%p)\n", args[0], &args[0]);
741 return 1; 742 return 1;
742 } 743 }
743 res = !nexpr(n); 744 res = !nexpr(n);
@@ -756,15 +757,15 @@ static number_t aexpr(enum token n)
756 757
757 nest_msg(">aexpr(%s)\n", TOKSTR[n]); 758 nest_msg(">aexpr(%s)\n", TOKSTR[n]);
758 res = nexpr(n); 759 res = nexpr(n);
759 dbg_msg("aexpr: nexpr:%lld, next args:%s\n", res, args[1]); 760 dbg_msg("aexpr: nexpr:%lld, next args:%s(%p)\n", res, args[1], &args[1]);
760 if (check_operator(*++args) == BAND) { 761 if (check_operator(*++args) == BAND) {
761 dbg_msg("aexpr: arg is AND, next args:%s\n", args[1]); 762 dbg_msg("aexpr: arg is AND, next args:%s(%p)\n", args[1], &args[1]);
762 res = aexpr(check_operator(*++args)) && res; 763 res = aexpr(check_operator(*++args)) && res;
763 unnest_msg("<aexpr:%lld\n", res); 764 unnest_msg("<aexpr:%lld\n", res);
764 return res; 765 return res;
765 } 766 }
766 args--; 767 args--;
767 unnest_msg("<aexpr:%lld, args:%s\n", res, args[0]); 768 unnest_msg("<aexpr:%lld, args:%s(%p)\n", res, args[0], &args[0]);
768 return res; 769 return res;
769} 770}
770 771
@@ -775,15 +776,15 @@ static number_t oexpr(enum token n)
775 776
776 nest_msg(">oexpr(%s)\n", TOKSTR[n]); 777 nest_msg(">oexpr(%s)\n", TOKSTR[n]);
777 res = aexpr(n); 778 res = aexpr(n);
778 dbg_msg("oexpr: aexpr:%lld, next args:%s\n", res, args[1]); 779 dbg_msg("oexpr: aexpr:%lld, next args:%s(%p)\n", res, args[1], &args[1]);
779 if (check_operator(*++args) == BOR) { 780 if (check_operator(*++args) == BOR) {
780 dbg_msg("oexpr: next arg is OR, next args:%s\n", args[1]); 781 dbg_msg("oexpr: next arg is OR, next args:%s(%p)\n", args[1], &args[1]);
781 res = oexpr(check_operator(*++args)) || res; 782 res = oexpr(check_operator(*++args)) || res;
782 unnest_msg("<oexpr:%lld\n", res); 783 unnest_msg("<oexpr:%lld\n", res);
783 return res; 784 return res;
784 } 785 }
785 args--; 786 args--;
786 unnest_msg("<oexpr:%lld, args:%s\n", res, args[0]); 787 unnest_msg("<oexpr:%lld, args:%s(%p)\n", res, args[0], &args[0]);
787 return res; 788 return res;
788} 789}
789 790
diff --git a/coreutils/touch.c b/coreutils/touch.c
index 0f980fd7b..1216ca202 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -7,7 +7,7 @@
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9 9
10/* BB_AUDIT SUSv3 _NOT_ compliant -- options -a, -m, -r, -t not supported. */ 10/* BB_AUDIT SUSv3 _NOT_ compliant -- options -a, -m not supported. */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/touch.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/touch.html */
12 12
13/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) 13/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
@@ -25,18 +25,26 @@
25//config: help 25//config: help
26//config: touch is used to create or change the access and/or 26//config: touch is used to create or change the access and/or
27//config: modification timestamp of specified files. 27//config: modification timestamp of specified files.
28//config:
29//config:config FEATURE_TOUCH_SUSV3
30//config: bool "Add support for SUSV3 features (-d -t -r)"
31//config: default y
32//config: depends on TOUCH
33//config: help
34//config: Enable touch to use a reference file or a given date/time argument.
28 35
29//applet:IF_TOUCH(APPLET_NOFORK(touch, touch, BB_DIR_BIN, BB_SUID_DROP, touch)) 36//applet:IF_TOUCH(APPLET_NOFORK(touch, touch, BB_DIR_BIN, BB_SUID_DROP, touch))
30 37
31//kbuild:lib-$(CONFIG_TOUCH) += touch.o 38//kbuild:lib-$(CONFIG_TOUCH) += touch.o
32 39
33//usage:#define touch_trivial_usage 40//usage:#define touch_trivial_usage
34//usage: "[-c]" IF_DESKTOP(" [-d DATE] [-r FILE]") " FILE [FILE]..." 41//usage: "[-c]" IF_FEATURE_TOUCH_SUSV3(" [-d DATE] [-t DATE] [-r FILE]") " FILE..."
35//usage:#define touch_full_usage "\n\n" 42//usage:#define touch_full_usage "\n\n"
36//usage: "Update the last-modified date on the given FILE[s]\n" 43//usage: "Update the last-modified date on the given FILE[s]\n"
37//usage: "\n -c Don't create files" 44//usage: "\n -c Don't create files"
38//usage: IF_DESKTOP( 45//usage: IF_FEATURE_TOUCH_SUSV3(
39//usage: "\n -d DT Date/time to use" 46//usage: "\n -d DT Date/time to use"
47//usage: "\n -t DT Date/time to use"
40//usage: "\n -r FILE Use FILE's date/time" 48//usage: "\n -r FILE Use FILE's date/time"
41//usage: ) 49//usage: )
42//usage: 50//usage:
@@ -71,7 +79,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
71 int fd; 79 int fd;
72 int status = EXIT_SUCCESS; 80 int status = EXIT_SUCCESS;
73 int opts; 81 int opts;
74#if ENABLE_DESKTOP 82#if ENABLE_FEATURE_TOUCH_SUSV3
75# if ENABLE_LONG_OPTS 83# if ENABLE_LONG_OPTS
76 static const char touch_longopts[] ALIGN1 = 84 static const char touch_longopts[] ALIGN1 =
77 /* name, has_arg, val */ 85 /* name, has_arg, val */
@@ -90,17 +98,17 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
90# define timebuf ((struct timeval*)NULL) 98# define timebuf ((struct timeval*)NULL)
91#endif 99#endif
92 100
93#if ENABLE_DESKTOP && ENABLE_LONG_OPTS 101#if ENABLE_FEATURE_TOUCH_SUSV3 && ENABLE_LONG_OPTS
94 applet_long_options = touch_longopts; 102 applet_long_options = touch_longopts;
95#endif 103#endif
96 /* -d and -t both set time. In coreutils, 104 /* -d and -t both set time. In coreutils,
97 * accepted data format differs a bit between -d and -t. 105 * accepted data format differs a bit between -d and -t.
98 * We accept the same formats for both */ 106 * We accept the same formats for both */
99 opts = getopt32(argv, "c" IF_DESKTOP("r:d:t:") 107 opts = getopt32(argv, "c" IF_FEATURE_TOUCH_SUSV3("r:d:t:")
100 /*ignored:*/ "fma" 108 /*ignored:*/ "fma"
101 IF_DESKTOP(, &reference_file) 109 IF_FEATURE_TOUCH_SUSV3(, &reference_file)
102 IF_DESKTOP(, &date_str) 110 IF_FEATURE_TOUCH_SUSV3(, &date_str)
103 IF_DESKTOP(, &date_str) 111 IF_FEATURE_TOUCH_SUSV3(, &date_str)
104 ); 112 );
105 113
106 opts &= 1; /* only -c bit is left */ 114 opts &= 1; /* only -c bit is left */
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c
index 23ff711fa..b298fcb95 100644
--- a/coreutils/uudecode.c
+++ b/coreutils/uudecode.c
@@ -15,7 +15,7 @@
15//usage: "[-o OUTFILE] [INFILE]" 15//usage: "[-o OUTFILE] [INFILE]"
16//usage:#define uudecode_full_usage "\n\n" 16//usage:#define uudecode_full_usage "\n\n"
17//usage: "Uudecode a file\n" 17//usage: "Uudecode a file\n"
18//usage: "Finds outfile name in uuencoded source unless -o is given" 18//usage: "Finds OUTFILE in uuencoded source unless -o is given"
19//usage: 19//usage:
20//usage:#define uudecode_example_usage 20//usage:#define uudecode_example_usage
21//usage: "$ uudecode -o busybox busybox.uu\n" 21//usage: "$ uudecode -o busybox busybox.uu\n"
diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c
index 84a489a11..673ef36e7 100644
--- a/coreutils/uuencode.c
+++ b/coreutils/uuencode.c
@@ -9,9 +9,9 @@
9 */ 9 */
10 10
11//usage:#define uuencode_trivial_usage 11//usage:#define uuencode_trivial_usage
12//usage: "[-m] [INFILE] STORED_FILENAME" 12//usage: "[-m] [FILE] STORED_FILENAME"
13//usage:#define uuencode_full_usage "\n\n" 13//usage:#define uuencode_full_usage "\n\n"
14//usage: "Uuencode a file to stdout\n" 14//usage: "Uuencode FILE (or stdin) to stdout\n"
15//usage: "\n -m Use base64 encoding per RFC1521" 15//usage: "\n -m Use base64 encoding per RFC1521"
16//usage: 16//usage:
17//usage:#define uuencode_example_usage 17//usage:#define uuencode_example_usage