github.com/hanwen/go-fuse@v1.0.0/fuse/syscall_linux.go (about) 1 // Copyright 2016 the Go-FUSE Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package fuse 6 7 import ( 8 "os" 9 "syscall" 10 "unsafe" 11 ) 12 13 // TODO - move these into Go's syscall package. 14 15 func sys_writev(fd int, iovecs *syscall.Iovec, cnt int) (n int, err error) { 16 n1, _, e1 := syscall.Syscall( 17 syscall.SYS_WRITEV, 18 uintptr(fd), uintptr(unsafe.Pointer(iovecs)), uintptr(cnt)) 19 n = int(n1) 20 if e1 != 0 { 21 err = syscall.Errno(e1) 22 } 23 return n, err 24 } 25 26 func writev(fd int, packet [][]byte) (n int, err error) { 27 iovecs := make([]syscall.Iovec, 0, len(packet)) 28 29 for _, v := range packet { 30 if len(v) == 0 { 31 continue 32 } 33 vec := syscall.Iovec{ 34 Base: &v[0], 35 } 36 vec.SetLen(len(v)) 37 iovecs = append(iovecs, vec) 38 } 39 40 sysErr := handleEINTR(func() error { 41 var err error 42 n, err = sys_writev(fd, &iovecs[0], len(iovecs)) 43 return err 44 }) 45 if sysErr != nil { 46 err = os.NewSyscallError("writev", sysErr) 47 } 48 return n, err 49 }