blob: ce98f6b524e6564f278655f2153b6a77686313db [file] [log] [blame]
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build fuchsia
// Package fdio provides unix-style IO, implementing Zircon's "system/ulib/fdio"
package fdio
import (
"syscall/zx"
"syscall/zx/io"
)
// MaxUnderlyingHandles is the maximum number of handles which are
// necessary to implement any FDIO object.
const MaxUnderlyingHandles = 2
// FDIO provides classic unix-style IO over various transports
type FDIO interface {
Handles() []zx.Handle
Clone() (FDIO, error)
Close() error
Sync() error
GetAttr() (io.NodeAttributes, error)
SetAttr(flags uint32, attr io.NodeAttributes) error
Ioctl(op uint32, max uint64, in []byte, handles []zx.Handle) ([]byte, []zx.Handle, error)
Read(data []byte) (int, error)
ReadAt(data []byte, off int64) (int, error)
Write(data []byte) (int, error)
WriteAt(data []byte, off int64) (int, error)
Seek(offset int64, whence int) (int64, error)
Truncate(length uint64) error
Open(path string, flags uint32, mode uint32) (FDIO, error)
Link(oldpath, newpath string) error
Rename(oldpath, newpath string) error
Unlink(path string) error
ReadDirents(max uint64) ([]byte, error)
Rewind() error
}
type Vtype uint32
// bit-compatible with POSIX stat
const (
VtypeMask Vtype = 0170000
VtypeSock Vtype = 0140000
VtypeLink Vtype = 0120000
VtypeFile Vtype = 0100000
VtypeBdev Vtype = 0060000
VtypeDir Vtype = 0040000
VtypeCdev Vtype = 0020000
VtypePipe Vtype = 0010000
VtypeISUID Vtype = 0004000
VtypeISGID Vtype = 0002000
VtypeISVTX Vtype = 0001000
VtypeIRWXU Vtype = 0000700
VtypeIRUSR Vtype = 0000400
VtypeIWUSR Vtype = 0000200
VtypeIXUSR Vtype = 0000100
VtypeIRWXG Vtype = 0000070
VtypeIRGRP Vtype = 0000040
VtypeIWGRP Vtype = 0000020
VtypeIXGRP Vtype = 0000010
VtypeIRWXO Vtype = 0000007
VtypeIROTH Vtype = 0000004
VtypeIWOTH Vtype = 0000002
VtypeIXOTH Vtype = 0000001
)
const (
HandleTypeFileDescriptor = 0x30
HandleTypeRemote = 0x32
HandleTypeLogger = 0x35
HandleTypeSocket = 0x36
)