mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-13 15:33:40 +00:00
os: Use a uintptr for NewFile
This appears to have been how it is upstream for about 10 years. Using an interface breaks if a file descriptor number is passed directly to `NewFile`, e.g., `NewFile(3, "fuzz_in")` as used in Go 1.18 fuzzing code.
This commit is contained in:
committed by
Ayke
parent
bf23839931
commit
a680bfbb7a
@@ -21,9 +21,9 @@ func init() {
|
||||
// Stdin, Stdout, and Stderr are open Files pointing to the standard input,
|
||||
// standard output, and standard error file descriptors.
|
||||
var (
|
||||
Stdin = NewFile(unixFileHandle(syscall.Stdin), "/dev/stdin")
|
||||
Stdout = NewFile(unixFileHandle(syscall.Stdout), "/dev/stdout")
|
||||
Stderr = NewFile(unixFileHandle(syscall.Stderr), "/dev/stderr")
|
||||
Stdin = NewFile(uintptr(syscall.Stdin), "/dev/stdin")
|
||||
Stdout = NewFile(uintptr(syscall.Stdout), "/dev/stdout")
|
||||
Stderr = NewFile(uintptr(syscall.Stderr), "/dev/stderr")
|
||||
)
|
||||
|
||||
const DevNull = "/dev/null"
|
||||
@@ -87,9 +87,9 @@ func (fs unixFilesystem) Remove(path string) error {
|
||||
return &PathError{Op: "remove", Path: path, Err: e}
|
||||
}
|
||||
|
||||
func (fs unixFilesystem) OpenFile(path string, flag int, perm FileMode) (FileHandle, error) {
|
||||
func (fs unixFilesystem) OpenFile(path string, flag int, perm FileMode) (uintptr, error) {
|
||||
fp, err := syscall.Open(path, flag, uint32(perm))
|
||||
return unixFileHandle(fp), handleSyscallError(err)
|
||||
return uintptr(fp), handleSyscallError(err)
|
||||
}
|
||||
|
||||
// unixFileHandle is a Unix file pointer with associated methods that implement
|
||||
|
||||
Reference in New Issue
Block a user