| 1 |
// Copyright 2009 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
//go:build ignore |
| 6 |
|
| 7 |
/* |
| 8 |
Input to cgo -godefs. See also mkerrors.sh and mkall.sh |
| 9 |
*/ |
| 10 |
|
| 11 |
// +godefs map struct_in_addr [4]byte /* in_addr */ |
| 12 |
// +godefs map struct_in6_addr [16]byte /* in6_addr */ |
| 13 |
|
| 14 |
package syscall |
| 15 |
|
| 16 |
/* |
| 17 |
#define _LARGEFILE_SOURCE |
| 18 |
#define _LARGEFILE64_SOURCE |
| 19 |
#define _FILE_OFFSET_BITS 64 |
| 20 |
#define _GNU_SOURCE |
| 21 |
|
| 22 |
#include <dirent.h> |
| 23 |
#include <fcntl.h> |
| 24 |
#include <netinet/in.h> |
| 25 |
#include <netinet/tcp.h> |
| 26 |
#include <netpacket/packet.h> |
| 27 |
#include <signal.h> |
| 28 |
#include <stdio.h> |
| 29 |
#include <sys/epoll.h> |
| 30 |
#include <sys/inotify.h> |
| 31 |
#include <sys/mman.h> |
| 32 |
#include <sys/mount.h> |
| 33 |
#include <sys/param.h> |
| 34 |
#include <sys/ptrace.h> |
| 35 |
#include <sys/resource.h> |
| 36 |
#include <sys/select.h> |
| 37 |
#include <sys/signal.h> |
| 38 |
#include <sys/stat.h> |
| 39 |
#include <sys/statfs.h> |
| 40 |
#include <sys/sysinfo.h> |
| 41 |
#include <sys/time.h> |
| 42 |
#include <sys/times.h> |
| 43 |
#include <sys/timex.h> |
| 44 |
#include <sys/types.h> |
| 45 |
#include <sys/un.h> |
| 46 |
#include <sys/user.h> |
| 47 |
#include <sys/utsname.h> |
| 48 |
#include <sys/wait.h> |
| 49 |
#include <linux/filter.h> |
| 50 |
#include <linux/netlink.h> |
| 51 |
#include <linux/rtnetlink.h> |
| 52 |
#include <linux/icmpv6.h> |
| 53 |
#include <poll.h> |
| 54 |
#include <termios.h> |
| 55 |
#include <time.h> |
| 56 |
#include <unistd.h> |
| 57 |
#include <utime.h> |
| 58 |
|
| 59 |
enum { |
| 60 |
sizeofPtr = sizeof(void*), |
| 61 |
}; |
| 62 |
|
| 63 |
union sockaddr_all { |
| 64 |
struct sockaddr s1; // this one gets used for fields |
| 65 |
struct sockaddr_in s2; // these pad it out |
| 66 |
struct sockaddr_in6 s3; |
| 67 |
struct sockaddr_un s4; |
| 68 |
struct sockaddr_ll s5; |
| 69 |
struct sockaddr_nl s6; |
| 70 |
}; |
| 71 |
|
| 72 |
struct sockaddr_any { |
| 73 |
struct sockaddr addr; |
| 74 |
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; |
| 75 |
}; |
| 76 |
|
| 77 |
// copied from /usr/include/linux/un.h |
| 78 |
struct my_sockaddr_un { |
| 79 |
sa_family_t sun_family; |
| 80 |
#if defined(__ARM_EABI__) || defined(__powerpc64__) || defined(__riscv__) || defined(__s390x__) |
| 81 |
// on ARM, PPC, RISC-V, and s390x char is by default unsigned |
| 82 |
signed char sun_path[108]; |
| 83 |
#else |
| 84 |
char sun_path[108]; |
| 85 |
#endif |
| 86 |
}; |
| 87 |
|
| 88 |
#ifdef __ARM_EABI__ |
| 89 |
typedef struct user_regs PtraceRegs; |
| 90 |
#elif defined(__aarch64__) |
| 91 |
typedef struct user_pt_regs PtraceRegs; |
| 92 |
#elif defined(__powerpc64__) |
| 93 |
typedef struct pt_regs PtraceRegs; |
| 94 |
#elif defined(__mips__) |
| 95 |
typedef struct user PtraceRegs; |
| 96 |
#elif defined(__s390x__) |
| 97 |
typedef struct _user_regs_struct PtraceRegs; |
| 98 |
#else |
| 99 |
typedef struct user_regs_struct PtraceRegs; |
| 100 |
#endif |
| 101 |
|
| 102 |
#if defined(__s390x__) |
| 103 |
typedef struct _user_psw_struct ptracePsw; |
| 104 |
typedef struct _user_fpregs_struct ptraceFpregs; |
| 105 |
typedef struct _user_per_struct ptracePer; |
| 106 |
#else |
| 107 |
typedef struct {} ptracePsw; |
| 108 |
typedef struct {} ptraceFpregs; |
| 109 |
typedef struct {} ptracePer; |
| 110 |
#endif |
| 111 |
|
| 112 |
// The real epoll_event is a union, and godefs doesn't handle it well. |
| 113 |
struct my_epoll_event { |
| 114 |
uint32_t events; |
| 115 |
#if defined(__ARM_EABI__) || defined(__aarch64__) || (defined(__mips__) && _MIPS_SIM == _ABIO32) |
| 116 |
// padding is not specified in linux/eventpoll.h but added to conform to the |
| 117 |
// alignment requirements of EABI |
| 118 |
int32_t padFd; |
| 119 |
#endif |
| 120 |
#if defined(__powerpc64__) || defined(__s390x__) || (defined(__riscv_xlen) && __riscv_xlen == 64) \ |
| 121 |
|| (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI64) || defined(__loongarch64) |
| 122 |
int32_t _padFd; |
| 123 |
#endif |
| 124 |
int32_t fd; |
| 125 |
int32_t pad; |
| 126 |
}; |
| 127 |
|
| 128 |
// ustat is deprecated and glibc 2.28 removed ustat.h. Provide the type here for |
| 129 |
// backwards compatibility. Copied from /usr/include/bits/ustat.h |
| 130 |
struct ustat { |
| 131 |
__daddr_t f_tfree; |
| 132 |
__ino_t f_tinode; |
| 133 |
char f_fname[6]; |
| 134 |
char f_fpack[6]; |
| 135 |
}; |
| 136 |
|
| 137 |
*/ |
| 138 |
import "C" |
| 139 |
|
| 140 |
// Machine characteristics; for internal use. |
| 141 |
|
| 142 |
const ( |
| 143 |
sizeofPtr = C.sizeofPtr |
| 144 |
sizeofShort = C.sizeof_short |
| 145 |
sizeofInt = C.sizeof_int |
| 146 |
sizeofLong = C.sizeof_long |
| 147 |
sizeofLongLong = C.sizeof_longlong |
| 148 |
PathMax = C.PATH_MAX |
| 149 |
) |
| 150 |
|
| 151 |
// Basic types |
| 152 |
|
| 153 |
type ( |
| 154 |
_C_short C.short |
| 155 |
_C_int C.int |
| 156 |
_C_long C.long |
| 157 |
_C_long_long C.longlong |
| 158 |
) |
| 159 |
|
| 160 |
// Time |
| 161 |
|
| 162 |
type Timespec C.struct_timespec |
| 163 |
|
| 164 |
type Timeval C.struct_timeval |
| 165 |
|
| 166 |
type Timex C.struct_timex |
| 167 |
|
| 168 |
type Time_t C.time_t |
| 169 |
|
| 170 |
type Tms C.struct_tms |
| 171 |
|
| 172 |
type Utimbuf C.struct_utimbuf |
| 173 |
|
| 174 |
// Processes |
| 175 |
|
| 176 |
type Rusage C.struct_rusage |
| 177 |
|
| 178 |
type Rlimit C.struct_rlimit |
| 179 |
|
| 180 |
type _Gid_t C.gid_t |
| 181 |
|
| 182 |
// Files |
| 183 |
|
| 184 |
type Stat_t C.struct_stat |
| 185 |
|
| 186 |
type statxTimestamp C.struct_statx_timestamp |
| 187 |
|
| 188 |
type statx_t C.struct_statx |
| 189 |
|
| 190 |
type Statfs_t C.struct_statfs |
| 191 |
|
| 192 |
type Dirent C.struct_dirent |
| 193 |
|
| 194 |
type Fsid C.fsid_t |
| 195 |
|
| 196 |
type Flock_t C.struct_flock |
| 197 |
|
| 198 |
// Sockets |
| 199 |
|
| 200 |
type RawSockaddrInet4 C.struct_sockaddr_in |
| 201 |
|
| 202 |
type RawSockaddrInet6 C.struct_sockaddr_in6 |
| 203 |
|
| 204 |
type RawSockaddrUnix C.struct_my_sockaddr_un |
| 205 |
|
| 206 |
type RawSockaddrLinklayer C.struct_sockaddr_ll |
| 207 |
|
| 208 |
type RawSockaddrNetlink C.struct_sockaddr_nl |
| 209 |
|
| 210 |
type RawSockaddr C.struct_sockaddr |
| 211 |
|
| 212 |
type RawSockaddrAny C.struct_sockaddr_any |
| 213 |
|
| 214 |
type _Socklen C.socklen_t |
| 215 |
|
| 216 |
type Linger C.struct_linger |
| 217 |
|
| 218 |
type Iovec C.struct_iovec |
| 219 |
|
| 220 |
type IPMreq C.struct_ip_mreq |
| 221 |
|
| 222 |
type IPMreqn C.struct_ip_mreqn |
| 223 |
|
| 224 |
type IPv6Mreq C.struct_ipv6_mreq |
| 225 |
|
| 226 |
type Msghdr C.struct_msghdr |
| 227 |
|
| 228 |
type Cmsghdr C.struct_cmsghdr |
| 229 |
|
| 230 |
type Inet4Pktinfo C.struct_in_pktinfo |
| 231 |
|
| 232 |
type Inet6Pktinfo C.struct_in6_pktinfo |
| 233 |
|
| 234 |
type IPv6MTUInfo C.struct_ip6_mtuinfo |
| 235 |
|
| 236 |
type ICMPv6Filter C.struct_icmp6_filter |
| 237 |
|
| 238 |
type Ucred C.struct_ucred |
| 239 |
|
| 240 |
type TCPInfo C.struct_tcp_info |
| 241 |
|
| 242 |
const ( |
| 243 |
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in |
| 244 |
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 |
| 245 |
SizeofSockaddrAny = C.sizeof_struct_sockaddr_any |
| 246 |
SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un |
| 247 |
SizeofSockaddrLinklayer = C.sizeof_struct_sockaddr_ll |
| 248 |
SizeofSockaddrNetlink = C.sizeof_struct_sockaddr_nl |
| 249 |
SizeofLinger = C.sizeof_struct_linger |
| 250 |
SizeofIPMreq = C.sizeof_struct_ip_mreq |
| 251 |
SizeofIPMreqn = C.sizeof_struct_ip_mreqn |
| 252 |
SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq |
| 253 |
SizeofMsghdr = C.sizeof_struct_msghdr |
| 254 |
SizeofCmsghdr = C.sizeof_struct_cmsghdr |
| 255 |
SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo |
| 256 |
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo |
| 257 |
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo |
| 258 |
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter |
| 259 |
SizeofUcred = C.sizeof_struct_ucred |
| 260 |
SizeofTCPInfo = C.sizeof_struct_tcp_info |
| 261 |
) |
| 262 |
|
| 263 |
// Netlink routing and interface messages |
| 264 |
|
| 265 |
const ( |
| 266 |
IFA_UNSPEC = C.IFA_UNSPEC |
| 267 |
IFA_ADDRESS = C.IFA_ADDRESS |
| 268 |
IFA_LOCAL = C.IFA_LOCAL |
| 269 |
IFA_LABEL = C.IFA_LABEL |
| 270 |
IFA_BROADCAST = C.IFA_BROADCAST |
| 271 |
IFA_ANYCAST = C.IFA_ANYCAST |
| 272 |
IFA_CACHEINFO = C.IFA_CACHEINFO |
| 273 |
IFA_MULTICAST = C.IFA_MULTICAST |
| 274 |
IFLA_UNSPEC = C.IFLA_UNSPEC |
| 275 |
IFLA_ADDRESS = C.IFLA_ADDRESS |
| 276 |
IFLA_BROADCAST = C.IFLA_BROADCAST |
| 277 |
IFLA_IFNAME = C.IFLA_IFNAME |
| 278 |
IFLA_MTU = C.IFLA_MTU |
| 279 |
IFLA_LINK = C.IFLA_LINK |
| 280 |
IFLA_QDISC = C.IFLA_QDISC |
| 281 |
IFLA_STATS = C.IFLA_STATS |
| 282 |
IFLA_COST = C.IFLA_COST |
| 283 |
IFLA_PRIORITY = C.IFLA_PRIORITY |
| 284 |
IFLA_MASTER = C.IFLA_MASTER |
| 285 |
IFLA_WIRELESS = C.IFLA_WIRELESS |
| 286 |
IFLA_PROTINFO = C.IFLA_PROTINFO |
| 287 |
IFLA_TXQLEN = C.IFLA_TXQLEN |
| 288 |
IFLA_MAP = C.IFLA_MAP |
| 289 |
IFLA_WEIGHT = C.IFLA_WEIGHT |
| 290 |
IFLA_OPERSTATE = C.IFLA_OPERSTATE |
| 291 |
IFLA_LINKMODE = C.IFLA_LINKMODE |
| 292 |
IFLA_LINKINFO = C.IFLA_LINKINFO |
| 293 |
IFLA_NET_NS_PID = C.IFLA_NET_NS_PID |
| 294 |
IFLA_IFALIAS = C.IFLA_IFALIAS |
| 295 |
IFLA_MAX = C.IFLA_MAX |
| 296 |
RT_SCOPE_UNIVERSE = C.RT_SCOPE_UNIVERSE |
| 297 |
RT_SCOPE_SITE = C.RT_SCOPE_SITE |
| 298 |
RT_SCOPE_LINK = C.RT_SCOPE_LINK |
| 299 |
RT_SCOPE_HOST = C.RT_SCOPE_HOST |
| 300 |
RT_SCOPE_NOWHERE = C.RT_SCOPE_NOWHERE |
| 301 |
RT_TABLE_UNSPEC = C.RT_TABLE_UNSPEC |
| 302 |
RT_TABLE_COMPAT = C.RT_TABLE_COMPAT |
| 303 |
RT_TABLE_DEFAULT = C.RT_TABLE_DEFAULT |
| 304 |
RT_TABLE_MAIN = C.RT_TABLE_MAIN |
| 305 |
RT_TABLE_LOCAL = C.RT_TABLE_LOCAL |
| 306 |
RT_TABLE_MAX = C.RT_TABLE_MAX |
| 307 |
RTA_UNSPEC = C.RTA_UNSPEC |
| 308 |
RTA_DST = C.RTA_DST |
| 309 |
RTA_SRC = C.RTA_SRC |
| 310 |
RTA_IIF = C.RTA_IIF |
| 311 |
RTA_OIF = C.RTA_OIF |
| 312 |
RTA_GATEWAY = C.RTA_GATEWAY |
| 313 |
RTA_PRIORITY = C.RTA_PRIORITY |
| 314 |
RTA_PREFSRC = C.RTA_PREFSRC |
| 315 |
RTA_METRICS = C.RTA_METRICS |
| 316 |
RTA_MULTIPATH = C.RTA_MULTIPATH |
| 317 |
RTA_FLOW = C.RTA_FLOW |
| 318 |
RTA_CACHEINFO = C.RTA_CACHEINFO |
| 319 |
RTA_TABLE = C.RTA_TABLE |
| 320 |
RTN_UNSPEC = C.RTN_UNSPEC |
| 321 |
RTN_UNICAST = C.RTN_UNICAST |
| 322 |
RTN_LOCAL = C.RTN_LOCAL |
| 323 |
RTN_BROADCAST = C.RTN_BROADCAST |
| 324 |
RTN_ANYCAST = C.RTN_ANYCAST |
| 325 |
RTN_MULTICAST = C.RTN_MULTICAST |
| 326 |
RTN_BLACKHOLE = C.RTN_BLACKHOLE |
| 327 |
RTN_UNREACHABLE = C.RTN_UNREACHABLE |
| 328 |
RTN_PROHIBIT = C.RTN_PROHIBIT |
| 329 |
RTN_THROW = C.RTN_THROW |
| 330 |
RTN_NAT = C.RTN_NAT |
| 331 |
RTN_XRESOLVE = C.RTN_XRESOLVE |
| 332 |
RTNLGRP_NONE = C.RTNLGRP_NONE |
| 333 |
RTNLGRP_LINK = C.RTNLGRP_LINK |
| 334 |
RTNLGRP_NOTIFY = C.RTNLGRP_NOTIFY |
| 335 |
RTNLGRP_NEIGH = C.RTNLGRP_NEIGH |
| 336 |
RTNLGRP_TC = C.RTNLGRP_TC |
| 337 |
RTNLGRP_IPV4_IFADDR = C.RTNLGRP_IPV4_IFADDR |
| 338 |
RTNLGRP_IPV4_MROUTE = C.RTNLGRP_IPV4_MROUTE |
| 339 |
RTNLGRP_IPV4_ROUTE = C.RTNLGRP_IPV4_ROUTE |
| 340 |
RTNLGRP_IPV4_RULE = C.RTNLGRP_IPV4_RULE |
| 341 |
RTNLGRP_IPV6_IFADDR = C.RTNLGRP_IPV6_IFADDR |
| 342 |
RTNLGRP_IPV6_MROUTE = C.RTNLGRP_IPV6_MROUTE |
| 343 |
RTNLGRP_IPV6_ROUTE = C.RTNLGRP_IPV6_ROUTE |
| 344 |
RTNLGRP_IPV6_IFINFO = C.RTNLGRP_IPV6_IFINFO |
| 345 |
RTNLGRP_IPV6_PREFIX = C.RTNLGRP_IPV6_PREFIX |
| 346 |
RTNLGRP_IPV6_RULE = C.RTNLGRP_IPV6_RULE |
| 347 |
RTNLGRP_ND_USEROPT = C.RTNLGRP_ND_USEROPT |
| 348 |
SizeofNlMsghdr = C.sizeof_struct_nlmsghdr |
| 349 |
SizeofNlMsgerr = C.sizeof_struct_nlmsgerr |
| 350 |
SizeofRtGenmsg = C.sizeof_struct_rtgenmsg |
| 351 |
SizeofNlAttr = C.sizeof_struct_nlattr |
| 352 |
SizeofRtAttr = C.sizeof_struct_rtattr |
| 353 |
SizeofIfInfomsg = C.sizeof_struct_ifinfomsg |
| 354 |
SizeofIfAddrmsg = C.sizeof_struct_ifaddrmsg |
| 355 |
SizeofRtMsg = C.sizeof_struct_rtmsg |
| 356 |
SizeofRtNexthop = C.sizeof_struct_rtnexthop |
| 357 |
) |
| 358 |
|
| 359 |
type NlMsghdr C.struct_nlmsghdr |
| 360 |
|
| 361 |
type NlMsgerr C.struct_nlmsgerr |
| 362 |
|
| 363 |
type RtGenmsg C.struct_rtgenmsg |
| 364 |
|
| 365 |
type NlAttr C.struct_nlattr |
| 366 |
|
| 367 |
type RtAttr C.struct_rtattr |
| 368 |
|
| 369 |
type IfInfomsg C.struct_ifinfomsg |
| 370 |
|
| 371 |
type IfAddrmsg C.struct_ifaddrmsg |
| 372 |
|
| 373 |
type RtMsg C.struct_rtmsg |
| 374 |
|
| 375 |
type RtNexthop C.struct_rtnexthop |
| 376 |
|
| 377 |
// Linux socket filter |
| 378 |
|
| 379 |
const ( |
| 380 |
SizeofSockFilter = C.sizeof_struct_sock_filter |
| 381 |
SizeofSockFprog = C.sizeof_struct_sock_fprog |
| 382 |
) |
| 383 |
|
| 384 |
type SockFilter C.struct_sock_filter |
| 385 |
|
| 386 |
type SockFprog C.struct_sock_fprog |
| 387 |
|
| 388 |
// Inotify |
| 389 |
|
| 390 |
type InotifyEvent C.struct_inotify_event |
| 391 |
|
| 392 |
const SizeofInotifyEvent = C.sizeof_struct_inotify_event |
| 393 |
|
| 394 |
// Ptrace |
| 395 |
|
| 396 |
// Register structures |
| 397 |
type PtraceRegs C.PtraceRegs |
| 398 |
|
| 399 |
// Structures contained in PtraceRegs on s390x (exported by post.go) |
| 400 |
type ptracePsw C.ptracePsw |
| 401 |
|
| 402 |
type ptraceFpregs C.ptraceFpregs |
| 403 |
|
| 404 |
type ptracePer C.ptracePer |
| 405 |
|
| 406 |
// Misc |
| 407 |
|
| 408 |
type FdSet C.fd_set |
| 409 |
|
| 410 |
type Sysinfo_t C.struct_sysinfo |
| 411 |
|
| 412 |
type Utsname C.struct_utsname |
| 413 |
|
| 414 |
type Ustat_t C.struct_ustat |
| 415 |
|
| 416 |
type EpollEvent C.struct_my_epoll_event |
| 417 |
|
| 418 |
const ( |
| 419 |
_AT_FDCWD = C.AT_FDCWD |
| 420 |
_AT_REMOVEDIR = C.AT_REMOVEDIR |
| 421 |
_AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW |
| 422 |
_AT_EACCESS = C.AT_EACCESS |
| 423 |
_AT_EMPTY_PATH = C.AT_EMPTY_PATH |
| 424 |
_AT_NO_AUTOMOUNT = C.AT_NO_AUTOMOUNT |
| 425 |
_STATX_BASIC_STATS = C.STATX_BASIC_STATS |
| 426 |
) |
| 427 |
|
| 428 |
type pollFd C.struct_pollfd |
| 429 |
|
| 430 |
// Terminal handling |
| 431 |
|
| 432 |
type Termios C.struct_termios |
| 433 |
|
| 434 |
const ( |
| 435 |
IUCLC = C.IUCLC |
| 436 |
OLCUC = C.OLCUC |
| 437 |
TCGETS = C.TCGETS |
| 438 |
TCSETS = C.TCSETS |
| 439 |
XCASE = C.XCASE |
| 440 |
) |