summaryrefslogtreecommitdiff
path: root/libgo/go/syscall/syscall_js.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/syscall/syscall_js.go')
-rw-r--r--libgo/go/syscall/syscall_js.go64
1 files changed, 56 insertions, 8 deletions
diff --git a/libgo/go/syscall/syscall_js.go b/libgo/go/syscall/syscall_js.go
index 2e1a9ec9f1f..99f9a935fe5 100644
--- a/libgo/go/syscall/syscall_js.go
+++ b/libgo/go/syscall/syscall_js.go
@@ -7,6 +7,7 @@
package syscall
import (
+ "internal/oserror"
"sync"
"unsafe"
)
@@ -55,6 +56,22 @@ func (e Errno) Error() string {
return "errno " + itoa(int(e))
}
+func (e Errno) Is(target error) bool {
+ switch target {
+ case oserror.ErrTemporary:
+ return e.Temporary()
+ case oserror.ErrTimeout:
+ return e.Timeout()
+ case oserror.ErrPermission:
+ return e == EACCES || e == EPERM
+ case oserror.ErrExist:
+ return e == EEXIST || e == ENOTEMPTY
+ case oserror.ErrNotExist:
+ return e == ENOENT
+ }
+ return false
+}
+
func (e Errno) Temporary() bool {
return e == EINTR || e == EMFILE || e.Timeout()
}
@@ -268,14 +285,45 @@ func Getwd() (wd string, err error) {
return string(buf[:n]), nil
}
-func Getegid() int { return 1 }
-func Geteuid() int { return 1 }
-func Getgid() int { return 1 }
-func Getgroups() ([]int, error) { return []int{1}, nil }
-func Getppid() int { return 2 }
-func Getpid() int { return 3 }
-func Gettimeofday(tv *Timeval) error { return ENOSYS }
-func Getuid() int { return 1 }
+func Getuid() int {
+ return jsProcess.Call("getuid").Int()
+}
+
+func Getgid() int {
+ return jsProcess.Call("getgid").Int()
+}
+
+func Geteuid() int {
+ return jsProcess.Call("geteuid").Int()
+}
+
+func Getegid() int {
+ return jsProcess.Call("getegid").Int()
+}
+
+func Getgroups() ([]int, error) {
+ array := jsProcess.Call("getgroups")
+ groups := make([]int, array.Length())
+ for i := range groups {
+ groups[i] = array.Index(i).Int()
+ }
+ return groups, nil
+}
+
+func Getpid() int {
+ return jsProcess.Get("pid").Int()
+}
+
+func Getppid() int {
+ return jsProcess.Get("ppid").Int()
+}
+
+func Umask(mask int) (oldmask int) {
+ return jsProcess.Call("umask", mask).Int()
+}
+
+func Gettimeofday(tv *Timeval) error { return ENOSYS }
+
func Kill(pid int, signum Signal) error { return ENOSYS }
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
return 0, ENOSYS