Linux id-dci-web1412.main-hosting.eu 5.14.0-611.20.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jan 14 06:35:04 EST 2026 x86_64
LiteSpeed
: 2a02:4780:6:1512:0:19fc:adf1:2 | : 216.73.216.85
Cant Read [ /etc/named.conf ]
8.1.34
u435990001
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
opt /
go /
pkg /
mod /
golang.org /
x /
sys@v0.16.0 /
unix /
[ HOME SHELL ]
Name
Size
Permission
Action
internal
[ DIR ]
dr-xr-xr-x
linux
[ DIR ]
dr-xr-xr-x
.gitignore
16
B
-r--r--r--
README.md
8.48
KB
-r--r--r--
affinity_linux.go
1.88
KB
-r--r--r--
aliases.go
396
B
-r--r--r--
asm_aix_ppc64.s
407
B
-r--r--r--
asm_bsd_386.s
696
B
-r--r--r--
asm_bsd_amd64.s
722
B
-r--r--r--
asm_bsd_arm.s
686
B
-r--r--r--
asm_bsd_arm64.s
709
B
-r--r--r--
asm_bsd_ppc64.s
716
B
-r--r--r--
asm_bsd_riscv64.s
711
B
-r--r--r--
asm_linux_386.s
1.44
KB
-r--r--r--
asm_linux_amd64.s
1.18
KB
-r--r--r--
asm_linux_arm.s
1.11
KB
-r--r--r--
asm_linux_arm64.s
1.08
KB
-r--r--r--
asm_linux_loong64.s
1.16
KB
-r--r--r--
asm_linux_mips64x.s
1.14
KB
-r--r--r--
asm_linux_mipsx.s
1.14
KB
-r--r--r--
asm_linux_ppc64x.s
909
B
-r--r--r--
asm_linux_riscv64.s
1.02
KB
-r--r--r--
asm_linux_s390x.s
1.12
KB
-r--r--r--
asm_openbsd_mips64.s
677
B
-r--r--r--
asm_solaris_amd64.s
423
B
-r--r--r--
asm_zos_s390x.s
8.4
KB
-r--r--r--
bluetooth_linux.go
680
B
-r--r--r--
cap_freebsd.go
5.01
KB
-r--r--r--
constants.go
318
B
-r--r--r--
creds_test.go
7.23
KB
-r--r--r--
darwin_amd64_test.go
6.73
KB
-r--r--r--
darwin_arm64_test.go
6.71
KB
-r--r--r--
darwin_test.go
2.3
KB
-r--r--r--
dev_aix_ppc.go
739
B
-r--r--r--
dev_aix_ppc64.go
858
B
-r--r--r--
dev_darwin.go
747
B
-r--r--r--
dev_dragonfly.go
1.01
KB
-r--r--r--
dev_freebsd.go
1013
B
-r--r--r--
dev_linux.go
1.54
KB
-r--r--r--
dev_linux_test.go
1.46
KB
-r--r--r--
dev_netbsd.go
913
B
-r--r--r--
dev_openbsd.go
918
B
-r--r--r--
dev_zos.go
830
B
-r--r--r--
dev_zos_test.go
1.37
KB
-r--r--r--
dirent.go
3.01
KB
-r--r--r--
dirent_test.go
3.14
KB
-r--r--r--
dup3_test.go
1.44
KB
-r--r--r--
endian_big.go
330
B
-r--r--r--
endian_little.go
358
B
-r--r--r--
env_unix.go
645
B
-r--r--r--
epoll_zos.go
5.02
KB
-r--r--r--
epoll_zos_test.go
6.24
KB
-r--r--r--
example_exec_test.go
426
B
-r--r--r--
example_flock_test.go
613
B
-r--r--r--
example_sysvshm_test.go
1.32
KB
-r--r--r--
export_mremap_test.go
272
B
-r--r--r--
fcntl.go
1.05
KB
-r--r--r--
fcntl_darwin.go
806
B
-r--r--r--
fcntl_linux_32bit.go
436
B
-r--r--r--
fdset.go
781
B
-r--r--r--
fdset_test.go
1.26
KB
-r--r--r--
fstatfs_zos.go
4.07
KB
-r--r--r--
fstatfs_zos_test.go
1.77
KB
-r--r--r--
gccgo.go
1.91
KB
-r--r--r--
gccgo_c.c
1.49
KB
-r--r--r--
gccgo_linux_amd64.go
436
B
-r--r--r--
getdirentries_test.go
1.69
KB
-r--r--r--
getfsstat_test.go
1006
B
-r--r--r--
ifreq_linux.go
4.27
KB
-r--r--r--
ifreq_linux_test.go
4.35
KB
-r--r--r--
ioctl_linux.go
8.07
KB
-r--r--r--
ioctl_signed.go
2.2
KB
-r--r--r--
ioctl_unsigned.go
2.26
KB
-r--r--r--
ioctl_zos.go
2.03
KB
-r--r--r--
mkall.sh
8.11
KB
-r--r--r--
mkasm.go
3.75
KB
-r--r--r--
mkerrors.sh
20.11
KB
-r--r--r--
mkpost.go
9.48
KB
-r--r--r--
mksyscall.go
12.21
KB
-r--r--r--
mksyscall_aix_ppc.go
11.97
KB
-r--r--r--
mksyscall_aix_ppc64.go
18.84
KB
-r--r--r--
mksyscall_solaris.go
9.65
KB
-r--r--r--
mksysctl_openbsd.go
7.96
KB
-r--r--r--
mksysnum.go
4.74
KB
-r--r--r--
mmap_nomremap.go
336
B
-r--r--r--
mmap_unix_test.go
1.38
KB
-r--r--r--
mmap_zos_test.go
1.83
KB
-r--r--r--
mremap.go
1.36
KB
-r--r--r--
mremap_test.go
1.13
KB
-r--r--r--
openbsd_test.go
2.43
KB
-r--r--r--
pagesize_unix.go
389
B
-r--r--r--
pipe2_test.go
2.05
KB
-r--r--r--
pledge_openbsd.go
2.33
KB
-r--r--r--
ptrace_darwin.go
315
B
-r--r--r--
ptrace_ios.go
284
B
-r--r--r--
race.go
629
B
-r--r--r--
race0.go
553
B
-r--r--r--
readdirent_getdents.go
401
B
-r--r--r--
readdirent_getdirentries.go
698
B
-r--r--r--
sendfile_test.go
2.28
KB
-r--r--r--
sockcmsg_dragonfly.go
544
B
-r--r--r--
sockcmsg_linux.go
2.6
KB
-r--r--r--
sockcmsg_unix.go
3.14
KB
-r--r--r--
sockcmsg_unix_other.go
1.2
KB
-r--r--r--
syscall.go
2.81
KB
-r--r--r--
syscall_aix.go
16.1
KB
-r--r--r--
syscall_aix_ppc.go
1.27
KB
-r--r--r--
syscall_aix_ppc64.go
1.9
KB
-r--r--r--
syscall_aix_test.go
2.1
KB
-r--r--r--
syscall_bsd.go
14.96
KB
-r--r--r--
syscall_bsd_test.go
1.41
KB
-r--r--r--
syscall_darwin.go
20.72
KB
-r--r--r--
syscall_darwin_amd64.go
1.49
KB
-r--r--r--
syscall_darwin_arm64.go
1.41
KB
-r--r--r--
syscall_darwin_libSystem.go
1.21
KB
-r--r--r--
syscall_darwin_test.go
6.05
KB
-r--r--r--
syscall_dragonfly.go
11.18
KB
-r--r--r--
syscall_dragonfly_amd64.go
1.25
KB
-r--r--r--
syscall_freebsd.go
15.34
KB
-r--r--r--
syscall_freebsd_386.go
1.48
KB
-r--r--r--
syscall_freebsd_amd64.go
1.44
KB
-r--r--r--
syscall_freebsd_arm.go
1.35
KB
-r--r--r--
syscall_freebsd_arm64.go
1.31
KB
-r--r--r--
syscall_freebsd_riscv64.go
1.32
KB
-r--r--r--
syscall_freebsd_test.go
7.45
KB
-r--r--r--
syscall_hurd.go
635
B
-r--r--r--
syscall_hurd_386.go
447
B
-r--r--r--
syscall_illumos.go
1.76
KB
-r--r--r--
syscall_internal_bsd_test.go
3.16
KB
-r--r--r--
syscall_internal_darwin_test.g...
4.31
KB
-r--r--r--
syscall_internal_linux_test.go
20.1
KB
-r--r--r--
syscall_internal_solaris_test....
8.75
KB
-r--r--r--
syscall_linux.go
74.41
KB
-r--r--r--
syscall_linux_386.go
8.88
KB
-r--r--r--
syscall_linux_alarm.go
440
B
-r--r--r--
syscall_linux_amd64.go
5.28
KB
-r--r--r--
syscall_linux_amd64_gc.go
290
B
-r--r--r--
syscall_linux_arm.go
6.94
KB
-r--r--r--
syscall_linux_arm64.go
5.97
KB
-r--r--r--
syscall_linux_gc.go
495
B
-r--r--r--
syscall_linux_gc_386.go
585
B
-r--r--r--
syscall_linux_gc_arm.go
411
B
-r--r--r--
syscall_linux_gccgo_386.go
986
B
-r--r--r--
syscall_linux_gccgo_arm.go
596
B
-r--r--r--
syscall_linux_loong64.go
6.66
KB
-r--r--r--
syscall_linux_mips64x.go
5.83
KB
-r--r--r--
syscall_linux_mipsx.go
5.81
KB
-r--r--r--
syscall_linux_ppc.go
6.85
KB
-r--r--r--
syscall_linux_ppc64x.go
4.98
KB
-r--r--r--
syscall_linux_riscv64.go
6.13
KB
-r--r--r--
syscall_linux_s390x.go
9.29
KB
-r--r--r--
syscall_linux_sparc64.go
4.37
KB
-r--r--r--
syscall_linux_test.go
30.8
KB
-r--r--r--
syscall_netbsd.go
12.35
KB
-r--r--r--
syscall_netbsd_386.go
819
B
-r--r--r--
syscall_netbsd_amd64.go
814
B
-r--r--r--
syscall_netbsd_arm.go
819
B
-r--r--r--
syscall_netbsd_arm64.go
814
B
-r--r--r--
syscall_netbsd_test.go
1.81
KB
-r--r--r--
syscall_openbsd.go
11.04
KB
-r--r--r--
syscall_openbsd_386.go
1000
B
-r--r--r--
syscall_openbsd_amd64.go
990
B
-r--r--r--
syscall_openbsd_arm.go
1000
B
-r--r--r--
syscall_openbsd_arm64.go
990
B
-r--r--r--
syscall_openbsd_libc.go
1.1
KB
-r--r--r--
syscall_openbsd_mips64.go
955
B
-r--r--r--
syscall_openbsd_ppc64.go
990
B
-r--r--r--
syscall_openbsd_riscv64.go
994
B
-r--r--r--
syscall_openbsd_test.go
1005
B
-r--r--r--
syscall_solaris.go
31.11
KB
-r--r--r--
syscall_solaris_amd64.go
593
B
-r--r--r--
syscall_solaris_test.go
10.35
KB
-r--r--r--
syscall_test.go
1.26
KB
-r--r--r--
syscall_unix.go
16.45
KB
-r--r--r--
syscall_unix_gc.go
640
B
-r--r--r--
syscall_unix_gc_ppc64x.go
786
B
-r--r--r--
syscall_unix_test.go
26.9
KB
-r--r--r--
syscall_zos_s390x.go
52.88
KB
-r--r--r--
syscall_zos_test.go
19.66
KB
-r--r--r--
sysctl_netbsd_test.go
327
B
-r--r--r--
sysvshm_linux.go
521
B
-r--r--r--
sysvshm_unix.go
1.42
KB
-r--r--r--
sysvshm_unix_other.go
398
B
-r--r--r--
sysvshm_unix_test.go
1.53
KB
-r--r--r--
timestruct.go
2.2
KB
-r--r--r--
timestruct_test.go
1.71
KB
-r--r--r--
types_aix.go
4.25
KB
-r--r--r--
types_darwin.go
7.58
KB
-r--r--r--
types_dragonfly.go
5.37
KB
-r--r--r--
types_freebsd.go
7.75
KB
-r--r--r--
types_netbsd.go
5.99
KB
-r--r--r--
types_openbsd.go
5.48
KB
-r--r--r--
types_solaris.go
7.13
KB
-r--r--r--
unveil_openbsd.go
1.19
KB
-r--r--r--
xattr_bsd.go
5.66
KB
-r--r--r--
xattr_test.go
4.58
KB
-r--r--r--
zerrors_aix_ppc.go
52.42
KB
-r--r--r--
zerrors_aix_ppc64.go
52.67
KB
-r--r--r--
zerrors_darwin_amd64.go
87.45
KB
-r--r--r--
zerrors_darwin_arm64.go
87.45
KB
-r--r--r--
zerrors_dragonfly_amd64.go
70.7
KB
-r--r--r--
zerrors_freebsd_386.go
79.55
KB
-r--r--r--
zerrors_freebsd_amd64.go
79.44
KB
-r--r--r--
zerrors_freebsd_arm.go
79.19
KB
-r--r--r--
zerrors_freebsd_arm64.go
79.22
KB
-r--r--r--
zerrors_freebsd_riscv64.go
83.75
KB
-r--r--r--
zerrors_linux.go
182.73
KB
-r--r--r--
zerrors_linux_386.go
33.98
KB
-r--r--r--
zerrors_linux_amd64.go
34
KB
-r--r--r--
zerrors_linux_arm.go
34.22
KB
-r--r--r--
zerrors_linux_arm64.go
34.05
KB
-r--r--r--
zerrors_linux_loong64.go
33.73
KB
-r--r--r--
zerrors_linux_mips.go
34.54
KB
-r--r--r--
zerrors_linux_mips64.go
34.54
KB
-r--r--r--
zerrors_linux_mips64le.go
34.55
KB
-r--r--r--
zerrors_linux_mipsle.go
34.54
KB
-r--r--r--
zerrors_linux_ppc.go
36.62
KB
-r--r--r--
zerrors_linux_ppc64.go
36.79
KB
-r--r--r--
zerrors_linux_ppc64le.go
36.8
KB
-r--r--r--
zerrors_linux_riscv64.go
33.59
KB
-r--r--r--
zerrors_linux_s390x.go
36.53
KB
-r--r--r--
zerrors_linux_sparc64.go
38.61
KB
-r--r--r--
zerrors_netbsd_386.go
72.76
KB
-r--r--r--
zerrors_netbsd_amd64.go
72.35
KB
-r--r--r--
zerrors_netbsd_arm.go
71.89
KB
-r--r--r--
zerrors_netbsd_arm64.go
72.35
KB
-r--r--r--
zerrors_openbsd_386.go
78.55
KB
-r--r--r--
zerrors_openbsd_amd64.go
78.55
KB
-r--r--r--
zerrors_openbsd_arm.go
78.54
KB
-r--r--r--
zerrors_openbsd_arm64.go
78.55
KB
-r--r--r--
zerrors_openbsd_mips64.go
78.55
KB
-r--r--r--
zerrors_openbsd_ppc64.go
78.51
KB
-r--r--r--
zerrors_openbsd_riscv64.go
78.47
KB
-r--r--r--
zerrors_solaris_amd64.go
59
KB
-r--r--r--
zerrors_zos_s390x.go
34.47
KB
-r--r--r--
zptrace_armnn_linux.go
1.17
KB
-r--r--r--
zptrace_linux_arm64.go
721
B
-r--r--r--
zptrace_mipsnn_linux.go
1.36
KB
-r--r--r--
zptrace_mipsnnle_linux.go
1.41
KB
-r--r--r--
zptrace_x86_linux.go
1.81
KB
-r--r--r--
zsyscall_aix_ppc.go
35.68
KB
-r--r--r--
zsyscall_aix_ppc64.go
30.04
KB
-r--r--r--
zsyscall_aix_ppc64_gc.go
42.43
KB
-r--r--r--
zsyscall_aix_ppc64_gccgo.go
30.85
KB
-r--r--r--
zsyscall_darwin_amd64.go
66.74
KB
-r--r--r--
zsyscall_darwin_amd64.s
29.28
KB
-r--r--r--
zsyscall_darwin_arm64.go
66.69
KB
-r--r--r--
zsyscall_darwin_arm64.s
29.21
KB
-r--r--r--
zsyscall_dragonfly_amd64.go
38.79
KB
-r--r--r--
zsyscall_freebsd_386.go
45.09
KB
-r--r--r--
zsyscall_freebsd_amd64.go
44.9
KB
-r--r--r--
zsyscall_freebsd_arm.go
45.13
KB
-r--r--r--
zsyscall_freebsd_arm64.go
44.9
KB
-r--r--r--
zsyscall_freebsd_riscv64.go
44.91
KB
-r--r--r--
zsyscall_illumos_amd64.go
2.63
KB
-r--r--r--
zsyscall_linux.go
54.29
KB
-r--r--r--
zsyscall_linux_386.go
12.11
KB
-r--r--r--
zsyscall_linux_amd64.go
16.5
KB
-r--r--r--
zsyscall_linux_arm.go
15.61
KB
-r--r--r--
zsyscall_linux_arm64.go
14.22
KB
-r--r--r--
zsyscall_linux_loong64.go
12.61
KB
-r--r--r--
zsyscall_linux_mips.go
16.76
KB
-r--r--r--
zsyscall_linux_mips64.go
16.27
KB
-r--r--r--
zsyscall_linux_mips64le.go
16.01
KB
-r--r--r--
zsyscall_linux_mipsle.go
16.76
KB
-r--r--r--
zsyscall_linux_ppc.go
16.83
KB
-r--r--r--
zsyscall_linux_ppc64.go
17.79
KB
-r--r--r--
zsyscall_linux_ppc64le.go
17.79
KB
-r--r--r--
zsyscall_linux_riscv64.go
14.2
KB
-r--r--r--
zsyscall_linux_s390x.go
12.11
KB
-r--r--r--
zsyscall_linux_sparc64.go
16.43
KB
-r--r--r--
zsyscall_netbsd_386.go
44.13
KB
-r--r--r--
zsyscall_netbsd_amd64.go
43.94
KB
-r--r--r--
zsyscall_netbsd_arm.go
44.13
KB
-r--r--r--
zsyscall_netbsd_arm64.go
43.94
KB
-r--r--r--
zsyscall_openbsd_386.go
57.66
KB
-r--r--r--
zsyscall_openbsd_386.s
26.7
KB
-r--r--r--
zsyscall_openbsd_amd64.go
57.52
KB
-r--r--r--
zsyscall_openbsd_amd64.s
26.7
KB
-r--r--r--
zsyscall_openbsd_arm.go
57.69
KB
-r--r--r--
zsyscall_openbsd_arm.s
26.7
KB
-r--r--r--
zsyscall_openbsd_arm64.go
57.52
KB
-r--r--r--
zsyscall_openbsd_arm64.s
26.7
KB
-r--r--r--
zsyscall_openbsd_mips64.go
57.52
KB
-r--r--r--
zsyscall_openbsd_mips64.s
26.7
KB
-r--r--r--
zsyscall_openbsd_ppc64.go
57.52
KB
-r--r--r--
zsyscall_openbsd_ppc64.s
27.51
KB
-r--r--r--
zsyscall_openbsd_riscv64.go
57.53
KB
-r--r--r--
zsyscall_openbsd_riscv64.s
26.7
KB
-r--r--r--
zsyscall_solaris_amd64.go
59.74
KB
-r--r--r--
zsyscall_zos_s390x.go
29.82
KB
-r--r--r--
zsysctl_openbsd_386.go
11.93
KB
-r--r--r--
zsysctl_openbsd_amd64.go
11.93
KB
-r--r--r--
zsysctl_openbsd_arm.go
11.93
KB
-r--r--r--
zsysctl_openbsd_arm64.go
11.93
KB
-r--r--r--
zsysctl_openbsd_mips64.go
11.93
KB
-r--r--r--
zsysctl_openbsd_ppc64.go
11.93
KB
-r--r--r--
zsysctl_openbsd_riscv64.go
11.97
KB
-r--r--r--
zsysnum_darwin_amd64.go
17.84
KB
-r--r--r--
zsysnum_darwin_arm64.go
17.76
KB
-r--r--r--
zsysnum_dragonfly_amd64.go
27.61
KB
-r--r--r--
zsysnum_freebsd_386.go
36.09
KB
-r--r--r--
zsysnum_freebsd_amd64.go
36.1
KB
-r--r--r--
zsysnum_freebsd_arm.go
36.09
KB
-r--r--r--
zsysnum_freebsd_arm64.go
36.1
KB
-r--r--r--
zsysnum_freebsd_riscv64.go
36.1
KB
-r--r--r--
zsysnum_linux_386.go
17.38
KB
-r--r--r--
zsysnum_linux_amd64.go
12.59
KB
-r--r--r--
zsysnum_linux_arm.go
15.99
KB
-r--r--r--
zsysnum_linux_arm64.go
10.69
KB
-r--r--r--
zsysnum_linux_loong64.go
10.48
KB
-r--r--r--
zsysnum_linux_mips.go
17.27
KB
-r--r--r--
zsysnum_linux_mips64.go
12.74
KB
-r--r--r--
zsysnum_linux_mips64le.go
12.74
KB
-r--r--r--
zsysnum_linux_mipsle.go
17.28
KB
-r--r--r--
zsysnum_linux_ppc.go
17.02
KB
-r--r--r--
zsysnum_linux_ppc64.go
13.95
KB
-r--r--r--
zsysnum_linux_ppc64le.go
13.96
KB
-r--r--r--
zsysnum_linux_riscv64.go
10.71
KB
-r--r--r--
zsysnum_linux_s390x.go
12.84
KB
-r--r--r--
zsysnum_linux_sparc64.go
13.26
KB
-r--r--r--
zsysnum_netbsd_386.go
25.72
KB
-r--r--r--
zsysnum_netbsd_amd64.go
25.73
KB
-r--r--r--
zsysnum_netbsd_arm.go
25.72
KB
-r--r--r--
zsysnum_netbsd_arm64.go
25.71
KB
-r--r--r--
zsysnum_openbsd_386.go
17.91
KB
-r--r--r--
zsysnum_openbsd_amd64.go
17.91
KB
-r--r--r--
zsysnum_openbsd_arm.go
17.91
KB
-r--r--r--
zsysnum_openbsd_arm64.go
17.82
KB
-r--r--r--
zsysnum_openbsd_mips64.go
18.05
KB
-r--r--r--
zsysnum_openbsd_ppc64.go
17.76
KB
-r--r--r--
zsysnum_openbsd_riscv64.go
17.83
KB
-r--r--r--
zsysnum_zos_s390x.go
116.99
KB
-r--r--r--
ztypes_aix_ppc.go
4.91
KB
-r--r--r--
ztypes_aix_ppc64.go
4.98
KB
-r--r--r--
ztypes_darwin_amd64.go
12.4
KB
-r--r--r--
ztypes_darwin_arm64.go
12.4
KB
-r--r--r--
ztypes_dragonfly_amd64.go
6.91
KB
-r--r--r--
ztypes_freebsd_386.go
9.63
KB
-r--r--r--
ztypes_freebsd_amd64.go
9.68
KB
-r--r--r--
ztypes_freebsd_arm.go
9.5
KB
-r--r--r--
ztypes_freebsd_arm64.go
9.39
KB
-r--r--r--
ztypes_freebsd_riscv64.go
9.46
KB
-r--r--r--
ztypes_linux.go
246.65
KB
-r--r--r--
ztypes_linux_386.go
12.37
KB
-r--r--r--
ztypes_linux_amd64.go
12.56
KB
-r--r--r--
ztypes_linux_arm.go
12.33
KB
-r--r--r--
ztypes_linux_arm64.go
12.21
KB
-r--r--r--
ztypes_linux_loong64.go
12.23
KB
-r--r--r--
ztypes_linux_mips.go
12.39
KB
-r--r--r--
ztypes_linux_mips64.go
12.26
KB
-r--r--r--
ztypes_linux_mips64le.go
12.27
KB
-r--r--r--
ztypes_linux_mipsle.go
12.4
KB
-r--r--r--
ztypes_linux_ppc.go
12.57
KB
-r--r--r--
ztypes_linux_ppc64.go
12.4
KB
-r--r--r--
ztypes_linux_ppc64le.go
12.41
KB
-r--r--r--
ztypes_linux_riscv64.go
13.44
KB
-r--r--r--
ztypes_linux_s390x.go
12.7
KB
-r--r--r--
ztypes_linux_sparc64.go
12.26
KB
-r--r--r--
ztypes_netbsd_386.go
9.46
KB
-r--r--r--
ztypes_netbsd_amd64.go
9.65
KB
-r--r--r--
ztypes_netbsd_arm.go
9.59
KB
-r--r--r--
ztypes_netbsd_arm64.go
9.65
KB
-r--r--r--
ztypes_openbsd_386.go
9.24
KB
-r--r--r--
ztypes_openbsd_amd64.go
9.25
KB
-r--r--r--
ztypes_openbsd_arm.go
9.38
KB
-r--r--r--
ztypes_openbsd_arm64.go
9.26
KB
-r--r--r--
ztypes_openbsd_mips64.go
9.26
KB
-r--r--r--
ztypes_openbsd_ppc64.go
9.28
KB
-r--r--r--
ztypes_openbsd_riscv64.go
9.29
KB
-r--r--r--
ztypes_solaris_amd64.go
7.53
KB
-r--r--r--
ztypes_zos_s390x.go
6.66
KB
-r--r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : syscall_unix_test.go
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris package unix_test import ( "bytes" "flag" "fmt" "io" "net" "os" "os/exec" "path/filepath" "reflect" "runtime" "strconv" "sync" "syscall" "testing" "time" "golang.org/x/sys/unix" ) // Tests that below functions, structures and constants are consistent // on all Unix-like systems. func _() { // program scheduling priority functions and constants var ( _ func(int, int, int) error = unix.Setpriority _ func(int, int) (int, error) = unix.Getpriority ) const ( _ int = unix.PRIO_USER _ int = unix.PRIO_PROCESS _ int = unix.PRIO_PGRP ) // termios constants const ( _ int = unix.TCIFLUSH _ int = unix.TCIOFLUSH _ int = unix.TCOFLUSH ) // fcntl file locking structure and constants var ( _ = unix.Flock_t{ Type: int16(0), Whence: int16(0), Start: int64(0), Len: int64(0), Pid: int32(0), } ) const ( _ = unix.F_GETLK _ = unix.F_SETLK _ = unix.F_SETLKW ) } func TestErrnoSignalName(t *testing.T) { testErrors := []struct { num syscall.Errno name string }{ {syscall.EPERM, "EPERM"}, {syscall.EINVAL, "EINVAL"}, {syscall.ENOENT, "ENOENT"}, } for _, te := range testErrors { t.Run(fmt.Sprintf("%d/%s", te.num, te.name), func(t *testing.T) { e := unix.ErrnoName(te.num) if e != te.name { t.Errorf("ErrnoName(%d) returned %s, want %s", te.num, e, te.name) } }) } testSignals := []struct { num syscall.Signal name string }{ {syscall.SIGHUP, "SIGHUP"}, {syscall.SIGPIPE, "SIGPIPE"}, {syscall.SIGSEGV, "SIGSEGV"}, } for _, ts := range testSignals { t.Run(fmt.Sprintf("%d/%s", ts.num, ts.name), func(t *testing.T) { s := unix.SignalName(ts.num) if s != ts.name { t.Errorf("SignalName(%d) returned %s, want %s", ts.num, s, ts.name) } }) } } func TestSignalNum(t *testing.T) { testSignals := []struct { name string want syscall.Signal }{ {"SIGHUP", syscall.SIGHUP}, {"SIGPIPE", syscall.SIGPIPE}, {"SIGSEGV", syscall.SIGSEGV}, {"NONEXISTS", 0}, } for _, ts := range testSignals { t.Run(fmt.Sprintf("%s/%d", ts.name, ts.want), func(t *testing.T) { got := unix.SignalNum(ts.name) if got != ts.want { t.Errorf("SignalNum(%s) returned %d, want %d", ts.name, got, ts.want) } }) } } func TestFcntlInt(t *testing.T) { t.Parallel() file, err := os.Create(filepath.Join(t.TempDir(), t.Name())) if err != nil { t.Fatal(err) } defer file.Close() f := file.Fd() flags, err := unix.FcntlInt(f, unix.F_GETFD, 0) if err != nil { t.Fatal(err) } if flags&unix.FD_CLOEXEC == 0 { t.Errorf("flags %#x do not include FD_CLOEXEC", flags) } } // TestFcntlFlock tests whether the file locking structure matches // the calling convention of each kernel. func TestFcntlFlock(t *testing.T) { name := filepath.Join(t.TempDir(), "TestFcntlFlock") fd, err := unix.Open(name, unix.O_CREAT|unix.O_RDWR|unix.O_CLOEXEC, 0) if err != nil { t.Fatalf("Open failed: %v", err) } defer unix.Close(fd) flock := unix.Flock_t{ Type: unix.F_RDLCK, Start: 0, Len: 0, Whence: 1, } if err := unix.FcntlFlock(uintptr(fd), unix.F_GETLK, &flock); err != nil { t.Fatalf("FcntlFlock failed: %v", err) } } // TestPassFD tests passing a file descriptor over a Unix socket. // // This test involved both a parent and child process. The parent // process is invoked as a normal test, with "go test", which then // runs the child process by running the current test binary with args // "-test.run=^TestPassFD$" and an environment variable used to signal // that the test should become the child process instead. func TestPassFD(t *testing.T) { if runtime.GOOS == "ios" { t.Skip("cannot exec subprocess on iOS, skipping test") } if os.Getenv("GO_WANT_HELPER_PROCESS") == "1" { passFDChild() return } if runtime.GOOS == "aix" { // Unix network isn't properly working on AIX // 7.2 with Technical Level < 2 out, err := exec.Command("oslevel", "-s").Output() if err != nil { t.Skipf("skipping on AIX because oslevel -s failed: %v", err) } if len(out) < len("7200-XX-ZZ-YYMM") { // AIX 7.2, Tech Level XX, Service Pack ZZ, date YYMM t.Skip("skipping on AIX because oslevel -s hasn't the right length") } aixVer := string(out[:4]) tl, err := strconv.Atoi(string(out[5:7])) if err != nil { t.Skipf("skipping on AIX because oslevel -s output cannot be parsed: %v", err) } if aixVer < "7200" || (aixVer == "7200" && tl < 2) { t.Skip("skipped on AIX versions previous to 7.2 TL 2") } } fds, err := unix.Socketpair(unix.AF_LOCAL, unix.SOCK_STREAM, 0) if err != nil { t.Fatalf("Socketpair: %v", err) } writeFile := os.NewFile(uintptr(fds[0]), "child-writes") readFile := os.NewFile(uintptr(fds[1]), "parent-reads") defer writeFile.Close() defer readFile.Close() cmd := exec.Command(os.Args[0], "-test.run=^TestPassFD$", "--", t.TempDir()) cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"} if lp := os.Getenv("LD_LIBRARY_PATH"); lp != "" { cmd.Env = append(cmd.Env, "LD_LIBRARY_PATH="+lp) } cmd.ExtraFiles = []*os.File{writeFile} out, err := cmd.CombinedOutput() if len(out) > 0 || err != nil { t.Fatalf("child process: %q, %v", out, err) } c, err := net.FileConn(readFile) if err != nil { t.Fatalf("FileConn: %v", err) } defer c.Close() uc, ok := c.(*net.UnixConn) if !ok { t.Fatalf("unexpected FileConn type; expected UnixConn, got %T", c) } buf := make([]byte, 32) // expect 1 byte oob := make([]byte, 32) // expect 24 bytes closeUnix := time.AfterFunc(5*time.Second, func() { t.Logf("timeout reading from unix socket") uc.Close() }) _, oobn, _, _, err := uc.ReadMsgUnix(buf, oob) if err != nil { t.Fatalf("ReadMsgUnix: %v", err) } closeUnix.Stop() scms, err := unix.ParseSocketControlMessage(oob[:oobn]) if err != nil { t.Fatalf("ParseSocketControlMessage: %v", err) } if len(scms) != 1 { t.Fatalf("expected 1 SocketControlMessage; got scms = %#v", scms) } scm := scms[0] gotFds, err := unix.ParseUnixRights(&scm) if err != nil { t.Fatalf("unix.ParseUnixRights: %v", err) } if len(gotFds) != 1 { t.Fatalf("wanted 1 fd; got %#v", gotFds) } f := os.NewFile(uintptr(gotFds[0]), "fd-from-child") defer f.Close() got, err := io.ReadAll(f) want := "Hello from child process!\n" if string(got) != want { t.Errorf("child process ReadAll: %q, %v; want %q", got, err, want) } } // passFDChild is the child process used by TestPassFD. func passFDChild() { defer os.Exit(0) // Look for our fd. It should be fd 3, but we work around an fd leak // bug here (http://golang.org/issue/2603) to let it be elsewhere. var uc *net.UnixConn for fd := uintptr(3); fd <= 10; fd++ { f := os.NewFile(fd, "unix-conn") var ok bool netc, _ := net.FileConn(f) uc, ok = netc.(*net.UnixConn) if ok { break } } if uc == nil { fmt.Println("failed to find unix fd") return } // Make a file f to send to our parent process on uc. // We make it in tempDir, which our parent will clean up. flag.Parse() tempDir := flag.Arg(0) f, err := os.Create(filepath.Join(tempDir, "file")) if err != nil { fmt.Println(err) return } f.Write([]byte("Hello from child process!\n")) f.Seek(0, 0) rights := unix.UnixRights(int(f.Fd())) dummyByte := []byte("x") n, oobn, err := uc.WriteMsgUnix(dummyByte, rights, nil) if err != nil { fmt.Printf("WriteMsgUnix: %v", err) return } if n != 1 || oobn != len(rights) { fmt.Printf("WriteMsgUnix = %d, %d; want 1, %d", n, oobn, len(rights)) return } } // TestUnixRightsRoundtrip tests that UnixRights, ParseSocketControlMessage, ParseOneSocketControlMessage, // and ParseUnixRights are able to successfully round-trip lists of file descriptors. func TestUnixRightsRoundtrip(t *testing.T) { testCases := [...][][]int{ {{42}}, {{1, 2}}, {{3, 4, 5}}, {{}}, {{1, 2}, {3, 4, 5}, {}, {7}}, } for _, testCase := range testCases { b := []byte{} var n int for _, fds := range testCase { // Last assignment to n wins n = len(b) + unix.CmsgLen(4*len(fds)) b = append(b, unix.UnixRights(fds...)...) } // Truncate b b = b[:n] scms, err := unix.ParseSocketControlMessage(b) if err != nil { t.Fatalf("ParseSocketControlMessage: %v", err) } if len(scms) != len(testCase) { t.Fatalf("expected %v SocketControlMessage; got scms = %#v", len(testCase), scms) } var c int for len(b) > 0 { hdr, data, remainder, err := unix.ParseOneSocketControlMessage(b) if err != nil { t.Fatalf("ParseOneSocketControlMessage: %v", err) } if scms[c].Header != hdr || !bytes.Equal(scms[c].Data, data) { t.Fatal("expected SocketControlMessage header and data to match") } b = remainder c++ } if c != len(scms) { t.Fatalf("expected %d SocketControlMessages; got %d", len(scms), c) } for i, scm := range scms { gotFds, err := unix.ParseUnixRights(&scm) if err != nil { t.Fatalf("ParseUnixRights: %v", err) } wantFds := testCase[i] if len(gotFds) != len(wantFds) { t.Fatalf("expected %v fds, got %#v", len(wantFds), gotFds) } for j, fd := range gotFds { if fd != wantFds[j] { t.Fatalf("expected fd %v, got %v", wantFds[j], fd) } } } } } func TestRlimit(t *testing.T) { var rlimit, zero unix.Rlimit err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlimit) if err != nil { t.Fatalf("Getrlimit: save failed: %v", err) } if zero == rlimit { t.Fatalf("Getrlimit: save failed: got zero value %#v", rlimit) } set := rlimit set.Cur = set.Max - 1 if (runtime.GOOS == "darwin" || runtime.GOOS == "ios") && set.Cur > 4096 { // rlim_min for RLIMIT_NOFILE should be equal to // or lower than kern.maxfilesperproc, which on // some machines are 4096. See #40564. set.Cur = 4096 } err = unix.Setrlimit(unix.RLIMIT_NOFILE, &set) if err != nil { t.Fatalf("Setrlimit: set failed: %#v %v", set, err) } var get unix.Rlimit err = unix.Getrlimit(unix.RLIMIT_NOFILE, &get) if err != nil { t.Fatalf("Getrlimit: get failed: %v", err) } set = rlimit set.Cur = set.Max - 1 if (runtime.GOOS == "darwin" || runtime.GOOS == "ios") && set.Cur > 4096 { set.Cur = 4096 } if set != get { // Seems like Darwin requires some privilege to // increase the soft limit of rlimit sandbox, though // Setrlimit never reports an error. switch runtime.GOOS { case "darwin", "ios": default: t.Fatalf("Rlimit: change failed: wanted %#v got %#v", set, get) } } err = unix.Setrlimit(unix.RLIMIT_NOFILE, &rlimit) if err != nil { t.Fatalf("Setrlimit: restore failed: %#v %v", rlimit, err) } // make sure RLIM_INFINITY can be assigned to Rlimit members _ = unix.Rlimit{ Cur: unix.RLIM_INFINITY, Max: unix.RLIM_INFINITY, } } func TestSeekFailure(t *testing.T) { _, err := unix.Seek(-1, 0, 0) if err == nil { t.Fatalf("Seek(-1, 0, 0) did not fail") } str := err.Error() // used to crash on Linux t.Logf("Seek: %v", str) if str == "" { t.Fatalf("Seek(-1, 0, 0) return error with empty message") } } func TestSetsockoptString(t *testing.T) { // should not panic on empty string, see issue #31277 err := unix.SetsockoptString(-1, 0, 0, "") if err == nil { t.Fatalf("SetsockoptString: did not fail") } } func TestDup(t *testing.T) { file, err := os.Create(filepath.Join(t.TempDir(), t.Name())) if err != nil { t.Fatal(err) } defer file.Close() f := int(file.Fd()) newFd, err := unix.Dup(f) if err != nil { t.Fatalf("Dup: %v", err) } // Create and reserve a file descriptor. // Dup2 automatically closes it before reusing it. nullFile, err := os.Open("/dev/null") if err != nil { t.Fatal(err) } dupFd := int(file.Fd()) err = unix.Dup2(newFd, dupFd) if err != nil { t.Fatalf("Dup2: %v", err) } // Keep the dummy file open long enough to not be closed in // its finalizer. runtime.KeepAlive(nullFile) b1 := []byte("Test123") b2 := make([]byte, 7) _, err = unix.Write(dupFd, b1) if err != nil { t.Fatalf("Write to dup2 fd failed: %v", err) } _, err = unix.Seek(f, 0, 0) if err != nil { t.Fatalf("Seek failed: %v", err) } _, err = unix.Read(f, b2) if err != nil { t.Fatalf("Read back failed: %v", err) } if string(b1) != string(b2) { t.Errorf("Dup: stdout write not in file, expected %v, got %v", string(b1), string(b2)) } } func TestPoll(t *testing.T) { if runtime.GOOS == "android" || runtime.GOOS == "ios" { t.Skip("mkfifo syscall is not available on android and iOS, skipping test") } chtmpdir(t) f := mktmpfifo(t) const timeout = 100 ok := make(chan bool, 1) go func() { select { case <-time.After(10 * timeout * time.Millisecond): t.Errorf("Poll: failed to timeout after %d milliseconds", 10*timeout) case <-ok: } }() for { fds := []unix.PollFd{{Fd: int32(f.Fd()), Events: unix.POLLIN}} n, err := unix.Poll(fds, timeout) ok <- true if err == unix.EINTR { t.Logf("Poll interrupted") continue } else if err != nil { t.Errorf("Poll: unexpected error: %v", err) return } if n != 0 { t.Errorf("Poll: wrong number of events: got %v, expected %v", n, 0) // Identify which event(s) caused Poll to return. // We can't trivially use a table here because Revents // isn't the same type on all systems. if fds[0].Revents&unix.POLLIN != 0 { t.Log("found POLLIN event") } if fds[0].Revents&unix.POLLPRI != 0 { t.Log("found POLLPRI event") } if fds[0].Revents&unix.POLLOUT != 0 { t.Log("found POLLOUT event") } if fds[0].Revents&unix.POLLERR != 0 { t.Log("found POLLERR event") } if fds[0].Revents&unix.POLLHUP != 0 { t.Log("found POLLHUP event") } if fds[0].Revents&unix.POLLNVAL != 0 { t.Log("found POLLNVAL event") } } break } } func TestSelect(t *testing.T) { for { n, err := unix.Select(0, nil, nil, nil, &unix.Timeval{Sec: 0, Usec: 0}) if err == unix.EINTR { t.Logf("Select interrupted") continue } else if err != nil { t.Fatalf("Select: %v", err) } if n != 0 { t.Fatalf("Select: got %v ready file descriptors, expected 0", n) } break } dur := 250 * time.Millisecond var took time.Duration for { // On some platforms (e.g. Linux), the passed-in timeval is // updated by select(2). Make sure to reset to the full duration // in case of an EINTR. tv := unix.NsecToTimeval(int64(dur)) start := time.Now() n, err := unix.Select(0, nil, nil, nil, &tv) took = time.Since(start) if err == unix.EINTR { t.Logf("Select interrupted after %v", took) continue } else if err != nil { t.Fatalf("Select: %v", err) } if n != 0 { t.Fatalf("Select: got %v ready file descriptors, expected 0", n) } break } // On some platforms (e.g. NetBSD) the actual timeout might be arbitrarily // less than requested. However, Linux in particular promises to only return // early if a file descriptor becomes ready (not applicable here), or the call // is interrupted by a signal handler (explicitly retried in the loop above), // or the timeout expires. if took < dur { if runtime.GOOS == "linux" { t.Errorf("Select: slept for %v, expected %v", took, dur) } else { t.Logf("Select: slept for %v, requested %v", took, dur) } } rr, ww, err := os.Pipe() if err != nil { t.Fatal(err) } defer rr.Close() defer ww.Close() if _, err := ww.Write([]byte("HELLO GOPHER")); err != nil { t.Fatal(err) } rFdSet := &unix.FdSet{} fd := int(rr.Fd()) rFdSet.Set(fd) for { n, err := unix.Select(fd+1, rFdSet, nil, nil, nil) if err == unix.EINTR { t.Log("Select interrupted") continue } else if err != nil { t.Fatalf("Select: %v", err) } if n != 1 { t.Fatalf("Select: got %v ready file descriptors, expected 1", n) } break } } func TestGetwd(t *testing.T) { fd, err := os.Open(".") if err != nil { t.Fatalf("Open .: %s", err) } defer fd.Close() // Directory list for test. Do not worry if any are symlinks or do not // exist on some common unix desktop environments. That will be checked. dirs := []string{"/", "/usr/bin", "/etc", "/var", "/opt"} switch runtime.GOOS { case "android": dirs = []string{"/", "/system/bin"} case "ios": dirs = []string{t.TempDir(), t.TempDir()} } oldwd := os.Getenv("PWD") for _, d := range dirs { // Check whether d exists, is a dir and that d's path does not contain a symlink fi, err := os.Stat(d) if err != nil || !fi.IsDir() { t.Logf("Test dir %s stat error (%v) or not a directory, skipping", d, err) continue } check, err := filepath.EvalSymlinks(d) if err != nil || check != d { t.Logf("Test dir %s (%s) is symlink or other error (%v), skipping", d, check, err) continue } err = os.Chdir(d) if err != nil { t.Fatalf("Chdir: %v", err) } pwd, err := unix.Getwd() if err != nil { t.Fatalf("Getwd in %s: %s", d, err) } os.Setenv("PWD", oldwd) err = fd.Chdir() if err != nil { // We changed the current directory and cannot go back. // Don't let the tests continue; they'll scribble // all over some other directory. fmt.Fprintf(os.Stderr, "fchdir back to dot failed: %s\n", err) os.Exit(1) } if pwd != d { t.Fatalf("Getwd returned %q want %q", pwd, d) } } } func compareStat_t(t *testing.T, otherStat string, st1, st2 *unix.Stat_t) { if st2.Dev != st1.Dev { t.Errorf("%s/Fstatat: got dev %v, expected %v", otherStat, st2.Dev, st1.Dev) } if st2.Ino != st1.Ino { t.Errorf("%s/Fstatat: got ino %v, expected %v", otherStat, st2.Ino, st1.Ino) } if st2.Mode != st1.Mode { t.Errorf("%s/Fstatat: got mode %v, expected %v", otherStat, st2.Mode, st1.Mode) } if st2.Uid != st1.Uid { t.Errorf("%s/Fstatat: got uid %v, expected %v", otherStat, st2.Uid, st1.Uid) } if st2.Gid != st1.Gid { t.Errorf("%s/Fstatat: got gid %v, expected %v", otherStat, st2.Gid, st1.Gid) } if st2.Size != st1.Size { t.Errorf("%s/Fstatat: got size %v, expected %v", otherStat, st2.Size, st1.Size) } } func TestFstatat(t *testing.T) { chtmpdir(t) touch(t, "file1") var st1 unix.Stat_t err := unix.Stat("file1", &st1) if err != nil { t.Fatalf("Stat: %v", err) } var st2 unix.Stat_t err = unix.Fstatat(unix.AT_FDCWD, "file1", &st2, 0) if err != nil { t.Fatalf("Fstatat: %v", err) } compareStat_t(t, "Stat", &st1, &st2) err = os.Symlink("file1", "symlink1") if err != nil { t.Fatal(err) } err = unix.Lstat("symlink1", &st1) if err != nil { t.Fatalf("Lstat: %v", err) } err = unix.Fstatat(unix.AT_FDCWD, "symlink1", &st2, unix.AT_SYMLINK_NOFOLLOW) if err != nil { t.Fatalf("Fstatat: %v", err) } compareStat_t(t, "Lstat", &st1, &st2) } func TestFchmodat(t *testing.T) { chtmpdir(t) touch(t, "file1") err := os.Symlink("file1", "symlink1") if err != nil { t.Fatal(err) } mode := os.FileMode(0444) err = unix.Fchmodat(unix.AT_FDCWD, "symlink1", uint32(mode), 0) if err != nil { t.Fatalf("Fchmodat: unexpected error: %v", err) } fi, err := os.Stat("file1") if err != nil { t.Fatal(err) } if fi.Mode() != mode { t.Errorf("Fchmodat: failed to change file mode: expected %v, got %v", mode, fi.Mode()) } mode = os.FileMode(0644) didChmodSymlink := true err = unix.Fchmodat(unix.AT_FDCWD, "symlink1", uint32(mode), unix.AT_SYMLINK_NOFOLLOW) if err != nil { if (runtime.GOOS == "android" || runtime.GOOS == "linux" || runtime.GOOS == "solaris" || runtime.GOOS == "illumos") && err == unix.EOPNOTSUPP { // Linux and Illumos don't support flags != 0 didChmodSymlink = false } else { t.Fatalf("Fchmodat: unexpected error: %v", err) } } if !didChmodSymlink { // Didn't change mode of the symlink. On Linux, the permissions // of a symbolic link are always 0777 according to symlink(7) mode = os.FileMode(0777) } var st unix.Stat_t err = unix.Lstat("symlink1", &st) if err != nil { t.Fatal(err) } got := os.FileMode(st.Mode & 0777) if got != mode { t.Errorf("Fchmodat: failed to change symlink mode: expected %v, got %v", mode, got) } } func TestMkdev(t *testing.T) { major := uint32(42) minor := uint32(7) dev := unix.Mkdev(major, minor) if unix.Major(dev) != major { t.Errorf("Major(%#x) == %d, want %d", dev, unix.Major(dev), major) } if unix.Minor(dev) != minor { t.Errorf("Minor(%#x) == %d, want %d", dev, unix.Minor(dev), minor) } } func TestPipe(t *testing.T) { const s = "hello" var pipes [2]int err := unix.Pipe(pipes[:]) if err != nil { t.Fatalf("pipe: %v", err) } r := pipes[0] w := pipes[1] go func() { n, err := unix.Write(w, []byte(s)) if err != nil { t.Errorf("bad write: %v", err) return } if n != len(s) { t.Errorf("bad write count: %d", n) return } err = unix.Close(w) if err != nil { t.Errorf("bad close: %v", err) return } }() var buf [10 + len(s)]byte n, err := unix.Read(r, buf[:]) if err != nil { t.Fatalf("bad read: %v", err) } if n != len(s) { t.Fatalf("bad read count: %d", n) } if string(buf[:n]) != s { t.Fatalf("bad contents: %s", string(buf[:n])) } err = unix.Close(r) if err != nil { t.Fatalf("bad close: %v", err) } } func TestRenameat(t *testing.T) { chtmpdir(t) from, to := "renamefrom", "renameto" touch(t, from) err := unix.Renameat(unix.AT_FDCWD, from, unix.AT_FDCWD, to) if err != nil { t.Fatalf("Renameat: unexpected error: %v", err) } _, err = os.Stat(to) if err != nil { t.Error(err) } _, err = os.Stat(from) if err == nil { t.Errorf("Renameat: stat of renamed file %q unexpectedly succeeded", from) } } func TestUtimesNanoAt(t *testing.T) { chtmpdir(t) symlink := "symlink1" os.Remove(symlink) err := os.Symlink("nonexisting", symlink) if err != nil { t.Fatal(err) } // Some filesystems only support microsecond resolution. Account for // that in Nsec. ts := []unix.Timespec{ {Sec: 1111, Nsec: 2000}, {Sec: 3333, Nsec: 4000}, } err = unix.UtimesNanoAt(unix.AT_FDCWD, symlink, ts, unix.AT_SYMLINK_NOFOLLOW) if err != nil { t.Fatalf("UtimesNanoAt: %v", err) } var st unix.Stat_t err = unix.Lstat(symlink, &st) if err != nil { t.Fatalf("Lstat: %v", err) } // Only check Mtim, Atim might not be supported by the underlying filesystem expected := ts[1] if st.Mtim.Nsec == 0 { // Some filesystems only support 1-second time stamp resolution // and will always set Nsec to 0. expected.Nsec = 0 } if st.Mtim != expected { t.Errorf("UtimesNanoAt: wrong mtime: got %v, expected %v", st.Mtim, expected) } } func TestSend(t *testing.T) { ec := make(chan error, 2) ts := []byte("HELLO GOPHER") fds, err := unix.Socketpair(unix.AF_LOCAL, unix.SOCK_STREAM, 0) if err != nil { t.Fatalf("Socketpair: %v", err) } defer unix.Close(fds[0]) defer unix.Close(fds[1]) go func() { data := make([]byte, len(ts)) _, _, err := unix.Recvfrom(fds[1], data, 0) if err != nil { ec <- err } if !bytes.Equal(ts, data) { ec <- fmt.Errorf("data sent != data received. Received %q", data) } ec <- nil }() err = unix.Send(fds[0], ts, 0) if err != nil { ec <- err } select { case err = <-ec: if err != nil { t.Fatalf("Send: %v", err) } case <-time.After(2 * time.Second): t.Fatal("Send: nothing received after 2 seconds") } } func TestSendmsgBuffers(t *testing.T) { fds, err := unix.Socketpair(unix.AF_LOCAL, unix.SOCK_STREAM, 0) if err != nil { t.Fatal(err) } defer unix.Close(fds[0]) defer unix.Close(fds[1]) var wg sync.WaitGroup wg.Add(1) go func() { defer wg.Done() bufs := [][]byte{ make([]byte, 5), nil, make([]byte, 5), } n, oobn, recvflags, _, err := unix.RecvmsgBuffers(fds[1], bufs, nil, 0) if err != nil { t.Error(err) return } if n != 10 { t.Errorf("got %d bytes, want 10", n) } if oobn != 0 { t.Errorf("got %d OOB bytes, want 0", oobn) } if recvflags != 0 { t.Errorf("got flags %#x, want %#x", recvflags, 0) } want := [][]byte{ []byte("01234"), nil, []byte("56789"), } if !reflect.DeepEqual(bufs, want) { t.Errorf("got data %q, want %q", bufs, want) } }() defer wg.Wait() bufs := [][]byte{ []byte("012"), []byte("34"), nil, []byte("5678"), []byte("9"), } n, err := unix.SendmsgBuffers(fds[0], bufs, nil, nil, 0) if err != nil { t.Fatal(err) } if n != 10 { t.Errorf("sent %d bytes, want 10", n) } } // Issue 56384. func TestRecvmsgControl(t *testing.T) { switch runtime.GOOS { case "solaris", "illumos": // Test fails on Solaris, saying // "got 0 control messages, want 1". // Not sure why; Solaris recvmsg man page says // "For processes on the same host, recvmsg() can be // used to receive a file descriptor from another // process, but it cannot receive ancillary data." t.Skipf("skipping on %s", runtime.GOOS) } fds, err := unix.Socketpair(unix.AF_UNIX, unix.SOCK_STREAM, 0) if err != nil { t.Fatal(err) } defer unix.Close(fds[0]) defer unix.Close(fds[1]) const payload = "hello" // Start a goroutine that sends a control message followed by // a payload on fds[1]. go func() { f, err := os.Create(filepath.Join(t.TempDir(), "file")) if err != nil { t.Error(err) return } defer f.Close() rc, err := f.SyscallConn() if err != nil { t.Error(err) return } var rights []byte err = rc.Control(func(fd uintptr) { rights = unix.UnixRights(int(fd)) }) if err != nil { t.Error(err) return } _, err = unix.SendmsgN(fds[1], nil, rights, nil, 0) if err != nil { t.Error(err) } if _, err := unix.Write(fds[1], []byte(payload)); err != nil { t.Error(err) } }() // Read the control message sent by the goroutine. The // goroutine writes to fds[1], we read from fds[0]. cbuf := make([]byte, unix.CmsgSpace(4)) _, cn, _, _, err := unix.Recvmsg(fds[0], nil, cbuf, 0) if err != nil { t.Fatal(err) } cbuf = cbuf[:cn] // Read the payload sent by the goroutine. buf := make([]byte, len(payload)) n, err := unix.Read(fds[0], buf) if err != nil { t.Fatal(err) } buf = buf[:n] if payload != string(buf) { t.Errorf("read payload %q, want %q", buf, payload) } // Check the control message. cmsgs, err := unix.ParseSocketControlMessage(cbuf) if err != nil { t.Fatal(err) } if len(cmsgs) != 1 { t.Fatalf("got %d control messages, want 1", len(cmsgs)) } cfds, err := unix.ParseUnixRights(&cmsgs[0]) if err != nil { t.Fatal(err) } if len(cfds) != 1 { t.Fatalf("got %d fds, want 1", len(cfds)) } defer unix.Close(cfds[0]) } // mktmpfifo creates a temporary FIFO and sets up a cleanup function. func mktmpfifo(t *testing.T) *os.File { t.Helper() err := unix.Mkfifo("fifo", 0666) if err != nil { t.Fatalf("mktmpfifo: failed to create FIFO: %v", err) } f, err := os.OpenFile("fifo", os.O_RDWR, 0666) if err != nil { os.Remove("fifo") t.Fatal(err) } t.Cleanup(func() { f.Close() os.Remove("fifo") }) return f } // utilities taken from os/os_test.go func touch(t *testing.T, name string) { t.Helper() f, err := os.Create(name) if err != nil { t.Fatal(err) } if err := f.Close(); err != nil { t.Fatal(err) } } // chtmpdir changes the working directory to a new temporary directory and // sets up a cleanup function. Used when PWD is read-only. func chtmpdir(t *testing.T) { t.Helper() oldwd, err := os.Getwd() if err != nil { t.Fatal(err) } if err := os.Chdir(t.TempDir()); err != nil { t.Fatal(err) } t.Cleanup(func() { if err := os.Chdir(oldwd); err != nil { t.Fatal(err) } }) }
Close