// NewSyscallError returns, as an error, a new SyscallError
// with the given system call name and error details.
// As a convenience, if err is nil, NewSyscallError returns nil.
-func NewSyscallError(syscall string, err syscall.Error) error {
+func NewSyscallError(syscall string, err error) error {
if err == nil {
return nil
}
func OpenFile(name string, flag int, perm uint32) (file *File, err error) {
var (
fd int
- e syscall.Error
+ e error
create bool
excl bool
trunc bool
} else {
fd, e = syscall.Open(name, flag)
if e != nil && create {
- var e1 syscall.Error
+ var e1 error
fd, e1 = syscall.Create(name, flag, perm)
if e1 == nil {
e = nil
// read reads up to len(b) bytes from the File.
// It returns the number of bytes read and an error, if any.
-func (f *File) read(b []byte) (n int, err syscall.Error) {
+func (f *File) read(b []byte) (n int, err error) {
return syscall.Read(f.fd, b)
}
// pread reads len(b) bytes from the File starting at byte offset off.
// It returns the number of bytes read and the error, if any.
// EOF is signaled by a zero count with err set to nil.
-func (f *File) pread(b []byte, off int64) (n int, err syscall.Error) {
+func (f *File) pread(b []byte, off int64) (n int, err error) {
return syscall.Pread(f.fd, b, off)
}
// write writes len(b) bytes to the File.
// It returns the number of bytes written and an error, if any.
-func (f *File) write(b []byte) (n int, err syscall.Error) {
+func (f *File) write(b []byte) (n int, err error) {
return syscall.Write(f.fd, b)
}
// pwrite writes len(b) bytes to the File starting at byte offset off.
// It returns the number of bytes written and an error, if any.
-func (f *File) pwrite(b []byte, off int64) (n int, err syscall.Error) {
+func (f *File) pwrite(b []byte, off int64) (n int, err error) {
return syscall.Pwrite(f.fd, b, off)
}
// according to whence: 0 means relative to the origin of the file, 1 means
// relative to the current offset, and 2 means relative to the end.
// It returns the new offset and an error, if any.
-func (f *File) seek(offset int64, whence int) (ret int64, err syscall.Error) {
+func (f *File) seek(offset int64, whence int) (ret int64, err error) {
return syscall.Seek(f.fd, offset, whence)
}
buf := make([]byte, nd)
var n int
- var e syscall.Error
+ var e error
switch syscallArg := arg.(type) {
case *File:
}
// readdirnames returns the names of files inside the directory represented by dirfd.
-func readdirnames(dirfd int) (names []string, err Error) {
+func readdirnames(dirfd int) (names []string, err error) {
result := make([]string, 0, 100)
var buf [STATMAX]byte
// readdupdevice returns a list of currently opened fds (excluding stdin, stdout, stderr) from the dup device #d.
// ForkLock should be write locked before calling, so that no new fds would be created while the fd list is being read.
-func readdupdevice() (fds []int, err Error) {
+func readdupdevice() (fds []int, err error) {
dupdevfd, err := Open("#d", O_RDONLY)
if err != nil {
// no rescheduling, no malloc calls, and no new stack segments.
// The calls to RawSyscall are okay because they are assembly
// functions that do not grow the stack.
-func forkAndExecInChild(argv0 *byte, argv []*byte, envv []envItem, dir *byte, attr *ProcAttr, fdsToClose []int, pipe int, rflag int) (pid int, err Error) {
+func forkAndExecInChild(argv0 *byte, argv []*byte, envv []envItem, dir *byte, attr *ProcAttr, fdsToClose []int, pipe int, rflag int) (pid int, err error) {
// Declare all variables at top in case any
// declarations require heap allocation (e.g., errbuf).
var (
panic("unreached")
}
-func cexecPipe(p []int) Error {
+func cexecPipe(p []int) error {
e := Pipe(p)
if e != nil {
return e
var zeroProcAttr ProcAttr
var zeroSysProcAttr SysProcAttr
-func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err Error) {
+func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) {
var (
p [2]int
n int
}
// Combination of fork and exec, careful to be thread safe.
-func ForkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err Error) {
+func ForkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) {
return forkExec(argv0, argv, attr)
}
// StartProcess wraps ForkExec for package os.
-func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid, handle int, err Error) {
+func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid, handle int, err error) {
pid, err = forkExec(argv0, argv, attr)
return pid, 0, err
}
// Ordinary exec.
-func Exec(argv0 string, argv []string, envv []string) (err Error) {
+func Exec(argv0 string, argv []string, envv []string) (err error) {
if envv != nil {
r1, _, _ := RawSyscall(SYS_RFORK, RFCENVG, 0, 0)
if int(r1) == -1 {
func (e ErrorString) Error() string { return string(e) }
// NewError converts s to an ErrorString, which satisfies the Error interface.
-func NewError(s string) Error { return ErrorString(s) }
+func NewError(s string) error { return ErrorString(s) }
var (
Stdin = 0
Exits(&msg)
}
-func readnum(path string) (uint, Error) {
+func readnum(path string) (uint, error) {
var b [12]byte
fd, e := Open(path, O_RDONLY)
return int(n)
}
-func Read(fd int, p []byte) (n int, err Error) {
+func Read(fd int, p []byte) (n int, err error) {
return Pread(fd, p, -1)
}
-func Write(fd int, p []byte) (n int, err Error) {
+func Write(fd int, p []byte) (n int, err error) {
return Pwrite(fd, p, -1)
}
-func Getwd() (wd string, err Error) {
+func Getwd() (wd string, err error) {
fd, e := Open(".", O_RDONLY)
if e != nil {
return Fd2path(fd)
}
-//sys fd2path(fd int, buf []byte) (err Error)
-func Fd2path(fd int) (path string, err Error) {
+//sys fd2path(fd int, buf []byte) (err error)
+func Fd2path(fd int) (path string, err error) {
var buf [512]byte
e := fd2path(fd, buf[:])
return cstring(buf[:]), nil
}
-//sys pipe(p *[2]_C_int) (err Error)
-func Pipe(p []int) (err Error) {
+//sys pipe(p *[2]_C_int) (err error)
+func Pipe(p []int) (err error) {
if len(p) != 2 {
return NewError("bad arg in system call")
}
// Implemented in assembly to avoid allocation.
func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string)
-func Seek(fd int, offset int64, whence int) (newoffset int64, err Error) {
+func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
newoffset, e := seek(0, fd, offset, whence)
err = nil
return
}
-func Mkdir(path string, mode uint32) (err Error) {
+func Mkdir(path string, mode uint32) (err error) {
fd, err := Create(path, O_RDONLY, DMDIR|mode)
if fd != -1 {
return 1
}
-//sys await(s []byte) (n int, err Error)
-func Await(w *Waitmsg) (err Error) {
+//sys await(s []byte) (n int, err error)
+func Await(w *Waitmsg) (err error) {
var buf [512]byte
var f [5][]byte
return
}
-func Unmount(name, old string) (err Error) {
+func Unmount(name, old string) (err error) {
oldp := uintptr(unsafe.Pointer(StringBytePtr(old)))
var r0 uintptr
return
}
-func Fchdir(fd int) (err Error) {
+func Fchdir(fd int) (err error) {
path, err := Fd2path(fd)
if err != nil {
return
}
-func DecodeBintime(b []byte) (nsec int64, err Error) {
+func DecodeBintime(b []byte) (nsec int64, err error) {
if len(b) != 8 {
return -1, NewError("bad /dev/bintime format")
}
return
}
-func Gettimeofday(tv *Timeval) (err Error) {
+func Gettimeofday(tv *Timeval) (err error) {
// TODO(paulzhol):
// avoid reopening a file descriptor for /dev/bintime on each call,
// use lower-level calls to avoid allocation.
func Getgid() (gid int) { return -1 }
func Getuid() (uid int) { return -1 }
-func Getgroups() (gids []int, err Error) {
+func Getgroups() (gids []int, err error) {
return make([]int, 0), nil
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func fd2path(fd int, buf []byte) (err Error) {
+func fd2path(fd int, buf []byte) (err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func pipe(p *[2]_C_int) (err Error) {
+func pipe(p *[2]_C_int) (err error) {
r0, _, e1 := Syscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
err = nil
if int(r0) == -1 {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func sleep(millisecs int32) (err Error) {
+func sleep(millisecs int32) (err error) {
r0, _, e1 := Syscall(SYS_SLEEP, uintptr(millisecs), 0, 0)
err = nil
if int(r0) == -1 {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func await(s []byte) (n int, err Error) {
+func await(s []byte) (n int, err error) {
var _p0 unsafe.Pointer
if len(s) > 0 {
_p0 = unsafe.Pointer(&s[0])
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Dup(oldfd int, newfd int) (fd int, err Error) {
+func Dup(oldfd int, newfd int) (fd int, err error) {
r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), uintptr(newfd), 0)
fd = int(r0)
err = nil
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Open(path string, mode int) (fd int, err Error) {
+func Open(path string, mode int) (fd int, err error) {
r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(mode), 0)
fd = int(r0)
err = nil
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Create(path string, mode int, perm uint32) (fd int, err Error) {
+func Create(path string, mode int, perm uint32) (fd int, err error) {
r0, _, e1 := Syscall(SYS_CREATE, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(mode), uintptr(perm))
fd = int(r0)
err = nil
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Remove(path string) (err Error) {
+func Remove(path string) (err error) {
r0, _, e1 := Syscall(SYS_REMOVE, uintptr(unsafe.Pointer(StringBytePtr(path))), 0, 0)
err = nil
if int(r0) == -1 {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Pread(fd int, p []byte, offset int64) (n int, err Error) {
+func Pread(fd int, p []byte, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Pwrite(fd int, p []byte, offset int64) (n int, err Error) {
+func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Close(fd int) (err Error) {
+func Close(fd int) (err error) {
r0, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
err = nil
if int(r0) == -1 {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Chdir(path string) (err Error) {
+func Chdir(path string) (err error) {
r0, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(StringBytePtr(path))), 0, 0)
err = nil
if int(r0) == -1 {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Bind(name string, old string, flag int) (err Error) {
+func Bind(name string, old string, flag int) (err error) {
r0, _, e1 := Syscall(SYS_BIND, uintptr(unsafe.Pointer(StringBytePtr(name))), uintptr(unsafe.Pointer(StringBytePtr(old))), uintptr(flag))
err = nil
if int(r0) == -1 {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Mount(fd int, afd int, old string, flag int, aname string) (err Error) {
+func Mount(fd int, afd int, old string, flag int, aname string) (err error) {
r0, _, e1 := Syscall6(SYS_MOUNT, uintptr(fd), uintptr(afd), uintptr(unsafe.Pointer(StringBytePtr(old))), uintptr(flag), uintptr(unsafe.Pointer(StringBytePtr(aname))), 0)
err = nil
if int(r0) == -1 {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Stat(path string, edir []byte) (n int, err Error) {
+func Stat(path string, edir []byte) (n int, err error) {
var _p0 unsafe.Pointer
if len(edir) > 0 {
_p0 = unsafe.Pointer(&edir[0])
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Fstat(fd int, edir []byte) (n int, err Error) {
+func Fstat(fd int, edir []byte) (n int, err error) {
var _p0 unsafe.Pointer
if len(edir) > 0 {
_p0 = unsafe.Pointer(&edir[0])
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Wstat(path string, edir []byte) (err Error) {
+func Wstat(path string, edir []byte) (err error) {
var _p0 unsafe.Pointer
if len(edir) > 0 {
_p0 = unsafe.Pointer(&edir[0])
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Fwstat(fd int, edir []byte) (err Error) {
+func Fwstat(fd int, edir []byte) (err error) {
var _p0 unsafe.Pointer
if len(edir) > 0 {
_p0 = unsafe.Pointer(&edir[0])
package time
-import (
- "os"
- "syscall"
-)
-
// for testing: whatever interrupts a sleep
func interrupt() {
// cannot predict pid, don't want to kill group