add support for fractional second timeouts in busybox read (issue #221)

This commit is contained in:
Trammell Hudson 2017-07-18 09:11:05 -04:00
parent f0913e9670
commit 39ade211ce
Failed to extract signature

View File

@ -1,6 +1,6 @@
diff --recursive -u /home/hudson/build/clean/busybox-1.25.0/e2fsprogs/fsck.c ./busybox-1.25.0/e2fsprogs/fsck.c
--- /home/hudson/build/clean/busybox-1.25.0/e2fsprogs/fsck.c 2016-05-26 13:42:44.000000000 -0400
+++ busybox-1.25.0/e2fsprogs/fsck.c 2017-01-28 14:02:37.674839434 -0500
diff -u --recursive ./clean/busybox-1.26.2/e2fsprogs/fsck.c busybox-1.26.2/e2fsprogs/fsck.c
--- ./clean/busybox-1.26.2/e2fsprogs/fsck.c 2016-12-10 12:46:36.000000000 -0500
+++ busybox-1.26.2/e2fsprogs/fsck.c 2017-07-17 09:24:54.571441419 -0400
@@ -1071,7 +1071,7 @@
new_args(); /* G.args[G.num_args - 1] is the last, NULL element */
@ -10,9 +10,9 @@ diff --recursive -u /home/hudson/build/clean/busybox-1.25.0/e2fsprogs/fsck.c ./b
/* Even plain "fsck /dev/hda1" needs fstab to get fs type,
* so we are scanning it anyway */
diff --recursive -u /home/hudson/build/clean/busybox-1.25.0/editors/vi.c ./busybox-1.25.0/editors/vi.c
--- /home/hudson/build/clean/busybox-1.25.0/editors/vi.c 2016-05-26 13:42:44.000000000 -0400
+++ busybox-1.25.0/editors/vi.c 2017-01-28 14:02:19.970827576 -0500
diff -u --recursive ./clean/busybox-1.26.2/editors/vi.c busybox-1.26.2/editors/vi.c
--- ./clean/busybox-1.26.2/editors/vi.c 2016-09-28 17:02:40.000000000 -0400
+++ busybox-1.26.2/editors/vi.c 2017-07-17 09:24:54.571441419 -0400
@@ -1461,7 +1461,7 @@
}
#endif /* FEATURE_VI_SEARCH */
@ -22,9 +22,9 @@ diff --recursive -u /home/hudson/build/clean/busybox-1.25.0/editors/vi.c ./busyb
} else if (strncmp(cmd, "write", i) == 0 // write text to file
|| strncmp(cmd, "wq", i) == 0
|| strncmp(cmd, "wn", i) == 0
diff --recursive -u /home/hudson/build/clean/busybox-1.25.0/libbb/messages.c ./busybox-1.25.0/libbb/messages.c
--- /home/hudson/build/clean/busybox-1.25.0/libbb/messages.c 2016-05-26 13:42:44.000000000 -0400
+++ busybox-1.25.0/libbb/messages.c 2017-01-28 14:14:36.593045461 -0500
diff -u --recursive ./clean/busybox-1.26.2/libbb/messages.c busybox-1.26.2/libbb/messages.c
--- ./clean/busybox-1.26.2/libbb/messages.c 2016-09-27 12:53:50.000000000 -0400
+++ busybox-1.26.2/libbb/messages.c 2017-07-17 09:24:54.575441453 -0400
@@ -17,7 +17,7 @@
#define BB_EXTRA_VERSION BB_BT
#endif
@ -34,3 +34,52 @@ diff --recursive -u /home/hudson/build/clean/busybox-1.25.0/libbb/messages.c ./b
const char bb_banner[] ALIGN1 = BANNER;
diff -u --recursive ./clean/busybox-1.26.2/shell/shell_common.c busybox-1.26.2/shell/shell_common.c
--- ./clean/busybox-1.26.2/shell/shell_common.c 2016-10-07 10:47:12.000000000 -0400
+++ busybox-1.26.2/shell/shell_common.c 2017-07-17 15:16:31.943268623 -0400
@@ -90,19 +90,22 @@
}
end_ms = 0;
if (opt_t) {
+#if 0
end_ms = bb_strtou(opt_t, NULL, 10);
if (errno || end_ms > UINT_MAX / 2048)
return "invalid timeout";
end_ms *= 1000;
-#if 0 /* even bash has no -t N.NNN support */
- ts.tv_sec = bb_strtou(opt_t, &p, 10);
- ts.tv_usec = 0;
+#else
+ /* bash has -t N.NNN support */
+ char * p;
+ int end_sec = bb_strtou(opt_t, &p, 10);
+ int end_usec = 0;
/* EINVAL means number is ok, but not terminated by NUL */
if (*p == '.' && errno == EINVAL) {
char *p2;
if (*++p) {
int scale;
- ts.tv_usec = bb_strtou(p, &p2, 10);
+ end_usec = bb_strtou(p, &p2, 10);
if (errno)
return "invalid timeout";
scale = p2 - p;
@@ -110,14 +113,15 @@
if (scale > 6)
return "invalid timeout";
while (scale++ < 6)
- ts.tv_usec *= 10;
+ end_usec *= 10;
}
- } else if (ts.tv_sec < 0 || errno) {
+ } else if (end_sec < 0 || errno) {
return "invalid timeout";
}
- if (!(ts.tv_sec | ts.tv_usec)) { /* both are 0? */
+ if (!(end_sec | end_usec)) { /* both are 0? */
return "invalid timeout";
}
+ end_ms = end_sec * 1000 + end_usec / 1000;
#endif /* if 0 */
}
fd = STDIN_FILENO;