Project import generated by Copybara.
NOKEYCHECK=True
GitOrigin-RevId: 846e4cca8bff85b6448631644a16c474bf2e7e62
diff --git a/busybox.patches/busybox-50.patch b/busybox.patches/busybox-50.patch
new file mode 100644
index 0000000..08d388e
--- /dev/null
+++ b/busybox.patches/busybox-50.patch
@@ -0,0 +1,12 @@
+diff -aruN a/Makefile.flags b/Makefile.flags
+--- a/Makefile.flags 2010-08-22 01:21:38.000000000 -0700
++++ b/Makefile.flags 2010-10-08 14:45:16.517324148 -0700
+@@ -41,7 +41,7 @@
+ ## and I am unwilling to do crazy gcc specific ({ void *ppp = ...; })
+ ## stuff in macros. This would obfuscate the code too much.
+ ## Maybe try __attribute__((__may_alias__))?
+-#CFLAGS += $(call cc-ifversion, -eq, 0404, -fno-strict-aliasing)
++CFLAGS += $(call cc-ifversion, -ge, 0404, -fno-strict-aliasing)
+ endif
+ # gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
+ CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
diff --git a/busybox.patches/busybox-51.patch b/busybox.patches/busybox-51.patch
new file mode 100644
index 0000000..6a97363
--- /dev/null
+++ b/busybox.patches/busybox-51.patch
@@ -0,0 +1,70 @@
+diff -aruN a/sysklogd/syslogd.c c/sysklogd/syslogd.c
+--- a/sysklogd/syslogd.c 2011-10-29 04:43:01.000000000 -0700
++++ c/sysklogd/syslogd.c 2012-01-04 10:11:05.921879376 -0800
+@@ -24,6 +24,7 @@
+ //usage: "\n -O FILE Log to FILE (default:/var/log/messages)"
+ //usage: "\n -l N Log only messages more urgent than prio N (1-8)"
+ //usage: "\n -S Smaller output"
++//usage: "\n -u Log time stamps in Coordinated Universal Time (UTC)"
+ //usage: IF_FEATURE_ROTATE_LOGFILE(
+ //usage: "\n -s SIZE Max size (KB) before rotation (default:200KB, 0=off)"
+ //usage: "\n -b N N rotated logs to keep (default:1, max=99, 0=purge)"
+@@ -205,6 +206,7 @@
+ OPTBIT_outfile, // -O
+ OPTBIT_loglevel, // -l
+ OPTBIT_small, // -S
++ OPTBIT_utc, // -u
+ IF_FEATURE_ROTATE_LOGFILE(OPTBIT_filesize ,) // -s
+ IF_FEATURE_ROTATE_LOGFILE(OPTBIT_rotatecnt ,) // -b
+ IF_FEATURE_REMOTE_LOG( OPTBIT_remotelog ,) // -R
+@@ -218,6 +220,7 @@
+ OPT_outfile = 1 << OPTBIT_outfile ,
+ OPT_loglevel = 1 << OPTBIT_loglevel,
+ OPT_small = 1 << OPTBIT_small ,
++ OPT_utc = 1 << OPTBIT_utc ,
+ OPT_filesize = IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_filesize )) + 0,
+ OPT_rotatecnt = IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_rotatecnt )) + 0,
+ OPT_remotelog = IF_FEATURE_REMOTE_LOG( (1 << OPTBIT_remotelog )) + 0,
+@@ -226,7 +229,7 @@
+ OPT_dup = IF_FEATURE_SYSLOGD_DUP( (1 << OPTBIT_dup )) + 0,
+ OPT_cfg = IF_FEATURE_SYSLOGD_CFG( (1 << OPTBIT_cfg )) + 0,
+ };
+-#define OPTION_STR "m:nO:l:S" \
++#define OPTION_STR "m:nO:l:Su" \
+ IF_FEATURE_ROTATE_LOGFILE("s:" ) \
+ IF_FEATURE_ROTATE_LOGFILE("b:" ) \
+ IF_FEATURE_REMOTE_LOG( "R:" ) \
+@@ -649,10 +652,30 @@
+ || msg[9] != ':' || msg[12] != ':' || msg[15] != ' '
+ ) {
+ time(&now);
+- timestamp = ctime(&now) + 4; /* skip day of week */
++ if (option_mask32 & OPT_utc)
++ timestamp = asctime(gmtime(&now));
++ else
++ timestamp = asctime(localtime(&now));
++ timestamp += 4; /* skip day of week */
+ } else {
+- now = 0;
+- timestamp = msg;
++ if (option_mask32 & OPT_utc) {
++ struct tm parsed, local;
++ now = time(NULL);
++ localtime_r(&now, &local);
++ if (strptime(msg, "%h %e %T", &parsed) != NULL) {
++ parsed.tm_gmtoff = local.tm_gmtoff;
++ parsed.tm_zone = local.tm_zone;
++ parsed.tm_year = local.tm_year;
++ parsed.tm_isdst = local.tm_isdst;
++ now = mktime(&parsed);
++ timestamp = asctime(gmtime(&now)) + 4;
++ } else {
++ timestamp = msg;
++ }
++ } else {
++ now = 0;
++ timestamp = msg;
++ }
+ msg += 16;
+ }
+ timestamp[15] = '\0';
diff --git a/busybox.patches/busybox-52.patch b/busybox.patches/busybox-52.patch
new file mode 100644
index 0000000..d12177b
--- /dev/null
+++ b/busybox.patches/busybox-52.patch
@@ -0,0 +1,121 @@
+diff -aruN a/sysklogd/syslogd.c b/sysklogd/syslogd.c
+--- a/sysklogd/syslogd.c 2012-01-04 10:13:07.989873065 -0800
++++ b/sysklogd/syslogd.c 2012-01-04 10:08:05.000000000 -0800
+@@ -165,10 +165,10 @@
+ /* ...then copy to parsebuf, escaping control chars */
+ /* (can grow x2 max) */
+ char parsebuf[MAX_READ*2];
+- /* ...then sprintf into printbuf, adding timestamp (15 chars),
++ /* ...then sprintf into printbuf, adding timestamp (26 chars),
+ * host (64), fac.prio (20) to the message */
+- /* (growth by: 15 + 64 + 20 + delims = ~110) */
+- char printbuf[MAX_READ*2 + 128];
++ /* (growth by: 26 + 64 + 20 + delims = ~121) */
++ char printbuf[MAX_READ*2 + 139];
+ };
+
+ static const struct init_globals init_data = {
+@@ -638,47 +638,62 @@
+ snprintf(res20, 20, "<%d>", pri);
+ }
+
++static struct tm * generate_time(struct timeval *tvp, struct tm *tmp)
++{
++ struct tm *tm;
++
++ gettimeofday(tvp, NULL);
++
++ if (option_mask32 & OPT_utc) {
++ tm = gmtime_r(&tvp->tv_sec, tmp);
++ } else {
++ tm = localtime_r(&tvp->tv_sec, tmp);
++ }
++
++ return tm;
++}
++
+ /* len parameter is used only for "is there a timestamp?" check.
+ * NB: some callers cheat and supply len==0 when they know
+ * that there is no timestamp, short-circuiting the test. */
+ static void timestamp_and_log(int pri, char *msg, int len)
+ {
+- char *timestamp;
+- time_t now;
++ char timestamp[27];
++ struct timeval tvnow;
++ struct tm parsed, tmnow, *tmp;
++ size_t n;
+
+ /* Jan 18 00:11:22 msg... */
+ /* 01234567890123456 */
+ if (len < 16 || msg[3] != ' ' || msg[6] != ' '
+ || msg[9] != ':' || msg[12] != ':' || msg[15] != ' '
+ ) {
+- time(&now);
+- if (option_mask32 & OPT_utc)
+- timestamp = asctime(gmtime(&now));
+- else
+- timestamp = asctime(localtime(&now));
+- timestamp += 4; /* skip day of week */
++ tmp = generate_time(&tvnow, &tmnow);
+ } else {
+- if (option_mask32 & OPT_utc) {
+- struct tm parsed, local;
+- now = time(NULL);
+- localtime_r(&now, &local);
+- if (strptime(msg, "%h %e %T", &parsed) != NULL) {
+- parsed.tm_gmtoff = local.tm_gmtoff;
+- parsed.tm_zone = local.tm_zone;
+- parsed.tm_year = local.tm_year;
+- parsed.tm_isdst = local.tm_isdst;
+- now = mktime(&parsed);
+- timestamp = asctime(gmtime(&now)) + 4;
++ struct tm local;
++ tvnow.tv_sec = time(NULL);
++ localtime_r(&tvnow.tv_sec, &local);
++ if (strptime(msg, "%h %e %T", &parsed) != NULL) {
++
++ parsed.tm_gmtoff = local.tm_gmtoff;
++ parsed.tm_zone = local.tm_zone;
++ parsed.tm_year = local.tm_year;
++ parsed.tm_isdst = local.tm_isdst;
++ tvnow.tv_sec = mktime(&parsed);
++ tvnow.tv_usec = 0;
++
++ if (option_mask32 & OPT_utc) {
++ tmp = gmtime_r(&tvnow.tv_sec, &tmnow);
+ } else {
+- timestamp = msg;
++ tmp = &parsed;
+ }
+ } else {
+- now = 0;
+- timestamp = msg;
++ tmp = generate_time(&tvnow, &tmnow);
+ }
+ msg += 16;
+ }
+- timestamp[15] = '\0';
++ n = strftime(timestamp, sizeof(timestamp), "%F %T", tmp);
++ snprintf(timestamp + n, sizeof(timestamp) - n, ".%06ld", tvnow.tv_usec);
+
+ if (option_mask32 & OPT_small)
+ sprintf(G.printbuf, "%s %s\n", timestamp, msg);
+@@ -698,7 +713,7 @@
+
+ for (rule = G.log_rules; rule; rule = rule->next) {
+ if (rule->enabled_facility_priomap[facility] & prio_bit) {
+- log_locally(now, G.printbuf, rule->file);
++ log_locally(tvnow.tv_sec, G.printbuf, rule->file);
+ match = 1;
+ }
+ }
+@@ -713,7 +728,7 @@
+ return;
+ }
+ #endif
+- log_locally(now, G.printbuf, &G.logFile);
++ log_locally(tvnow.tv_sec, G.printbuf, &G.logFile);
+ }
+ }
+
diff --git a/busybox.patches/busybox-53.patch b/busybox.patches/busybox-53.patch
new file mode 100644
index 0000000..309517a
--- /dev/null
+++ b/busybox.patches/busybox-53.patch
@@ -0,0 +1,12 @@
+diff -aruN a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
+--- a/scripts/kconfig/Makefile 2011-09-05 19:35:17.000000000 -0700
++++ b/scripts/kconfig/Makefile 2012-01-04 10:28:30.000000000 -0800
+@@ -87,7 +87,7 @@
+ $(MTIME_IS_COARSE) && sleep 1
+
+ %_defconfig: $(obj)/conf
+- $(Q)$< -D configs/$@ Config.in
++ $(Q)$< -D $@ Config.in
+ $(MTIME_IS_COARSE) && sleep 1
+
+ # Help text used by make help
diff --git a/busybox.patches/busybox-54.patch b/busybox.patches/busybox-54.patch
new file mode 100644
index 0000000..bb80a35
--- /dev/null
+++ b/busybox.patches/busybox-54.patch
@@ -0,0 +1,16 @@
+diff -Naur a/util-linux/rdev.c b/util-linux/rdev.c
+--- a/util-linux/rdev.c 2011-09-05 19:35:17.000000000 -0700
++++ b/util-linux/rdev.c 2014-10-24 11:41:55.922803554 -0700
+@@ -23,10 +23,11 @@
+ int rdev_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+ int rdev_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
+ {
+- char const * const root_device = find_block_device("/");
++ char * const root_device = find_block_device("/");
+
+ if (root_device != NULL) {
+ printf("%s /\n", root_device);
++ free(root_device);
+ return EXIT_SUCCESS;
+ }
+ return EXIT_FAILURE;
diff --git a/busybox.patches/busybox-55.patch b/busybox.patches/busybox-55.patch
new file mode 100644
index 0000000..03067f6
--- /dev/null
+++ b/busybox.patches/busybox-55.patch
@@ -0,0 +1,79 @@
+diff -Naur a/libbb/find_root_device.c b/libbb/find_root_device.c
+--- a/libbb/find_root_device.c 2014-10-27 13:01:18.984487421 -0700
++++ b/libbb/find_root_device.c 2014-10-27 13:36:07.469359713 -0700
+@@ -9,6 +9,15 @@
+
+ #include "libbb.h"
+
++/* #define DEBUGGING 1 */
++
++#ifdef DEBUGGING
++#define debug(...) do { printf(__VA_ARGS__); } while (0)
++#else
++#define debug(...) ((void)0)
++#endif
++
++
+ /* Find block device /dev/XXX which contains specified file
+ * We handle /dev/dir/dir/dir too, at a cost of ~80 more bytes code */
+
+@@ -63,6 +72,46 @@
+ return retpath;
+ }
+
++#define PROC_MOUNTINFO "/proc/self/mountinfo"
++/* A major of zero indicates a non-device mount. Use the kernel's show_mountinfo(),
++ * exposed through /proc/self/mountinfo to lookup the device reference. */
++static char *find_device_in_mountinfo(struct arena *ap)
++{
++ char line[1024];
++ char *linePtr;
++ char *retpath = NULL;
++
++ FILE *fp = fopen_for_read(PROC_MOUNTINFO);
++ if (!fp)
++ return NULL;
++
++ debug("Looking for device %u:%u\n", major(ap->dev), minor(ap->dev));
++ while (fgets(line, sizeof(line), fp)) {
++ int mnt_id, parent_mnt_id;
++ unsigned int major, minor;
++ char mnt_typename[1024], mnt_devname[1024];
++
++ linePtr = line;
++ if (sscanf(linePtr, "%i %i %u:%u", &mnt_id, &parent_mnt_id, &major, &minor) != 4) {
++ debug("Couldn't parse line: '%s'\n", line);
++ } else if ((linePtr = strstr(linePtr, " - ")) == NULL) {
++ debug("Couldn't find ' - ': '%s'\n", line);
++ } else if (sscanf(linePtr, " - %s %s ", mnt_typename, mnt_devname) != 2) {
++ debug("Couldn't parse line: '%s'\n", line);
++ } else if ((major(ap->dev) != major) || (minor(ap->dev) != minor)) {
++ debug("Non-matching device %u:%u --> %s\n", major, minor, mnt_devname);
++ } else {
++ debug("Found a match %u:%u --> %s\n", major, minor, mnt_devname);
++ retpath = xstrdup(mnt_devname);
++ break;
++ }
++ }
++
++ fclose(fp);
++
++ return retpath;
++}
++
+ char* FAST_FUNC find_block_device(const char *path)
+ {
+ struct arena a;
+@@ -70,6 +119,10 @@
+ if (stat(path, &a.st) != 0)
+ return NULL;
+ a.dev = S_ISBLK(a.st.st_mode) ? a.st.st_rdev : a.st.st_dev;
+- strcpy(a.devpath, "/dev");
+- return find_block_device_in_dir(&a);
++ if (major(a.dev) != 0) {
++ strcpy(a.devpath, "/dev");
++ return find_block_device_in_dir(&a);
++ } else {
++ return find_device_in_mountinfo(&a);
++ }
+ }
diff --git a/busybox.patches/busybox-56.patch b/busybox.patches/busybox-56.patch
new file mode 100644
index 0000000..23f2337
--- /dev/null
+++ b/busybox.patches/busybox-56.patch
@@ -0,0 +1,11 @@
+diff -Naur a/include/libbb.h b/include/libbb.h
+--- a/include/libbb.h 2011-09-05 19:35:36.000000000 -0700
++++ b/include/libbb.h 2016-09-07 22:07:18.448919508 -0700
+@@ -35,6 +35,7 @@
+ #include <sys/poll.h>
+ #include <sys/ioctl.h>
+ #include <sys/mman.h>
++#include <sys/resource.h>
+ #include <sys/socket.h>
+ #include <sys/stat.h>
+ #include <sys/time.h>
diff --git a/busybox.patches/busybox-57.patch b/busybox.patches/busybox-57.patch
new file mode 100644
index 0000000..86f5b75
--- /dev/null
+++ b/busybox.patches/busybox-57.patch
@@ -0,0 +1,40 @@
+diff -aruN a/sysklogd/syslogd.c b/sysklogd/syslogd.c
+--- a/sysklogd/syslogd.c 2017-03-07 13:38:44.406178588 -0800
++++ b/sysklogd/syslogd.c 2017-03-07 13:34:40.891055910 -0800
+@@ -665,33 +665,12 @@
+
+ /* Jan 18 00:11:22 msg... */
+ /* 01234567890123456 */
+- if (len < 16 || msg[3] != ' ' || msg[6] != ' '
++ if (!(len < 16 || msg[3] != ' ' || msg[6] != ' '
+ || msg[9] != ':' || msg[12] != ':' || msg[15] != ' '
+- ) {
+- tmp = generate_time(&tvnow, &tmnow);
+- } else {
+- struct tm local;
+- tvnow.tv_sec = time(NULL);
+- localtime_r(&tvnow.tv_sec, &local);
+- if (strptime(msg, "%h %e %T", &parsed) != NULL) {
+-
+- parsed.tm_gmtoff = local.tm_gmtoff;
+- parsed.tm_zone = local.tm_zone;
+- parsed.tm_year = local.tm_year;
+- parsed.tm_isdst = local.tm_isdst;
+- tvnow.tv_sec = mktime(&parsed);
+- tvnow.tv_usec = 0;
+-
+- if (option_mask32 & OPT_utc) {
+- tmp = gmtime_r(&tvnow.tv_sec, &tmnow);
+- } else {
+- tmp = &parsed;
+- }
+- } else {
+- tmp = generate_time(&tvnow, &tmnow);
+- }
++ )) {
+ msg += 16;
+ }
++ tmp = generate_time(&tvnow, &tmnow);
+ n = strftime(timestamp, sizeof(timestamp), "%F %T", tmp);
+ snprintf(timestamp + n, sizeof(timestamp) - n, ".%06ld", tvnow.tv_usec);
+
diff --git a/busybox.tar.bz2 b/busybox.tar.bz2
new file mode 100644
index 0000000..34a1a92
--- /dev/null
+++ b/busybox.tar.bz2
Binary files differ
diff --git a/busybox.url b/busybox.url
new file mode 100644
index 0000000..194e9ca
--- /dev/null
+++ b/busybox.url
@@ -0,0 +1 @@
+http://busybox.net/downloads/busybox-1.19.3.tar.bz2
diff --git a/busybox.version b/busybox.version
new file mode 100644
index 0000000..1b92e58
--- /dev/null
+++ b/busybox.version
@@ -0,0 +1 @@
+1.19.3