Codebase list golang-golang-x-sys / 34affea
Import upstream version 0.0~git20220520.bc2c85a Debian Janitor 1 year, 11 months ago
71 changed file(s) with 285 addition(s) and 198 deletion(s). Raw diff Collapse all Expand all
105105
106106 // ARM contains the supported CPU features of the current ARM (32-bit) platform.
107107 // All feature flags are false if:
108 // 1. the current platform is not arm, or
109 // 2. the current operating system is not Linux.
108 // 1. the current platform is not arm, or
109 // 2. the current operating system is not Linux.
110110 var ARM struct {
111111 _ CacheLinePad
112112 HasSWP bool // SWP instruction support
5252 // LookPath instead returns an error.
5353 func LookPath(file string) (string, error) {
5454 path, err := exec.LookPath(file)
55 if err != nil {
55 if err != nil && !isGo119ErrDot(err) {
5656 return "", err
5757 }
5858 if filepath.Base(file) == file && !filepath.IsAbs(path) {
0 // Copyright 2022 The Go Authors. All rights reserved.
1 // Use of this source code is governed by a BSD-style
2 // license that can be found in the LICENSE file.
3
4 //go:build !go1.19
5 // +build !go1.19
6
7 package execabs
8
9 func isGo119ErrDot(err error) bool {
10 return false
11 }
0 // Copyright 2022 The Go Authors. All rights reserved.
1 // Use of this source code is governed by a BSD-style
2 // license that can be found in the LICENSE file.
3
4 //go:build go1.19
5 // +build go1.19
6
7 package execabs
8
9 import "strings"
10
11 func isGo119ErrDot(err error) bool {
12 // TODO: return errors.Is(err, exec.ErrDot)
13 return strings.Contains(err.Error(), "current directory")
14 }
99 (like syscall_plan9.go) and generates system call bodies.
1010 The prototypes are marked by lines beginning with "//sys"
1111 and read like func declarations if //sys is replaced by func, but:
12 * The parameter lists must give a name for each argument.
13 This includes return parameters.
14 * The parameter lists must give a type for each argument:
15 the (x, y, z int) shorthand is not allowed.
16 * If the return parameter is an error number, it must be named errno.
12 - The parameter lists must give a name for each argument.
13 This includes return parameters.
14 - The parameter lists must give a type for each argument:
15 the (x, y, z int) shorthand is not allowed.
16 - If the return parameter is an error number, it must be named errno.
1717
1818 A line beginning with //sysnb is like //sys, except that the
1919 goroutine will not be suspended during the execution of the system
112112
113113 // use is a no-op, but the compiler cannot see that it is.
114114 // Calling use(p) ensures that p is kept live until that point.
115 //
115116 //go:noescape
116117 func use(p unsafe.Pointer)
114114 var ioSync int64
115115
116116 //sys fd2path(fd int, buf []byte) (err error)
117
117118 func Fd2path(fd int) (path string, err error) {
118119 var buf [512]byte
119120
125126 }
126127
127128 //sys pipe(p *[2]int32) (err error)
129
128130 func Pipe(p []int) (err error) {
129131 if len(p) != 2 {
130132 return syscall.ErrorString("bad arg in system call")
179181 }
180182
181183 //sys await(s []byte) (n int, err error)
184
182185 func Await(w *Waitmsg) (err error) {
183186 var buf [512]byte
184187 var f [5][]byte
300303 }
301304
302305 //sys open(path string, mode int) (fd int, err error)
306
303307 func Open(path string, mode int) (fd int, err error) {
304308 fixwd()
305309 return open(path, mode)
306310 }
307311
308312 //sys create(path string, mode int, perm uint32) (fd int, err error)
313
309314 func Create(path string, mode int, perm uint32) (fd int, err error) {
310315 fixwd()
311316 return create(path, mode, perm)
312317 }
313318
314319 //sys remove(path string) (err error)
320
315321 func Remove(path string) error {
316322 fixwd()
317323 return remove(path)
318324 }
319325
320326 //sys stat(path string, edir []byte) (n int, err error)
327
321328 func Stat(path string, edir []byte) (n int, err error) {
322329 fixwd()
323330 return stat(path, edir)
324331 }
325332
326333 //sys bind(name string, old string, flag int) (err error)
334
327335 func Bind(name string, old string, flag int) (err error) {
328336 fixwd()
329337 return bind(name, old, flag)
330338 }
331339
332340 //sys mount(fd int, afd int, old string, flag int, aname string) (err error)
341
333342 func Mount(fd int, afd int, old string, flag int, aname string) (err error) {
334343 fixwd()
335344 return mount(fd, afd, old, flag, aname)
336345 }
337346
338347 //sys wstat(path string, edir []byte) (err error)
348
339349 func Wstat(path string, edir []byte) (err error) {
340350 fixwd()
341351 return wstat(path, edir)
8989 {"mlock", libc_mlock_trampoline_addr},
9090 {"mlockall", libc_mlockall_trampoline_addr},
9191 {"mmap", libc_mmap_trampoline_addr},
92 {"mount", libc_mount_trampoline_addr},
9293 {"mprotect", libc_mprotect_trampoline_addr},
9394 {"msync", libc_msync_trampoline_addr},
9495 {"munlock", libc_munlock_trampoline_addr},
8989 {"mlock", libc_mlock_trampoline_addr},
9090 {"mlockall", libc_mlockall_trampoline_addr},
9191 {"mmap", libc_mmap_trampoline_addr},
92 {"mount", libc_mount_trampoline_addr},
9293 {"mprotect", libc_mprotect_trampoline_addr},
9394 {"msync", libc_msync_trampoline_addr},
9495 {"munlock", libc_munlock_trampoline_addr},
77 package unix
88
99 import (
10 "bytes"
1110 "unsafe"
1211 )
1312
4443
4544 // Name returns the interface name associated with the Ifreq.
4645 func (ifr *Ifreq) Name() string {
47 // BytePtrToString requires a NULL terminator or the program may crash. If
48 // one is not present, just return the empty string.
49 if !bytes.Contains(ifr.raw.Ifrn[:], []byte{0x00}) {
50 return ""
51 }
52
53 return BytePtrToString(&ifr.raw.Ifrn[0])
46 return ByteSliceToString(ifr.raw.Ifrn[:])
5447 }
5548
5649 // According to netdevice(7), only AF_INET addresses are returned for numerous
3838 }
3939
4040 func TestIfreqName(t *testing.T) {
41 // Invalid ifreq (no NULL terminator), so expect empty string.
42 var name [IFNAMSIZ]byte
43 for i := range name {
44 name[i] = 0xff
45 }
46
47 bad := &Ifreq{raw: ifreq{Ifrn: name}}
48 if got := bad.Name(); got != "" {
49 t.Fatalf("expected empty ifreq name, but got: %q", got)
50 }
51
5241 // Valid ifreq, expect the hard-coded testIfreq name.
5342 ifr := testIfreq(t)
5443 if want, got := ifreqName, ifr.Name(); want != got {
55 // consts, funcs, and types into a common source file, per GOOS.
66 //
77 // Usage:
8 // $ mkmerge -out MERGED FILE [FILE ...]
8 //
9 // $ mkmerge -out MERGED FILE [FILE ...]
910 //
1011 // Example:
11 // # Remove all common consts, funcs, and types from zerrors_linux_*.go
12 // # and write the common code into zerrors_linux.go
13 // $ mkmerge -out zerrors_linux.go zerrors_linux_*.go
12 //
13 // # Remove all common consts, funcs, and types from zerrors_linux_*.go
14 // # and write the common code into zerrors_linux.go
15 // $ mkmerge -out zerrors_linux.go zerrors_linux_*.go
1416 //
1517 // mkmerge performs the merge in the following steps:
16 // 1. Construct the set of common code that is identical in all
17 // architecture-specific files.
18 // 2. Write this common code to the merged file.
19 // 3. Remove the common code from all architecture-specific files.
18 // 1. Construct the set of common code that is identical in all
19 // architecture-specific files.
20 // 2. Write this common code to the merged file.
21 // 3. Remove the common code from all architecture-specific files.
2022 package main
2123
2224 import (
5757 && apt-get clean \
5858 && rm -rf /var/lib/apt/lists/*
5959
60 # Only for loong64, add patch and build golang
61 RUN git clone https://go.googlesource.com/go --branch go1.18 /git/go \
62 && cd /git/loong64-patches && git checkout go-v1.18 && cd /git/go && git am /git/loong64-patches/*.patch \
63 && rm -rf /git/loong64-patches && cd /git/go/src && ./make.bash
60 # Only for loong64, build Go from master until 1.19 is released
61 RUN git clone https://go.googlesource.com/go --branch master /git/go \
62 && cd /git/go/src && ./make.bash
6463
6564 ENV PATH /git/go/bin:$PATH
6665
55 // +build ignore
66
77 // mkasm_darwin.go generates assembly trampolines to call libSystem routines from Go.
8 //This program must be run after mksyscall.go.
8 // This program must be run after mksyscall.go.
99 package main
1010
1111 import (
100100 convertUtsnameRegex := regexp.MustCompile(`((Sys|Node|Domain)name|Release|Version|Machine)(\s+)\[(\d+)\]u?int8`)
101101 b = convertUtsnameRegex.ReplaceAll(b, []byte("$1$3[$4]byte"))
102102
103 // Convert [n]int8 to [n]byte in Statvfs_t members to simplify
103 // Convert [n]int8 to [n]byte in Statvfs_t and Statfs_t members to simplify
104104 // conversion to string.
105 convertStatvfsRegex := regexp.MustCompile(`((Fstype|Mnton|Mntfrom)name)(\s+)\[(\d+)\]int8`)
105 convertStatvfsRegex := regexp.MustCompile(`(([Ff]stype|[Mm]nton|[Mm]ntfrom)name|mntfromspec)(\s+)\[(\d+)\]int8`)
106106 b = convertStatvfsRegex.ReplaceAll(b, []byte("$1$3[$4]byte"))
107107
108108 // Convert []int8 to []byte in device mapper ioctl interface
99 (like syscall_darwin.go) and generates system call bodies.
1010 The prototypes are marked by lines beginning with "//sys"
1111 and read like func declarations if //sys is replaced by func, but:
12 * The parameter lists must give a name for each argument.
13 This includes return parameters.
14 * The parameter lists must give a type for each argument:
15 the (x, y, z int) shorthand is not allowed.
16 * If the return parameter is an error number, it must be named errno.
12 - The parameter lists must give a name for each argument.
13 This includes return parameters.
14 - The parameter lists must give a type for each argument:
15 the (x, y, z int) shorthand is not allowed.
16 - If the return parameter is an error number, it must be named errno.
1717
1818 A line beginning with //sysnb is like //sys, except that the
1919 goroutine will not be suspended during the execution of the system
99 (like syscall_aix.go) and generates system call bodies.
1010 The prototypes are marked by lines beginning with "//sys"
1111 and read like func declarations if //sys is replaced by func, but:
12 * The parameter lists must give a name for each argument.
13 This includes return parameters.
14 * The parameter lists must give a type for each argument:
15 the (x, y, z int) shorthand is not allowed.
16 * If the return parameter is an error number, it must be named err.
17 * If go func name needs to be different than its libc name,
18 * or the function is not in libc, name could be specified
19 * at the end, after "=" sign, like
20 //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
12 - The parameter lists must give a name for each argument.
13 This includes return parameters.
14 - The parameter lists must give a type for each argument:
15 the (x, y, z int) shorthand is not allowed.
16 - If the return parameter is an error number, it must be named err.
17 - If go func name needs to be different than its libc name,
18 - or the function is not in libc, name could be specified
19 - at the end, after "=" sign, like
20 //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
2121 */
2222 package main
2323
3636 }
3737
3838 //sys utimes(path string, times *[2]Timeval) (err error)
39
3940 func Utimes(path string, tv []Timeval) error {
4041 if len(tv) != 2 {
4142 return EINVAL
4445 }
4546
4647 //sys utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error)
48
4749 func UtimesNano(path string, ts []Timespec) error {
4850 if len(ts) != 2 {
4951 return EINVAL
299301 }
300302
301303 //sys getdirent(fd int, buf []byte) (n int, err error)
304
302305 func Getdents(fd int, buf []byte) (n int, err error) {
303306 return getdirent(fd, buf)
304307 }
305308
306309 //sys wait4(pid Pid_t, status *_C_int, options int, rusage *Rusage) (wpid Pid_t, err error)
310
307311 func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
308312 var status _C_int
309313 var r Pid_t
371375 //sys fcntl(fd int, cmd int, arg int) (val int, err error)
372376
373377 //sys fsyncRange(fd int, how int, start int64, length int64) (err error) = fsync_range
378
374379 func Fsync(fd int) error {
375380 return fsyncRange(fd, O_SYNC, 0, 0)
376381 }
535540 //sys Getsystemcfg(label int) (n uint64)
536541
537542 //sys umount(target string) (err error)
543
538544 func Unmount(target string, flags int) (err error) {
539545 if flags != 0 {
540546 // AIX doesn't have any flags for umount.
503503 //sys Mkdirat(dirfd int, path string, mode uint32) (err error)
504504 //sys Mkfifo(path string, mode uint32) (err error)
505505 //sys Mknod(path string, mode uint32, dev int) (err error)
506 //sys Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error)
506507 //sys Open(path string, mode int, perm uint32) (fd int, err error)
507508 //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error)
508509 //sys Pathconf(path string, name int) (val int, err error)
571572 // Nfssvc
572573 // Getfh
573574 // Quotactl
574 // Mount
575575 // Csops
576576 // Waitid
577577 // Add_profil
124124 }
125125
126126 //sys extpread(fd int, p []byte, flags int, offset int64) (n int, err error)
127
127128 func pread(fd int, p []byte, offset int64) (n int, err error) {
128129 return extpread(fd, p, 0, offset)
129130 }
130131
131132 //sys extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error)
133
132134 func pwrite(fd int, p []byte, offset int64) (n int, err error) {
133135 return extpwrite(fd, p, 0, offset)
134136 }
511511 //
512512 // Server example:
513513 //
514 // fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)
515 // _ = unix.Bind(fd, &unix.SockaddrRFCOMM{
516 // Channel: 1,
517 // Addr: [6]uint8{0, 0, 0, 0, 0, 0}, // BDADDR_ANY or 00:00:00:00:00:00
518 // })
519 // _ = Listen(fd, 1)
520 // nfd, sa, _ := Accept(fd)
521 // fmt.Printf("conn addr=%v fd=%d", sa.(*unix.SockaddrRFCOMM).Addr, nfd)
522 // Read(nfd, buf)
514 // fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)
515 // _ = unix.Bind(fd, &unix.SockaddrRFCOMM{
516 // Channel: 1,
517 // Addr: [6]uint8{0, 0, 0, 0, 0, 0}, // BDADDR_ANY or 00:00:00:00:00:00
518 // })
519 // _ = Listen(fd, 1)
520 // nfd, sa, _ := Accept(fd)
521 // fmt.Printf("conn addr=%v fd=%d", sa.(*unix.SockaddrRFCOMM).Addr, nfd)
522 // Read(nfd, buf)
523523 //
524524 // Client example:
525525 //
526 // fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)
527 // _ = Connect(fd, &SockaddrRFCOMM{
528 // Channel: 1,
529 // Addr: [6]byte{0x11, 0x22, 0x33, 0xaa, 0xbb, 0xcc}, // CC:BB:AA:33:22:11
530 // })
531 // Write(fd, []byte(`hello`))
526 // fd, _ := Socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)
527 // _ = Connect(fd, &SockaddrRFCOMM{
528 // Channel: 1,
529 // Addr: [6]byte{0x11, 0x22, 0x33, 0xaa, 0xbb, 0xcc}, // CC:BB:AA:33:22:11
530 // })
531 // Write(fd, []byte(`hello`))
532532 type SockaddrRFCOMM struct {
533533 // Addr represents a bluetooth address, byte ordering is little-endian.
534534 Addr [6]uint8
555555 // The SockaddrCAN struct must be bound to the socket file descriptor
556556 // using Bind before the CAN socket can be used.
557557 //
558 // // Read one raw CAN frame
559 // fd, _ := Socket(AF_CAN, SOCK_RAW, CAN_RAW)
560 // addr := &SockaddrCAN{Ifindex: index}
561 // Bind(fd, addr)
562 // frame := make([]byte, 16)
563 // Read(fd, frame)
558 // // Read one raw CAN frame
559 // fd, _ := Socket(AF_CAN, SOCK_RAW, CAN_RAW)
560 // addr := &SockaddrCAN{Ifindex: index}
561 // Bind(fd, addr)
562 // frame := make([]byte, 16)
563 // Read(fd, frame)
564564 //
565565 // The full SocketCAN documentation can be found in the linux kernel
566566 // archives at: https://www.kernel.org/doc/Documentation/networking/can.txt
631631 // Here is an example of using an AF_ALG socket with SHA1 hashing.
632632 // The initial socket setup process is as follows:
633633 //
634 // // Open a socket to perform SHA1 hashing.
635 // fd, _ := unix.Socket(unix.AF_ALG, unix.SOCK_SEQPACKET, 0)
636 // addr := &unix.SockaddrALG{Type: "hash", Name: "sha1"}
637 // unix.Bind(fd, addr)
638 // // Note: unix.Accept does not work at this time; must invoke accept()
639 // // manually using unix.Syscall.
640 // hashfd, _, _ := unix.Syscall(unix.SYS_ACCEPT, uintptr(fd), 0, 0)
634 // // Open a socket to perform SHA1 hashing.
635 // fd, _ := unix.Socket(unix.AF_ALG, unix.SOCK_SEQPACKET, 0)
636 // addr := &unix.SockaddrALG{Type: "hash", Name: "sha1"}
637 // unix.Bind(fd, addr)
638 // // Note: unix.Accept does not work at this time; must invoke accept()
639 // // manually using unix.Syscall.
640 // hashfd, _, _ := unix.Syscall(unix.SYS_ACCEPT, uintptr(fd), 0, 0)
641641 //
642642 // Once a file descriptor has been returned from Accept, it may be used to
643643 // perform SHA1 hashing. The descriptor is not safe for concurrent use, but
646646 // When hashing a small byte slice or string, a single Write and Read may
647647 // be used:
648648 //
649 // // Assume hashfd is already configured using the setup process.
650 // hash := os.NewFile(hashfd, "sha1")
651 // // Hash an input string and read the results. Each Write discards
652 // // previous hash state. Read always reads the current state.
653 // b := make([]byte, 20)
654 // for i := 0; i < 2; i++ {
655 // io.WriteString(hash, "Hello, world.")
656 // hash.Read(b)
657 // fmt.Println(hex.EncodeToString(b))
658 // }
659 // // Output:
660 // // 2ae01472317d1935a84797ec1983ae243fc6aa28
661 // // 2ae01472317d1935a84797ec1983ae243fc6aa28
649 // // Assume hashfd is already configured using the setup process.
650 // hash := os.NewFile(hashfd, "sha1")
651 // // Hash an input string and read the results. Each Write discards
652 // // previous hash state. Read always reads the current state.
653 // b := make([]byte, 20)
654 // for i := 0; i < 2; i++ {
655 // io.WriteString(hash, "Hello, world.")
656 // hash.Read(b)
657 // fmt.Println(hex.EncodeToString(b))
658 // }
659 // // Output:
660 // // 2ae01472317d1935a84797ec1983ae243fc6aa28
661 // // 2ae01472317d1935a84797ec1983ae243fc6aa28
662662 //
663663 // For hashing larger byte slices, or byte streams such as those read from
664664 // a file or socket, use Sendto with MSG_MORE to instruct the kernel to update
665665 // the hash digest instead of creating a new one for a given chunk and finalizing it.
666666 //
667 // // Assume hashfd and addr are already configured using the setup process.
668 // hash := os.NewFile(hashfd, "sha1")
669 // // Hash the contents of a file.
670 // f, _ := os.Open("/tmp/linux-4.10-rc7.tar.xz")
671 // b := make([]byte, 4096)
672 // for {
673 // n, err := f.Read(b)
674 // if err == io.EOF {
675 // break
676 // }
677 // unix.Sendto(hashfd, b[:n], unix.MSG_MORE, addr)
678 // }
679 // hash.Read(b)
680 // fmt.Println(hex.EncodeToString(b))
681 // // Output: 85cdcad0c06eef66f805ecce353bec9accbeecc5
667 // // Assume hashfd and addr are already configured using the setup process.
668 // hash := os.NewFile(hashfd, "sha1")
669 // // Hash the contents of a file.
670 // f, _ := os.Open("/tmp/linux-4.10-rc7.tar.xz")
671 // b := make([]byte, 4096)
672 // for {
673 // n, err := f.Read(b)
674 // if err == io.EOF {
675 // break
676 // }
677 // unix.Sendto(hashfd, b[:n], unix.MSG_MORE, addr)
678 // }
679 // hash.Read(b)
680 // fmt.Println(hex.EncodeToString(b))
681 // // Output: 85cdcad0c06eef66f805ecce353bec9accbeecc5
682682 //
683683 // For more information, see: http://www.chronox.de/crypto-API/crypto/userspace-if.html.
684684 type SockaddrALG struct {
44 package unix_test
55
66 import (
7 "bytes"
87 "os"
98 "testing"
109
3837 t.Fatalf("IoctlGetPtmget: %v\n", err)
3938 }
4039
41 t.Logf("sfd = %v, ptsname = %v", ptm.Sfd, string(ptm.Sn[:bytes.IndexByte(ptm.Sn[:], 0)]))
40 t.Logf("sfd = %v, ptsname = %v", ptm.Sfd, unix.ByteSliceToString(ptm.Sn[:]))
4241 }
4342
4443 func TestStatvfs(t *testing.T) {
8080 }
8181
8282 //sysnb pipe2(p *[2]_C_int, flags int) (err error)
83
8384 func Pipe2(p []int, flags int) error {
8485 if len(p) != 2 {
8586 return EINVAL
9495 }
9596
9697 //sys Getdents(fd int, buf []byte) (n int, err error)
98
9799 func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
98100 n, err = Getdents(fd, buf)
99101 if err != nil || basep == nil {
44 // +build 386,linux
55
66 // Code generated by cmd/cgo -godefs; DO NOT EDIT.
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -m32 /build/unix/_const.go
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -m32 _const.go
88
99 package unix
1010
44 // +build amd64,linux
55
66 // Code generated by cmd/cgo -godefs; DO NOT EDIT.
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -m64 /build/unix/_const.go
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -m64 _const.go
88
99 package unix
1010
44 // +build arm,linux
55
66 // Code generated by cmd/cgo -godefs; DO NOT EDIT.
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go
88
99 package unix
1010
44 // +build arm64,linux
55
66 // Code generated by cmd/cgo -godefs; DO NOT EDIT.
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/unix/_const.go
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char _const.go
88
99 package unix
1010
44 // +build loong64,linux
55
66 // Code generated by cmd/cgo -godefs; DO NOT EDIT.
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go
88
99 package unix
1010
44 // +build mips,linux
55
66 // Code generated by cmd/cgo -godefs; DO NOT EDIT.
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go
88
99 package unix
1010
44 // +build mips64,linux
55
66 // Code generated by cmd/cgo -godefs; DO NOT EDIT.
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go
88
99 package unix
1010
44 // +build mips64le,linux
55
66 // Code generated by cmd/cgo -godefs; DO NOT EDIT.
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go
88
99 package unix
1010
44 // +build mipsle,linux
55
66 // Code generated by cmd/cgo -godefs; DO NOT EDIT.
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go
88
99 package unix
1010
44 // +build ppc,linux
55
66 // Code generated by cmd/cgo -godefs; DO NOT EDIT.
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go
88
99 package unix
1010
44 // +build ppc64,linux
55
66 // Code generated by cmd/cgo -godefs; DO NOT EDIT.
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go
88
99 package unix
1010
44 // +build ppc64le,linux
55
66 // Code generated by cmd/cgo -godefs; DO NOT EDIT.
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go
88
99 package unix
1010
44 // +build riscv64,linux
55
66 // Code generated by cmd/cgo -godefs; DO NOT EDIT.
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go
88
99 package unix
1010
44 // +build s390x,linux
55
66 // Code generated by cmd/cgo -godefs; DO NOT EDIT.
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/unix/_const.go
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char _const.go
88
99 package unix
1010
44 // +build sparc64,linux
55
66 // Code generated by cmd/cgo -godefs; DO NOT EDIT.
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/_const.go
7 // cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go
88
99 package unix
1010
16421642
16431643 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
16441644
1645 func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) {
1646 var _p0 *byte
1647 _p0, err = BytePtrFromString(fsType)
1648 if err != nil {
1649 return
1650 }
1651 var _p1 *byte
1652 _p1, err = BytePtrFromString(dir)
1653 if err != nil {
1654 return
1655 }
1656 _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0)
1657 if e1 != 0 {
1658 err = errnoErr(e1)
1659 }
1660 return
1661 }
1662
1663 var libc_mount_trampoline_addr uintptr
1664
1665 //go:cgo_import_dynamic libc_mount mount "/usr/lib/libSystem.B.dylib"
1666
1667 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1668
16451669 func Open(path string, mode int, perm uint32) (fd int, err error) {
16461670 var _p0 *byte
16471671 _p0, err = BytePtrFromString(path)
599599 GLOBL ·libc_mknod_trampoline_addr(SB), RODATA, $8
600600 DATA ·libc_mknod_trampoline_addr(SB)/8, $libc_mknod_trampoline<>(SB)
601601
602 TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0
603 JMP libc_mount(SB)
604
605 GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8
606 DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB)
607
602608 TEXT libc_open_trampoline<>(SB),NOSPLIT,$0-0
603609 JMP libc_open(SB)
604610
16421642
16431643 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
16441644
1645 func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) {
1646 var _p0 *byte
1647 _p0, err = BytePtrFromString(fsType)
1648 if err != nil {
1649 return
1650 }
1651 var _p1 *byte
1652 _p1, err = BytePtrFromString(dir)
1653 if err != nil {
1654 return
1655 }
1656 _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0)
1657 if e1 != 0 {
1658 err = errnoErr(e1)
1659 }
1660 return
1661 }
1662
1663 var libc_mount_trampoline_addr uintptr
1664
1665 //go:cgo_import_dynamic libc_mount mount "/usr/lib/libSystem.B.dylib"
1666
1667 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1668
16451669 func Open(path string, mode int, perm uint32) (fd int, err error) {
16461670 var _p0 *byte
16471671 _p0, err = BytePtrFromString(path)
599599 GLOBL ·libc_mknod_trampoline_addr(SB), RODATA, $8
600600 DATA ·libc_mknod_trampoline_addr(SB)/8, $libc_mknod_trampoline<>(SB)
601601
602 TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0
603 JMP libc_mount(SB)
604
605 GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8
606 DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB)
607
602608 TEXT libc_open_trampoline<>(SB),NOSPLIT,$0-0
603609 JMP libc_open(SB)
604610
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -m32 /build/unix/linux/types.go | go run mkpost.go
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -m32 linux/types.go | go run mkpost.go
11 // Code generated by the command above; see README.md. DO NOT EDIT.
22
33 //go:build 386 && linux
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -m64 /build/unix/linux/types.go | go run mkpost.go
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -m64 linux/types.go | go run mkpost.go
11 // Code generated by the command above; see README.md. DO NOT EDIT.
22
33 //go:build amd64 && linux
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go
11 // Code generated by the command above; see README.md. DO NOT EDIT.
22
33 //go:build arm && linux
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/unix/linux/types.go | go run mkpost.go
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char linux/types.go | go run mkpost.go
11 // Code generated by the command above; see README.md. DO NOT EDIT.
22
33 //go:build arm64 && linux
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go
11 // Code generated by the command above; see README.md. DO NOT EDIT.
22
33 //go:build loong64 && linux
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go
11 // Code generated by the command above; see README.md. DO NOT EDIT.
22
33 //go:build mips && linux
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go
11 // Code generated by the command above; see README.md. DO NOT EDIT.
22
33 //go:build mips64 && linux
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go
11 // Code generated by the command above; see README.md. DO NOT EDIT.
22
33 //go:build mips64le && linux
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go
11 // Code generated by the command above; see README.md. DO NOT EDIT.
22
33 //go:build mipsle && linux
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go
11 // Code generated by the command above; see README.md. DO NOT EDIT.
22
33 //go:build ppc && linux
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go
11 // Code generated by the command above; see README.md. DO NOT EDIT.
22
33 //go:build ppc64 && linux
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go
11 // Code generated by the command above; see README.md. DO NOT EDIT.
22
33 //go:build ppc64le && linux
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go
11 // Code generated by the command above; see README.md. DO NOT EDIT.
22
33 //go:build riscv64 && linux
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char /build/unix/linux/types.go | go run mkpost.go
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include -fsigned-char linux/types.go | go run mkpost.go
11 // Code generated by the command above; see README.md. DO NOT EDIT.
22
33 //go:build s390x && linux
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include /build/unix/linux/types.go | go run mkpost.go
0 // cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go
11 // Code generated by the command above; see README.md. DO NOT EDIT.
22
33 //go:build sparc64 && linux
9393 F_namemax uint32
9494 F_owner uint32
9595 F_ctime uint64
96 F_fstypename [16]int8
97 F_mntonname [90]int8
98 F_mntfromname [90]int8
99 F_mntfromspec [90]int8
96 F_fstypename [16]byte
97 F_mntonname [90]byte
98 F_mntfromname [90]byte
99 F_mntfromspec [90]byte
100100 Pad_cgo_0 [2]byte
101101 Mount_info [160]byte
102102 }
9595 F_namemax uint32
9696 F_owner uint32
9797 F_ctime uint64
98 F_fstypename [16]int8
99 F_mntonname [90]int8
100 F_mntfromname [90]int8
101 F_mntfromspec [90]int8
98 F_fstypename [16]byte
99 F_mntonname [90]byte
100 F_mntfromname [90]byte
101 F_mntfromspec [90]byte
102102 _ [2]byte
103103 Mount_info [160]byte
104104 }
9797 F_namemax uint32
9898 F_owner uint32
9999 F_ctime uint64
100 F_fstypename [16]int8
101 F_mntonname [90]int8
102 F_mntfromname [90]int8
103 F_mntfromspec [90]int8
100 F_fstypename [16]byte
101 F_mntonname [90]byte
102 F_mntfromname [90]byte
103 F_mntfromspec [90]byte
104104 _ [2]byte
105105 Mount_info [160]byte
106106 }
9393 F_namemax uint32
9494 F_owner uint32
9595 F_ctime uint64
96 F_fstypename [16]int8
97 F_mntonname [90]int8
98 F_mntfromname [90]int8
99 F_mntfromspec [90]int8
96 F_fstypename [16]byte
97 F_mntonname [90]byte
98 F_mntfromname [90]byte
99 F_mntfromspec [90]byte
100100 _ [2]byte
101101 Mount_info [160]byte
102102 }
9393 F_namemax uint32
9494 F_owner uint32
9595 F_ctime uint64
96 F_fstypename [16]int8
97 F_mntonname [90]int8
98 F_mntfromname [90]int8
99 F_mntfromspec [90]int8
96 F_fstypename [16]byte
97 F_mntonname [90]byte
98 F_mntfromname [90]byte
99 F_mntfromspec [90]byte
100100 _ [2]byte
101101 Mount_info [160]byte
102102 }
1414 // in http://msdn.microsoft.com/en-us/library/ms880421.
1515 // This function returns "" (2 double quotes) if s is empty.
1616 // Alternatively, these transformations are done:
17 // - every back slash (\) is doubled, but only if immediately
18 // followed by double quote (");
19 // - every double quote (") is escaped by back slash (\);
20 // - finally, s is wrapped with double quotes (arg -> "arg"),
21 // but only if there is space or tab inside s.
17 // - every back slash (\) is doubled, but only if immediately
18 // followed by double quote (");
19 // - every double quote (") is escaped by back slash (\);
20 // - finally, s is wrapped with double quotes (arg -> "arg"),
21 // but only if there is space or tab inside s.
2222 func EscapeArg(s string) string {
2323 if len(s) == 0 {
2424 return "\"\""
1111 The prototypes are marked by lines beginning with "//sys" and read
1212 like func declarations if //sys is replaced by func, but:
1313
14 * The parameter lists must give a name for each argument. This
15 includes return parameters.
16
17 * The parameter lists must give a type for each argument:
18 the (x, y, z int) shorthand is not allowed.
19
20 * If the return parameter is an error number, it must be named err.
21
22 * If go func name needs to be different from its winapi dll name,
23 the winapi name could be specified at the end, after "=" sign, like
24 //sys LoadLibrary(libname string) (handle uint32, err error) = LoadLibraryA
25
26 * Each function that returns err needs to supply a condition, that
27 return value of winapi will be tested against to detect failure.
28 This would set err to windows "last-error", otherwise it will be nil.
29 The value can be provided at end of //sys declaration, like
30 //sys LoadLibrary(libname string) (handle uint32, err error) [failretval==-1] = LoadLibraryA
31 and is [failretval==0] by default.
32
33 * If the function name ends in a "?", then the function not existing is non-
34 fatal, and an error will be returned instead of panicking.
14 - The parameter lists must give a name for each argument. This
15 includes return parameters.
16
17 - The parameter lists must give a type for each argument:
18 the (x, y, z int) shorthand is not allowed.
19
20 - If the return parameter is an error number, it must be named err.
21
22 - If go func name needs to be different from its winapi dll name,
23 the winapi name could be specified at the end, after "=" sign, like
24 //sys LoadLibrary(libname string) (handle uint32, err error) = LoadLibraryA
25
26 - Each function that returns err needs to supply a condition, that
27 return value of winapi will be tested against to detect failure.
28 This would set err to windows "last-error", otherwise it will be nil.
29 The value can be provided at end of //sys declaration, like
30 //sys LoadLibrary(libname string) (handle uint32, err error) [failretval==-1] = LoadLibraryA
31 and is [failretval==0] by default.
32
33 - If the function name ends in a "?", then the function not existing is non-
34 fatal, and an error will be returned instead of panicking.
3535
3636 Usage:
37
3738 mkwinsyscall [flags] [path ...]
3839
3940 The flags are:
41
4042 -output
4143 Specify output file name (outputs to console if blank).
4244 -trace
1919 // log.Fatal(err)
2020 // }
2121 // fmt.Printf("Windows system root is %q\n", s)
22 //
2322 package registry
2423
2524 import (
55 // +build windows
66
77 // Package debug provides facilities to execute svc.Handler on console.
8 //
98 package debug
109
1110 import (
55 // +build windows
66
77 // Package eventlog implements access to Windows event log.
8 //
98 package eventlog
109
1110 import (
1111 // stop / start / pause / continue any service, and how to
1212 // write to event log. It also shows how to use debug
1313 // facilities available in debug package.
14 //
1514 package main
1615
1716 import (
88 // It can be used to install and remove them. It can also start,
99 // stop and pause them. The package can query / change current
1010 // service state and config parameters.
11 //
1211 package mgr
1312
1413 import (
55 // +build windows
66
77 // Package svc provides everything required to build Windows service.
8 //
98 package svc
109
1110 import (
622622
623623 func getStdHandle(stdhandle uint32) (fd Handle) {
624624 r, _ := GetStdHandle(stdhandle)
625 CloseOnExec(r)
626625 return r
627626 }
628627