ref: ca845d8cb698f7822497046525c1ea477a944835
parent: 1bb9fd59499eb6fb7e8b56e4cee72365074d172e
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Oct 7 01:34:42 EDT 2015
Actually check the last error.
--- a/lib/std/syswrap+plan9.myr
+++ b/lib/std/syswrap+plan9.myr
@@ -4,6 +4,8 @@
use "types.use"
use "errno.use"
use "result.use"
+use "cstrconv.use"
+use "strfind.use"
pkg std =
type fd = sys.fd
@@ -235,5 +237,25 @@
}
const lasterr = {
- -> Emisc
+ var errbuf : byte[sys.Maxerr]
+ var err
+
+ sys.errstr(errbuf[:])
+ err = cstrconv(errbuf[:])
+ if strhas(err, "no error")
+ -> Enone
+ elif strhas(err, "already exists")
+ -> Eexist
+ elif strhas(err, "read or write too large")
+ -> Erange
+ elif strhas(err, "read or write too small")
+ -> Erange
+ elif strhas(err, "i/o error")
+ -> Eio
+ elif strhas(err, "fd out of range or not open")
+ -> Ebadf
+ else
+ -> Emisc
+ ;;
}
+
--- a/lib/sys/sys+plan9-x64.myr
+++ b/lib/sys/sys+plan9-x64.myr
@@ -25,6 +25,7 @@
what : uint32 /* plink */
;;
+ const Maxerr : size = 128
const Ordonly : fdopt = 0
const Owronly : fdopt = 1