func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { newoffset, e := seek(0, fd, offset, whence) if newoffset == -1 { err = syscall.ErrorString(e) } return }
//sys pipe(p *[2]int32) (err error) func Pipe(p []int) (err error) { if len(p) != 2 { return syscall.ErrorString("bad arg in system call") } var pp [2]int32 err = pipe(&pp) p[0] = int(pp[0]) p[1] = int(pp[1]) return }
//sys await(s []byte) (n int, err error) func Await(w *Waitmsg) (err error) { var buf [512]byte var f [5][]byte n, err := await(buf[:]) if err != nil || w == nil { return } nf := 0 p := 0 for i := 0; i < n && nf < len(f)-1; i++ { if buf[i] == ' ' { f[nf] = buf[p:i] p = i + 1 nf++ } } f[nf] = buf[p:] nf++ if nf != len(f) { return syscall.ErrorString("invalid wait message") } w.Pid = int(atoi(f[0])) w.Time[0] = uint32(atoi(f[1])) w.Time[1] = uint32(atoi(f[2])) w.Time[2] = uint32(atoi(f[3])) w.Msg = cstring(f[4]) if w.Msg == "''" { // await() returns '' for no error w.Msg = "" } return }
O_SYNC = 0x00000 O_ASYNC = 0x00000 S_IFMT = 0x1f000 S_IFIFO = 0x1000 S_IFCHR = 0x2000 S_IFDIR = 0x4000 S_IFBLK = 0x6000 S_IFREG = 0x8000 S_IFLNK = 0xa000 S_IFSOCK = 0xc000 ) // Errors var ( EINVAL = syscall.ErrorString("bad arg in system call") ENOTDIR = syscall.ErrorString("not a directory") EISDIR = syscall.ErrorString("file is a directory") ENOENT = syscall.ErrorString("file does not exist") EEXIST = syscall.ErrorString("file already exists") EMFILE = syscall.ErrorString("no free file descriptors") EIO = syscall.ErrorString("i/o error") ENAMETOOLONG = syscall.ErrorString("file name too long") EINTR = syscall.ErrorString("interrupted") EPERM = syscall.ErrorString("permission denied") EBUSY = syscall.ErrorString("no free devices") ETIMEDOUT = syscall.ErrorString("connection timed out") EPLAN9 = syscall.ErrorString("not supported by plan 9") // The following errors do not correspond to any // Plan 9 system messages. Invented to support