vendor/golang.org/x/sys/unix/syscall_netbsd.go
changeset 256 6d9efbef00a9
parent 251 1c52a0eeb952
child 260 445e01aede7e
equal deleted inserted replaced
255:4f153a23adab 256:6d9efbef00a9
    27 	Nlen   uint8
    27 	Nlen   uint8
    28 	Alen   uint8
    28 	Alen   uint8
    29 	Slen   uint8
    29 	Slen   uint8
    30 	Data   [12]int8
    30 	Data   [12]int8
    31 	raw    RawSockaddrDatalink
    31 	raw    RawSockaddrDatalink
       
    32 }
       
    33 
       
    34 func anyToSockaddrGOOS(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
       
    35 	return nil, EAFNOSUPPORT
    32 }
    36 }
    33 
    37 
    34 func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
    38 func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
    35 
    39 
    36 func sysctlNodes(mib []_C_int) (nodes []Sysctlnode, err error) {
    40 func sysctlNodes(mib []_C_int) (nodes []Sysctlnode, err error) {
   104 
   108 
   105 func direntNamlen(buf []byte) (uint64, bool) {
   109 func direntNamlen(buf []byte) (uint64, bool) {
   106 	return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
   110 	return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
   107 }
   111 }
   108 
   112 
   109 //sysnb pipe() (fd1 int, fd2 int, err error)
   113 //sysnb	pipe() (fd1 int, fd2 int, err error)
       
   114 
   110 func Pipe(p []int) (err error) {
   115 func Pipe(p []int) (err error) {
   111 	if len(p) != 2 {
   116 	if len(p) != 2 {
   112 		return EINVAL
   117 		return EINVAL
   113 	}
   118 	}
   114 	p[0], p[1], err = pipe()
   119 	p[0], p[1], err = pipe()
   115 	return
   120 	return
   116 }
   121 }
   117 
   122 
   118 //sys Getdents(fd int, buf []byte) (n int, err error)
   123 //sysnb	pipe2(p *[2]_C_int, flags int) (err error)
       
   124 
       
   125 func Pipe2(p []int, flags int) error {
       
   126 	if len(p) != 2 {
       
   127 		return EINVAL
       
   128 	}
       
   129 	var pp [2]_C_int
       
   130 	err := pipe2(&pp, flags)
       
   131 	p[0] = int(pp[0])
       
   132 	p[1] = int(pp[1])
       
   133 	return err
       
   134 }
       
   135 
       
   136 //sys	Getdents(fd int, buf []byte) (n int, err error)
       
   137 
   119 func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
   138 func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
   120 	n, err = Getdents(fd, buf)
   139 	n, err = Getdents(fd, buf)
   121 	if err != nil || basep == nil {
   140 	if err != nil || basep == nil {
   122 		return
   141 		return
   123 	}
   142 	}
   139 		err = EIO
   158 		err = EIO
   140 	}
   159 	}
   141 	return
   160 	return
   142 }
   161 }
   143 
   162 
   144 const ImplementsGetwd = true
       
   145 
       
   146 //sys	Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
   163 //sys	Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
   147 
       
   148 func Getwd() (string, error) {
       
   149 	var buf [PathMax]byte
       
   150 	_, err := Getcwd(buf[0:])
       
   151 	if err != nil {
       
   152 		return "", err
       
   153 	}
       
   154 	n := clen(buf[:])
       
   155 	if n < 1 {
       
   156 		return "", EINVAL
       
   157 	}
       
   158 	return string(buf[:n]), nil
       
   159 }
       
   160 
   164 
   161 // TODO
   165 // TODO
   162 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
   166 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
   163 	return -1, ENOSYS
   167 	return -1, ENOSYS
   164 }
   168 }
   168 	return ENOSYS
   172 	return ENOSYS
   169 }
   173 }
   170 
   174 
   171 //sys	ioctl(fd int, req uint, arg uintptr) (err error)
   175 //sys	ioctl(fd int, req uint, arg uintptr) (err error)
   172 
   176 
   173 //sys   sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
   177 //sys	sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
   174 
   178 
   175 func IoctlGetPtmget(fd int, req uint) (*Ptmget, error) {
   179 func IoctlGetPtmget(fd int, req uint) (*Ptmget, error) {
   176 	var value Ptmget
   180 	var value Ptmget
   177 	err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
   181 	err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
   178 	runtime.KeepAlive(value)
   182 	runtime.KeepAlive(value)