1
0
mirror of https://github.com/golang/go synced 2024-11-08 08:46:17 -07:00
go/src/os
Ian Lance Taylor 30641e36aa internal/poll: if copy_file_range returns 0, assume it failed
On current Linux kernels copy_file_range does not correctly handle
files in certain special file systems, such as /proc. For those file
systems it fails to copy any data and returns zero. This breaks Go's
io.Copy for those files.

Fix the problem by assuming that if copy_file_range returns 0 the
first time it is called on a file, that that file is not supported.
In that case fall back to just using read. This will force an extra
system call when using io.Copy to copy a zero-sized normal file,
but at least it will work correctly.

For #36817
Fixes #44272

Change-Id: I02e81872cb70fda0ce5485e2ea712f219132e614
Reviewed-on: https://go-review.googlesource.com/c/go/+/291989
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-02-16 00:46:04 +00:00
..
exec all: update to use os.ReadDir where appropriate 2020-12-09 19:12:27 +00:00
signal os/signal: fix a deadlock with syscall.AllThreadsSyscall() use 2020-12-23 05:27:04 +00:00
testdata testing/fstest,os: clarify racy behavior of TestFS 2021-01-08 16:34:00 +00:00
user all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp 2020-12-09 19:12:23 +00:00
dir_darwin.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dir_plan9.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
dir_unix.go os: remove unused variable in unix implementation of File.readdir 2020-11-05 16:20:01 +00:00
dir_windows.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
dir.go os: add ReadFile, WriteFile, CreateTemp (was TempFile), MkdirTemp (was TempDir) from io/ioutil 2020-12-02 17:00:06 +00:00
dirent_aix.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dirent_dragonfly.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dirent_freebsd.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dirent_js.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dirent_linux.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dirent_netbsd.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dirent_openbsd.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
dirent_solaris.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
endian_big.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
endian_little.go os: add File.ReadDir method and DirEntry type 2020-10-20 00:59:20 +00:00
env_test.go
env_unix_test.go
env.go
error_errno.go
error_plan9.go
error_posix.go
error_test.go all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp 2020-12-09 19:12:23 +00:00
error_unix_test.go all: update references to symbols moved from os to io/fs 2020-10-20 02:32:42 +00:00
error_windows_test.go all: update references to symbols moved from os to io/fs 2020-10-20 02:32:42 +00:00
error.go os: clarify that IsExist and friends do not use errors.Is 2020-11-11 20:26:44 +00:00
example_test.go os: add ReadFile, WriteFile, CreateTemp (was TempFile), MkdirTemp (was TempDir) from io/ioutil 2020-12-02 17:00:06 +00:00
exec_plan9.go os: export ErrProcessDone variable in windows and plan9 2020-11-03 00:56:12 +00:00
exec_posix.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
exec_unix_test.go os: export errFinished as ErrProcessDone 2020-10-31 08:41:25 +00:00
exec_unix.go os: export ErrProcessDone variable in windows and plan9 2020-11-03 00:56:12 +00:00
exec_windows.go os: export ErrProcessDone variable in windows and plan9 2020-11-03 00:56:12 +00:00
exec.go os: export ErrProcessDone variable in windows and plan9 2020-11-03 00:56:12 +00:00
executable_darwin.go
executable_dragonfly.go os: gofmt 2020-11-12 10:22:50 +00:00
executable_freebsd.go os: gofmt 2020-11-12 10:22:50 +00:00
executable_path.go
executable_plan9.go
executable_procfs.go os: do not use procfs for os.Executable in dragonfly 2020-10-28 17:08:06 +00:00
executable_solaris.go
executable_sysctl.go os: do not use procfs for os.Executable in dragonfly 2020-10-28 17:08:06 +00:00
executable_test.go
executable_windows.go
executable.go
export_linux_test.go
export_test.go os: add ReadFile, WriteFile, CreateTemp (was TempFile), MkdirTemp (was TempDir) from io/ioutil 2020-12-02 17:00:06 +00:00
export_unix_test.go
export_windows_test.go
fifo_test.go all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp 2020-12-09 19:12:23 +00:00
file_plan9.go os: remove dependency on strings package 2020-12-18 18:25:14 +00:00
file_posix.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
file_unix.go os: further document limitations around naked file descriptors 2021-01-26 00:30:18 +00:00
file_windows.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
file.go io/fs: allow backslash in ValidPath, reject in os.DirFS.Open 2021-02-11 01:10:28 +00:00
getwd.go
os_test.go io/fs: allow backslash in ValidPath, reject in os.DirFS.Open 2021-02-11 01:10:28 +00:00
os_unix_test.go all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp 2020-12-09 19:12:23 +00:00
os_windows_test.go os: do not close syscall.Stdin in TestReadStdin 2021-01-18 17:21:53 +00:00
path_plan9.go
path_test.go all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp 2020-12-09 19:12:23 +00:00
path_unix.go
path_windows_test.go all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp 2020-12-09 19:12:23 +00:00
path_windows.go
path.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
pipe2_bsd.go
pipe2_illumos.go
pipe_bsd.go
pipe_linux.go
pipe_test.go all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp 2020-12-09 19:12:23 +00:00
proc.go
rawconn_test.go
rawconn.go
read_test.go os: add ReadFile, WriteFile, CreateTemp (was TempFile), MkdirTemp (was TempDir) from io/ioutil 2020-12-02 17:00:06 +00:00
readfrom_linux_test.go internal/poll: if copy_file_range returns 0, assume it failed 2021-02-16 00:46:04 +00:00
readfrom_linux.go
readfrom_stub.go
removeall_at.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
removeall_noat.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
removeall_test.go all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp 2020-12-09 19:12:23 +00:00
stat_aix.go
stat_darwin.go
stat_dragonfly.go
stat_freebsd.go
stat_js.go
stat_linux.go
stat_netbsd.go
stat_openbsd.go
stat_plan9.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
stat_solaris.go
stat_test.go all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp 2020-12-09 19:12:23 +00:00
stat_unix.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
stat_windows.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
stat.go
sticky_bsd.go
sticky_notbsd.go
str.go
sys_aix.go
sys_bsd.go
sys_js.go
sys_linux.go
sys_plan9.go
sys_solaris.go
sys_unix.go
sys_windows.go
sys.go
tempfile_test.go os: add ReadFile, WriteFile, CreateTemp (was TempFile), MkdirTemp (was TempDir) from io/ioutil 2020-12-02 17:00:06 +00:00
tempfile.go os: correct names in CreateTemp and MkdirTemp doc comments 2021-01-26 00:02:49 +00:00
timeout_test.go all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp 2020-12-09 19:12:23 +00:00
types_plan9.go
types_unix.go
types_windows.go os: use keyed literals for PathError 2020-10-20 00:59:22 +00:00
types.go io/fs: move FileInfo, FileMode, PathError, ErrInvalid, ... from os to io/fs 2020-10-20 02:32:41 +00:00
wait_unimp.go
wait_wait6.go
wait_waitid.go