Browse code

Merge pull request #41482 from tklauser/unix-fileclone

Brian Goff authored on 2020/09/26 09:02:17
Showing 45 changed files
... ...
@@ -42,7 +42,7 @@ func copyRegular(srcPath, dstPath string, fileinfo os.FileInfo, copyWithFileRang
42 42
 	defer dstFile.Close()
43 43
 
44 44
 	if *copyWithFileClone {
45
-		err = fiClone(srcFile, dstFile)
45
+		err = unix.IoctlFileClone(int(dstFile.Fd()), int(srcFile.Fd()))
46 46
 		if err == nil {
47 47
 			return nil
48 48
 		}
49 49
deleted file mode 100644
... ...
@@ -1,22 +0,0 @@
1
-// +build linux,cgo
2
-
3
-package copy // import "github.com/docker/docker/daemon/graphdriver/copy"
4
-
5
-/*
6
-#include <linux/fs.h>
7
-
8
-#ifndef FICLONE
9
-#define FICLONE		_IOW(0x94, 9, int)
10
-#endif
11
-*/
12
-import "C"
13
-import (
14
-	"os"
15
-
16
-	"golang.org/x/sys/unix"
17
-)
18
-
19
-func fiClone(srcFile, dstFile *os.File) error {
20
-	_, _, err := unix.Syscall(unix.SYS_IOCTL, dstFile.Fd(), C.FICLONE, srcFile.Fd())
21
-	return err
22
-}
23 1
deleted file mode 100644
... ...
@@ -1,13 +0,0 @@
1
-// +build linux,!cgo
2
-
3
-package copy // import "github.com/docker/docker/daemon/graphdriver/copy"
4
-
5
-import (
6
-	"os"
7
-
8
-	"golang.org/x/sys/unix"
9
-)
10
-
11
-func fiClone(srcFile, dstFile *os.File) error {
12
-	return unix.ENOSYS
13
-}
... ...
@@ -14,7 +14,7 @@ github.com/konsorten/go-windows-terminal-sequences  edb144dfd453055e1e49a3d8b410
14 14
 github.com/sirupsen/logrus                          60c74ad9be0d874af0ab0daef6ab07c5c5911f0d # v1.6.0
15 15
 github.com/tchap/go-patricia                        a7f0089c6f496e8e70402f61733606daa326cac5 # v2.3.0
16 16
 golang.org/x/net                                    ab34263943818b32f575efc978a3d24e80b04bd7
17
-golang.org/x/sys                                    196b9ba8737a10c9253b04174f25881e562da5b8
17
+golang.org/x/sys                                    aee5d888a86055dc6ab0342f9cdc7b53aaeaec62
18 18
 github.com/docker/go-units                          519db1ee28dcc9fd2474ae59fca29a810482bfb1 # v0.4.0
19 19
 github.com/docker/go-connections                    7395e3f8aa162843a74ed6d48e79627d9792ac55 # v0.4.0
20 20
 github.com/moby/sys                                 6154f11e6840c0d6b0dbb23f4125a6134b3013c9 # mountinfo/v0.1.3
... ...
@@ -16,3 +16,9 @@ func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
16 16
 	_, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk))))
17 17
 	return err
18 18
 }
19
+
20
+// FcntlFstore performs a fcntl syscall for the F_PREALLOCATE command.
21
+func FcntlFstore(fd uintptr, cmd int, fstore *Fstore_t) error {
22
+	_, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(fstore))))
23
+	return err
24
+}
... ...
@@ -401,6 +401,8 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
401 401
 //sys	Chroot(path string) (err error)
402 402
 //sys	ClockGettime(clockid int32, time *Timespec) (err error)
403 403
 //sys	Close(fd int) (err error)
404
+//sys	Clonefile(src string, dst string, flags int) (err error)
405
+//sys	Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error)
404 406
 //sys	Dup(fd int) (nfd int, err error)
405 407
 //sys	Dup2(from int, to int) (err error)
406 408
 //sys	Exchangedata(path1 string, path2 string, options int) (err error)
... ...
@@ -412,6 +414,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
412 412
 //sys	Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
413 413
 //sys	Fchown(fd int, uid int, gid int) (err error)
414 414
 //sys	Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
415
+//sys	Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error)
415 416
 //sys	Flock(fd int, how int) (err error)
416 417
 //sys	Fpathconf(fd int, name int) (val int, err error)
417 418
 //sys	Fsync(fd int) (err error)
... ...
@@ -24,7 +24,7 @@ func bytes2iovec(bs [][]byte) []Iovec {
24 24
 	return iovecs
25 25
 }
26 26
 
27
-//sys   readv(fd int, iovs []Iovec) (n int, err error)
27
+//sys	readv(fd int, iovs []Iovec) (n int, err error)
28 28
 
29 29
 func Readv(fd int, iovs [][]byte) (n int, err error) {
30 30
 	iovecs := bytes2iovec(iovs)
... ...
@@ -32,7 +32,7 @@ func Readv(fd int, iovs [][]byte) (n int, err error) {
32 32
 	return n, err
33 33
 }
34 34
 
35
-//sys   preadv(fd int, iovs []Iovec, off int64) (n int, err error)
35
+//sys	preadv(fd int, iovs []Iovec, off int64) (n int, err error)
36 36
 
37 37
 func Preadv(fd int, iovs [][]byte, off int64) (n int, err error) {
38 38
 	iovecs := bytes2iovec(iovs)
... ...
@@ -40,7 +40,7 @@ func Preadv(fd int, iovs [][]byte, off int64) (n int, err error) {
40 40
 	return n, err
41 41
 }
42 42
 
43
-//sys   writev(fd int, iovs []Iovec) (n int, err error)
43
+//sys	writev(fd int, iovs []Iovec) (n int, err error)
44 44
 
45 45
 func Writev(fd int, iovs [][]byte) (n int, err error) {
46 46
 	iovecs := bytes2iovec(iovs)
... ...
@@ -48,10 +48,43 @@ func Writev(fd int, iovs [][]byte) (n int, err error) {
48 48
 	return n, err
49 49
 }
50 50
 
51
-//sys   pwritev(fd int, iovs []Iovec, off int64) (n int, err error)
51
+//sys	pwritev(fd int, iovs []Iovec, off int64) (n int, err error)
52 52
 
53 53
 func Pwritev(fd int, iovs [][]byte, off int64) (n int, err error) {
54 54
 	iovecs := bytes2iovec(iovs)
55 55
 	n, err = pwritev(fd, iovecs, off)
56 56
 	return n, err
57 57
 }
58
+
59
+//sys	accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) = libsocket.accept4
60
+
61
+func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) {
62
+	var rsa RawSockaddrAny
63
+	var len _Socklen = SizeofSockaddrAny
64
+	nfd, err = accept4(fd, &rsa, &len, flags)
65
+	if err != nil {
66
+		return
67
+	}
68
+	if len > SizeofSockaddrAny {
69
+		panic("RawSockaddrAny too small")
70
+	}
71
+	sa, err = anyToSockaddr(fd, &rsa)
72
+	if err != nil {
73
+		Close(nfd)
74
+		nfd = 0
75
+	}
76
+	return
77
+}
78
+
79
+//sysnb	pipe2(p *[2]_C_int, flags int) (err error)
80
+
81
+func Pipe2(p []int, flags int) error {
82
+	if len(p) != 2 {
83
+		return EINVAL
84
+	}
85
+	var pp [2]_C_int
86
+	err := pipe2(&pp, flags)
87
+	p[0] = int(pp[0])
88
+	p[1] = int(pp[1])
89
+	return err
90
+}
... ...
@@ -112,6 +112,31 @@ func IoctlGetRTCWkAlrm(fd int) (*RTCWkAlrm, error) {
112 112
 	return &value, err
113 113
 }
114 114
 
115
+// IoctlFileClone performs an FICLONERANGE ioctl operation to clone the range of
116
+// data conveyed in value to the file associated with the file descriptor
117
+// destFd. See the ioctl_ficlonerange(2) man page for details.
118
+func IoctlFileCloneRange(destFd int, value *FileCloneRange) error {
119
+	err := ioctl(destFd, FICLONERANGE, uintptr(unsafe.Pointer(value)))
120
+	runtime.KeepAlive(value)
121
+	return err
122
+}
123
+
124
+// IoctlFileClone performs an FICLONE ioctl operation to clone the entire file
125
+// associated with the file description srcFd to the file associated with the
126
+// file descriptor destFd. See the ioctl_ficlone(2) man page for details.
127
+func IoctlFileClone(destFd, srcFd int) error {
128
+	return ioctl(destFd, FICLONE, uintptr(srcFd))
129
+}
130
+
131
+// IoctlFileClone performs an FIDEDUPERANGE ioctl operation to share the range of
132
+// data conveyed in value with the file associated with the file descriptor
133
+// destFd. See the ioctl_fideduperange(2) man page for details.
134
+func IoctlFileDedupeRange(destFd int, value *FileDedupeRange) error {
135
+	err := ioctl(destFd, FIDEDUPERANGE, uintptr(unsafe.Pointer(value)))
136
+	runtime.KeepAlive(value)
137
+	return err
138
+}
139
+
115 140
 //sys	Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error)
116 141
 
117 142
 func Link(oldpath string, newpath string) (err error) {
... ...
@@ -136,6 +161,12 @@ func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
136 136
 	return openat(dirfd, path, flags|O_LARGEFILE, mode)
137 137
 }
138 138
 
139
+//sys	openat2(dirfd int, path string, open_how *OpenHow, size int) (fd int, err error)
140
+
141
+func Openat2(dirfd int, path string, how *OpenHow) (fd int, err error) {
142
+	return openat2(dirfd, path, how, SizeofOpenHow)
143
+}
144
+
139 145
 //sys	ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error)
140 146
 
141 147
 func Ppoll(fds []PollFd, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
... ...
@@ -232,6 +232,8 @@ const (
232 232
 	CLOCK_THREAD_CPUTIME_ID           = 0x10
233 233
 	CLOCK_UPTIME_RAW                  = 0x8
234 234
 	CLOCK_UPTIME_RAW_APPROX           = 0x9
235
+	CLONE_NOFOLLOW                    = 0x1
236
+	CLONE_NOOWNERCOPY                 = 0x2
235 237
 	CR0                               = 0x0
236 238
 	CR1                               = 0x1000
237 239
 	CR2                               = 0x2000
... ...
@@ -232,6 +232,8 @@ const (
232 232
 	CLOCK_THREAD_CPUTIME_ID           = 0x10
233 233
 	CLOCK_UPTIME_RAW                  = 0x8
234 234
 	CLOCK_UPTIME_RAW_APPROX           = 0x9
235
+	CLONE_NOFOLLOW                    = 0x1
236
+	CLONE_NOOWNERCOPY                 = 0x2
235 237
 	CR0                               = 0x0
236 238
 	CR1                               = 0x1000
237 239
 	CR2                               = 0x2000
... ...
@@ -232,6 +232,8 @@ const (
232 232
 	CLOCK_THREAD_CPUTIME_ID           = 0x10
233 233
 	CLOCK_UPTIME_RAW                  = 0x8
234 234
 	CLOCK_UPTIME_RAW_APPROX           = 0x9
235
+	CLONE_NOFOLLOW                    = 0x1
236
+	CLONE_NOOWNERCOPY                 = 0x2
235 237
 	CR0                               = 0x0
236 238
 	CR1                               = 0x1000
237 239
 	CR2                               = 0x2000
... ...
@@ -232,6 +232,8 @@ const (
232 232
 	CLOCK_THREAD_CPUTIME_ID           = 0x10
233 233
 	CLOCK_UPTIME_RAW                  = 0x8
234 234
 	CLOCK_UPTIME_RAW_APPROX           = 0x9
235
+	CLONE_NOFOLLOW                    = 0x1
236
+	CLONE_NOOWNERCOPY                 = 0x2
235 237
 	CR0                               = 0x0
236 238
 	CR1                               = 0x1000
237 239
 	CR2                               = 0x2000
... ...
@@ -686,6 +686,7 @@ const (
686 686
 	FD_CLOEXEC                                  = 0x1
687 687
 	FD_SETSIZE                                  = 0x400
688 688
 	FF0                                         = 0x0
689
+	FIDEDUPERANGE                               = 0xc0189436
689 690
 	FSCRYPT_KEY_DESCRIPTOR_SIZE                 = 0x8
690 691
 	FSCRYPT_KEY_DESC_PREFIX                     = "fscrypt:"
691 692
 	FSCRYPT_KEY_DESC_PREFIX_SIZE                = 0x8
... ...
@@ -71,6 +71,8 @@ const (
71 71
 	EXTPROC                          = 0x10000
72 72
 	FF1                              = 0x8000
73 73
 	FFDLY                            = 0x8000
74
+	FICLONE                          = 0x40049409
75
+	FICLONERANGE                     = 0x4020940d
74 76
 	FLUSHO                           = 0x1000
75 77
 	FP_XSTATE_MAGIC2                 = 0x46505845
76 78
 	FS_IOC_ENABLE_VERITY             = 0x40806685
... ...
@@ -71,6 +71,8 @@ const (
71 71
 	EXTPROC                          = 0x10000
72 72
 	FF1                              = 0x8000
73 73
 	FFDLY                            = 0x8000
74
+	FICLONE                          = 0x40049409
75
+	FICLONERANGE                     = 0x4020940d
74 76
 	FLUSHO                           = 0x1000
75 77
 	FP_XSTATE_MAGIC2                 = 0x46505845
76 78
 	FS_IOC_ENABLE_VERITY             = 0x40806685
... ...
@@ -71,6 +71,8 @@ const (
71 71
 	EXTPROC                          = 0x10000
72 72
 	FF1                              = 0x8000
73 73
 	FFDLY                            = 0x8000
74
+	FICLONE                          = 0x40049409
75
+	FICLONERANGE                     = 0x4020940d
74 76
 	FLUSHO                           = 0x1000
75 77
 	FS_IOC_ENABLE_VERITY             = 0x40806685
76 78
 	FS_IOC_GETFLAGS                  = 0x80046601
... ...
@@ -73,6 +73,8 @@ const (
73 73
 	EXTRA_MAGIC                      = 0x45585401
74 74
 	FF1                              = 0x8000
75 75
 	FFDLY                            = 0x8000
76
+	FICLONE                          = 0x40049409
77
+	FICLONERANGE                     = 0x4020940d
76 78
 	FLUSHO                           = 0x1000
77 79
 	FPSIMD_MAGIC                     = 0x46508001
78 80
 	FS_IOC_ENABLE_VERITY             = 0x40806685
... ...
@@ -71,6 +71,8 @@ const (
71 71
 	EXTPROC                          = 0x10000
72 72
 	FF1                              = 0x8000
73 73
 	FFDLY                            = 0x8000
74
+	FICLONE                          = 0x80049409
75
+	FICLONERANGE                     = 0x8020940d
74 76
 	FLUSHO                           = 0x2000
75 77
 	FS_IOC_ENABLE_VERITY             = 0x80806685
76 78
 	FS_IOC_GETFLAGS                  = 0x40046601
... ...
@@ -71,6 +71,8 @@ const (
71 71
 	EXTPROC                          = 0x10000
72 72
 	FF1                              = 0x8000
73 73
 	FFDLY                            = 0x8000
74
+	FICLONE                          = 0x80049409
75
+	FICLONERANGE                     = 0x8020940d
74 76
 	FLUSHO                           = 0x2000
75 77
 	FS_IOC_ENABLE_VERITY             = 0x80806685
76 78
 	FS_IOC_GETFLAGS                  = 0x40086601
... ...
@@ -71,6 +71,8 @@ const (
71 71
 	EXTPROC                          = 0x10000
72 72
 	FF1                              = 0x8000
73 73
 	FFDLY                            = 0x8000
74
+	FICLONE                          = 0x80049409
75
+	FICLONERANGE                     = 0x8020940d
74 76
 	FLUSHO                           = 0x2000
75 77
 	FS_IOC_ENABLE_VERITY             = 0x80806685
76 78
 	FS_IOC_GETFLAGS                  = 0x40086601
... ...
@@ -71,6 +71,8 @@ const (
71 71
 	EXTPROC                          = 0x10000
72 72
 	FF1                              = 0x8000
73 73
 	FFDLY                            = 0x8000
74
+	FICLONE                          = 0x80049409
75
+	FICLONERANGE                     = 0x8020940d
74 76
 	FLUSHO                           = 0x2000
75 77
 	FS_IOC_ENABLE_VERITY             = 0x80806685
76 78
 	FS_IOC_GETFLAGS                  = 0x40046601
... ...
@@ -71,6 +71,8 @@ const (
71 71
 	EXTPROC                          = 0x10000000
72 72
 	FF1                              = 0x4000
73 73
 	FFDLY                            = 0x4000
74
+	FICLONE                          = 0x80049409
75
+	FICLONERANGE                     = 0x8020940d
74 76
 	FLUSHO                           = 0x800000
75 77
 	FS_IOC_ENABLE_VERITY             = 0x80806685
76 78
 	FS_IOC_GETFLAGS                  = 0x40086601
... ...
@@ -71,6 +71,8 @@ const (
71 71
 	EXTPROC                          = 0x10000000
72 72
 	FF1                              = 0x4000
73 73
 	FFDLY                            = 0x4000
74
+	FICLONE                          = 0x80049409
75
+	FICLONERANGE                     = 0x8020940d
74 76
 	FLUSHO                           = 0x800000
75 77
 	FS_IOC_ENABLE_VERITY             = 0x80806685
76 78
 	FS_IOC_GETFLAGS                  = 0x40086601
... ...
@@ -71,6 +71,8 @@ const (
71 71
 	EXTPROC                          = 0x10000
72 72
 	FF1                              = 0x8000
73 73
 	FFDLY                            = 0x8000
74
+	FICLONE                          = 0x40049409
75
+	FICLONERANGE                     = 0x4020940d
74 76
 	FLUSHO                           = 0x1000
75 77
 	FS_IOC_ENABLE_VERITY             = 0x40806685
76 78
 	FS_IOC_GETFLAGS                  = 0x80086601
... ...
@@ -71,6 +71,8 @@ const (
71 71
 	EXTPROC                          = 0x10000
72 72
 	FF1                              = 0x8000
73 73
 	FFDLY                            = 0x8000
74
+	FICLONE                          = 0x40049409
75
+	FICLONERANGE                     = 0x4020940d
74 76
 	FLUSHO                           = 0x1000
75 77
 	FS_IOC_ENABLE_VERITY             = 0x40806685
76 78
 	FS_IOC_GETFLAGS                  = 0x80086601
... ...
@@ -75,6 +75,8 @@ const (
75 75
 	EXTPROC                          = 0x10000
76 76
 	FF1                              = 0x8000
77 77
 	FFDLY                            = 0x8000
78
+	FICLONE                          = 0x80049409
79
+	FICLONERANGE                     = 0x8020940d
78 80
 	FLUSHO                           = 0x1000
79 81
 	FS_IOC_ENABLE_VERITY             = 0x80806685
80 82
 	FS_IOC_GETFLAGS                  = 0x40086601
... ...
@@ -958,6 +958,56 @@ func libc_close_trampoline()
958 958
 
959 959
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
960 960
 
961
+func Clonefile(src string, dst string, flags int) (err error) {
962
+	var _p0 *byte
963
+	_p0, err = BytePtrFromString(src)
964
+	if err != nil {
965
+		return
966
+	}
967
+	var _p1 *byte
968
+	_p1, err = BytePtrFromString(dst)
969
+	if err != nil {
970
+		return
971
+	}
972
+	_, _, e1 := syscall_syscall(funcPC(libc_clonefile_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags))
973
+	if e1 != 0 {
974
+		err = errnoErr(e1)
975
+	}
976
+	return
977
+}
978
+
979
+func libc_clonefile_trampoline()
980
+
981
+//go:linkname libc_clonefile libc_clonefile
982
+//go:cgo_import_dynamic libc_clonefile clonefile "/usr/lib/libSystem.B.dylib"
983
+
984
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
985
+
986
+func Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error) {
987
+	var _p0 *byte
988
+	_p0, err = BytePtrFromString(src)
989
+	if err != nil {
990
+		return
991
+	}
992
+	var _p1 *byte
993
+	_p1, err = BytePtrFromString(dst)
994
+	if err != nil {
995
+		return
996
+	}
997
+	_, _, e1 := syscall_syscall6(funcPC(libc_clonefileat_trampoline), uintptr(srcDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
998
+	if e1 != 0 {
999
+		err = errnoErr(e1)
1000
+	}
1001
+	return
1002
+}
1003
+
1004
+func libc_clonefileat_trampoline()
1005
+
1006
+//go:linkname libc_clonefileat libc_clonefileat
1007
+//go:cgo_import_dynamic libc_clonefileat clonefileat "/usr/lib/libSystem.B.dylib"
1008
+
1009
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1010
+
961 1011
 func Dup(fd int) (nfd int, err error) {
962 1012
 	r0, _, e1 := syscall_syscall(funcPC(libc_dup_trampoline), uintptr(fd), 0, 0)
963 1013
 	nfd = int(r0)
... ...
@@ -1146,6 +1196,26 @@ func libc_fchownat_trampoline()
1146 1146
 
1147 1147
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1148 1148
 
1149
+func Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error) {
1150
+	var _p0 *byte
1151
+	_p0, err = BytePtrFromString(dst)
1152
+	if err != nil {
1153
+		return
1154
+	}
1155
+	_, _, e1 := syscall_syscall6(funcPC(libc_fclonefileat_trampoline), uintptr(srcDirfd), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0, 0)
1156
+	if e1 != 0 {
1157
+		err = errnoErr(e1)
1158
+	}
1159
+	return
1160
+}
1161
+
1162
+func libc_fclonefileat_trampoline()
1163
+
1164
+//go:linkname libc_fclonefileat libc_fclonefileat
1165
+//go:cgo_import_dynamic libc_fclonefileat fclonefileat "/usr/lib/libSystem.B.dylib"
1166
+
1167
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1168
+
1149 1169
 func Flock(fd int, how int) (err error) {
1150 1170
 	_, _, e1 := syscall_syscall(funcPC(libc_flock_trampoline), uintptr(fd), uintptr(how), 0)
1151 1171
 	if e1 != 0 {
... ...
@@ -110,6 +110,10 @@ TEXT ·libc_clock_gettime_trampoline(SB),NOSPLIT,$0-0
110 110
 	JMP	libc_clock_gettime(SB)
111 111
 TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0
112 112
 	JMP	libc_close(SB)
113
+TEXT ·libc_clonefile_trampoline(SB),NOSPLIT,$0-0
114
+	JMP	libc_clonefile(SB)
115
+TEXT ·libc_clonefileat_trampoline(SB),NOSPLIT,$0-0
116
+	JMP	libc_clonefileat(SB)
113 117
 TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0
114 118
 	JMP	libc_dup(SB)
115 119
 TEXT ·libc_dup2_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -132,6 +136,8 @@ TEXT ·libc_fchown_trampoline(SB),NOSPLIT,$0-0
132 132
 	JMP	libc_fchown(SB)
133 133
 TEXT ·libc_fchownat_trampoline(SB),NOSPLIT,$0-0
134 134
 	JMP	libc_fchownat(SB)
135
+TEXT ·libc_fclonefileat_trampoline(SB),NOSPLIT,$0-0
136
+	JMP	libc_fclonefileat(SB)
135 137
 TEXT ·libc_flock_trampoline(SB),NOSPLIT,$0-0
136 138
 	JMP	libc_flock(SB)
137 139
 TEXT ·libc_fpathconf_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -164,6 +170,8 @@ TEXT ·libc_getrusage_trampoline(SB),NOSPLIT,$0-0
164 164
 	JMP	libc_getrusage(SB)
165 165
 TEXT ·libc_getsid_trampoline(SB),NOSPLIT,$0-0
166 166
 	JMP	libc_getsid(SB)
167
+TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0
168
+	JMP	libc_gettimeofday(SB)
167 169
 TEXT ·libc_getuid_trampoline(SB),NOSPLIT,$0-0
168 170
 	JMP	libc_getuid(SB)
169 171
 TEXT ·libc_issetugid_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -266,8 +274,6 @@ TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
266 266
 	JMP	libc_munmap(SB)
267 267
 TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0
268 268
 	JMP	libc_ptrace(SB)
269
-TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0
270
-	JMP	libc_gettimeofday(SB)
271 269
 TEXT ·libc_fstat64_trampoline(SB),NOSPLIT,$0-0
272 270
 	JMP	libc_fstat64(SB)
273 271
 TEXT ·libc_fstatat64_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -958,6 +958,56 @@ func libc_close_trampoline()
958 958
 
959 959
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
960 960
 
961
+func Clonefile(src string, dst string, flags int) (err error) {
962
+	var _p0 *byte
963
+	_p0, err = BytePtrFromString(src)
964
+	if err != nil {
965
+		return
966
+	}
967
+	var _p1 *byte
968
+	_p1, err = BytePtrFromString(dst)
969
+	if err != nil {
970
+		return
971
+	}
972
+	_, _, e1 := syscall_syscall(funcPC(libc_clonefile_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags))
973
+	if e1 != 0 {
974
+		err = errnoErr(e1)
975
+	}
976
+	return
977
+}
978
+
979
+func libc_clonefile_trampoline()
980
+
981
+//go:linkname libc_clonefile libc_clonefile
982
+//go:cgo_import_dynamic libc_clonefile clonefile "/usr/lib/libSystem.B.dylib"
983
+
984
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
985
+
986
+func Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error) {
987
+	var _p0 *byte
988
+	_p0, err = BytePtrFromString(src)
989
+	if err != nil {
990
+		return
991
+	}
992
+	var _p1 *byte
993
+	_p1, err = BytePtrFromString(dst)
994
+	if err != nil {
995
+		return
996
+	}
997
+	_, _, e1 := syscall_syscall6(funcPC(libc_clonefileat_trampoline), uintptr(srcDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
998
+	if e1 != 0 {
999
+		err = errnoErr(e1)
1000
+	}
1001
+	return
1002
+}
1003
+
1004
+func libc_clonefileat_trampoline()
1005
+
1006
+//go:linkname libc_clonefileat libc_clonefileat
1007
+//go:cgo_import_dynamic libc_clonefileat clonefileat "/usr/lib/libSystem.B.dylib"
1008
+
1009
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1010
+
961 1011
 func Dup(fd int) (nfd int, err error) {
962 1012
 	r0, _, e1 := syscall_syscall(funcPC(libc_dup_trampoline), uintptr(fd), 0, 0)
963 1013
 	nfd = int(r0)
... ...
@@ -1146,6 +1196,26 @@ func libc_fchownat_trampoline()
1146 1146
 
1147 1147
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1148 1148
 
1149
+func Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error) {
1150
+	var _p0 *byte
1151
+	_p0, err = BytePtrFromString(dst)
1152
+	if err != nil {
1153
+		return
1154
+	}
1155
+	_, _, e1 := syscall_syscall6(funcPC(libc_fclonefileat_trampoline), uintptr(srcDirfd), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0, 0)
1156
+	if e1 != 0 {
1157
+		err = errnoErr(e1)
1158
+	}
1159
+	return
1160
+}
1161
+
1162
+func libc_fclonefileat_trampoline()
1163
+
1164
+//go:linkname libc_fclonefileat libc_fclonefileat
1165
+//go:cgo_import_dynamic libc_fclonefileat fclonefileat "/usr/lib/libSystem.B.dylib"
1166
+
1167
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1168
+
1149 1169
 func Flock(fd int, how int) (err error) {
1150 1170
 	_, _, e1 := syscall_syscall(funcPC(libc_flock_trampoline), uintptr(fd), uintptr(how), 0)
1151 1171
 	if e1 != 0 {
... ...
@@ -110,6 +110,10 @@ TEXT ·libc_clock_gettime_trampoline(SB),NOSPLIT,$0-0
110 110
 	JMP	libc_clock_gettime(SB)
111 111
 TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0
112 112
 	JMP	libc_close(SB)
113
+TEXT ·libc_clonefile_trampoline(SB),NOSPLIT,$0-0
114
+	JMP	libc_clonefile(SB)
115
+TEXT ·libc_clonefileat_trampoline(SB),NOSPLIT,$0-0
116
+	JMP	libc_clonefileat(SB)
113 117
 TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0
114 118
 	JMP	libc_dup(SB)
115 119
 TEXT ·libc_dup2_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -132,6 +136,8 @@ TEXT ·libc_fchown_trampoline(SB),NOSPLIT,$0-0
132 132
 	JMP	libc_fchown(SB)
133 133
 TEXT ·libc_fchownat_trampoline(SB),NOSPLIT,$0-0
134 134
 	JMP	libc_fchownat(SB)
135
+TEXT ·libc_fclonefileat_trampoline(SB),NOSPLIT,$0-0
136
+	JMP	libc_fclonefileat(SB)
135 137
 TEXT ·libc_flock_trampoline(SB),NOSPLIT,$0-0
136 138
 	JMP	libc_flock(SB)
137 139
 TEXT ·libc_fpathconf_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -164,6 +170,8 @@ TEXT ·libc_getrusage_trampoline(SB),NOSPLIT,$0-0
164 164
 	JMP	libc_getrusage(SB)
165 165
 TEXT ·libc_getsid_trampoline(SB),NOSPLIT,$0-0
166 166
 	JMP	libc_getsid(SB)
167
+TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0
168
+	JMP	libc_gettimeofday(SB)
167 169
 TEXT ·libc_getuid_trampoline(SB),NOSPLIT,$0-0
168 170
 	JMP	libc_getuid(SB)
169 171
 TEXT ·libc_issetugid_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -266,8 +274,6 @@ TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
266 266
 	JMP	libc_munmap(SB)
267 267
 TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0
268 268
 	JMP	libc_ptrace(SB)
269
-TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0
270
-	JMP	libc_gettimeofday(SB)
271 269
 TEXT ·libc_fstat64_trampoline(SB),NOSPLIT,$0-0
272 270
 	JMP	libc_fstat64(SB)
273 271
 TEXT ·libc_fstatat64_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -958,6 +958,56 @@ func libc_close_trampoline()
958 958
 
959 959
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
960 960
 
961
+func Clonefile(src string, dst string, flags int) (err error) {
962
+	var _p0 *byte
963
+	_p0, err = BytePtrFromString(src)
964
+	if err != nil {
965
+		return
966
+	}
967
+	var _p1 *byte
968
+	_p1, err = BytePtrFromString(dst)
969
+	if err != nil {
970
+		return
971
+	}
972
+	_, _, e1 := syscall_syscall(funcPC(libc_clonefile_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags))
973
+	if e1 != 0 {
974
+		err = errnoErr(e1)
975
+	}
976
+	return
977
+}
978
+
979
+func libc_clonefile_trampoline()
980
+
981
+//go:linkname libc_clonefile libc_clonefile
982
+//go:cgo_import_dynamic libc_clonefile clonefile "/usr/lib/libSystem.B.dylib"
983
+
984
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
985
+
986
+func Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error) {
987
+	var _p0 *byte
988
+	_p0, err = BytePtrFromString(src)
989
+	if err != nil {
990
+		return
991
+	}
992
+	var _p1 *byte
993
+	_p1, err = BytePtrFromString(dst)
994
+	if err != nil {
995
+		return
996
+	}
997
+	_, _, e1 := syscall_syscall6(funcPC(libc_clonefileat_trampoline), uintptr(srcDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
998
+	if e1 != 0 {
999
+		err = errnoErr(e1)
1000
+	}
1001
+	return
1002
+}
1003
+
1004
+func libc_clonefileat_trampoline()
1005
+
1006
+//go:linkname libc_clonefileat libc_clonefileat
1007
+//go:cgo_import_dynamic libc_clonefileat clonefileat "/usr/lib/libSystem.B.dylib"
1008
+
1009
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1010
+
961 1011
 func Dup(fd int) (nfd int, err error) {
962 1012
 	r0, _, e1 := syscall_syscall(funcPC(libc_dup_trampoline), uintptr(fd), 0, 0)
963 1013
 	nfd = int(r0)
... ...
@@ -1146,6 +1196,26 @@ func libc_fchownat_trampoline()
1146 1146
 
1147 1147
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1148 1148
 
1149
+func Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error) {
1150
+	var _p0 *byte
1151
+	_p0, err = BytePtrFromString(dst)
1152
+	if err != nil {
1153
+		return
1154
+	}
1155
+	_, _, e1 := syscall_syscall6(funcPC(libc_fclonefileat_trampoline), uintptr(srcDirfd), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0, 0)
1156
+	if e1 != 0 {
1157
+		err = errnoErr(e1)
1158
+	}
1159
+	return
1160
+}
1161
+
1162
+func libc_fclonefileat_trampoline()
1163
+
1164
+//go:linkname libc_fclonefileat libc_fclonefileat
1165
+//go:cgo_import_dynamic libc_fclonefileat fclonefileat "/usr/lib/libSystem.B.dylib"
1166
+
1167
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1168
+
1149 1169
 func Flock(fd int, how int) (err error) {
1150 1170
 	_, _, e1 := syscall_syscall(funcPC(libc_flock_trampoline), uintptr(fd), uintptr(how), 0)
1151 1171
 	if e1 != 0 {
... ...
@@ -110,6 +110,10 @@ TEXT ·libc_clock_gettime_trampoline(SB),NOSPLIT,$0-0
110 110
 	JMP	libc_clock_gettime(SB)
111 111
 TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0
112 112
 	JMP	libc_close(SB)
113
+TEXT ·libc_clonefile_trampoline(SB),NOSPLIT,$0-0
114
+	JMP	libc_clonefile(SB)
115
+TEXT ·libc_clonefileat_trampoline(SB),NOSPLIT,$0-0
116
+	JMP	libc_clonefileat(SB)
113 117
 TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0
114 118
 	JMP	libc_dup(SB)
115 119
 TEXT ·libc_dup2_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -132,6 +136,8 @@ TEXT ·libc_fchown_trampoline(SB),NOSPLIT,$0-0
132 132
 	JMP	libc_fchown(SB)
133 133
 TEXT ·libc_fchownat_trampoline(SB),NOSPLIT,$0-0
134 134
 	JMP	libc_fchownat(SB)
135
+TEXT ·libc_fclonefileat_trampoline(SB),NOSPLIT,$0-0
136
+	JMP	libc_fclonefileat(SB)
135 137
 TEXT ·libc_flock_trampoline(SB),NOSPLIT,$0-0
136 138
 	JMP	libc_flock(SB)
137 139
 TEXT ·libc_fpathconf_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -164,6 +170,8 @@ TEXT ·libc_getrusage_trampoline(SB),NOSPLIT,$0-0
164 164
 	JMP	libc_getrusage(SB)
165 165
 TEXT ·libc_getsid_trampoline(SB),NOSPLIT,$0-0
166 166
 	JMP	libc_getsid(SB)
167
+TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0
168
+	JMP	libc_gettimeofday(SB)
167 169
 TEXT ·libc_getuid_trampoline(SB),NOSPLIT,$0-0
168 170
 	JMP	libc_getuid(SB)
169 171
 TEXT ·libc_issetugid_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -264,8 +272,6 @@ TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0
264 264
 	JMP	libc_mmap(SB)
265 265
 TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
266 266
 	JMP	libc_munmap(SB)
267
-TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0
268
-	JMP	libc_gettimeofday(SB)
269 267
 TEXT ·libc_fstat_trampoline(SB),NOSPLIT,$0-0
270 268
 	JMP	libc_fstat(SB)
271 269
 TEXT ·libc_fstatat_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -958,6 +958,56 @@ func libc_close_trampoline()
958 958
 
959 959
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
960 960
 
961
+func Clonefile(src string, dst string, flags int) (err error) {
962
+	var _p0 *byte
963
+	_p0, err = BytePtrFromString(src)
964
+	if err != nil {
965
+		return
966
+	}
967
+	var _p1 *byte
968
+	_p1, err = BytePtrFromString(dst)
969
+	if err != nil {
970
+		return
971
+	}
972
+	_, _, e1 := syscall_syscall(funcPC(libc_clonefile_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags))
973
+	if e1 != 0 {
974
+		err = errnoErr(e1)
975
+	}
976
+	return
977
+}
978
+
979
+func libc_clonefile_trampoline()
980
+
981
+//go:linkname libc_clonefile libc_clonefile
982
+//go:cgo_import_dynamic libc_clonefile clonefile "/usr/lib/libSystem.B.dylib"
983
+
984
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
985
+
986
+func Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error) {
987
+	var _p0 *byte
988
+	_p0, err = BytePtrFromString(src)
989
+	if err != nil {
990
+		return
991
+	}
992
+	var _p1 *byte
993
+	_p1, err = BytePtrFromString(dst)
994
+	if err != nil {
995
+		return
996
+	}
997
+	_, _, e1 := syscall_syscall6(funcPC(libc_clonefileat_trampoline), uintptr(srcDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
998
+	if e1 != 0 {
999
+		err = errnoErr(e1)
1000
+	}
1001
+	return
1002
+}
1003
+
1004
+func libc_clonefileat_trampoline()
1005
+
1006
+//go:linkname libc_clonefileat libc_clonefileat
1007
+//go:cgo_import_dynamic libc_clonefileat clonefileat "/usr/lib/libSystem.B.dylib"
1008
+
1009
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1010
+
961 1011
 func Dup(fd int) (nfd int, err error) {
962 1012
 	r0, _, e1 := syscall_syscall(funcPC(libc_dup_trampoline), uintptr(fd), 0, 0)
963 1013
 	nfd = int(r0)
... ...
@@ -1146,6 +1196,26 @@ func libc_fchownat_trampoline()
1146 1146
 
1147 1147
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1148 1148
 
1149
+func Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error) {
1150
+	var _p0 *byte
1151
+	_p0, err = BytePtrFromString(dst)
1152
+	if err != nil {
1153
+		return
1154
+	}
1155
+	_, _, e1 := syscall_syscall6(funcPC(libc_fclonefileat_trampoline), uintptr(srcDirfd), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0, 0)
1156
+	if e1 != 0 {
1157
+		err = errnoErr(e1)
1158
+	}
1159
+	return
1160
+}
1161
+
1162
+func libc_fclonefileat_trampoline()
1163
+
1164
+//go:linkname libc_fclonefileat libc_fclonefileat
1165
+//go:cgo_import_dynamic libc_fclonefileat fclonefileat "/usr/lib/libSystem.B.dylib"
1166
+
1167
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1168
+
1149 1169
 func Flock(fd int, how int) (err error) {
1150 1170
 	_, _, e1 := syscall_syscall(funcPC(libc_flock_trampoline), uintptr(fd), uintptr(how), 0)
1151 1171
 	if e1 != 0 {
... ...
@@ -110,6 +110,10 @@ TEXT ·libc_clock_gettime_trampoline(SB),NOSPLIT,$0-0
110 110
 	JMP	libc_clock_gettime(SB)
111 111
 TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0
112 112
 	JMP	libc_close(SB)
113
+TEXT ·libc_clonefile_trampoline(SB),NOSPLIT,$0-0
114
+	JMP	libc_clonefile(SB)
115
+TEXT ·libc_clonefileat_trampoline(SB),NOSPLIT,$0-0
116
+	JMP	libc_clonefileat(SB)
113 117
 TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0
114 118
 	JMP	libc_dup(SB)
115 119
 TEXT ·libc_dup2_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -132,6 +136,8 @@ TEXT ·libc_fchown_trampoline(SB),NOSPLIT,$0-0
132 132
 	JMP	libc_fchown(SB)
133 133
 TEXT ·libc_fchownat_trampoline(SB),NOSPLIT,$0-0
134 134
 	JMP	libc_fchownat(SB)
135
+TEXT ·libc_fclonefileat_trampoline(SB),NOSPLIT,$0-0
136
+	JMP	libc_fclonefileat(SB)
135 137
 TEXT ·libc_flock_trampoline(SB),NOSPLIT,$0-0
136 138
 	JMP	libc_flock(SB)
137 139
 TEXT ·libc_fpathconf_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -164,6 +170,8 @@ TEXT ·libc_getrusage_trampoline(SB),NOSPLIT,$0-0
164 164
 	JMP	libc_getrusage(SB)
165 165
 TEXT ·libc_getsid_trampoline(SB),NOSPLIT,$0-0
166 166
 	JMP	libc_getsid(SB)
167
+TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0
168
+	JMP	libc_gettimeofday(SB)
167 169
 TEXT ·libc_getuid_trampoline(SB),NOSPLIT,$0-0
168 170
 	JMP	libc_getuid(SB)
169 171
 TEXT ·libc_issetugid_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -264,8 +272,6 @@ TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0
264 264
 	JMP	libc_mmap(SB)
265 265
 TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
266 266
 	JMP	libc_munmap(SB)
267
-TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0
268
-	JMP	libc_gettimeofday(SB)
269 267
 TEXT ·libc_fstat_trampoline(SB),NOSPLIT,$0-0
270 268
 	JMP	libc_fstat(SB)
271 269
 TEXT ·libc_fstatat_trampoline(SB),NOSPLIT,$0-0
... ...
@@ -13,17 +13,23 @@ import (
13 13
 //go:cgo_import_dynamic libc_preadv preadv "libc.so"
14 14
 //go:cgo_import_dynamic libc_writev writev "libc.so"
15 15
 //go:cgo_import_dynamic libc_pwritev pwritev "libc.so"
16
+//go:cgo_import_dynamic libc_accept4 accept4 "libsocket.so"
17
+//go:cgo_import_dynamic libc_pipe2 pipe2 "libc.so"
16 18
 
17 19
 //go:linkname procreadv libc_readv
18 20
 //go:linkname procpreadv libc_preadv
19 21
 //go:linkname procwritev libc_writev
20 22
 //go:linkname procpwritev libc_pwritev
23
+//go:linkname procaccept4 libc_accept4
24
+//go:linkname procpipe2 libc_pipe2
21 25
 
22 26
 var (
23 27
 	procreadv,
24 28
 	procpreadv,
25 29
 	procwritev,
26
-	procpwritev syscallFunc
30
+	procpwritev,
31
+	procaccept4,
32
+	procpipe2 syscallFunc
27 33
 )
28 34
 
29 35
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
... ...
@@ -85,3 +91,24 @@ func pwritev(fd int, iovs []Iovec, off int64) (n int, err error) {
85 85
 	}
86 86
 	return
87 87
 }
88
+
89
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
90
+
91
+func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
92
+	r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procaccept4)), 4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
93
+	fd = int(r0)
94
+	if e1 != 0 {
95
+		err = e1
96
+	}
97
+	return
98
+}
99
+
100
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
101
+
102
+func pipe2(p *[2]_C_int, flags int) (err error) {
103
+	_, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procpipe2)), 2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0, 0, 0, 0)
104
+	if e1 != 0 {
105
+		err = e1
106
+	}
107
+	return
108
+}
... ...
@@ -83,6 +83,22 @@ func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
83 83
 
84 84
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
85 85
 
86
+func openat2(dirfd int, path string, open_how *OpenHow, size int) (fd int, err error) {
87
+	var _p0 *byte
88
+	_p0, err = BytePtrFromString(path)
89
+	if err != nil {
90
+		return
91
+	}
92
+	r0, _, e1 := Syscall6(SYS_OPENAT2, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(open_how)), uintptr(size), 0, 0)
93
+	fd = int(r0)
94
+	if e1 != 0 {
95
+		err = errnoErr(e1)
96
+	}
97
+	return
98
+}
99
+
100
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
101
+
86 102
 func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
87 103
 	r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
88 104
 	n = int(r0)
... ...
@@ -76,6 +76,21 @@ type Fsid struct {
76 76
 	Val [2]int32
77 77
 }
78 78
 
79
+type FileCloneRange struct {
80
+	Src_fd      int64
81
+	Src_offset  uint64
82
+	Src_length  uint64
83
+	Dest_offset uint64
84
+}
85
+
86
+type FileDedupeRange struct {
87
+	Src_offset uint64
88
+	Src_length uint64
89
+	Dest_count uint16
90
+	Reserved1  uint16
91
+	Reserved2  uint32
92
+}
93
+
79 94
 type FscryptPolicy struct {
80 95
 	Version                   uint8
81 96
 	Contents_encryption_mode  uint8
... ...
@@ -752,6 +767,22 @@ const (
752 752
 	AT_EACCESS = 0x200
753 753
 )
754 754
 
755
+type OpenHow struct {
756
+	Flags   uint64
757
+	Mode    uint64
758
+	Resolve uint64
759
+}
760
+
761
+const SizeofOpenHow = 0x18
762
+
763
+const (
764
+	RESOLVE_BENEATH       = 0x8
765
+	RESOLVE_IN_ROOT       = 0x10
766
+	RESOLVE_NO_MAGICLINKS = 0x2
767
+	RESOLVE_NO_SYMLINKS   = 0x4
768
+	RESOLVE_NO_XDEV       = 0x1
769
+)
770
+
755 771
 type PollFd struct {
756 772
 	Fd      int32
757 773
 	Events  int16
... ...
@@ -65,6 +65,7 @@ const (
65 65
 	SERVICE_ACCEPT_HARDWAREPROFILECHANGE = 32
66 66
 	SERVICE_ACCEPT_POWEREVENT            = 64
67 67
 	SERVICE_ACCEPT_SESSIONCHANGE         = 128
68
+	SERVICE_ACCEPT_PRESHUTDOWN           = 256
68 69
 
69 70
 	SERVICE_CONTROL_STOP                  = 1
70 71
 	SERVICE_CONTROL_PAUSE                 = 2
... ...
@@ -80,6 +81,7 @@ const (
80 80
 	SERVICE_CONTROL_HARDWAREPROFILECHANGE = 12
81 81
 	SERVICE_CONTROL_POWEREVENT            = 13
82 82
 	SERVICE_CONTROL_SESSIONCHANGE         = 14
83
+	SERVICE_CONTROL_PRESHUTDOWN           = 15
83 84
 
84 85
 	SERVICE_ACTIVE    = 1
85 86
 	SERVICE_INACTIVE  = 2
... ...
@@ -50,6 +50,7 @@ const (
50 50
 	HardwareProfileChange = Cmd(windows.SERVICE_CONTROL_HARDWAREPROFILECHANGE)
51 51
 	PowerEvent            = Cmd(windows.SERVICE_CONTROL_POWEREVENT)
52 52
 	SessionChange         = Cmd(windows.SERVICE_CONTROL_SESSIONCHANGE)
53
+	PreShutdown           = Cmd(windows.SERVICE_CONTROL_PRESHUTDOWN)
53 54
 )
54 55
 
55 56
 // Accepted is used to describe commands accepted by the service.
... ...
@@ -65,6 +66,7 @@ const (
65 65
 	AcceptHardwareProfileChange = Accepted(windows.SERVICE_ACCEPT_HARDWAREPROFILECHANGE)
66 66
 	AcceptPowerEvent            = Accepted(windows.SERVICE_ACCEPT_POWEREVENT)
67 67
 	AcceptSessionChange         = Accepted(windows.SERVICE_ACCEPT_SESSIONCHANGE)
68
+	AcceptPreShutdown           = Accepted(windows.SERVICE_ACCEPT_PRESHUTDOWN)
68 69
 )
69 70
 
70 71
 // Status combines State and Accepted commands to fully describe running service.
... ...
@@ -202,6 +204,9 @@ func (s *service) updateStatus(status *Status, ec *exitCode) error {
202 202
 	if status.Accepts&AcceptSessionChange != 0 {
203 203
 		t.ControlsAccepted |= windows.SERVICE_ACCEPT_SESSIONCHANGE
204 204
 	}
205
+	if status.Accepts&AcceptPreShutdown != 0 {
206
+		t.ControlsAccepted |= windows.SERVICE_ACCEPT_PRESHUTDOWN
207
+	}
205 208
 	if ec.errno == 0 {
206 209
 		t.Win32ExitCode = windows.NO_ERROR
207 210
 		t.ServiceSpecificExitCode = windows.NO_ERROR
... ...
@@ -303,6 +303,7 @@ func NewCallbackCDecl(fn interface{}) uintptr {
303 303
 //sys	ResumeThread(thread Handle) (ret uint32, err error) [failretval==0xffffffff] = kernel32.ResumeThread
304 304
 //sys	SetPriorityClass(process Handle, priorityClass uint32) (err error) = kernel32.SetPriorityClass
305 305
 //sys	GetPriorityClass(process Handle) (ret uint32, err error) = kernel32.GetPriorityClass
306
+//sys	QueryInformationJobObject(job Handle, JobObjectInformationClass int32, JobObjectInformation uintptr, JobObjectInformationLength uint32, retlen *uint32) (err error) = kernel32.QueryInformationJobObject
306 307
 //sys	SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error)
307 308
 //sys	GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error)
308 309
 //sys	GetProcessId(process Handle) (id uint32, err error)
... ...
@@ -1584,18 +1584,6 @@ const (
1584 1584
 	JOB_OBJECT_LIMIT_WORKINGSET                 = 0x00000001
1585 1585
 )
1586 1586
 
1587
-type JOBOBJECT_BASIC_LIMIT_INFORMATION struct {
1588
-	PerProcessUserTimeLimit int64
1589
-	PerJobUserTimeLimit     int64
1590
-	LimitFlags              uint32
1591
-	MinimumWorkingSetSize   uintptr
1592
-	MaximumWorkingSetSize   uintptr
1593
-	ActiveProcessLimit      uint32
1594
-	Affinity                uintptr
1595
-	PriorityClass           uint32
1596
-	SchedulingClass         uint32
1597
-}
1598
-
1599 1587
 type IO_COUNTERS struct {
1600 1588
 	ReadOperationCount  uint64
1601 1589
 	WriteOperationCount uint64
... ...
@@ -20,3 +20,16 @@ type Servent struct {
20 20
 	Port    uint16
21 21
 	Proto   *byte
22 22
 }
23
+
24
+type JOBOBJECT_BASIC_LIMIT_INFORMATION struct {
25
+	PerProcessUserTimeLimit int64
26
+	PerJobUserTimeLimit     int64
27
+	LimitFlags              uint32
28
+	MinimumWorkingSetSize   uintptr
29
+	MaximumWorkingSetSize   uintptr
30
+	ActiveProcessLimit      uint32
31
+	Affinity                uintptr
32
+	PriorityClass           uint32
33
+	SchedulingClass         uint32
34
+	_                       uint32 // pad to 8 byte boundary
35
+}
... ...
@@ -20,3 +20,15 @@ type Servent struct {
20 20
 	Proto   *byte
21 21
 	Port    uint16
22 22
 }
23
+
24
+type JOBOBJECT_BASIC_LIMIT_INFORMATION struct {
25
+	PerProcessUserTimeLimit int64
26
+	PerJobUserTimeLimit     int64
27
+	LimitFlags              uint32
28
+	MinimumWorkingSetSize   uintptr
29
+	MaximumWorkingSetSize   uintptr
30
+	ActiveProcessLimit      uint32
31
+	Affinity                uintptr
32
+	PriorityClass           uint32
33
+	SchedulingClass         uint32
34
+}
... ...
@@ -20,3 +20,16 @@ type Servent struct {
20 20
 	Port    uint16
21 21
 	Proto   *byte
22 22
 }
23
+
24
+type JOBOBJECT_BASIC_LIMIT_INFORMATION struct {
25
+	PerProcessUserTimeLimit int64
26
+	PerJobUserTimeLimit     int64
27
+	LimitFlags              uint32
28
+	MinimumWorkingSetSize   uintptr
29
+	MaximumWorkingSetSize   uintptr
30
+	ActiveProcessLimit      uint32
31
+	Affinity                uintptr
32
+	PriorityClass           uint32
33
+	SchedulingClass         uint32
34
+	_                       uint32 // pad to 8 byte boundary
35
+}
... ...
@@ -212,6 +212,7 @@ var (
212 212
 	procResumeThread                                         = modkernel32.NewProc("ResumeThread")
213 213
 	procSetPriorityClass                                     = modkernel32.NewProc("SetPriorityClass")
214 214
 	procGetPriorityClass                                     = modkernel32.NewProc("GetPriorityClass")
215
+	procQueryInformationJobObject                            = modkernel32.NewProc("QueryInformationJobObject")
215 216
 	procSetInformationJobObject                              = modkernel32.NewProc("SetInformationJobObject")
216 217
 	procGenerateConsoleCtrlEvent                             = modkernel32.NewProc("GenerateConsoleCtrlEvent")
217 218
 	procGetProcessId                                         = modkernel32.NewProc("GetProcessId")
... ...
@@ -2341,6 +2342,18 @@ func GetPriorityClass(process Handle) (ret uint32, err error) {
2341 2341
 	return
2342 2342
 }
2343 2343
 
2344
+func QueryInformationJobObject(job Handle, JobObjectInformationClass int32, JobObjectInformation uintptr, JobObjectInformationLength uint32, retlen *uint32) (err error) {
2345
+	r1, _, e1 := syscall.Syscall6(procQueryInformationJobObject.Addr(), 5, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), uintptr(unsafe.Pointer(retlen)), 0)
2346
+	if r1 == 0 {
2347
+		if e1 != 0 {
2348
+			err = errnoErr(e1)
2349
+		} else {
2350
+			err = syscall.EINVAL
2351
+		}
2352
+	}
2353
+	return
2354
+}
2355
+
2344 2356
 func SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error) {
2345 2357
 	r0, _, e1 := syscall.Syscall6(procSetInformationJobObject.Addr(), 4, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), 0, 0)
2346 2358
 	ret = int(r0)