github.com/FISCO-BCOS/crypto@v0.0.0-20200202032121-bd8ab0b5d4f1/internal/poll/fd_posix.go (about) 1 // Copyright 2009 The Go 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 // +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris windows 6 7 package poll 8 9 import ( 10 "io" 11 "syscall" 12 ) 13 14 // eofError returns io.EOF when fd is available for reading end of 15 // file. 16 func (fd *FD) eofError(n int, err error) error { 17 if n == 0 && err == nil && fd.ZeroReadIsEOF { 18 return io.EOF 19 } 20 return err 21 } 22 23 // Fchmod wraps syscall.Fchmod. 24 func (fd *FD) Fchmod(mode uint32) error { 25 if err := fd.incref(); err != nil { 26 return err 27 } 28 defer fd.decref() 29 return syscall.Fchmod(fd.Sysfd, mode) 30 } 31 32 // Fchown wraps syscall.Fchown. 33 func (fd *FD) Fchown(uid, gid int) error { 34 if err := fd.incref(); err != nil { 35 return err 36 } 37 defer fd.decref() 38 return syscall.Fchown(fd.Sysfd, uid, gid) 39 } 40 41 // Ftruncate wraps syscall.Ftruncate. 42 func (fd *FD) Ftruncate(size int64) error { 43 if err := fd.incref(); err != nil { 44 return err 45 } 46 defer fd.decref() 47 return syscall.Ftruncate(fd.Sysfd, size) 48 }