1// Copyright 2020 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 zos && s390x
6
7// Hand edited based on ztypes_linux_s390x.go
8// TODO: auto-generate.
9
10package unix
11
12const (
13	SizeofPtr      = 0x8
14	SizeofShort    = 0x2
15	SizeofInt      = 0x4
16	SizeofLong     = 0x8
17	SizeofLongLong = 0x8
18	PathMax        = 0x1000
19)
20
21const (
22	SizeofSockaddrAny   = 128
23	SizeofCmsghdr       = 12
24	SizeofIPMreq        = 8
25	SizeofIPv6Mreq      = 20
26	SizeofICMPv6Filter  = 32
27	SizeofIPv6MTUInfo   = 32
28	SizeofInet4Pktinfo  = 8
29	SizeofInet6Pktinfo  = 20
30	SizeofLinger        = 8
31	SizeofSockaddrInet4 = 16
32	SizeofSockaddrInet6 = 28
33	SizeofTCPInfo       = 0x68
34	SizeofUcred         = 12
35)
36
37type (
38	_C_short     int16
39	_C_int       int32
40	_C_long      int64
41	_C_long_long int64
42)
43
44type Timespec struct {
45	Sec  int64
46	Nsec int64
47}
48
49type Timeval struct {
50	Sec  int64
51	Usec int64
52}
53
54type timeval_zos struct { //correct (with padding and all)
55	Sec  int64
56	_    [4]byte // pad
57	Usec int32
58}
59
60type Tms struct { //clock_t is 4-byte unsigned int in zos
61	Utime  uint32
62	Stime  uint32
63	Cutime uint32
64	Cstime uint32
65}
66
67type Time_t int64
68
69type Utimbuf struct {
70	Actime  int64
71	Modtime int64
72}
73
74type Utsname struct {
75	Sysname  [16]byte
76	Nodename [32]byte
77	Release  [8]byte
78	Version  [8]byte
79	Machine  [16]byte
80}
81
82type Ucred struct {
83	Pid int32
84	Uid uint32
85	Gid uint32
86}
87
88type RawSockaddrInet4 struct {
89	Len    uint8
90	Family uint8
91	Port   uint16
92	Addr   [4]byte /* in_addr */
93	Zero   [8]uint8
94}
95
96type RawSockaddrInet6 struct {
97	Len      uint8
98	Family   uint8
99	Port     uint16
100	Flowinfo uint32
101	Addr     [16]byte /* in6_addr */
102	Scope_id uint32
103}
104
105type RawSockaddrUnix struct {
106	Len    uint8
107	Family uint8
108	Path   [108]int8
109}
110
111type RawSockaddr struct {
112	Len    uint8
113	Family uint8
114	Data   [14]uint8
115}
116
117type RawSockaddrAny struct {
118	Addr RawSockaddr
119	_    [112]uint8 // pad
120}
121
122type _Socklen uint32
123
124type Linger struct {
125	Onoff  int32
126	Linger int32
127}
128
129type Iovec struct {
130	Base *byte
131	Len  uint64
132}
133
134type IPMreq struct {
135	Multiaddr [4]byte /* in_addr */
136	Interface [4]byte /* in_addr */
137}
138
139type IPv6Mreq struct {
140	Multiaddr [16]byte /* in6_addr */
141	Interface uint32
142}
143
144type Msghdr struct {
145	Name       *byte
146	Iov        *Iovec
147	Control    *byte
148	Flags      int32
149	Namelen    int32
150	Iovlen     int32
151	Controllen int32
152}
153
154type Cmsghdr struct {
155	Len   int32
156	Level int32
157	Type  int32
158}
159
160type Inet4Pktinfo struct {
161	Addr    [4]byte /* in_addr */
162	Ifindex uint32
163}
164
165type Inet6Pktinfo struct {
166	Addr    [16]byte /* in6_addr */
167	Ifindex uint32
168}
169
170type IPv6MTUInfo struct {
171	Addr RawSockaddrInet6
172	Mtu  uint32
173}
174
175type ICMPv6Filter struct {
176	Data [8]uint32
177}
178
179type TCPInfo struct {
180	State          uint8
181	Ca_state       uint8
182	Retransmits    uint8
183	Probes         uint8
184	Backoff        uint8
185	Options        uint8
186	Rto            uint32
187	Ato            uint32
188	Snd_mss        uint32
189	Rcv_mss        uint32
190	Unacked        uint32
191	Sacked         uint32
192	Lost           uint32
193	Retrans        uint32
194	Fackets        uint32
195	Last_data_sent uint32
196	Last_ack_sent  uint32
197	Last_data_recv uint32
198	Last_ack_recv  uint32
199	Pmtu           uint32
200	Rcv_ssthresh   uint32
201	Rtt            uint32
202	Rttvar         uint32
203	Snd_ssthresh   uint32
204	Snd_cwnd       uint32
205	Advmss         uint32
206	Reordering     uint32
207	Rcv_rtt        uint32
208	Rcv_space      uint32
209	Total_retrans  uint32
210}
211
212type _Gid_t uint32
213
214type rusage_zos struct {
215	Utime timeval_zos
216	Stime timeval_zos
217}
218
219type Rusage struct {
220	Utime    Timeval
221	Stime    Timeval
222	Maxrss   int64
223	Ixrss    int64
224	Idrss    int64
225	Isrss    int64
226	Minflt   int64
227	Majflt   int64
228	Nswap    int64
229	Inblock  int64
230	Oublock  int64
231	Msgsnd   int64
232	Msgrcv   int64
233	Nsignals int64
234	Nvcsw    int64
235	Nivcsw   int64
236}
237
238type Rlimit struct {
239	Cur uint64
240	Max uint64
241}
242
243// { int, short, short } in poll.h
244type PollFd struct {
245	Fd      int32
246	Events  int16
247	Revents int16
248}
249
250type Stat_t struct { //Linux Definition
251	Dev     uint64
252	Ino     uint64
253	Nlink   uint64
254	Mode    uint32
255	Uid     uint32
256	Gid     uint32
257	_       int32
258	Rdev    uint64
259	Size    int64
260	Atim    Timespec
261	Mtim    Timespec
262	Ctim    Timespec
263	Blksize int64
264	Blocks  int64
265	_       [3]int64
266}
267
268type Stat_LE_t struct {
269	_            [4]byte // eye catcher
270	Length       uint16
271	Version      uint16
272	Mode         int32
273	Ino          uint32
274	Dev          uint32
275	Nlink        int32
276	Uid          int32
277	Gid          int32
278	Size         int64
279	Atim31       [4]byte
280	Mtim31       [4]byte
281	Ctim31       [4]byte
282	Rdev         uint32
283	Auditoraudit uint32
284	Useraudit    uint32
285	Blksize      int32
286	Creatim31    [4]byte
287	AuditID      [16]byte
288	_            [4]byte // rsrvd1
289	File_tag     struct {
290		Ccsid   uint16
291		Txtflag uint16 // aggregating Txflag:1 deferred:1 rsvflags:14
292	}
293	CharsetID [8]byte
294	Blocks    int64
295	Genvalue  uint32
296	Reftim31  [4]byte
297	Fid       [8]byte
298	Filefmt   byte
299	Fspflag2  byte
300	_         [2]byte // rsrvd2
301	Ctimemsec int32
302	Seclabel  [8]byte
303	_         [4]byte // rsrvd3
304	_         [4]byte // rsrvd4
305	Atim      Time_t
306	Mtim      Time_t
307	Ctim      Time_t
308	Creatim   Time_t
309	Reftim    Time_t
310	_         [24]byte // rsrvd5
311}
312
313type Statvfs_t struct {
314	ID          [4]byte
315	Len         int32
316	Bsize       uint64
317	Blocks      uint64
318	Usedspace   uint64
319	Bavail      uint64
320	Flag        uint64
321	Maxfilesize int64
322	_           [16]byte
323	Frsize      uint64
324	Bfree       uint64
325	Files       uint32
326	Ffree       uint32
327	Favail      uint32
328	Namemax31   uint32
329	Invarsec    uint32
330	_           [4]byte
331	Fsid        uint64
332	Namemax     uint64
333}
334
335type Statfs_t struct {
336	Type    uint64
337	Bsize   uint64
338	Blocks  uint64
339	Bfree   uint64
340	Bavail  uint64
341	Files   uint32
342	Ffree   uint32
343	Fsid    uint64
344	Namelen uint64
345	Frsize  uint64
346	Flags   uint64
347	_       [4]uint64
348}
349
350type direntLE struct {
351	Reclen uint16
352	Namlen uint16
353	Ino    uint32
354	Extra  uintptr
355	Name   [256]byte
356}
357
358type Dirent struct {
359	Ino    uint64
360	Off    int64
361	Reclen uint16
362	Type   uint8
363	Name   [256]uint8
364	_      [5]byte
365}
366
367type FdSet struct {
368	Bits [64]int32
369}
370
371// This struct is packed on z/OS so it can't be used directly.
372type Flock_t struct {
373	Type   int16
374	Whence int16
375	Start  int64
376	Len    int64
377	Pid    int32
378}
379
380type Termios struct {
381	Cflag uint32
382	Iflag uint32
383	Lflag uint32
384	Oflag uint32
385	Cc    [11]uint8
386}
387
388type Winsize struct {
389	Row    uint16
390	Col    uint16
391	Xpixel uint16
392	Ypixel uint16
393}
394
395type W_Mnth struct {
396	Hid   [4]byte
397	Size  int32
398	Cur1  int32 //32bit pointer
399	Cur2  int32 //^
400	Devno uint32
401	_     [4]byte
402}
403
404type W_Mntent struct {
405	Fstype       uint32
406	Mode         uint32
407	Dev          uint32
408	Parentdev    uint32
409	Rootino      uint32
410	Status       byte
411	Ddname       [9]byte
412	Fstname      [9]byte
413	Fsname       [45]byte
414	Pathlen      uint32
415	Mountpoint   [1024]byte
416	Jobname      [8]byte
417	PID          int32
418	Parmoffset   int32
419	Parmlen      int16
420	Owner        [8]byte
421	Quiesceowner [8]byte
422	_            [38]byte
423}
424
425type EpollEvent struct {
426	Events uint32
427	_      int32
428	Fd     int32
429	Pad    int32
430}
431
432type InotifyEvent struct {
433	Wd     int32
434	Mask   uint32
435	Cookie uint32
436	Len    uint32
437	Name   string
438}
439
440const (
441	SizeofInotifyEvent = 0x10
442)
443
444type ConsMsg2 struct {
445	Cm2Format       uint16
446	Cm2R1           uint16
447	Cm2Msglength    uint32
448	Cm2Msg          *byte
449	Cm2R2           [4]byte
450	Cm2R3           [4]byte
451	Cm2Routcde      *uint32
452	Cm2Descr        *uint32
453	Cm2Msgflag      uint32
454	Cm2Token        uint32
455	Cm2Msgid        *uint32
456	Cm2R4           [4]byte
457	Cm2DomToken     uint32
458	Cm2DomMsgid     *uint32
459	Cm2ModCartptr   *byte
460	Cm2ModConsidptr *byte
461	Cm2MsgCart      [8]byte
462	Cm2MsgConsid    [4]byte
463	Cm2R5           [12]byte
464}
465
466const (
467	CC_modify        = 1
468	CC_stop          = 2
469	CONSOLE_FORMAT_2 = 2
470	CONSOLE_FORMAT_3 = 3
471	CONSOLE_HRDCPY   = 0x80000000
472)
473
474type OpenHow struct {
475	Flags   uint64
476	Mode    uint64
477	Resolve uint64
478}
479
480const SizeofOpenHow = 0x18
481
482const (
483	RESOLVE_CACHED        = 0x20
484	RESOLVE_BENEATH       = 0x8
485	RESOLVE_IN_ROOT       = 0x10
486	RESOLVE_NO_MAGICLINKS = 0x2
487	RESOLVE_NO_SYMLINKS   = 0x4
488	RESOLVE_NO_XDEV       = 0x1
489)
490
491type Siginfo struct {
492	Signo int32
493	Errno int32
494	Code  int32
495	Pid   int32
496	Uid   uint32
497	_     [44]byte
498}
499
500type SysvIpcPerm struct {
501	Uid  uint32
502	Gid  uint32
503	Cuid uint32
504	Cgid uint32
505	Mode int32
506}
507
508type SysvShmDesc struct {
509	Perm   SysvIpcPerm
510	_      [4]byte
511	Lpid   int32
512	Cpid   int32
513	Nattch uint32
514	_      [4]byte
515	_      [4]byte
516	_      [4]byte
517	_      int32
518	_      uint8
519	_      uint8
520	_      uint16
521	_      *byte
522	Segsz  uint64
523	Atime  Time_t
524	Dtime  Time_t
525	Ctime  Time_t
526}
527
528type SysvShmDesc64 struct {
529	Perm   SysvIpcPerm
530	_      [4]byte
531	Lpid   int32
532	Cpid   int32
533	Nattch uint32
534	_      [4]byte
535	_      [4]byte
536	_      [4]byte
537	_      int32
538	_      byte
539	_      uint8
540	_      uint16
541	_      *byte
542	Segsz  uint64
543	Atime  int64
544	Dtime  int64
545	Ctime  int64
546}
547