| // Copyright 2023 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. |
| |
| //go:build fuchsia |
| |
| package unix |
| |
| import "syscall" |
| import "syscall/zx" |
| |
| func Fcntl(fd int, cmd int, arg int) (int, error) { |
| if cmd == syscall.F_GETFL { |
| fdio := syscall.FDIOForFD(fd) |
| if fdio == nil { |
| return 0, syscall.EBADF |
| } |
| flags, err := fdio.GetFlags() |
| if err, ok := err.(*zx.Error); ok && err.Status == zx.ErrNotSupported { |
| return 0, nil |
| } |
| // Don't need to set the NONBLOCK flag because it's always false. |
| return int(syscall.ZXIOFlagsToFDIO(uint32(flags))), err |
| } |
| return 0, syscall.ENOSYS |
| } |