Skip to content

os: IsPermission returns false when reading a write-only file descriptor. #15629

@Julio-Guerra

Description

@Julio-Guerra
  1. What version of Go are you using (go version)?

go version go1.6.1 linux/amd64

  1. What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
  1. What did you do?

Given any file descriptor correctly opened with a write-only access level, reading from it correctly returns the errno EBADF as specified in read(2):

EBADF fd is not a valid file descriptor or is not open for reading.

But os.IsPermission() does not check this case and returns false instead of true.

https://play.golang.org/p/sPZWxH5JA7

The context provided by os.PathError should allow to return true correctly.

Regarding the case "fd is not a valid file descriptor", it could be excluded by also checking that the file descriptor is valid with something like fcntl(fd, F_GETFD) (but the fd is not in the error context).

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions