From aa3dbf2947a5bce8c5a3595fafd0e26f184dabf5 Mon Sep 17 00:00:00 2001 From: Lucio De Re Date: Fri, 18 Nov 2011 13:36:06 -0500 Subject: [PATCH] syscall: fix env routines for Plan 9 R=golang-dev CC=ality, golang-dev, rsc https://golang.org/cl/5364063 --- src/pkg/syscall/env_plan9.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/pkg/syscall/env_plan9.go b/src/pkg/syscall/env_plan9.go index 7a6ea90bf1..518573318e 100644 --- a/src/pkg/syscall/env_plan9.go +++ b/src/pkg/syscall/env_plan9.go @@ -10,40 +10,40 @@ import "errors" func Getenv(key string) (value string, found bool) { if len(key) == 0 { - return "", EINVAL + return "", false } - f, e := Open("/env/" + key) + f, e := Open("/env/"+key, O_RDONLY) if e != nil { - return "", ENOENV + return "", false } - defer f.Close() + defer Close(f) - l, _ := f.Seek(0, 2) - f.Seek(0, 0) + l, _ := Seek(f, 0, 2) + Seek(f, 0, 0) buf := make([]byte, l) - n, e := f.Read(buf) + n, e := Read(f, buf) if e != nil { - return "", ENOENV + return "", false } if n > 0 && buf[n-1] == 0 { buf = buf[:n-1] } - return string(buf), nil + return string(buf), true } func Setenv(key, value string) error { if len(key) == 0 { - return EINVAL + return errors.New("bad arg in system call") } - f, e := Create("/env/" + key) + f, e := Create("/env/"+key, O_RDWR, 0666) if e != nil { return e } - defer f.Close() + defer Close(f) - _, e = f.Write([]byte(value)) + _, e = Write(f, []byte(value)) return nil } @@ -54,13 +54,13 @@ func Clearenv() { func Environ() []string { env := make([]string, 0, 100) - f, e := Open("/env") + f, e := Open("/env", O_RDONLY) if e != nil { panic(e) } - defer f.Close() + defer Close(f) - names, e := f.Readdirnames(-1) + names, e := readdirnames(f) if e != nil { panic(e) }