The old stuff wasn't working, at least not for echo, which calls bash's
internal error function (builtin_error).  It looks like that
USE_AKAROS_STRERROR wasn't defined.

Now we just tack on errstr after printing the error message and
strerror.  It's not perfect, since the IO stream isn't locked, but it's
good enough.  Additionally, there's a change we're printing an old
errstr, same as with other apps.

Regardless, bash's now reports error strings:

$ echo garbage > /prof/mpstat
bash: echo: write error: Generic Failure, Bad mpstat option (reset|ipi|on|off)

Signed-off-by: Barret Rhoden <b...@cs.berkeley.edu>
---
 .../akaros-patches/4.3.30/0004-errstr-patch   | 60 ++++---------------
 1 file changed, 10 insertions(+), 50 deletions(-)

diff --git a/tools/sys-apps/bash/akaros-patches/4.3.30/0004-errstr-patch 
b/tools/sys-apps/bash/akaros-patches/4.3.30/0004-errstr-patch
index 95a227c35707..dc4ae61a074e 100644
--- a/tools/sys-apps/bash/akaros-patches/4.3.30/0004-errstr-patch
+++ b/tools/sys-apps/bash/akaros-patches/4.3.30/0004-errstr-patch
@@ -1,51 +1,11 @@
-diff -ur bash-4.3.30.dist/error.c bash-4.3.30/error.c
---- bash-4.3.30.dist/error.c   2014-01-17 08:09:33.000000000 -0500
-+++ bash-4.3.30/error.c        2016-05-25 13:40:26.978379551 -0400
-@@ -487,3 +487,32 @@
- {
-   report_error (_("%s: readonly variable"), s);
- }
-+
-+#if defined (USE_AKAROS_STRERROR)
-+#ifndef MAX_ERRSTR_LEN
-+#define MAX_ERRSTR_LEN 128
-+#endif
-+char *
-+akaros_strerror(e)
-+      int e;
-+{
-+  static char emsg[2*MAX_ERRSTR_LEN];
-+  char ebuf[MAX_ERRSTR_LEN];
-+  size_t len;
-+  int serrno;
-+  char *estr, *strerror_str;
-+
-+  serrno = errno;
-+  estr = errstr ();
-+  strerror_str = strerror_r (e, ebuf, sizeof (ebuf));
-+  len = strlen (strerror_str);
-+  if (len > (sizeof (emsg) - 1))
-+    len = sizeof (emsg) - 1;
-+  memmove (emsg, strerror_str, len);
-+  if (e == serrno && estr && *estr)
-+    snprintf (emsg + len, sizeof (emsg) - len, ", %s", estr);
-+  ebuf[sizeof (ebuf) - 1] = '\0';
-+
-+  return emsg;
-+}
-+#endif
-diff -ur bash-4.3.30.dist/mksyntax.c bash-4.3.30/mksyntax.c
---- bash-4.3.30.dist/mksyntax.c        2012-07-29 19:48:38.000000000 -0400
-+++ bash-4.3.30/mksyntax.c     2016-05-25 11:59:57.560352289 -0400
-@@ -40,6 +40,10 @@
- extern int errno;
- #endif
+--- bash-4.3.30.dist/builtins/common.c 2018-09-30 21:21:24.260581893 -0400
++++ bash-4.3.30/builtins/common.c      2018-09-30 21:07:29.591957129 -0400
+@@ -120,6 +120,8 @@
+   SH_VA_START (args, format);
  
-+#ifdef strerror
-+#undef strerror
-+#endif
-+
- #ifndef HAVE_STRERROR
- extern char *strerror();
- #endif
-
+   vfprintf (stderr, format, args);
++  if (errstr())
++    fprintf (stderr, ", %s", errstr());
+   va_end (args);
+   fprintf (stderr, "\n");
+ }
-- 
2.19.0.605.g01d371f741-goog

-- 
You received this message because you are subscribed to the Google Groups 
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akaros+unsubscr...@googlegroups.com.
To post to this group, send email to akaros@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/akaros/20181002192529.228381-8-brho%40cs.berkeley.edu.
For more options, visit https://groups.google.com/d/optout.

Reply via email to