On Sun, Jul 21, 2019 at 12:14 PM <xxxxxx@ancell-ent.com> wrote:

And I wonder for what purposes this is required.  Faking an error when calling errno-error to raise an exception works, otherwise, I've generally desired the reverse mapping.

I don't know any other way of dispatching on the error code, since the mapping isn't consistent across different Posix systems.

  Which the UNIX/POSIX world has not seen fit to provide besides requiring you to follow a trail of crumbs to find the real file, on my Bionic Beaver it totals 5 files after /usr/include/errno.h. 

Construct a file "errno.c" like this:

#include <errno.h>
(define errno/noent ENOENT)
(define errno/perm EPERM)

and then do "gcc -E errno.c | grep -v '^#' | grep -v '^extern' >errno.scm" and you have it.  (You can use clang as well.)   If the specific system doesn't support some E-identifier, you'll get an "undefined variable" error from Scheme.

And of course the message string for humans doesn't include preprocessor define strings like "ESRCH", just "No such process".  Oh, even better, I just noticed the latest POSIX standard says ESTALE is "Reserved", but my Linux defines it as "Stale file handle".

I think that is NFS-specific.
Creating errno/perm etc. will be a bit obnoxious if there are systems out there that don't actually define all of the POSIX set (and of course they can define additional ones, which this SRFI can't require including).  But not that big a deal if there's value to it.

- Harold