Bug Summary

File:obj-scan-build/term/termServer.c
Location:line 722, column 2
Description:Assigned value is garbage or undefined

Annotated Source Code

1/* Module term */
2
3#ifndef _GNU_SOURCE1
4#define _GNU_SOURCE1 1
5#endif
6
7#define EXPORT_BOOLEAN
8#include <mach/boolean.h>
9#include <mach/kern_return.h>
10#include <mach/message.h>
11#include <mach/mig_errors.h>
12#include <mach/mig_support.h>
13
14#ifndef mig_internalstatic
15#define mig_internalstatic static
16#endif
17
18#ifndef mig_external
19#define mig_external
20#endif
21
22#ifndef mig_unlikely
23#define mig_unlikely(X)__builtin_expect (!! (X), 0) __builtin_expect (!! (X), 0)
24#endif
25
26#ifndef TypeCheck1
27#define TypeCheck1 1
28#endif
29
30#ifndef UseExternRCSId1
31#define UseExternRCSId1 1
32#endif
33
34#define BAD_TYPECHECK(type, check)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; }
)), 0)
mig_unlikely (({\__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; }
)), 0)
35 union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; }
)), 0)
36 _t.t = *(type); _c.t = *(check);_t.w != _c.w; }))__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; }
)), 0)
37#define msgh_request_portmsgh_local_port msgh_local_port
38#define MACH_MSGH_BITS_REQUEST(bits)(((bits) & 0x0000ff00) >> 8) MACH_MSGH_BITS_LOCAL(bits)(((bits) & 0x0000ff00) >> 8)
39#define msgh_reply_portmsgh_remote_port msgh_remote_port
40#define MACH_MSGH_BITS_REPLY(bits)((bits) & 0x000000ff) MACH_MSGH_BITS_REMOTE(bits)((bits) & 0x000000ff)
41
42#include <hurd/ports.h>
43#include <mach/std_types.h>
44#include <mach/mach_types.h>
45#include <device/device_types.h>
46#include <device/net_status.h>
47#include <sys/types.h>
48#include <sys/stat.h>
49#include <sys/statfs.h>
50#include <sys/resource.h>
51#include <sys/utsname.h>
52#include <hurd/hurd_types.h>
53#include "../libtrivfs/mig-decls.h"
54#include "mig-decls.h"
55
56/* Routine term_getctty */
57mig_internalstatic void _Xterm_getctty
58 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
59{
60 typedef struct {
61 mach_msg_header_t Head;
62 } Request;
63
64 typedef struct {
65 mach_msg_header_t Head;
66 mach_msg_type_t RetCodeType;
67 kern_return_t RetCode;
68 mach_msg_type_t cttyType;
69 mach_port_t ctty;
70 } Reply;
71
72 Request *In0P = (Request *) InHeadP;
73 Reply *OutP = (Reply *) OutHeadP;
74 mig_external kern_return_t S_term_getctty
75 (trivfs_protid_t terminal, mach_port_t *ctty, mach_msg_type_name_t *cttyPoly);
76
77 boolean_t msgh_simple = msgh_simple;
78 const mach_msg_type_t cttyType = {
79 /* msgt_name = */ -1,
80 /* msgt_size = */ 32,
81 /* msgt_number = */ 1,
82 /* msgt_inline = */ TRUE((boolean_t) 1),
83 /* msgt_longform = */ FALSE((boolean_t) 0),
84 /* msgt_deallocate = */ FALSE((boolean_t) 0),
85 /* msgt_unused = */ 0
86 };
87
88 trivfs_protid_t terminal;
89 mach_msg_type_name_t cttyPoly;
90
91#if TypeCheck1
92 if (mig_unlikely ((In0P->Head.msgh_size != 24) ||__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
93 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
94 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
95#endif /* TypeCheck */
96
97 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
98 terminal = trivfs_begin_using_protid_payload(In0P->Head.msgh_protected_payload);
99 else
100 terminal = trivfs_begin_using_protid(In0P->Head.msgh_request_portmsgh_local_port);
101
102 OutP->RetCode = S_term_getctty(terminal, &OutP->ctty, &cttyPoly);
103 trivfs_end_using_protid(terminal);
104 if (OutP->RetCode != KERN_SUCCESS0)
105 return;
106
107 msgh_simple = TRUE((boolean_t) 1);
108 OutP->Head.msgh_size = 40;
109
110 OutP->cttyType = cttyType;
111
112 if (MACH_MSG_TYPE_PORT_ANY(cttyPoly)(((cttyPoly) >= 16) && ((cttyPoly) <= 21)))
113 msgh_simple = FALSE((boolean_t) 0);
114
115 OutP->cttyType.msgt_name = cttyPoly;
116
117 if (!msgh_simple)
118 OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U;
119}
120
121/* Default implementation of S_term_getctty */
122#ifdef MIG_EOPNOTSUPP
123kern_return_t __attribute__ ((weak))
124S_term_getctty
125(
126 trivfs_protid_t terminal,
127 mach_port_t *ctty,
128 mach_msg_type_name_t *cttyPoly
129) { return MIG_EOPNOTSUPP; }
130#endif /* MIG_EOPNOTSUPP */
131
132/* Routine term_open_ctty */
133mig_internalstatic void _Xterm_open_ctty
134 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
135{
136 typedef struct {
137 mach_msg_header_t Head;
138 mach_msg_type_t pidType;
139 pid_t pid;
140 mach_msg_type_t pgrpType;
141 pid_t pgrp;
142 } Request;
143
144 typedef struct {
145 mach_msg_header_t Head;
146 mach_msg_type_t RetCodeType;
147 kern_return_t RetCode;
148 mach_msg_type_t newttyType;
149 mach_port_t newtty;
150 } Reply;
151
152 Request *In0P = (Request *) InHeadP;
153 Reply *OutP = (Reply *) OutHeadP;
154 mig_external kern_return_t S_term_open_ctty
155 (trivfs_protid_t terminal, pid_t pid, pid_t pgrp, mach_port_t *newtty, mach_msg_type_name_t *newttyPoly);
156
157 boolean_t msgh_simple = msgh_simple;
158 const mach_msg_type_t pidCheck = {
159 /* msgt_name = */ 2,
160 /* msgt_size = */ 32,
161 /* msgt_number = */ 1,
162 /* msgt_inline = */ TRUE((boolean_t) 1),
163 /* msgt_longform = */ FALSE((boolean_t) 0),
164 /* msgt_deallocate = */ FALSE((boolean_t) 0),
165 /* msgt_unused = */ 0
166 };
167
168 const mach_msg_type_t pgrpCheck = {
169 /* msgt_name = */ 2,
170 /* msgt_size = */ 32,
171 /* msgt_number = */ 1,
172 /* msgt_inline = */ TRUE((boolean_t) 1),
173 /* msgt_longform = */ FALSE((boolean_t) 0),
174 /* msgt_deallocate = */ FALSE((boolean_t) 0),
175 /* msgt_unused = */ 0
176 };
177
178 const mach_msg_type_t newttyType = {
179 /* msgt_name = */ -1,
180 /* msgt_size = */ 32,
181 /* msgt_number = */ 1,
182 /* msgt_inline = */ TRUE((boolean_t) 1),
183 /* msgt_longform = */ FALSE((boolean_t) 0),
184 /* msgt_deallocate = */ FALSE((boolean_t) 0),
185 /* msgt_unused = */ 0
186 };
187
188 trivfs_protid_t terminal;
189 mach_msg_type_name_t newttyPoly;
190
191#if TypeCheck1
192 if (mig_unlikely ((In0P->Head.msgh_size != 40) ||__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
193 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
194 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
195#endif /* TypeCheck */
196
197#if TypeCheck1
198 if (BAD_TYPECHECK(&In0P->pidType, &pidCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->pidType); _c.t = *(&
pidCheck);_t.w != _c.w; })), 0)
)
199 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
200#endif /* TypeCheck */
201
202#if TypeCheck1
203 if (BAD_TYPECHECK(&In0P->pgrpType, &pgrpCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->pgrpType); _c.t = *(&
pgrpCheck);_t.w != _c.w; })), 0)
)
204 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
205#endif /* TypeCheck */
206
207 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
208 terminal = trivfs_begin_using_protid_payload(In0P->Head.msgh_protected_payload);
209 else
210 terminal = trivfs_begin_using_protid(In0P->Head.msgh_request_portmsgh_local_port);
211
212 OutP->RetCode = S_term_open_ctty(terminal, In0P->pid, In0P->pgrp, &OutP->newtty, &newttyPoly);
213 trivfs_end_using_protid(terminal);
214 if (OutP->RetCode != KERN_SUCCESS0)
215 return;
216
217 msgh_simple = TRUE((boolean_t) 1);
218 OutP->Head.msgh_size = 40;
219
220 OutP->newttyType = newttyType;
221
222 if (MACH_MSG_TYPE_PORT_ANY(newttyPoly)(((newttyPoly) >= 16) && ((newttyPoly) <= 21)))
223 msgh_simple = FALSE((boolean_t) 0);
224
225 OutP->newttyType.msgt_name = newttyPoly;
226
227 if (!msgh_simple)
228 OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U;
229}
230
231/* Default implementation of S_term_open_ctty */
232#ifdef MIG_EOPNOTSUPP
233kern_return_t __attribute__ ((weak))
234S_term_open_ctty
235(
236 trivfs_protid_t terminal,
237 pid_t pid,
238 pid_t pgrp,
239 mach_port_t *newtty,
240 mach_msg_type_name_t *newttyPoly
241) { return MIG_EOPNOTSUPP; }
242#endif /* MIG_EOPNOTSUPP */
243
244/* Routine term_set_nodename */
245mig_internalstatic void _Xterm_set_nodename
246 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
247{
248 typedef struct {
249 mach_msg_header_t Head;
250 mach_msg_type_t nameType;
251 string_t name;
252 } Request;
253
254 typedef struct {
255 mach_msg_header_t Head;
256 mach_msg_type_t RetCodeType;
257 kern_return_t RetCode;
258 } Reply;
259
260 Request *In0P = (Request *) InHeadP;
261 Reply *OutP = (Reply *) OutHeadP;
262 mig_external kern_return_t S_term_set_nodename
263 (trivfs_protid_t terminal, string_t name);
264
265 const mach_msg_type_t nameCheck = {
266 /* msgt_name = */ MACH_MSG_TYPE_STRING_C12,
267 /* msgt_size = */ 8,
268 /* msgt_number = */ 1024,
269 /* msgt_inline = */ TRUE((boolean_t) 1),
270 /* msgt_longform = */ FALSE((boolean_t) 0),
271 /* msgt_deallocate = */ FALSE((boolean_t) 0),
272 /* msgt_unused = */ 0
273 };
274
275 trivfs_protid_t terminal;
276
277#if TypeCheck1
278 if (mig_unlikely ((In0P->Head.msgh_size != 1052) ||__builtin_expect (!! ((In0P->Head.msgh_size != 1052) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
279 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 1052) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
280 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
281#endif /* TypeCheck */
282
283#if TypeCheck1
284 if (BAD_TYPECHECK(&In0P->nameType, &nameCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->nameType); _c.t = *(&
nameCheck);_t.w != _c.w; })), 0)
)
285 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
286#endif /* TypeCheck */
287
288 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
289 terminal = trivfs_begin_using_protid_payload(In0P->Head.msgh_protected_payload);
290 else
291 terminal = trivfs_begin_using_protid(In0P->Head.msgh_request_portmsgh_local_port);
292
293 OutP->RetCode = S_term_set_nodename(terminal, In0P->name);
294 trivfs_end_using_protid(terminal);
295}
296
297/* Default implementation of S_term_set_nodename */
298#ifdef MIG_EOPNOTSUPP
299kern_return_t __attribute__ ((weak))
300S_term_set_nodename
301(
302 trivfs_protid_t terminal,
303 string_t name
304) { return MIG_EOPNOTSUPP; }
305#endif /* MIG_EOPNOTSUPP */
306
307/* Routine term_get_nodename */
308mig_internalstatic void _Xterm_get_nodename
309 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
310{
311 typedef struct {
312 mach_msg_header_t Head;
313 } Request;
314
315 typedef struct {
316 mach_msg_header_t Head;
317 mach_msg_type_t RetCodeType;
318 kern_return_t RetCode;
319 mach_msg_type_t nameType;
320 string_t name;
321 } Reply;
322
323 Request *In0P = (Request *) InHeadP;
324 Reply *OutP = (Reply *) OutHeadP;
325 mig_external kern_return_t S_term_get_nodename
326 (trivfs_protid_t terminal, string_t name);
327
328 const mach_msg_type_t nameType = {
329 /* msgt_name = */ MACH_MSG_TYPE_STRING_C12,
330 /* msgt_size = */ 8,
331 /* msgt_number = */ 1024,
332 /* msgt_inline = */ TRUE((boolean_t) 1),
333 /* msgt_longform = */ FALSE((boolean_t) 0),
334 /* msgt_deallocate = */ FALSE((boolean_t) 0),
335 /* msgt_unused = */ 0
336 };
337
338 trivfs_protid_t terminal;
339
340#if TypeCheck1
341 if (mig_unlikely ((In0P->Head.msgh_size != 24) ||__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
342 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
343 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
344#endif /* TypeCheck */
345
346 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
347 terminal = trivfs_begin_using_protid_payload(In0P->Head.msgh_protected_payload);
348 else
349 terminal = trivfs_begin_using_protid(In0P->Head.msgh_request_portmsgh_local_port);
350
351 OutP->RetCode = S_term_get_nodename(terminal, OutP->name);
352 trivfs_end_using_protid(terminal);
353 if (OutP->RetCode != KERN_SUCCESS0)
354 return;
355
356 OutP->Head.msgh_size = 1060;
357
358 OutP->nameType = nameType;
359}
360
361/* Default implementation of S_term_get_nodename */
362#ifdef MIG_EOPNOTSUPP
363kern_return_t __attribute__ ((weak))
364S_term_get_nodename
365(
366 trivfs_protid_t terminal,
367 string_t name
368) { return MIG_EOPNOTSUPP; }
369#endif /* MIG_EOPNOTSUPP */
370
371/* Routine term_set_filenode */
372mig_internalstatic void _Xterm_set_filenode
373 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
374{
375 typedef struct {
376 mach_msg_header_t Head;
377 mach_msg_type_t filenodeType;
378 file_t filenode;
379 } Request;
380
381 typedef struct {
382 mach_msg_header_t Head;
383 mach_msg_type_t RetCodeType;
384 kern_return_t RetCode;
385 } Reply;
386
387 Request *In0P = (Request *) InHeadP;
388 Reply *OutP = (Reply *) OutHeadP;
389 mig_external kern_return_t S_term_set_filenode
390 (trivfs_protid_t terminal, file_t filenode);
391
392 const mach_msg_type_t filenodeCheck = {
393 /* msgt_name = */ 17,
394 /* msgt_size = */ 32,
395 /* msgt_number = */ 1,
396 /* msgt_inline = */ TRUE((boolean_t) 1),
397 /* msgt_longform = */ FALSE((boolean_t) 0),
398 /* msgt_deallocate = */ FALSE((boolean_t) 0),
399 /* msgt_unused = */ 0
400 };
401
402 trivfs_protid_t terminal;
403 file_t filenode;
404
405#if TypeCheck1
406 if (mig_unlikely ((In0P->Head.msgh_size != 32) ||__builtin_expect (!! ((In0P->Head.msgh_size != 32) || !(In0P
->Head.msgh_bits & 0x80000000U)), 0)
407 !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 32) || !(In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
408 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
409#endif /* TypeCheck */
410
411#if TypeCheck1
412 if (BAD_TYPECHECK(&In0P->filenodeType, &filenodeCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->filenodeType); _c.t = *(
&filenodeCheck);_t.w != _c.w; })), 0)
)
413 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
414#endif /* TypeCheck */
415
416 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
417 terminal = trivfs_begin_using_protid_payload(In0P->Head.msgh_protected_payload);
418 else
419 terminal = trivfs_begin_using_protid(In0P->Head.msgh_request_portmsgh_local_port);
420
421 filenode = In0P->filenode;
422
423 OutP->RetCode = S_term_set_filenode(terminal, filenode);
424 trivfs_end_using_protid(terminal);
425}
426
427/* Default implementation of S_term_set_filenode */
428#ifdef MIG_EOPNOTSUPP
429kern_return_t __attribute__ ((weak))
430S_term_set_filenode
431(
432 trivfs_protid_t terminal,
433 file_t filenode
434) { return MIG_EOPNOTSUPP; }
435#endif /* MIG_EOPNOTSUPP */
436
437/* Routine term_get_bottom_type */
438mig_internalstatic void _Xterm_get_bottom_type
439 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
440{
441 typedef struct {
442 mach_msg_header_t Head;
443 } Request;
444
445 typedef struct {
446 mach_msg_header_t Head;
447 mach_msg_type_t RetCodeType;
448 kern_return_t RetCode;
449 mach_msg_type_t ttypeType;
450 int ttype;
451 } Reply;
452
453 Request *In0P = (Request *) InHeadP;
454 Reply *OutP = (Reply *) OutHeadP;
455 mig_external kern_return_t S_term_get_bottom_type
456 (trivfs_protid_t terminal, int *ttype);
457
458 const mach_msg_type_t ttypeType = {
459 /* msgt_name = */ 2,
460 /* msgt_size = */ 32,
461 /* msgt_number = */ 1,
462 /* msgt_inline = */ TRUE((boolean_t) 1),
463 /* msgt_longform = */ FALSE((boolean_t) 0),
464 /* msgt_deallocate = */ FALSE((boolean_t) 0),
465 /* msgt_unused = */ 0
466 };
467
468 trivfs_protid_t terminal;
469
470#if TypeCheck1
471 if (mig_unlikely ((In0P->Head.msgh_size != 24) ||__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
472 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
473 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
474#endif /* TypeCheck */
475
476 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
477 terminal = trivfs_begin_using_protid_payload(In0P->Head.msgh_protected_payload);
478 else
479 terminal = trivfs_begin_using_protid(In0P->Head.msgh_request_portmsgh_local_port);
480
481 OutP->RetCode = S_term_get_bottom_type(terminal, &OutP->ttype);
482 trivfs_end_using_protid(terminal);
483 if (OutP->RetCode != KERN_SUCCESS0)
484 return;
485
486 OutP->Head.msgh_size = 40;
487
488 OutP->ttypeType = ttypeType;
489}
490
491/* Default implementation of S_term_get_bottom_type */
492#ifdef MIG_EOPNOTSUPP
493kern_return_t __attribute__ ((weak))
494S_term_get_bottom_type
495(
496 trivfs_protid_t terminal,
497 int *ttype
498) { return MIG_EOPNOTSUPP; }
499#endif /* MIG_EOPNOTSUPP */
500
501/* Routine term_on_machdev */
502mig_internalstatic void _Xterm_on_machdev
503 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
504{
505 typedef struct {
506 mach_msg_header_t Head;
507 mach_msg_type_t machdevType;
508 mach_port_t machdev;
509 } Request;
510
511 typedef struct {
512 mach_msg_header_t Head;
513 mach_msg_type_t RetCodeType;
514 kern_return_t RetCode;
515 } Reply;
516
517 Request *In0P = (Request *) InHeadP;
518 Reply *OutP = (Reply *) OutHeadP;
519 mig_external kern_return_t S_term_on_machdev
520 (trivfs_protid_t terminal, mach_port_t machdev);
521
522 const mach_msg_type_t machdevCheck = {
523 /* msgt_name = */ 17,
524 /* msgt_size = */ 32,
525 /* msgt_number = */ 1,
526 /* msgt_inline = */ TRUE((boolean_t) 1),
527 /* msgt_longform = */ FALSE((boolean_t) 0),
528 /* msgt_deallocate = */ FALSE((boolean_t) 0),
529 /* msgt_unused = */ 0
530 };
531
532 trivfs_protid_t terminal;
533
534#if TypeCheck1
535 if (mig_unlikely ((In0P->Head.msgh_size != 32) ||__builtin_expect (!! ((In0P->Head.msgh_size != 32) || !(In0P
->Head.msgh_bits & 0x80000000U)), 0)
536 !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 32) || !(In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
537 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
538#endif /* TypeCheck */
539
540#if TypeCheck1
541 if (BAD_TYPECHECK(&In0P->machdevType, &machdevCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->machdevType); _c.t = *(&
machdevCheck);_t.w != _c.w; })), 0)
)
542 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
543#endif /* TypeCheck */
544
545 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
546 terminal = trivfs_begin_using_protid_payload(In0P->Head.msgh_protected_payload);
547 else
548 terminal = trivfs_begin_using_protid(In0P->Head.msgh_request_portmsgh_local_port);
549
550 OutP->RetCode = S_term_on_machdev(terminal, In0P->machdev);
551 trivfs_end_using_protid(terminal);
552}
553
554/* Default implementation of S_term_on_machdev */
555#ifdef MIG_EOPNOTSUPP
556kern_return_t __attribute__ ((weak))
557S_term_on_machdev
558(
559 trivfs_protid_t terminal,
560 mach_port_t machdev
561) { return MIG_EOPNOTSUPP; }
562#endif /* MIG_EOPNOTSUPP */
563
564/* Routine term_on_hurddev */
565mig_internalstatic void _Xterm_on_hurddev
566 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
567{
568 typedef struct {
569 mach_msg_header_t Head;
570 mach_msg_type_t hurddevType;
571 io_t hurddev;
572 } Request;
573
574 typedef struct {
575 mach_msg_header_t Head;
576 mach_msg_type_t RetCodeType;
577 kern_return_t RetCode;
578 } Reply;
579
580 Request *In0P = (Request *) InHeadP;
581 Reply *OutP = (Reply *) OutHeadP;
582 mig_external kern_return_t S_term_on_hurddev
583 (trivfs_protid_t terminal, trivfs_protid_t hurddev);
584
585 const mach_msg_type_t hurddevCheck = {
586 /* msgt_name = */ 17,
587 /* msgt_size = */ 32,
588 /* msgt_number = */ 1,
589 /* msgt_inline = */ TRUE((boolean_t) 1),
590 /* msgt_longform = */ FALSE((boolean_t) 0),
591 /* msgt_deallocate = */ FALSE((boolean_t) 0),
592 /* msgt_unused = */ 0
593 };
594
595 trivfs_protid_t terminal;
596 trivfs_protid_t hurddev;
597
598#if TypeCheck1
599 if (mig_unlikely ((In0P->Head.msgh_size != 32) ||__builtin_expect (!! ((In0P->Head.msgh_size != 32) || !(In0P
->Head.msgh_bits & 0x80000000U)), 0)
600 !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 32) || !(In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
601 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
602#endif /* TypeCheck */
603
604#if TypeCheck1
605 if (BAD_TYPECHECK(&In0P->hurddevType, &hurddevCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->hurddevType); _c.t = *(&
hurddevCheck);_t.w != _c.w; })), 0)
)
606 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
607#endif /* TypeCheck */
608
609 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
610 terminal = trivfs_begin_using_protid_payload(In0P->Head.msgh_protected_payload);
611 else
612 terminal = trivfs_begin_using_protid(In0P->Head.msgh_request_portmsgh_local_port);
613
614 hurddev = trivfs_begin_using_protid(In0P->hurddev);
615
616 OutP->RetCode = S_term_on_hurddev(terminal, hurddev);
617 trivfs_end_using_protid(hurddev);
618 trivfs_end_using_protid(terminal);
619}
620
621/* Default implementation of S_term_on_hurddev */
622#ifdef MIG_EOPNOTSUPP
623kern_return_t __attribute__ ((weak))
624S_term_on_hurddev
625(
626 trivfs_protid_t terminal,
627 trivfs_protid_t hurddev
628) { return MIG_EOPNOTSUPP; }
629#endif /* MIG_EOPNOTSUPP */
630
631/* Routine term_on_pty */
632mig_internalstatic void _Xterm_on_pty
633 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
634{
635 typedef struct {
636 mach_msg_header_t Head;
637 } Request;
638
639 typedef struct {
640 mach_msg_header_t Head;
641 mach_msg_type_t RetCodeType;
642 kern_return_t RetCode;
643 mach_msg_type_t ptymasterType;
644 io_t ptymaster;
645 } Reply;
646
647 Request *In0P = (Request *) InHeadP;
648 Reply *OutP = (Reply *) OutHeadP;
649 mig_external kern_return_t S_term_on_pty
650 (trivfs_protid_t terminal, trivfs_protid_t *ptymaster);
651
652 const mach_msg_type_t ptymasterType = {
653 /* msgt_name = */ 19,
654 /* msgt_size = */ 32,
655 /* msgt_number = */ 1,
656 /* msgt_inline = */ TRUE((boolean_t) 1),
657 /* msgt_longform = */ FALSE((boolean_t) 0),
658 /* msgt_deallocate = */ FALSE((boolean_t) 0),
659 /* msgt_unused = */ 0
660 };
661
662 trivfs_protid_t terminal;
663 trivfs_protid_t ptymaster;
664
665#if TypeCheck1
666 if (mig_unlikely ((In0P->Head.msgh_size != 24) ||__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
667 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
668 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
669#endif /* TypeCheck */
670
671 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
672 terminal = trivfs_begin_using_protid_payload(In0P->Head.msgh_protected_payload);
673 else
674 terminal = trivfs_begin_using_protid(In0P->Head.msgh_request_portmsgh_local_port);
675
676 OutP->RetCode = S_term_on_pty(terminal, &ptymaster);
677 trivfs_end_using_protid(terminal);
678 if (OutP->RetCode != KERN_SUCCESS0)
679 return;
680
681 OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U;
682 OutP->Head.msgh_size = 40;
683
684 OutP->ptymasterType = ptymasterType;
685
686 OutP->ptymaster = ptymaster;
687}
688
689/* Default implementation of S_term_on_pty */
690#ifdef MIG_EOPNOTSUPP
691kern_return_t __attribute__ ((weak))
692S_term_on_pty
693(
694 trivfs_protid_t terminal,
695 trivfs_protid_t *ptymaster
696) { return MIG_EOPNOTSUPP; }
697#endif /* MIG_EOPNOTSUPP */
698
699/* Routine termctty_open_terminal */
700mig_internalstatic void _Xtermctty_open_terminal
701 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
702{
703 typedef struct {
704 mach_msg_header_t Head;
705 mach_msg_type_t flagsType;
706 int flags;
707 } Request;
708
709 typedef struct {
710 mach_msg_header_t Head;
711 mach_msg_type_t RetCodeType;
712 kern_return_t RetCode;
713 mach_msg_type_t terminalType;
714 mach_port_t terminal;
715 } Reply;
716
717 Request *In0P = (Request *) InHeadP;
718 Reply *OutP = (Reply *) OutHeadP;
719 mig_external kern_return_t S_termctty_open_terminal
720 (port_info_t ctty, int flags, mach_port_t *terminal, mach_msg_type_name_t *terminalPoly);
721
722 boolean_t msgh_simple = msgh_simple;
Assigned value is garbage or undefined
723 const mach_msg_type_t flagsCheck = {
724 /* msgt_name = */ 2,
725 /* msgt_size = */ 32,
726 /* msgt_number = */ 1,
727 /* msgt_inline = */ TRUE((boolean_t) 1),
728 /* msgt_longform = */ FALSE((boolean_t) 0),
729 /* msgt_deallocate = */ FALSE((boolean_t) 0),
730 /* msgt_unused = */ 0
731 };
732
733 const mach_msg_type_t terminalType = {
734 /* msgt_name = */ -1,
735 /* msgt_size = */ 32,
736 /* msgt_number = */ 1,
737 /* msgt_inline = */ TRUE((boolean_t) 1),
738 /* msgt_longform = */ FALSE((boolean_t) 0),
739 /* msgt_deallocate = */ FALSE((boolean_t) 0),
740 /* msgt_unused = */ 0
741 };
742
743 port_info_t ctty;
744 mach_msg_type_name_t terminalPoly;
745
746#if TypeCheck1
747 if (mig_unlikely ((In0P->Head.msgh_size != 32) ||__builtin_expect (!! ((In0P->Head.msgh_size != 32) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
748 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 32) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
749 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
750#endif /* TypeCheck */
751
752#if TypeCheck1
753 if (BAD_TYPECHECK(&In0P->flagsType, &flagsCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->flagsType); _c.t = *(&
flagsCheck);_t.w != _c.w; })), 0)
)
754 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
755#endif /* TypeCheck */
756
757 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
758 ctty = begin_using_ctty_payload(In0P->Head.msgh_protected_payload);
759 else
760 ctty = begin_using_ctty_port(In0P->Head.msgh_request_portmsgh_local_port);
761
762 OutP->RetCode = S_termctty_open_terminal(ctty, In0P->flags, &OutP->terminal, &terminalPoly);
763 end_using_ctty(ctty);
764 if (OutP->RetCode != KERN_SUCCESS0)
765 return;
766
767 msgh_simple = TRUE((boolean_t) 1);
768 OutP->Head.msgh_size = 40;
769
770 OutP->terminalType = terminalType;
771
772 if (MACH_MSG_TYPE_PORT_ANY(terminalPoly)(((terminalPoly) >= 16) && ((terminalPoly) <= 21
))
)
773 msgh_simple = FALSE((boolean_t) 0);
774
775 OutP->terminalType.msgt_name = terminalPoly;
776
777 if (!msgh_simple)
778 OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U;
779}
780
781/* Default implementation of S_termctty_open_terminal */
782#ifdef MIG_EOPNOTSUPP
783kern_return_t __attribute__ ((weak))
784S_termctty_open_terminal
785(
786 port_info_t ctty,
787 int flags,
788 mach_port_t *terminal,
789 mach_msg_type_name_t *terminalPoly
790) { return MIG_EOPNOTSUPP; }
791#endif /* MIG_EOPNOTSUPP */
792
793/* Routine term_get_peername */
794mig_internalstatic void _Xterm_get_peername
795 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
796{
797 typedef struct {
798 mach_msg_header_t Head;
799 } Request;
800
801 typedef struct {
802 mach_msg_header_t Head;
803 mach_msg_type_t RetCodeType;
804 kern_return_t RetCode;
805 mach_msg_type_t nameType;
806 string_t name;
807 } Reply;
808
809 Request *In0P = (Request *) InHeadP;
810 Reply *OutP = (Reply *) OutHeadP;
811 mig_external kern_return_t S_term_get_peername
812 (trivfs_protid_t terminal, string_t name);
813
814 const mach_msg_type_t nameType = {
815 /* msgt_name = */ MACH_MSG_TYPE_STRING_C12,
816 /* msgt_size = */ 8,
817 /* msgt_number = */ 1024,
818 /* msgt_inline = */ TRUE((boolean_t) 1),
819 /* msgt_longform = */ FALSE((boolean_t) 0),
820 /* msgt_deallocate = */ FALSE((boolean_t) 0),
821 /* msgt_unused = */ 0
822 };
823
824 trivfs_protid_t terminal;
825
826#if TypeCheck1
827 if (mig_unlikely ((In0P->Head.msgh_size != 24) ||__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
828 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
829 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
830#endif /* TypeCheck */
831
832 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
833 terminal = trivfs_begin_using_protid_payload(In0P->Head.msgh_protected_payload);
834 else
835 terminal = trivfs_begin_using_protid(In0P->Head.msgh_request_portmsgh_local_port);
836
837 OutP->RetCode = S_term_get_peername(terminal, OutP->name);
838 trivfs_end_using_protid(terminal);
839 if (OutP->RetCode != KERN_SUCCESS0)
840 return;
841
842 OutP->Head.msgh_size = 1060;
843
844 OutP->nameType = nameType;
845}
846
847/* Default implementation of S_term_get_peername */
848#ifdef MIG_EOPNOTSUPP
849kern_return_t __attribute__ ((weak))
850S_term_get_peername
851(
852 trivfs_protid_t terminal,
853 string_t name
854) { return MIG_EOPNOTSUPP; }
855#endif /* MIG_EOPNOTSUPP */
856
857mig_routine_t term_server_routines[] = {
858 _Xterm_getctty,
859 _Xterm_open_ctty,
860 _Xterm_set_nodename,
861 _Xterm_get_nodename,
862 _Xterm_set_filenode,
863 _Xterm_get_bottom_type,
864 _Xterm_on_machdev,
865 _Xterm_on_hurddev,
866 _Xterm_on_pty,
867 _Xtermctty_open_terminal,
868 _Xterm_get_peername,
869};
870
871mig_external boolean_t term_server
872 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
873{
874 mach_msg_header_t *InP = InHeadP;
875 mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP;
876
877 const mach_msg_type_t RetCodeType = {
878 /* msgt_name = */ MACH_MSG_TYPE_INTEGER_322,
879 /* msgt_size = */ 32,
880 /* msgt_number = */ 1,
881 /* msgt_inline = */ TRUE((boolean_t) 1),
882 /* msgt_longform = */ FALSE((boolean_t) 0),
883 /* msgt_deallocate = */ FALSE((boolean_t) 0),
884 /* msgt_unused = */ 0
885 };
886
887 mig_routine_t routine;
888
889 OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0)((((InP->msgh_bits) & 0x000000ff)) | ((0) << 8));
890 OutP->Head.msgh_size = sizeof *OutP;
891 OutP->Head.msgh_remote_port = InP->msgh_reply_portmsgh_remote_port;
892 OutP->Head.msgh_local_port = MACH_PORT_NULL((mach_port_t) 0);
893 OutP->Head.msgh_seqno = 0;
894 OutP->Head.msgh_id = InP->msgh_id + 100;
895
896 OutP->RetCodeType = RetCodeType;
897
898 if ((InP->msgh_id > 28010) || (InP->msgh_id < 28000) ||
899 ((routine = term_server_routines[InP->msgh_id - 28000]) == 0)) {
900 OutP->RetCode = MIG_BAD_ID-303;
901 return FALSE((boolean_t) 0);
902 }
903 (*routine) (InP, &OutP->Head);
904 return TRUE((boolean_t) 1);
905}
906
907mig_external mig_routine_t term_server_routine
908 (const mach_msg_header_t *InHeadP)
909{
910 int msgh_id;
911
912 msgh_id = InHeadP->msgh_id - 28000;
913
914 if ((msgh_id > 10) || (msgh_id < 0))
915 return 0;
916
917 return term_server_routines[msgh_id];
918}
919