Commit abd32609 authored by Russ Cox's avatar Russ Cox

os: fixes for error (plan9)

The Plan 9 build stops in runtime,
but might as well fix these anyway.

R=adg
CC=golang-dev
https://golang.org/cl/5336045
parent f7b7338e
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package os package os
import ( import (
"errors"
"io" "io"
"syscall" "syscall"
) )
...@@ -293,7 +294,7 @@ func pbit64(b []byte, x uint64) []byte { ...@@ -293,7 +294,7 @@ func pbit64(b []byte, x uint64) []byte {
// pstring appends a Go string s to a 9P message b. // pstring appends a Go string s to a 9P message b.
func pstring(b []byte, s string) []byte { func pstring(b []byte, s string) []byte {
if len(s) >= 1<<16 { if len(s) >= 1<<16 {
panic(NewError("string too long")) panic(errors.New("string too long"))
} }
b = pbit16(b, uint16(len(s))) b = pbit16(b, uint16(len(s)))
b = append(b, s...) b = append(b, s...)
......
...@@ -6,10 +6,13 @@ ...@@ -6,10 +6,13 @@
package os package os
import "syscall" import (
"error"
"syscall"
)
// ENOENV is the error indicating that an environment variable does not exist. // ENOENV is the error indicating that an environment variable does not exist.
var ENOENV = NewError("no such environment variable") var ENOENV = errors.New("no such environment variable")
// Getenverror retrieves the value of the environment variable named by the key. // Getenverror retrieves the value of the environment variable named by the key.
// It returns the value and an error, if any. // It returns the value and an error, if any.
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
package os package os
import syscall "syscall" import (
"errors"
"syscall"
)
// SyscallError records an error from a specific system call. // SyscallError records an error from a specific system call.
type SyscallError struct { type SyscallError struct {
...@@ -29,15 +32,15 @@ func NewSyscallError(syscall string, err syscall.Error) error { ...@@ -29,15 +32,15 @@ func NewSyscallError(syscall string, err syscall.Error) error {
} }
var ( var (
Eshortstat = NewError("stat buffer too small") Eshortstat = errors.New("stat buffer too small")
Ebadstat = NewError("malformed stat buffer") Ebadstat = errors.New("malformed stat buffer")
Ebadfd = NewError("fd out of range or not open") Ebadfd = errors.New("fd out of range or not open")
Ebadarg = NewError("bad arg in system call") Ebadarg = errors.New("bad arg in system call")
Enotdir = NewError("not a directory") Enotdir = errors.New("not a directory")
Enonexist = NewError("file does not exist") Enonexist = errors.New("file does not exist")
Eexist = NewError("file already exists") Eexist = errors.New("file already exists")
Eio = NewError("i/o error") Eio = errors.New("i/o error")
Eperm = NewError("permission denied") Eperm = errors.New("permission denied")
EINVAL = Ebadarg EINVAL = Ebadarg
ENOTDIR = Enotdir ENOTDIR = Enotdir
...@@ -48,11 +51,11 @@ var ( ...@@ -48,11 +51,11 @@ var (
EPERM = Eperm EPERM = Eperm
EISDIR = syscall.EISDIR EISDIR = syscall.EISDIR
EBADF = NewError("bad file descriptor") EBADF = errors.New("bad file descriptor")
ENAMETOOLONG = NewError("file name too long") ENAMETOOLONG = errors.New("file name too long")
ERANGE = NewError("math result not representable") ERANGE = errors.New("math result not representable")
EPIPE = NewError("Broken Pipe") EPIPE = errors.New("Broken Pipe")
EPLAN9 = NewError("not supported by plan 9") EPLAN9 = errors.New("not supported by plan 9")
) )
func iserror(err syscall.Error) bool { func iserror(err syscall.Error) bool {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment