File: | obj-scan-build/boot/../../boot/boot.c |
Location: | line 1607, column 3 |
Description: | The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage |
1 | /* Load a task using the single server, and then run it | |||||
2 | as if we were the kernel. | |||||
3 | Copyright (C) 1993,94,95,96,97,98,99,2000,01,02,2006 | |||||
4 | Free Software Foundation, Inc. | |||||
5 | ||||||
6 | This file is part of the GNU Hurd. | |||||
7 | ||||||
8 | The GNU Hurd is free software; you can redistribute it and/or modify | |||||
9 | it under the terms of the GNU General Public License as published by | |||||
10 | the Free Software Foundation; either version 2, or (at your option) | |||||
11 | any later version. | |||||
12 | ||||||
13 | The GNU Hurd is distributed in the hope that it will be useful, | |||||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
16 | GNU General Public License for more details. | |||||
17 | ||||||
18 | You should have received a copy of the GNU General Public License | |||||
19 | along with the GNU Hurd; see the file COPYING. If not, write to | |||||
20 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |||||
21 | ||||||
22 | /* Written by Michael I. Bushnell. */ | |||||
23 | ||||||
24 | #include <mach.h> | |||||
25 | #include <mach/notify.h> | |||||
26 | #include <device/device.h> | |||||
27 | #include <a.out.h> | |||||
28 | #include <mach/message.h> | |||||
29 | #include <mach/mig_errors.h> | |||||
30 | #include <stdlib.h> | |||||
31 | #include <string.h> | |||||
32 | #include <stdio.h> | |||||
33 | #include <pthread.h> | |||||
34 | #include <fcntl.h> | |||||
35 | #include <elf.h> | |||||
36 | #include <mach/mig_support.h> | |||||
37 | #include <mach/default_pager.h> | |||||
38 | #include <mach/machine/vm_param.h> /* For VM_XXX_ADDRESS */ | |||||
39 | #include <argp.h> | |||||
40 | #include <hurd/store.h> | |||||
41 | #include <sys/mman.h> | |||||
42 | #include <version.h> | |||||
43 | ||||||
44 | #include "notify_S.h" | |||||
45 | #include "ourdevice_S.h" | |||||
46 | #include "io_S.h" | |||||
47 | #include "device_reply_U.h" | |||||
48 | #include "io_reply_U.h" | |||||
49 | #include "term_S.h" | |||||
50 | #include "bootstrap_S.h" | |||||
51 | /* #include "tioctl_S.h" */ | |||||
52 | ||||||
53 | #include "boot_script.h" | |||||
54 | ||||||
55 | #include <hurd/auth.h> | |||||
56 | ||||||
57 | #ifdef UX | |||||
58 | #undef STORE /* We can't use libstore when under UX. */ | |||||
59 | #else | |||||
60 | #define STORE | |||||
61 | #endif | |||||
62 | ||||||
63 | #ifdef UX | |||||
64 | ||||||
65 | #include "ux.h" | |||||
66 | ||||||
67 | #else /* !UX */ | |||||
68 | ||||||
69 | #include <unistd.h> | |||||
70 | #include <fcntl.h> | |||||
71 | #include <signal.h> | |||||
72 | #include <sys/ioctl.h> | |||||
73 | #include <sys/stat.h> | |||||
74 | #include <termios.h> | |||||
75 | #include <error.h> | |||||
76 | #include <hurd.h> | |||||
77 | #include <assert.h> | |||||
78 | ||||||
79 | static struct termios orig_tty_state; | |||||
80 | static int isig; | |||||
81 | static char *kernel_command_line; | |||||
82 | ||||||
83 | static void | |||||
84 | init_termstate () | |||||
85 | { | |||||
86 | struct termios tty_state; | |||||
87 | ||||||
88 | if (tcgetattr (0, &tty_state) < 0) | |||||
89 | error (10, errno(*__errno_location ()), "tcgetattr"); | |||||
90 | ||||||
91 | orig_tty_state = tty_state; | |||||
92 | cfmakeraw (&tty_state); | |||||
93 | if (isig) | |||||
94 | tty_state.c_lflag |= ISIG(1 << 7); | |||||
95 | ||||||
96 | if (tcsetattr (0, 0, &tty_state) < 0) | |||||
97 | error (11, errno(*__errno_location ()), "tcsetattr"); | |||||
98 | } | |||||
99 | ||||||
100 | static void | |||||
101 | restore_termstate () | |||||
102 | { | |||||
103 | tcsetattr (0, 0, &orig_tty_state); | |||||
104 | } | |||||
105 | ||||||
106 | #define host_fstatfstat fstat | |||||
107 | typedef struct stat host_stat_t; | |||||
108 | #define host_exitexit exit | |||||
109 | ||||||
110 | #endif /* UX */ | |||||
111 | ||||||
112 | mach_port_t privileged_host_port, master_device_port, defpager; | |||||
113 | mach_port_t pseudo_master_device_port; | |||||
114 | mach_port_t receive_set; | |||||
115 | mach_port_t pseudo_console, pseudo_root; | |||||
116 | auth_t authserver; | |||||
117 | ||||||
118 | struct store *root_store; | |||||
119 | ||||||
120 | pthread_spinlock_t queuelock = PTHREAD_SPINLOCK_INITIALIZER((__pthread_spinlock_t) 0); | |||||
121 | pthread_spinlock_t readlock = PTHREAD_SPINLOCK_INITIALIZER((__pthread_spinlock_t) 0); | |||||
122 | ||||||
123 | mach_port_t php_child_name, psmdp_child_name, taskname; | |||||
124 | ||||||
125 | task_t child_task; | |||||
126 | mach_port_t bootport; | |||||
127 | ||||||
128 | int console_mscount; | |||||
129 | ||||||
130 | vm_address_t fs_stack_base; | |||||
131 | vm_size_t fs_stack_size; | |||||
132 | ||||||
133 | void init_termstate (); | |||||
134 | void restore_termstate (); | |||||
135 | ||||||
136 | char *fsname; | |||||
137 | ||||||
138 | char bootstrap_args[100] = "-"; | |||||
139 | char *bootdevice = 0; | |||||
140 | char *bootscript = 0; | |||||
141 | ||||||
142 | ||||||
143 | void safe_gets (char *buf, int buf_len) | |||||
144 | { | |||||
145 | fgets (buf, buf_len, stdinstdin); | |||||
146 | } | |||||
147 | ||||||
148 | char *useropen_dir; | |||||
149 | ||||||
150 | int | |||||
151 | useropen (const char *name, int flags, int mode) | |||||
152 | { | |||||
153 | if (useropen_dir) | |||||
154 | { | |||||
155 | static int dlen; | |||||
156 | if (!dlen) dlen = strlen (useropen_dir); | |||||
157 | { | |||||
158 | int len = strlen (name); | |||||
159 | char try[dlen + 1 + len + 1]; | |||||
160 | int fd; | |||||
161 | memcpy (try, useropen_dir, dlen); | |||||
162 | try[dlen] = '/'; | |||||
163 | memcpy (&try[dlen + 1], name, len + 1); | |||||
164 | fd = open (try, flags, mode); | |||||
165 | if (fd >= 0) | |||||
166 | return fd; | |||||
167 | } | |||||
168 | } | |||||
169 | return open (name, flags, mode); | |||||
170 | } | |||||
171 | ||||||
172 | int | |||||
173 | request_server (mach_msg_header_t *inp, | |||||
174 | mach_msg_header_t *outp) | |||||
175 | { | |||||
176 | extern int io_server (mach_msg_header_t *, mach_msg_header_t *); | |||||
177 | extern int device_server (mach_msg_header_t *, mach_msg_header_t *); | |||||
178 | extern int notify_server (mach_msg_header_t *, mach_msg_header_t *); | |||||
179 | extern int term_server (mach_msg_header_t *, mach_msg_header_t *); | |||||
180 | /* extern int tioctl_server (mach_msg_header_t *, mach_msg_header_t *); */ | |||||
181 | extern int bootstrap_server (mach_msg_header_t *, mach_msg_header_t *); | |||||
182 | extern void bootstrap_compat (); | |||||
183 | ||||||
184 | #if 0 | |||||
185 | if (inp->msgh_local_port == bootport && boot_like_cmudef) | |||||
186 | { | |||||
187 | if (inp->msgh_id == 999999) | |||||
188 | { | |||||
189 | bootstrap_compat (inp, outp); | |||||
190 | return 1; | |||||
191 | } | |||||
192 | else | |||||
193 | return bootstrap_server (inp, outp); | |||||
194 | } | |||||
195 | else | |||||
196 | #endif | |||||
197 | return (io_server (inp, outp) | |||||
198 | || device_server (inp, outp) | |||||
199 | || notify_server (inp, outp) | |||||
200 | || term_server (inp, outp) | |||||
201 | /* || tioctl_server (inp, outp) */); | |||||
202 | } | |||||
203 | ||||||
204 | vm_address_t | |||||
205 | load_image (task_t t, | |||||
206 | char *file) | |||||
207 | { | |||||
208 | int fd; | |||||
209 | union | |||||
210 | { | |||||
211 | struct exec a; | |||||
212 | Elf32_Ehdr e; | |||||
213 | } hdr; | |||||
214 | char msg[] = ": cannot open bootstrap file\n"; | |||||
215 | ||||||
216 | fd = useropen (file, O_RDONLY0x0001, 0); | |||||
217 | ||||||
218 | if (fd == -1) | |||||
219 | { | |||||
220 | write (2, file, strlen (file)); | |||||
221 | write (2, msg, sizeof msg - 1); | |||||
222 | task_terminate (t); | |||||
223 | host_exitexit (1); | |||||
224 | } | |||||
225 | ||||||
226 | read (fd, &hdr, sizeof hdr); | |||||
227 | if (*(Elf32_Word *) hdr.e.e_ident == *(Elf32_Word *) "\177ELF") | |||||
228 | { | |||||
229 | Elf32_Phdr phdrs[hdr.e.e_phnum], *ph; | |||||
230 | lseek (fd, hdr.e.e_phoff, SEEK_SET0); | |||||
231 | read (fd, phdrs, sizeof phdrs); | |||||
232 | for (ph = phdrs; ph < &phdrs[sizeof phdrs/sizeof phdrs[0]]; ++ph) | |||||
233 | if (ph->p_type == PT_LOAD1) | |||||
234 | { | |||||
235 | vm_address_t buf; | |||||
236 | vm_size_t offs = ph->p_offset & (ph->p_align - 1); | |||||
237 | vm_size_t bufsz = round_page (ph->p_filesz + offs)((((vm_offset_t) (ph->p_filesz + offs) + __vm_page_size - 1 ) / __vm_page_size) * __vm_page_size); | |||||
238 | ||||||
239 | buf = (vm_address_t) mmap (0, bufsz, | |||||
240 | PROT_READ0x04|PROT_WRITE0x02, MAP_ANON0x0002, 0, 0); | |||||
241 | ||||||
242 | lseek (fd, ph->p_offset, SEEK_SET0); | |||||
243 | read (fd, (void *)(buf + offs), ph->p_filesz); | |||||
244 | ||||||
245 | ph->p_memsz = ((ph->p_vaddr + ph->p_memsz + ph->p_align - 1) | |||||
246 | & ~(ph->p_align - 1)); | |||||
247 | ph->p_vaddr &= ~(ph->p_align - 1); | |||||
248 | ph->p_memsz -= ph->p_vaddr; | |||||
249 | ||||||
250 | vm_allocate (t, (vm_address_t*)&ph->p_vaddr, ph->p_memsz, 0); | |||||
251 | vm_write (t, ph->p_vaddr, buf, bufsz); | |||||
252 | munmap ((caddr_t) buf, bufsz); | |||||
253 | vm_protect (t, ph->p_vaddr, ph->p_memsz, 0, | |||||
254 | ((ph->p_flags & PF_R(1 << 2)) ? VM_PROT_READ((vm_prot_t) 0x01) : 0) | | |||||
255 | ((ph->p_flags & PF_W(1 << 1)) ? VM_PROT_WRITE((vm_prot_t) 0x02) : 0) | | |||||
256 | ((ph->p_flags & PF_X(1 << 0)) ? VM_PROT_EXECUTE((vm_prot_t) 0x04) : 0)); | |||||
257 | } | |||||
258 | return hdr.e.e_entry; | |||||
259 | } | |||||
260 | else | |||||
261 | { | |||||
262 | /* a.out */ | |||||
263 | int magic = N_MAGIC (hdr.a)((hdr.a).a_info & 0xffff); | |||||
264 | int headercruft; | |||||
265 | vm_address_t base = 0x10000; | |||||
266 | int rndamount, amount; | |||||
267 | vm_address_t bsspagestart, bssstart; | |||||
268 | char *buf; | |||||
269 | ||||||
270 | headercruft = sizeof (struct exec) * (magic == ZMAGIC0413); | |||||
271 | ||||||
272 | amount = headercruft + hdr.a.a_text + hdr.a.a_data; | |||||
273 | rndamount = round_page (amount)((((vm_offset_t) (amount) + __vm_page_size - 1) / __vm_page_size ) * __vm_page_size); | |||||
274 | buf = mmap (0, rndamount, PROT_READ0x04|PROT_WRITE0x02, MAP_ANON0x0002, 0, 0); | |||||
275 | lseek (fd, sizeof hdr.a - headercruft, SEEK_SET0); | |||||
276 | read (fd, buf, amount); | |||||
277 | vm_allocate (t, &base, rndamount, 0); | |||||
278 | vm_write (t, base, (vm_address_t) buf, rndamount); | |||||
279 | if (magic != OMAGIC0407) | |||||
280 | vm_protect (t, base, trunc_page (headercruft + hdr.a.a_text)((((vm_offset_t) (headercruft + hdr.a.a_text)) / __vm_page_size ) * __vm_page_size), | |||||
281 | 0, VM_PROT_READ((vm_prot_t) 0x01) | VM_PROT_EXECUTE((vm_prot_t) 0x04)); | |||||
282 | munmap ((caddr_t) buf, rndamount); | |||||
283 | ||||||
284 | bssstart = base + hdr.a.a_text + hdr.a.a_data + headercruft; | |||||
285 | bsspagestart = round_page (bssstart)((((vm_offset_t) (bssstart) + __vm_page_size - 1) / __vm_page_size ) * __vm_page_size); | |||||
286 | vm_allocate (t, &bsspagestart, | |||||
287 | hdr.a.a_bss - (bsspagestart - bssstart), 0); | |||||
288 | ||||||
289 | return hdr.a.a_entry; | |||||
290 | } | |||||
291 | } | |||||
292 | ||||||
293 | ||||||
294 | void read_reply (); | |||||
295 | void * msg_thread (void *); | |||||
296 | ||||||
297 | /* Callbacks for boot_script.c; see boot_script.h. */ | |||||
298 | ||||||
299 | mach_port_t | |||||
300 | boot_script_read_file (const char *filename) | |||||
301 | { | |||||
302 | static const char msg[] = ": cannot open\n"; | |||||
303 | int fd = useropen (filename, O_RDONLY0x0001, 0); | |||||
304 | host_stat_t st; | |||||
305 | error_t err; | |||||
306 | mach_port_t memobj; | |||||
307 | vm_address_t region; | |||||
308 | ||||||
309 | write (2, filename, strlen (filename)); | |||||
310 | if (fd < 0) | |||||
311 | { | |||||
312 | write (2, msg, sizeof msg - 1); | |||||
313 | host_exitexit (1); | |||||
314 | } | |||||
315 | else | |||||
316 | write (2, msg + sizeof msg - 2, 1); | |||||
317 | ||||||
318 | host_fstatfstat (fd, &st); | |||||
319 | ||||||
320 | err = default_pager_object_create (defpager, &memobj, | |||||
321 | round_page (st.st_size)((((vm_offset_t) (st.st_size) + __vm_page_size - 1) / __vm_page_size ) * __vm_page_size)); | |||||
322 | if (err) | |||||
323 | { | |||||
324 | static const char msg[] = "cannot create default-pager object\n"; | |||||
325 | write (2, msg, sizeof msg - 1); | |||||
326 | host_exitexit (1); | |||||
327 | } | |||||
328 | ||||||
329 | region = 0; | |||||
330 | vm_map (mach_task_self ()((__mach_task_self_ + 0)), ®ion, round_page (st.st_size)((((vm_offset_t) (st.st_size) + __vm_page_size - 1) / __vm_page_size ) * __vm_page_size), | |||||
331 | 0, 1, memobj, 0, 0, VM_PROT_ALL(((vm_prot_t) 0x01)|((vm_prot_t) 0x02)|((vm_prot_t) 0x04)), VM_PROT_ALL(((vm_prot_t) 0x01)|((vm_prot_t) 0x02)|((vm_prot_t) 0x04)), VM_INHERIT_NONE((vm_inherit_t) 2)); | |||||
332 | read (fd, (char *) region, st.st_size); | |||||
333 | munmap ((caddr_t) region, round_page (st.st_size)((((vm_offset_t) (st.st_size) + __vm_page_size - 1) / __vm_page_size ) * __vm_page_size)); | |||||
334 | ||||||
335 | close (fd); | |||||
336 | return memobj; | |||||
337 | } | |||||
338 | ||||||
339 | int | |||||
340 | boot_script_exec_cmd (void *hook, | |||||
341 | mach_port_t task, char *path, int argc, | |||||
342 | char **argv, char *strings, int stringlen) | |||||
343 | { | |||||
344 | char *args, *p; | |||||
345 | int arg_len, i; | |||||
346 | size_t reg_size; | |||||
347 | void *arg_pos; | |||||
348 | vm_offset_t stack_start, stack_end; | |||||
349 | vm_address_t startpc, str_start; | |||||
350 | thread_t thread; | |||||
351 | ||||||
352 | write (2, path, strlen (path)); | |||||
353 | for (i = 1; i < argc; ++i) | |||||
354 | { | |||||
355 | write (2, " ", 1); | |||||
356 | write (2, argv[i], strlen (argv[i])); | |||||
357 | } | |||||
358 | write (2, "\r\n", 2); | |||||
359 | ||||||
360 | startpc = load_image (task, path); | |||||
361 | arg_len = stringlen + (argc + 2) * sizeof (char *) + sizeof (integer_t); | |||||
362 | arg_len += 5 * sizeof (int); | |||||
363 | stack_end = VM_MAX_ADDRESS(0x80000000UL); | |||||
364 | stack_start = VM_MAX_ADDRESS(0x80000000UL) - 16 * 1024 * 1024; | |||||
365 | vm_allocate (task, &stack_start, stack_end - stack_start, FALSE((boolean_t) 0)); | |||||
366 | arg_pos = (void *) ((stack_end - arg_len) & ~(sizeof (natural_t) - 1)); | |||||
367 | args = mmap (0, stack_end - trunc_page ((vm_offset_t) arg_pos)((((vm_offset_t) ((vm_offset_t) arg_pos)) / __vm_page_size) * __vm_page_size), | |||||
368 | PROT_READ0x04|PROT_WRITE0x02, MAP_ANON0x0002, 0, 0); | |||||
369 | str_start = ((vm_address_t) arg_pos | |||||
370 | + (argc + 2) * sizeof (char *) + sizeof (integer_t)); | |||||
371 | p = args + ((vm_address_t) arg_pos & (vm_page_size - 1)); | |||||
372 | *(int *) p = argc; | |||||
373 | p = (void *) p + sizeof (int); | |||||
374 | for (i = 0; i < argc; i++) | |||||
375 | { | |||||
376 | *(char **) p = argv[i] - strings + (char *) str_start; | |||||
377 | p = (void *) p + sizeof (char *); | |||||
378 | } | |||||
379 | *(char **) p = 0; | |||||
380 | p = (void *) p + sizeof (char *); | |||||
381 | *(char **) p = 0; | |||||
382 | p = (void *) p + sizeof (char *); | |||||
383 | memcpy (p, strings, stringlen); | |||||
384 | bzero (args, (vm_offset_t) arg_pos & (vm_page_size - 1)); | |||||
385 | vm_write (task, trunc_page ((vm_offset_t) arg_pos)((((vm_offset_t) ((vm_offset_t) arg_pos)) / __vm_page_size) * __vm_page_size), (vm_address_t) args, | |||||
386 | stack_end - trunc_page ((vm_offset_t) arg_pos)((((vm_offset_t) ((vm_offset_t) arg_pos)) / __vm_page_size) * __vm_page_size)); | |||||
387 | munmap ((caddr_t) args, | |||||
388 | stack_end - trunc_page ((vm_offset_t) arg_pos)((((vm_offset_t) ((vm_offset_t) arg_pos)) / __vm_page_size) * __vm_page_size)); | |||||
389 | ||||||
390 | thread_create (task, &thread); | |||||
391 | #ifdef i386_THREAD_STATE_COUNT(sizeof (struct i386_thread_state)/sizeof(unsigned int)) | |||||
392 | { | |||||
393 | struct i386_thread_state regs; | |||||
394 | reg_size = i386_THREAD_STATE_COUNT(sizeof (struct i386_thread_state)/sizeof(unsigned int)); | |||||
395 | thread_get_state (thread, i386_THREAD_STATE1, | |||||
396 | (thread_state_t) ®s, ®_size); | |||||
397 | regs.eip = (int) startpc; | |||||
398 | regs.uesp = (int) arg_pos; | |||||
399 | thread_set_state (thread, i386_THREAD_STATE1, | |||||
400 | (thread_state_t) ®s, reg_size); | |||||
401 | } | |||||
402 | #elif defined(ALPHA_THREAD_STATE_COUNT) | |||||
403 | { | |||||
404 | struct alpha_thread_state regs; | |||||
405 | reg_size = ALPHA_THREAD_STATE_COUNT; | |||||
406 | thread_get_state (thread, ALPHA_THREAD_STATE, | |||||
407 | (thread_state_t) ®s, ®_size); | |||||
408 | regs.r30 = (natural_t) arg_pos; | |||||
409 | regs.pc = (natural_t) startpc; | |||||
410 | thread_set_state (thread, ALPHA_THREAD_STATE, | |||||
411 | (thread_state_t) ®s, reg_size); | |||||
412 | } | |||||
413 | #else | |||||
414 | # error needs to be ported | |||||
415 | #endif | |||||
416 | ||||||
417 | thread_resume (thread); | |||||
418 | mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), thread); | |||||
419 | return 0; | |||||
420 | } | |||||
421 | ||||||
422 | const char *argp_program_version = STANDARD_HURD_VERSION (boot)"boot" " (GNU Hurd) " "0.5"; | |||||
423 | ||||||
424 | static struct argp_option options[] = | |||||
425 | { | |||||
426 | { "boot-root", 'D', "DIR", 0, | |||||
427 | "Root of a directory tree in which to find files specified in BOOT-SCRIPT" }, | |||||
428 | { "single-user", 's', 0, 0, | |||||
429 | "Boot in single user mode" }, | |||||
430 | { "kernel-command-line", 'c', "COMMAND LINE", 0, | |||||
431 | "Simulated multiboot command line to supply" }, | |||||
432 | { "pause" , 'd', 0, 0, | |||||
433 | "Pause for user confirmation at various times during booting" }, | |||||
434 | { "isig", 'I', 0, 0, | |||||
435 | "Do not disable terminal signals, so you can suspend and interrupt boot."}, | |||||
436 | { "device", 'f', "device_name=device_file", 0, | |||||
437 | "Specify a device file used by subhurd and its virtual name."}, | |||||
438 | { 0 } | |||||
439 | }; | |||||
440 | static char args_doc[] = "BOOT-SCRIPT"; | |||||
441 | static char doc[] = "Boot a second hurd"; | |||||
442 | ||||||
443 | struct dev_map | |||||
444 | { | |||||
445 | char *name; | |||||
446 | mach_port_t port; | |||||
447 | struct dev_map *next; | |||||
448 | }; | |||||
449 | ||||||
450 | static struct dev_map *dev_map_head; | |||||
451 | ||||||
452 | static struct dev_map *add_dev_map (char *dev_name, char *dev_file) | |||||
453 | { | |||||
454 | struct dev_map *map = malloc (sizeof (*map)); | |||||
455 | ||||||
456 | assert (map)((map) ? (void) (0) : __assert_fail ("map", "../../boot/boot.c" , 456, __PRETTY_FUNCTION__)); | |||||
457 | map->name = dev_name; | |||||
458 | map->port = file_name_lookup (dev_file, 0, 0); | |||||
459 | if (map->port == MACH_PORT_NULL((mach_port_t) 0)) | |||||
460 | error (1, errno(*__errno_location ()), "file_name_lookup: %s", dev_file); | |||||
461 | map->next = dev_map_head; | |||||
462 | dev_map_head = map; | |||||
463 | return map; | |||||
464 | } | |||||
465 | ||||||
466 | static struct dev_map *lookup_dev (char *dev_name) | |||||
467 | { | |||||
468 | struct dev_map *map; | |||||
469 | ||||||
470 | for (map = dev_map_head; map; map = map->next) | |||||
471 | { | |||||
472 | if (strcmp (map->name, dev_name) == 0) | |||||
473 | return map; | |||||
474 | } | |||||
475 | return NULL((void*)0); | |||||
476 | } | |||||
477 | ||||||
478 | static error_t | |||||
479 | parse_opt (int key, char *arg, struct argp_state *state) | |||||
480 | { | |||||
481 | char *dev_file; | |||||
482 | ||||||
483 | switch (key) | |||||
484 | { | |||||
485 | size_t len; | |||||
486 | ||||||
487 | case 'c': kernel_command_line = arg; break; | |||||
488 | ||||||
489 | case 'D': useropen_dir = arg; break; | |||||
490 | ||||||
491 | case 'I': isig = 1; break; | |||||
492 | ||||||
493 | case 's': case 'd': | |||||
494 | len = strlen (bootstrap_args); | |||||
495 | if (len >= sizeof bootstrap_args - 1) | |||||
496 | argp_error (state, "Too many bootstrap args"); | |||||
497 | bootstrap_args[len++] = key; | |||||
498 | bootstrap_args[len] = '\0'; | |||||
499 | break; | |||||
500 | ||||||
501 | case 'f': | |||||
502 | dev_file = strchr (arg, '='); | |||||
503 | if (dev_file == NULL((void*)0)) | |||||
504 | return ARGP_ERR_UNKNOWN((0x10 << 26) | ((7) & 0x3fff)); | |||||
505 | *dev_file = 0; | |||||
506 | add_dev_map (arg, dev_file+1); | |||||
507 | break; | |||||
508 | ||||||
509 | case ARGP_KEY_ARG0: | |||||
510 | if (state->arg_num == 0) | |||||
511 | bootscript = arg; | |||||
512 | else | |||||
513 | return ARGP_ERR_UNKNOWN((0x10 << 26) | ((7) & 0x3fff)); | |||||
514 | break; | |||||
515 | ||||||
516 | case ARGP_KEY_INIT0x1000003: | |||||
517 | state->child_inputs[0] = state->input; break; | |||||
518 | ||||||
519 | default: | |||||
520 | return ARGP_ERR_UNKNOWN((0x10 << 26) | ((7) & 0x3fff)); | |||||
521 | } | |||||
522 | return 0; | |||||
523 | } | |||||
524 | ||||||
525 | int | |||||
526 | main (int argc, char **argv, char **envp) | |||||
527 | { | |||||
528 | error_t err; | |||||
529 | mach_port_t foo; | |||||
530 | char *buf = 0; | |||||
531 | int i, len; | |||||
532 | pthread_t pthread_id; | |||||
533 | char *root_store_name; | |||||
534 | const struct argp_child kids[] = { { &store_argp }, { 0 }}; | |||||
535 | struct argp argp = { options, parse_opt, args_doc, doc, kids }; | |||||
536 | struct store_argp_params store_argp_params = { 0 }; | |||||
537 | ||||||
538 | argp_parse (&argp, argc, argv, 0, 0, &store_argp_params); | |||||
539 | err = store_parsed_name (store_argp_params.result, &root_store_name); | |||||
540 | if (err) | |||||
541 | error (2, err, "store_parsed_name"); | |||||
542 | ||||||
543 | err = store_parsed_open (store_argp_params.result, 0, &root_store); | |||||
544 | if (err) | |||||
545 | error (4, err, "%s", root_store_name); | |||||
546 | ||||||
547 | get_privileged_ports (&privileged_host_port, &master_device_port); | |||||
548 | ||||||
549 | defpager = MACH_PORT_NULL((mach_port_t) 0); | |||||
550 | vm_set_default_memory_manager (privileged_host_port, &defpager); | |||||
551 | ||||||
552 | strcat (bootstrap_args, "f"); | |||||
553 | ||||||
554 | mach_port_allocate (mach_task_self ()((__mach_task_self_ + 0)), MACH_PORT_RIGHT_PORT_SET((mach_port_right_t) 3), | |||||
555 | &receive_set); | |||||
556 | ||||||
557 | if (root_store->class == &store_device_class && root_store->name | |||||
558 | && (root_store->flags & STORE_ENFORCED0x2000) | |||||
559 | && root_store->num_runs == 1 && root_store->runs[0].start == 0) | |||||
560 | /* Let known device nodes pass through directly. */ | |||||
561 | bootdevice = root_store->name; | |||||
562 | else | |||||
563 | /* Pass a magic value that we can use to do I/O to ROOT_STORE. */ | |||||
564 | { | |||||
565 | bootdevice = "pseudo-root"; | |||||
566 | mach_port_allocate (mach_task_self ()((__mach_task_self_ + 0)), MACH_PORT_RIGHT_RECEIVE((mach_port_right_t) 1), | |||||
567 | &pseudo_root); | |||||
568 | mach_port_move_member (mach_task_self ()((__mach_task_self_ + 0)), pseudo_root, receive_set); | |||||
569 | } | |||||
570 | ||||||
571 | mach_port_allocate (mach_task_self ()((__mach_task_self_ + 0)), MACH_PORT_RIGHT_RECEIVE((mach_port_right_t) 1), | |||||
572 | &pseudo_master_device_port); | |||||
573 | mach_port_insert_right (mach_task_self ()((__mach_task_self_ + 0)), | |||||
574 | pseudo_master_device_port, | |||||
575 | pseudo_master_device_port, | |||||
576 | MACH_MSG_TYPE_MAKE_SEND20); | |||||
577 | mach_port_move_member (mach_task_self ()((__mach_task_self_ + 0)), pseudo_master_device_port, | |||||
578 | receive_set); | |||||
579 | mach_port_request_notification (mach_task_self ()((__mach_task_self_ + 0)), pseudo_master_device_port, | |||||
580 | MACH_NOTIFY_NO_SENDERS(0100 + 006), 1, | |||||
581 | pseudo_master_device_port, | |||||
582 | MACH_MSG_TYPE_MAKE_SEND_ONCE21, &foo); | |||||
583 | if (foo != MACH_PORT_NULL((mach_port_t) 0)) | |||||
584 | mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), foo); | |||||
585 | ||||||
586 | mach_port_allocate (mach_task_self ()((__mach_task_self_ + 0)), MACH_PORT_RIGHT_RECEIVE((mach_port_right_t) 1), | |||||
587 | &pseudo_console); | |||||
588 | mach_port_move_member (mach_task_self ()((__mach_task_self_ + 0)), pseudo_console, receive_set); | |||||
589 | mach_port_request_notification (mach_task_self ()((__mach_task_self_ + 0)), pseudo_console, | |||||
590 | MACH_NOTIFY_NO_SENDERS(0100 + 006), 1, pseudo_console, | |||||
591 | MACH_MSG_TYPE_MAKE_SEND_ONCE21, &foo); | |||||
592 | if (foo != MACH_PORT_NULL((mach_port_t) 0)) | |||||
593 | mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), foo); | |||||
594 | ||||||
595 | if (kernel_command_line == 0) | |||||
596 | asprintf (&kernel_command_line, "%s %s root=%s", | |||||
597 | argv[0], bootstrap_args, bootdevice); | |||||
598 | ||||||
599 | /* Initialize boot script variables. */ | |||||
600 | if (boot_script_set_variable ("host-port", VAL_PORT2, | |||||
601 | (int) privileged_host_port) | |||||
602 | || boot_script_set_variable ("device-port", VAL_PORT2, | |||||
603 | (integer_t) pseudo_master_device_port) | |||||
604 | || boot_script_set_variable ("kernel-command-line", VAL_STR1, | |||||
605 | (integer_t) kernel_command_line) | |||||
606 | || boot_script_set_variable ("root-device", | |||||
607 | VAL_STR1, (integer_t) bootdevice) | |||||
608 | || boot_script_set_variable ("boot-args", | |||||
609 | VAL_STR1, (integer_t) bootstrap_args)) | |||||
610 | { | |||||
611 | static const char msg[] = "error setting variable"; | |||||
612 | ||||||
613 | write (2, msg, strlen (msg)); | |||||
614 | host_exitexit (1); | |||||
615 | } | |||||
616 | ||||||
617 | /* Turn each `FOO=BAR' word in the command line into a boot script | |||||
618 | variable ${FOO} with value BAR. */ | |||||
619 | { | |||||
620 | int len = strlen (kernel_command_line) + 1; | |||||
621 | char *s = memcpy (alloca (len)__builtin_alloca (len), kernel_command_line, len); | |||||
622 | char *word; | |||||
623 | ||||||
624 | while ((word = strsep (&s, " \t")) != 0) | |||||
625 | { | |||||
626 | char *eq = strchr (word, '='); | |||||
627 | if (eq == 0) | |||||
628 | continue; | |||||
629 | *eq++ = '\0'; | |||||
630 | err = boot_script_set_variable (word, VAL_STR1, (integer_t) eq); | |||||
631 | if (err) | |||||
632 | { | |||||
633 | char *msg; | |||||
634 | asprintf (&msg, "cannot set boot-script variable %s: %s\n", | |||||
635 | word, boot_script_error_string (err)); | |||||
636 | assert (msg)((msg) ? (void) (0) : __assert_fail ("msg", "../../boot/boot.c" , 636, __PRETTY_FUNCTION__)); | |||||
637 | write (2, msg, strlen (msg)); | |||||
638 | free (msg); | |||||
639 | host_exitexit (1); | |||||
640 | } | |||||
641 | } | |||||
642 | } | |||||
643 | ||||||
644 | /* Parse the boot script. */ | |||||
645 | { | |||||
646 | char *p, *line; | |||||
647 | static const char filemsg[] = "Can't open boot script\n"; | |||||
648 | static const char memmsg[] = "Not enough memory\n"; | |||||
649 | int amt, fd, err; | |||||
650 | ||||||
651 | fd = open (bootscript, O_RDONLY0x0001, 0); | |||||
652 | if (fd < 0) | |||||
653 | { | |||||
654 | write (2, filemsg, sizeof (filemsg)); | |||||
655 | host_exitexit (1); | |||||
656 | } | |||||
657 | p = buf = malloc (500); | |||||
658 | if (!buf) | |||||
659 | { | |||||
660 | write (2, memmsg, sizeof (memmsg)); | |||||
661 | host_exitexit (1); | |||||
662 | } | |||||
663 | len = 500; | |||||
664 | amt = 0; | |||||
665 | while (1) | |||||
666 | { | |||||
667 | i = read (fd, p, len - (p - buf)); | |||||
668 | if (i <= 0) | |||||
669 | break; | |||||
670 | p += i; | |||||
671 | amt += i; | |||||
672 | if (p == buf + len) | |||||
673 | { | |||||
674 | char *newbuf; | |||||
675 | ||||||
676 | len += 500; | |||||
677 | newbuf = realloc (buf, len); | |||||
678 | if (!newbuf) | |||||
679 | { | |||||
680 | write (2, memmsg, sizeof (memmsg)); | |||||
681 | host_exitexit (1); | |||||
682 | } | |||||
683 | p = newbuf + (p - buf); | |||||
684 | buf = newbuf; | |||||
685 | } | |||||
686 | } | |||||
687 | line = p = buf; | |||||
688 | while (1) | |||||
689 | { | |||||
690 | while (p < buf + amt && *p != '\n') | |||||
691 | p++; | |||||
692 | *p = '\0'; | |||||
693 | err = boot_script_parse_line (0, line); | |||||
694 | if (err) | |||||
695 | { | |||||
696 | char *str; | |||||
697 | int i; | |||||
698 | ||||||
699 | str = boot_script_error_string (err); | |||||
700 | i = strlen (str); | |||||
701 | write (2, str, i); | |||||
702 | write (2, " in `", 5); | |||||
703 | write (2, line, strlen (line)); | |||||
704 | write (2, "'\n", 2); | |||||
705 | host_exitexit (1); | |||||
706 | } | |||||
707 | if (p == buf + amt) | |||||
708 | break; | |||||
709 | line = ++p; | |||||
710 | } | |||||
711 | } | |||||
712 | ||||||
713 | if (index (bootstrap_args, 'd')) | |||||
714 | { | |||||
715 | static const char msg[] = "Pausing. . ."; | |||||
716 | char c; | |||||
717 | write (2, msg, sizeof (msg) - 1); | |||||
718 | read (0, &c, 1); | |||||
719 | } | |||||
720 | ||||||
721 | init_termstate (); | |||||
722 | ||||||
723 | /* The boot script has now been parsed into internal data structures. | |||||
724 | Now execute its directives. */ | |||||
725 | { | |||||
726 | int err; | |||||
727 | ||||||
728 | err = boot_script_exec (); | |||||
729 | if (err) | |||||
730 | { | |||||
731 | char *str = boot_script_error_string (err); | |||||
732 | int i = strlen (str); | |||||
733 | ||||||
734 | write (2, str, i); | |||||
735 | write (2, "\n", 1); | |||||
736 | host_exitexit (1); | |||||
737 | } | |||||
738 | free (buf); | |||||
739 | } | |||||
740 | ||||||
741 | mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), pseudo_master_device_port); | |||||
742 | ||||||
743 | err = pthread_create (&pthread_id, NULL((void*)0), msg_thread, NULL((void*)0)); | |||||
744 | if (!err) | |||||
745 | pthread_detach (pthread_id); | |||||
746 | else | |||||
747 | { | |||||
748 | errno(*__errno_location ()) = err; | |||||
749 | perror ("pthread_create"); | |||||
750 | } | |||||
751 | ||||||
752 | for (;;) | |||||
753 | { | |||||
754 | fd_set rmask; | |||||
755 | FD_ZERO (&rmask)do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosl" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&rmask)->fds_bits)[0 ]) : "memory"); } while (0); | |||||
756 | FD_SET (0, &rmask)((void) (((&rmask)->fds_bits)[((0) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((0) % (8 * (int) sizeof (__fd_mask)))))); | |||||
757 | if (select (1, &rmask, 0, 0, 0) == 1) | |||||
758 | read_reply (); | |||||
759 | else /* We hosed */ | |||||
760 | error (5, errno(*__errno_location ()), "select"); | |||||
761 | } | |||||
762 | ||||||
763 | /* mach_msg_server (request_server, __vm_page_size * 2, receive_set); */ | |||||
764 | } | |||||
765 | ||||||
766 | void * | |||||
767 | msg_thread (void *arg) | |||||
768 | { | |||||
769 | while (1) | |||||
770 | mach_msg_server (request_server, 0, receive_set); | |||||
771 | } | |||||
772 | ||||||
773 | ||||||
774 | enum read_type | |||||
775 | { | |||||
776 | DEV_READ, | |||||
777 | DEV_READI, | |||||
778 | IO_READ, | |||||
779 | }; | |||||
780 | struct qr | |||||
781 | { | |||||
782 | enum read_type type; | |||||
783 | mach_port_t reply_port; | |||||
784 | mach_msg_type_name_t reply_type; | |||||
785 | int amount; | |||||
786 | struct qr *next; | |||||
787 | }; | |||||
788 | struct qr *qrhead, *qrtail; | |||||
789 | ||||||
790 | /* Queue a read for later reply. */ | |||||
791 | kern_return_t | |||||
792 | queue_read (enum read_type type, | |||||
793 | mach_port_t reply_port, | |||||
794 | mach_msg_type_name_t reply_type, | |||||
795 | int amount) | |||||
796 | { | |||||
797 | struct qr *qr; | |||||
798 | ||||||
799 | qr = malloc (sizeof (struct qr)); | |||||
800 | if (!qr) | |||||
801 | return D_NO_MEMORY2508; | |||||
802 | ||||||
803 | pthread_spin_lock (&queuelock); | |||||
804 | ||||||
805 | qr->type = type; | |||||
806 | qr->reply_port = reply_port; | |||||
807 | qr->reply_type = reply_type; | |||||
808 | qr->amount = amount; | |||||
809 | qr->next = 0; | |||||
810 | if (qrtail) | |||||
811 | qrtail->next = qr; | |||||
812 | else | |||||
813 | qrhead = qrtail = qr; | |||||
814 | ||||||
815 | pthread_spin_unlock (&queuelock); | |||||
816 | return D_SUCCESS0; | |||||
817 | } | |||||
818 | ||||||
819 | /* TRUE if there's data available on stdin, which should be used to satisfy | |||||
820 | console read requests. */ | |||||
821 | static int should_read = 0; | |||||
822 | ||||||
823 | /* Reply to a queued read. */ | |||||
824 | void | |||||
825 | read_reply () | |||||
826 | { | |||||
827 | int avail; | |||||
828 | struct qr *qr; | |||||
829 | char * buf; | |||||
830 | int amtread; | |||||
831 | ||||||
832 | /* By forcing SHOULD_READ to true before trying the lock, we ensure that | |||||
833 | either we get the lock ourselves or that whoever currently holds the | |||||
834 | lock will service this read when he unlocks it. */ | |||||
835 | should_read = 1; | |||||
836 | if (pthread_spin_trylock (&readlock)) | |||||
837 | return; | |||||
838 | ||||||
839 | /* Since we're committed to servicing the read, no one else need do so. */ | |||||
840 | should_read = 0; | |||||
841 | ||||||
842 | ioctl (0, FIONREAD(((127)) | ((((('f')) - 'f') | ((((0) | (((0) | ((1) | ((0) | ((0) | ((sizeof (int) == 8 ? IOC_64 : (sizeof (int) >> 1))) << 2) << 2) << 5) << 5) << 3))) | (IOC_OUT) << 19) << 4) << 7)), &avail); | |||||
843 | if (!avail) | |||||
844 | { | |||||
845 | pthread_spin_unlock (&readlock); | |||||
846 | return; | |||||
847 | } | |||||
848 | ||||||
849 | pthread_spin_lock (&queuelock); | |||||
850 | ||||||
851 | if (!qrhead) | |||||
852 | { | |||||
853 | pthread_spin_unlock (&queuelock); | |||||
854 | pthread_spin_unlock (&readlock); | |||||
855 | return; | |||||
856 | } | |||||
857 | ||||||
858 | qr = qrhead; | |||||
859 | qrhead = qr->next; | |||||
860 | if (qr == qrtail) | |||||
861 | qrtail = 0; | |||||
862 | ||||||
863 | pthread_spin_unlock (&queuelock); | |||||
864 | ||||||
865 | if (qr->type == DEV_READ) | |||||
866 | buf = mmap (0, qr->amount, PROT_READ0x04|PROT_WRITE0x02, MAP_ANON0x0002, 0, 0); | |||||
867 | else | |||||
868 | buf = alloca (qr->amount)__builtin_alloca (qr->amount); | |||||
869 | amtread = read (0, buf, qr->amount); | |||||
870 | ||||||
871 | pthread_spin_unlock (&readlock); | |||||
872 | ||||||
873 | switch (qr->type) | |||||
874 | { | |||||
875 | case DEV_READ: | |||||
876 | if (amtread >= 0) | |||||
877 | ds_device_read_reply (qr->reply_port, qr->reply_type, 0, | |||||
878 | (io_buf_ptr_t) buf, amtread); | |||||
879 | else | |||||
880 | ds_device_read_reply (qr->reply_port, qr->reply_type, errno(*__errno_location ()), 0, 0); | |||||
881 | break; | |||||
882 | ||||||
883 | case DEV_READI: | |||||
884 | if (amtread >= 0) | |||||
885 | ds_device_read_reply_inband (qr->reply_port, qr->reply_type, 0, | |||||
886 | buf, amtread); | |||||
887 | else | |||||
888 | ds_device_read_reply_inband (qr->reply_port, qr->reply_type, errno(*__errno_location ()), | |||||
889 | 0, 0); | |||||
890 | break; | |||||
891 | ||||||
892 | case IO_READ: | |||||
893 | if (amtread >= 0) | |||||
894 | io_read_reply (qr->reply_port, qr->reply_type, 0, | |||||
895 | buf, amtread); | |||||
896 | else | |||||
897 | io_read_reply (qr->reply_port, qr->reply_type, errno(*__errno_location ()), 0, 0); | |||||
898 | break; | |||||
899 | } | |||||
900 | ||||||
901 | free (qr); | |||||
902 | } | |||||
903 | ||||||
904 | /* Unlock READLOCK, and also service any new read requests that it was | |||||
905 | blocking. */ | |||||
906 | static void | |||||
907 | unlock_readlock () | |||||
908 | { | |||||
909 | pthread_spin_unlock (&readlock); | |||||
910 | while (should_read) | |||||
911 | read_reply (); | |||||
912 | } | |||||
913 | ||||||
914 | /* | |||||
915 | * Handle bootstrap requests. | |||||
916 | */ | |||||
917 | /* These two functions from .../mk/bootstrap/default_pager.c. */ | |||||
918 | ||||||
919 | kern_return_t | |||||
920 | do_bootstrap_privileged_ports(bootstrap, hostp, devicep) | |||||
921 | mach_port_t bootstrap; | |||||
922 | mach_port_t *hostp, *devicep; | |||||
923 | { | |||||
924 | *hostp = privileged_host_port; | |||||
925 | *devicep = pseudo_master_device_port; | |||||
926 | return KERN_SUCCESS0; | |||||
927 | } | |||||
928 | ||||||
929 | void | |||||
930 | bootstrap_compat(in, out) | |||||
931 | mach_msg_header_t *in, *out; | |||||
932 | { | |||||
933 | mig_reply_header_t *reply = (mig_reply_header_t *) out; | |||||
934 | mach_msg_return_t mr; | |||||
935 | ||||||
936 | struct imsg { | |||||
937 | mach_msg_header_t hdr; | |||||
938 | mach_msg_type_t port_desc_1; | |||||
939 | mach_port_t port_1; | |||||
940 | mach_msg_type_t port_desc_2; | |||||
941 | mach_port_t port_2; | |||||
942 | } imsg; | |||||
943 | ||||||
944 | /* | |||||
945 | * Send back the host and device ports. | |||||
946 | */ | |||||
947 | ||||||
948 | imsg.hdr.msgh_bits = MACH_MSGH_BITS_COMPLEX0x80000000U | | |||||
949 | MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(in->msgh_bits), 0)((((in->msgh_bits) & 0x000000ff)) | ((0) << 8)); | |||||
950 | /* msgh_size doesn't need to be initialized */ | |||||
951 | imsg.hdr.msgh_remote_port = in->msgh_remote_port; | |||||
952 | imsg.hdr.msgh_local_port = MACH_PORT_NULL((mach_port_t) 0); | |||||
953 | /* msgh_seqno doesn't need to be initialized */ | |||||
954 | imsg.hdr.msgh_id = in->msgh_id + 100; /* this is a reply msg */ | |||||
955 | ||||||
956 | imsg.port_desc_1.msgt_name = MACH_MSG_TYPE_COPY_SEND19; | |||||
957 | imsg.port_desc_1.msgt_size = (sizeof(mach_port_t) * 8); | |||||
958 | imsg.port_desc_1.msgt_number = 1; | |||||
959 | imsg.port_desc_1.msgt_inline = TRUE((boolean_t) 1); | |||||
960 | imsg.port_desc_1.msgt_longform = FALSE((boolean_t) 0); | |||||
961 | imsg.port_desc_1.msgt_deallocate = FALSE((boolean_t) 0); | |||||
962 | imsg.port_desc_1.msgt_unused = 0; | |||||
963 | ||||||
964 | imsg.port_1 = privileged_host_port; | |||||
965 | ||||||
966 | imsg.port_desc_2 = imsg.port_desc_1; | |||||
967 | ||||||
968 | imsg.port_desc_2.msgt_name = MACH_MSG_TYPE_MAKE_SEND20; | |||||
969 | imsg.port_2 = pseudo_master_device_port; | |||||
970 | ||||||
971 | /* | |||||
972 | * Send the reply message. | |||||
973 | * (mach_msg_server can not do this, because the reply | |||||
974 | * is not in standard format.) | |||||
975 | */ | |||||
976 | ||||||
977 | mr = mach_msg(&imsg.hdr, MACH_SEND_MSG0x00000001, | |||||
978 | sizeof imsg, 0, MACH_PORT_NULL((mach_port_t) 0), | |||||
979 | MACH_MSG_TIMEOUT_NONE((mach_msg_timeout_t) 0), MACH_PORT_NULL((mach_port_t) 0)); | |||||
980 | if (mr != MACH_MSG_SUCCESS0x00000000) | |||||
981 | (void) mach_port_deallocate(mach_task_self ()((__mach_task_self_ + 0)), | |||||
982 | imsg.hdr.msgh_remote_port); | |||||
983 | ||||||
984 | /* | |||||
985 | * Tell mach_msg_server to do nothing. | |||||
986 | */ | |||||
987 | ||||||
988 | reply->RetCode = MIG_NO_REPLY-305; | |||||
989 | } | |||||
990 | ||||||
991 | /* Implementation of device interface */ | |||||
992 | ||||||
993 | kern_return_t | |||||
994 | ds_device_open (mach_port_t master_port, | |||||
995 | mach_port_t reply_port, | |||||
996 | mach_msg_type_name_t reply_type, | |||||
997 | dev_mode_t mode, | |||||
998 | dev_name_t name, | |||||
999 | mach_port_t *device, | |||||
1000 | mach_msg_type_name_t *devicetype) | |||||
1001 | { | |||||
1002 | struct dev_map *map; | |||||
1003 | ||||||
1004 | if (master_port != pseudo_master_device_port) | |||||
1005 | return D_INVALID_OPERATION2505; | |||||
1006 | ||||||
1007 | if (!strcmp (name, "console")) | |||||
1008 | { | |||||
1009 | #if 0 | |||||
1010 | mach_port_insert_right (mach_task_self ()((__mach_task_self_ + 0)), pseudo_console, | |||||
1011 | pseudo_console, MACH_MSG_TYPE_MAKE_SEND20); | |||||
1012 | console_send_rights++; | |||||
1013 | #endif | |||||
1014 | console_mscount++; | |||||
1015 | *device = pseudo_console; | |||||
1016 | *devicetype = MACH_MSG_TYPE_MAKE_SEND20; | |||||
1017 | return 0; | |||||
1018 | } | |||||
1019 | else if (strcmp (name, "pseudo-root") == 0) | |||||
1020 | /* Magic root device. */ | |||||
1021 | { | |||||
1022 | *device = pseudo_root; | |||||
1023 | *devicetype = MACH_MSG_TYPE_MAKE_SEND20; | |||||
1024 | return 0; | |||||
1025 | } | |||||
1026 | ||||||
1027 | map = lookup_dev (name); | |||||
1028 | if (map) | |||||
1029 | { | |||||
1030 | *devicetype = MACH_MSG_TYPE_MOVE_SEND17; | |||||
1031 | return device_open (map->port, mode, "", device); | |||||
1032 | } | |||||
1033 | ||||||
1034 | *devicetype = MACH_MSG_TYPE_MOVE_SEND17; | |||||
1035 | return device_open (master_device_port, mode, name, device); | |||||
1036 | } | |||||
1037 | ||||||
1038 | kern_return_t | |||||
1039 | ds_device_close (device_t device) | |||||
1040 | { | |||||
1041 | if (device != pseudo_console && device != pseudo_root) | |||||
1042 | return D_NO_SUCH_DEVICE2502; | |||||
1043 | return 0; | |||||
1044 | } | |||||
1045 | ||||||
1046 | kern_return_t | |||||
1047 | ds_device_write (device_t device, | |||||
1048 | mach_port_t reply_port, | |||||
1049 | mach_msg_type_name_t reply_type, | |||||
1050 | dev_mode_t mode, | |||||
1051 | recnum_t recnum, | |||||
1052 | io_buf_ptr_t data, | |||||
1053 | size_t datalen, | |||||
1054 | int *bytes_written) | |||||
1055 | { | |||||
1056 | if (device == pseudo_console) | |||||
1057 | { | |||||
1058 | #if 0 | |||||
1059 | if (console_send_rights) | |||||
1060 | { | |||||
1061 | mach_port_mod_refs (mach_task_self ()((__mach_task_self_ + 0)), pseudo_console, | |||||
1062 | MACH_PORT_TYPE_SEND((mach_port_type_t)(1 << ((((mach_port_right_t) 0))+16) )), -console_send_rights); | |||||
1063 | console_send_rights = 0; | |||||
1064 | } | |||||
1065 | #endif | |||||
1066 | ||||||
1067 | *bytes_written = write (1, data, datalen); | |||||
1068 | ||||||
1069 | return (*bytes_written == -1 ? D_IO_ERROR2500 : D_SUCCESS0); | |||||
1070 | } | |||||
1071 | else if (device == pseudo_root) | |||||
1072 | { | |||||
1073 | size_t wrote; | |||||
1074 | if (store_write (root_store, recnum, data, datalen, &wrote) != 0) | |||||
1075 | return D_IO_ERROR2500; | |||||
1076 | *bytes_written = wrote; | |||||
1077 | return D_SUCCESS0; | |||||
1078 | } | |||||
1079 | else | |||||
1080 | return D_NO_SUCH_DEVICE2502; | |||||
1081 | } | |||||
1082 | ||||||
1083 | kern_return_t | |||||
1084 | ds_device_write_inband (device_t device, | |||||
1085 | mach_port_t reply_port, | |||||
1086 | mach_msg_type_name_t reply_type, | |||||
1087 | dev_mode_t mode, | |||||
1088 | recnum_t recnum, | |||||
1089 | io_buf_ptr_inband_t data, | |||||
1090 | size_t datalen, | |||||
1091 | int *bytes_written) | |||||
1092 | { | |||||
1093 | if (device == pseudo_console) | |||||
1094 | { | |||||
1095 | #if 0 | |||||
1096 | if (console_send_rights) | |||||
1097 | { | |||||
1098 | mach_port_mod_refs (mach_task_self ()((__mach_task_self_ + 0)), pseudo_console, | |||||
1099 | MACH_PORT_TYPE_SEND((mach_port_type_t)(1 << ((((mach_port_right_t) 0))+16) )), -console_send_rights); | |||||
1100 | console_send_rights = 0; | |||||
1101 | } | |||||
1102 | #endif | |||||
1103 | ||||||
1104 | *bytes_written = write (1, data, datalen); | |||||
1105 | ||||||
1106 | return (*bytes_written == -1 ? D_IO_ERROR2500 : D_SUCCESS0); | |||||
1107 | } | |||||
1108 | else if (device == pseudo_root) | |||||
1109 | { | |||||
1110 | size_t wrote; | |||||
1111 | if (store_write (root_store, recnum, data, datalen, &wrote) != 0) | |||||
1112 | return D_IO_ERROR2500; | |||||
1113 | *bytes_written = wrote; | |||||
1114 | return D_SUCCESS0; | |||||
1115 | } | |||||
1116 | else | |||||
1117 | return D_NO_SUCH_DEVICE2502; | |||||
1118 | } | |||||
1119 | ||||||
1120 | kern_return_t | |||||
1121 | ds_device_read (device_t device, | |||||
1122 | mach_port_t reply_port, | |||||
1123 | mach_msg_type_name_t reply_type, | |||||
1124 | dev_mode_t mode, | |||||
1125 | recnum_t recnum, | |||||
1126 | int bytes_wanted, | |||||
1127 | io_buf_ptr_t *data, | |||||
1128 | size_t *datalen) | |||||
1129 | { | |||||
1130 | if (device == pseudo_console) | |||||
1131 | { | |||||
1132 | int avail; | |||||
1133 | ||||||
1134 | #if 0 | |||||
1135 | if (console_send_rights) | |||||
1136 | { | |||||
1137 | mach_port_mod_refs (mach_task_self ()((__mach_task_self_ + 0)), pseudo_console, | |||||
1138 | MACH_PORT_TYPE_SEND((mach_port_type_t)(1 << ((((mach_port_right_t) 0))+16) )), -console_send_rights); | |||||
1139 | console_send_rights = 0; | |||||
1140 | } | |||||
1141 | #endif | |||||
1142 | ||||||
1143 | pthread_spin_lock (&readlock); | |||||
1144 | ioctl (0, FIONREAD(((127)) | ((((('f')) - 'f') | ((((0) | (((0) | ((1) | ((0) | ((0) | ((sizeof (int) == 8 ? IOC_64 : (sizeof (int) >> 1))) << 2) << 2) << 5) << 5) << 3))) | (IOC_OUT) << 19) << 4) << 7)), &avail); | |||||
1145 | if (avail) | |||||
1146 | { | |||||
1147 | *data = mmap (0, bytes_wanted, PROT_READ0x04|PROT_WRITE0x02, MAP_ANON0x0002, 0, 0); | |||||
1148 | *datalen = read (0, *data, bytes_wanted); | |||||
1149 | unlock_readlock (); | |||||
1150 | return (*datalen == -1 ? D_IO_ERROR2500 : D_SUCCESS0); | |||||
1151 | } | |||||
1152 | else | |||||
1153 | { | |||||
1154 | kern_return_t err; | |||||
1155 | ||||||
1156 | unlock_readlock (); | |||||
1157 | err = queue_read (DEV_READ, reply_port, reply_type, bytes_wanted); | |||||
1158 | if (err) | |||||
1159 | return err; | |||||
1160 | return MIG_NO_REPLY-305; | |||||
1161 | } | |||||
1162 | } | |||||
1163 | else if (device == pseudo_root) | |||||
1164 | { | |||||
1165 | *datalen = 0; | |||||
1166 | return | |||||
1167 | (store_read (root_store, recnum, bytes_wanted, (void **)data, datalen) == 0 | |||||
1168 | ? D_SUCCESS0 | |||||
1169 | : D_IO_ERROR2500); | |||||
1170 | } | |||||
1171 | else | |||||
1172 | return D_NO_SUCH_DEVICE2502; | |||||
1173 | } | |||||
1174 | ||||||
1175 | kern_return_t | |||||
1176 | ds_device_read_inband (device_t device, | |||||
1177 | mach_port_t reply_port, | |||||
1178 | mach_msg_type_name_t reply_type, | |||||
1179 | dev_mode_t mode, | |||||
1180 | recnum_t recnum, | |||||
1181 | int bytes_wanted, | |||||
1182 | io_buf_ptr_inband_t data, | |||||
1183 | size_t *datalen) | |||||
1184 | { | |||||
1185 | if (device == pseudo_console) | |||||
1186 | { | |||||
1187 | int avail; | |||||
1188 | ||||||
1189 | #if 0 | |||||
1190 | if (console_send_rights) | |||||
1191 | { | |||||
1192 | mach_port_mod_refs (mach_task_self ()((__mach_task_self_ + 0)), pseudo_console, | |||||
1193 | MACH_PORT_TYPE_SEND((mach_port_type_t)(1 << ((((mach_port_right_t) 0))+16) )), -console_send_rights); | |||||
1194 | console_send_rights = 0; | |||||
1195 | } | |||||
1196 | #endif | |||||
1197 | ||||||
1198 | pthread_spin_lock (&readlock); | |||||
1199 | ioctl (0, FIONREAD(((127)) | ((((('f')) - 'f') | ((((0) | (((0) | ((1) | ((0) | ((0) | ((sizeof (int) == 8 ? IOC_64 : (sizeof (int) >> 1))) << 2) << 2) << 5) << 5) << 3))) | (IOC_OUT) << 19) << 4) << 7)), &avail); | |||||
1200 | if (avail) | |||||
1201 | { | |||||
1202 | *datalen = read (0, data, bytes_wanted); | |||||
1203 | unlock_readlock (); | |||||
1204 | return (*datalen == -1 ? D_IO_ERROR2500 : D_SUCCESS0); | |||||
1205 | } | |||||
1206 | else | |||||
1207 | { | |||||
1208 | kern_return_t err; | |||||
1209 | ||||||
1210 | unlock_readlock (); | |||||
1211 | err = queue_read (DEV_READI, reply_port, reply_type, bytes_wanted); | |||||
1212 | if (err) | |||||
1213 | return err; | |||||
1214 | return MIG_NO_REPLY-305; | |||||
1215 | } | |||||
1216 | } | |||||
1217 | else if (device == pseudo_root) | |||||
1218 | { | |||||
1219 | error_t err; | |||||
1220 | void *returned = data; | |||||
1221 | ||||||
1222 | *datalen = bytes_wanted; | |||||
1223 | err = | |||||
1224 | store_read (root_store, recnum, bytes_wanted, (void **)&returned, datalen); | |||||
1225 | ||||||
1226 | if (! err) | |||||
1227 | { | |||||
1228 | if (returned != data) | |||||
1229 | { | |||||
1230 | bcopy (returned, (void *)data, *datalen); | |||||
1231 | munmap ((caddr_t) returned, *datalen); | |||||
1232 | } | |||||
1233 | return D_SUCCESS0; | |||||
1234 | } | |||||
1235 | else | |||||
1236 | return D_IO_ERROR2500; | |||||
1237 | } | |||||
1238 | else | |||||
1239 | return D_NO_SUCH_DEVICE2502; | |||||
1240 | } | |||||
1241 | ||||||
1242 | kern_return_t | |||||
1243 | ds_xxx_device_set_status (device_t device, | |||||
1244 | dev_flavor_t flavor, | |||||
1245 | dev_status_t status, | |||||
1246 | size_t statu_cnt) | |||||
1247 | { | |||||
1248 | if (device != pseudo_console) | |||||
1249 | return D_NO_SUCH_DEVICE2502; | |||||
1250 | return D_INVALID_OPERATION2505; | |||||
1251 | } | |||||
1252 | ||||||
1253 | kern_return_t | |||||
1254 | ds_xxx_device_get_status (device_t device, | |||||
1255 | dev_flavor_t flavor, | |||||
1256 | dev_status_t status, | |||||
1257 | size_t *statuscnt) | |||||
1258 | { | |||||
1259 | if (device != pseudo_console && device != pseudo_root) | |||||
1260 | return D_NO_SUCH_DEVICE2502; | |||||
1261 | return D_INVALID_OPERATION2505; | |||||
1262 | } | |||||
1263 | ||||||
1264 | kern_return_t | |||||
1265 | ds_xxx_device_set_filter (device_t device, | |||||
1266 | mach_port_t rec, | |||||
1267 | int pri, | |||||
1268 | filter_array_t filt, | |||||
1269 | size_t len) | |||||
1270 | { | |||||
1271 | if (device != pseudo_console && device != pseudo_root) | |||||
1272 | return D_NO_SUCH_DEVICE2502; | |||||
1273 | return D_INVALID_OPERATION2505; | |||||
1274 | } | |||||
1275 | ||||||
1276 | kern_return_t | |||||
1277 | ds_device_map (device_t device, | |||||
1278 | vm_prot_t prot, | |||||
1279 | vm_offset_t offset, | |||||
1280 | vm_size_t size, | |||||
1281 | memory_object_t *pager, | |||||
1282 | int unmap) | |||||
1283 | { | |||||
1284 | if (device != pseudo_console && device != pseudo_root) | |||||
1285 | return D_NO_SUCH_DEVICE2502; | |||||
1286 | return D_INVALID_OPERATION2505; | |||||
1287 | } | |||||
1288 | ||||||
1289 | kern_return_t | |||||
1290 | ds_device_set_status (device_t device, | |||||
1291 | dev_flavor_t flavor, | |||||
1292 | dev_status_t status, | |||||
1293 | size_t statuslen) | |||||
1294 | { | |||||
1295 | if (device != pseudo_console && device != pseudo_root) | |||||
1296 | return D_NO_SUCH_DEVICE2502; | |||||
1297 | return D_INVALID_OPERATION2505; | |||||
1298 | } | |||||
1299 | ||||||
1300 | kern_return_t | |||||
1301 | ds_device_get_status (device_t device, | |||||
1302 | dev_flavor_t flavor, | |||||
1303 | dev_status_t status, | |||||
1304 | size_t *statuslen) | |||||
1305 | { | |||||
1306 | if (device == pseudo_console) | |||||
1307 | return D_INVALID_OPERATION2505; | |||||
1308 | else if (device == pseudo_root) | |||||
1309 | if (flavor == DEV_GET_SIZE0) | |||||
1310 | if (*statuslen < DEV_GET_SIZE_COUNT2) | |||||
1311 | return D_INVALID_SIZE2507; | |||||
1312 | else | |||||
1313 | { | |||||
1314 | status[DEV_GET_SIZE_DEVICE_SIZE0] = root_store->size; | |||||
1315 | status[DEV_GET_SIZE_RECORD_SIZE1] = root_store->block_size; | |||||
1316 | *statuslen = DEV_GET_SIZE_COUNT2; | |||||
1317 | return D_SUCCESS0; | |||||
1318 | } | |||||
1319 | else | |||||
1320 | return D_INVALID_OPERATION2505; | |||||
1321 | else | |||||
1322 | return D_NO_SUCH_DEVICE2502; | |||||
1323 | } | |||||
1324 | ||||||
1325 | kern_return_t | |||||
1326 | ds_device_set_filter (device_t device, | |||||
1327 | mach_port_t receive_port, | |||||
1328 | int priority, | |||||
1329 | filter_array_t filter, | |||||
1330 | size_t filterlen) | |||||
1331 | { | |||||
1332 | if (device != pseudo_console && device != pseudo_root) | |||||
1333 | return D_NO_SUCH_DEVICE2502; | |||||
1334 | return D_INVALID_OPERATION2505; | |||||
1335 | } | |||||
1336 | ||||||
1337 | ||||||
1338 | /* Implementation of notify interface */ | |||||
1339 | kern_return_t | |||||
1340 | do_mach_notify_port_deleted (mach_port_t notify, | |||||
1341 | mach_port_t name) | |||||
1342 | { | |||||
1343 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1344 | } | |||||
1345 | ||||||
1346 | kern_return_t | |||||
1347 | do_mach_notify_msg_accepted (mach_port_t notify, | |||||
1348 | mach_port_t name) | |||||
1349 | { | |||||
1350 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1351 | } | |||||
1352 | ||||||
1353 | kern_return_t | |||||
1354 | do_mach_notify_port_destroyed (mach_port_t notify, | |||||
1355 | mach_port_t port) | |||||
1356 | { | |||||
1357 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1358 | } | |||||
1359 | ||||||
1360 | kern_return_t | |||||
1361 | do_mach_notify_no_senders (mach_port_t notify, | |||||
1362 | mach_port_mscount_t mscount) | |||||
1363 | { | |||||
1364 | static int no_console; | |||||
1365 | mach_port_t foo; | |||||
1366 | if (notify == pseudo_master_device_port) | |||||
1367 | { | |||||
1368 | if (no_console) | |||||
1369 | goto bye; | |||||
1370 | pseudo_master_device_port = MACH_PORT_NULL((mach_port_t) 0); | |||||
1371 | return 0; | |||||
1372 | } | |||||
1373 | if (notify == pseudo_console) | |||||
1374 | { | |||||
1375 | if (mscount == console_mscount && | |||||
1376 | pseudo_master_device_port == MACH_PORT_NULL((mach_port_t) 0)) | |||||
1377 | { | |||||
1378 | bye: | |||||
1379 | restore_termstate (); | |||||
1380 | write (2, "bye\n", 4); | |||||
1381 | host_exitexit (0); | |||||
1382 | } | |||||
1383 | else | |||||
1384 | { | |||||
1385 | no_console = (mscount == console_mscount); | |||||
1386 | ||||||
1387 | mach_port_request_notification (mach_task_self ()((__mach_task_self_ + 0)), pseudo_console, | |||||
1388 | MACH_NOTIFY_NO_SENDERS(0100 + 006), | |||||
1389 | console_mscount == mscount | |||||
1390 | ? mscount + 1 | |||||
1391 | : console_mscount, | |||||
1392 | pseudo_console, | |||||
1393 | MACH_MSG_TYPE_MAKE_SEND_ONCE21, &foo); | |||||
1394 | if (foo != MACH_PORT_NULL((mach_port_t) 0)) | |||||
1395 | mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), foo); | |||||
1396 | } | |||||
1397 | } | |||||
1398 | ||||||
1399 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1400 | } | |||||
1401 | ||||||
1402 | kern_return_t | |||||
1403 | do_mach_notify_send_once (mach_port_t notify) | |||||
1404 | { | |||||
1405 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1406 | } | |||||
1407 | ||||||
1408 | kern_return_t | |||||
1409 | do_mach_notify_dead_name (mach_port_t notify, | |||||
1410 | mach_port_t name) | |||||
1411 | { | |||||
1412 | #if 0 | |||||
1413 | if (name == child_task && notify == bootport) | |||||
1414 | host_exitexit (0); | |||||
1415 | #endif | |||||
1416 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1417 | } | |||||
1418 | ||||||
1419 | ||||||
1420 | /* Implementation of the Hurd I/O interface, which | |||||
1421 | we support for the console port only. */ | |||||
1422 | ||||||
1423 | kern_return_t | |||||
1424 | S_io_write (mach_port_t object, | |||||
1425 | mach_port_t reply_port, | |||||
1426 | mach_msg_type_name_t reply_type, | |||||
1427 | char *data, | |||||
1428 | mach_msg_type_number_t datalen, | |||||
1429 | off_t offset, | |||||
1430 | mach_msg_type_number_t *amtwritten) | |||||
1431 | { | |||||
1432 | if (object != pseudo_console) | |||||
1433 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1434 | ||||||
1435 | #if 0 | |||||
1436 | if (console_send_rights) | |||||
1437 | { | |||||
1438 | mach_port_mod_refs (mach_task_self ()((__mach_task_self_ + 0)), pseudo_console, | |||||
1439 | MACH_PORT_TYPE_SEND((mach_port_type_t)(1 << ((((mach_port_right_t) 0))+16) )), -console_send_rights); | |||||
1440 | console_send_rights = 0; | |||||
1441 | } | |||||
1442 | #endif | |||||
1443 | ||||||
1444 | *amtwritten = write (1, data, datalen); | |||||
1445 | return *amtwritten == -1 ? errno(*__errno_location ()) : 0; | |||||
1446 | } | |||||
1447 | ||||||
1448 | kern_return_t | |||||
1449 | S_io_read (mach_port_t object, | |||||
1450 | mach_port_t reply_port, | |||||
1451 | mach_msg_type_name_t reply_type, | |||||
1452 | char **data, | |||||
1453 | mach_msg_type_number_t *datalen, | |||||
1454 | off_t offset, | |||||
1455 | mach_msg_type_number_t amount) | |||||
1456 | { | |||||
1457 | mach_msg_type_number_t avail; | |||||
1458 | ||||||
1459 | if (object != pseudo_console) | |||||
1460 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1461 | ||||||
1462 | #if 0 | |||||
1463 | if (console_send_rights) | |||||
1464 | { | |||||
1465 | mach_port_mod_refs (mach_task_self ()((__mach_task_self_ + 0)), pseudo_console, | |||||
1466 | MACH_PORT_TYPE_SEND((mach_port_type_t)(1 << ((((mach_port_right_t) 0))+16) )), -console_send_rights); | |||||
1467 | console_send_rights = 0; | |||||
1468 | } | |||||
1469 | #endif | |||||
1470 | ||||||
1471 | pthread_spin_lock (&readlock); | |||||
1472 | ioctl (0, FIONREAD(((127)) | ((((('f')) - 'f') | ((((0) | (((0) | ((1) | ((0) | ((0) | ((sizeof (int) == 8 ? IOC_64 : (sizeof (int) >> 1))) << 2) << 2) << 5) << 5) << 3))) | (IOC_OUT) << 19) << 4) << 7)), &avail); | |||||
1473 | if (avail) | |||||
1474 | { | |||||
1475 | if (amount > *datalen) | |||||
1476 | *data = mmap (0, amount, PROT_READ0x04|PROT_WRITE0x02, MAP_ANON0x0002, 0, 0); | |||||
1477 | *datalen = read (0, *data, amount); | |||||
1478 | unlock_readlock (); | |||||
1479 | return *datalen == -1 ? errno(*__errno_location ()) : 0; | |||||
1480 | } | |||||
1481 | else | |||||
1482 | { | |||||
1483 | kern_return_t err; | |||||
1484 | unlock_readlock (); | |||||
1485 | err = queue_read (IO_READ, reply_port, reply_type, amount); | |||||
1486 | if (err) | |||||
1487 | return err; | |||||
1488 | return MIG_NO_REPLY-305; | |||||
1489 | } | |||||
1490 | } | |||||
1491 | ||||||
1492 | kern_return_t | |||||
1493 | S_io_seek (mach_port_t object, | |||||
1494 | mach_port_t reply_port, | |||||
1495 | mach_msg_type_name_t reply_type, | |||||
1496 | off_t offset, | |||||
1497 | int whence, | |||||
1498 | off_t *newp) | |||||
1499 | { | |||||
1500 | return object == pseudo_console ? ESPIPE((0x10 << 26) | ((29) & 0x3fff)) : EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1501 | } | |||||
1502 | ||||||
1503 | kern_return_t | |||||
1504 | S_io_readable (mach_port_t object, | |||||
1505 | mach_port_t reply_port, | |||||
1506 | mach_msg_type_name_t reply_type, | |||||
1507 | mach_msg_type_number_t *amt) | |||||
1508 | { | |||||
1509 | if (object != pseudo_console) | |||||
1510 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1511 | ioctl (0, FIONREAD(((127)) | ((((('f')) - 'f') | ((((0) | (((0) | ((1) | ((0) | ((0) | ((sizeof (int) == 8 ? IOC_64 : (sizeof (int) >> 1))) << 2) << 2) << 5) << 5) << 3))) | (IOC_OUT) << 19) << 4) << 7)), amt); | |||||
1512 | return 0; | |||||
1513 | } | |||||
1514 | ||||||
1515 | kern_return_t | |||||
1516 | S_io_set_all_openmodes (mach_port_t object, | |||||
1517 | mach_port_t reply_port, | |||||
1518 | mach_msg_type_name_t reply_type, | |||||
1519 | int bits) | |||||
1520 | { | |||||
1521 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1522 | } | |||||
1523 | ||||||
1524 | kern_return_t | |||||
1525 | S_io_get_openmodes (mach_port_t object, | |||||
1526 | mach_port_t reply_port, | |||||
1527 | mach_msg_type_name_t reply_type, | |||||
1528 | int *modes) | |||||
1529 | { | |||||
1530 | *modes = O_READ0x0001 | O_WRITE0x0002; | |||||
1531 | return object == pseudo_console ? 0 : EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1532 | } | |||||
1533 | ||||||
1534 | kern_return_t | |||||
1535 | S_io_set_some_openmodes (mach_port_t object, | |||||
1536 | mach_port_t reply_port, | |||||
1537 | mach_msg_type_name_t reply_type, | |||||
1538 | int bits) | |||||
1539 | { | |||||
1540 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1541 | } | |||||
1542 | ||||||
1543 | kern_return_t | |||||
1544 | S_io_clear_some_openmodes (mach_port_t object, | |||||
1545 | mach_port_t reply_port, | |||||
1546 | mach_msg_type_name_t reply_type, | |||||
1547 | int bits) | |||||
1548 | { | |||||
1549 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1550 | } | |||||
1551 | ||||||
1552 | kern_return_t | |||||
1553 | S_io_async (mach_port_t object, | |||||
1554 | mach_port_t reply_port, | |||||
1555 | mach_msg_type_name_t reply_type, | |||||
1556 | mach_port_t notify, | |||||
1557 | mach_port_t *id, | |||||
1558 | mach_msg_type_name_t *idtype) | |||||
1559 | { | |||||
1560 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1561 | } | |||||
1562 | ||||||
1563 | kern_return_t | |||||
1564 | S_io_mod_owner (mach_port_t object, | |||||
1565 | mach_port_t reply_port, | |||||
1566 | mach_msg_type_name_t reply_type, | |||||
1567 | pid_t owner) | |||||
1568 | { | |||||
1569 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1570 | } | |||||
1571 | ||||||
1572 | kern_return_t | |||||
1573 | S_io_get_owner (mach_port_t object, | |||||
1574 | mach_port_t reply_port, | |||||
1575 | mach_msg_type_name_t reply_type, | |||||
1576 | pid_t *owner) | |||||
1577 | { | |||||
1578 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1579 | } | |||||
1580 | ||||||
1581 | kern_return_t | |||||
1582 | S_io_get_icky_async_id (mach_port_t object, | |||||
1583 | mach_port_t reply_port, | |||||
1584 | mach_msg_type_name_t reply_type, | |||||
1585 | mach_port_t *id, | |||||
1586 | mach_msg_type_name_t *idtype) | |||||
1587 | { | |||||
1588 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1589 | } | |||||
1590 | ||||||
1591 | static kern_return_t | |||||
1592 | io_select_common (mach_port_t object, | |||||
1593 | mach_port_t reply_port, | |||||
1594 | mach_msg_type_name_t reply_type, | |||||
1595 | struct timespec *tsp, int *type) | |||||
1596 | { | |||||
1597 | struct timeval tv, *tvp; | |||||
1598 | fd_set r, w, x; | |||||
1599 | int n; | |||||
1600 | ||||||
1601 | if (object != pseudo_console) | |||||
1602 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1603 | ||||||
1604 | FD_ZERO (&r)do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosl" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&r)->fds_bits)[0]) : "memory"); } while (0); | |||||
1605 | FD_ZERO (&w)do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosl" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&w)->fds_bits)[0]) : "memory"); } while (0); | |||||
1606 | FD_ZERO (&x)do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosl" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&x)->fds_bits)[0]) : "memory"); } while (0); | |||||
1607 | FD_SET (0, &r)((void) (((&r)->fds_bits)[((0) / (8 * (int) sizeof (__fd_mask )))] |= ((__fd_mask) 1 << ((0) % (8 * (int) sizeof (__fd_mask )))))); | |||||
| ||||||
1608 | FD_SET (0, &w)((void) (((&w)->fds_bits)[((0) / (8 * (int) sizeof (__fd_mask )))] |= ((__fd_mask) 1 << ((0) % (8 * (int) sizeof (__fd_mask )))))); | |||||
1609 | FD_SET (0, &x)((void) (((&x)->fds_bits)[((0) / (8 * (int) sizeof (__fd_mask )))] |= ((__fd_mask) 1 << ((0) % (8 * (int) sizeof (__fd_mask )))))); | |||||
1610 | ||||||
1611 | if (tsp == NULL((void*)0)) | |||||
1612 | tvp = NULL((void*)0); | |||||
1613 | else | |||||
1614 | { | |||||
1615 | tv.tv_sec = tsp->tv_sec; | |||||
1616 | tv.tv_usec = tsp->tv_nsec / 1000; | |||||
1617 | tvp = &tv; | |||||
1618 | } | |||||
1619 | ||||||
1620 | n = select (1, | |||||
1621 | (*type & SELECT_READ0x00000001) ? &r : 0, | |||||
1622 | (*type & SELECT_WRITE0x00000002) ? &w : 0, | |||||
1623 | (*type & SELECT_URG0x00000004) ? &x : 0, | |||||
1624 | tvp); | |||||
1625 | if (n < 0) | |||||
1626 | return errno(*__errno_location ()); | |||||
1627 | ||||||
1628 | if (! FD_ISSET (0, &r)((((&r)->fds_bits)[((0) / (8 * (int) sizeof (__fd_mask )))] & ((__fd_mask) 1 << ((0) % (8 * (int) sizeof ( __fd_mask))))) != 0)) | |||||
1629 | *type &= ~SELECT_READ0x00000001; | |||||
1630 | if (! FD_ISSET (0, &w)((((&w)->fds_bits)[((0) / (8 * (int) sizeof (__fd_mask )))] & ((__fd_mask) 1 << ((0) % (8 * (int) sizeof ( __fd_mask))))) != 0)) | |||||
1631 | *type &= ~SELECT_WRITE0x00000002; | |||||
1632 | if (! FD_ISSET (0, &x)((((&x)->fds_bits)[((0) / (8 * (int) sizeof (__fd_mask )))] & ((__fd_mask) 1 << ((0) % (8 * (int) sizeof ( __fd_mask))))) != 0)) | |||||
1633 | *type &= ~SELECT_URG0x00000004; | |||||
1634 | ||||||
1635 | return 0; | |||||
1636 | } | |||||
1637 | ||||||
1638 | kern_return_t | |||||
1639 | S_io_select (mach_port_t object, | |||||
1640 | mach_port_t reply_port, | |||||
1641 | mach_msg_type_name_t reply_type, | |||||
1642 | int *type) | |||||
1643 | { | |||||
1644 | return io_select_common (object, reply_port, reply_type, NULL((void*)0), type); | |||||
1645 | } | |||||
1646 | ||||||
1647 | kern_return_t | |||||
1648 | S_io_select_timeout (mach_port_t object, | |||||
1649 | mach_port_t reply_port, | |||||
1650 | mach_msg_type_name_t reply_type, | |||||
1651 | struct timespec ts, | |||||
1652 | int *type) | |||||
1653 | { | |||||
1654 | return io_select_common (object, reply_port, reply_type, &ts, type); | |||||
| ||||||
1655 | } | |||||
1656 | ||||||
1657 | kern_return_t | |||||
1658 | S_io_stat (mach_port_t object, | |||||
1659 | mach_port_t reply_port, | |||||
1660 | mach_msg_type_name_t reply_type, | |||||
1661 | struct stat *st) | |||||
1662 | { | |||||
1663 | if (object != pseudo_console) | |||||
1664 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1665 | ||||||
1666 | bzero (st, sizeof (struct stat)); | |||||
1667 | st->st_blksize = 1024; | |||||
1668 | return 0; | |||||
1669 | } | |||||
1670 | ||||||
1671 | kern_return_t | |||||
1672 | S_io_reauthenticate (mach_port_t object, | |||||
1673 | mach_port_t reply_port, | |||||
1674 | mach_msg_type_name_t reply_type, | |||||
1675 | mach_port_t rend) | |||||
1676 | { | |||||
1677 | uid_t *gu, *au; | |||||
1678 | gid_t *gg, *ag; | |||||
1679 | size_t gulen = 0, aulen = 0, gglen = 0, aglen = 0; | |||||
1680 | error_t err; | |||||
1681 | ||||||
1682 | err = mach_port_insert_right (mach_task_self ()((__mach_task_self_ + 0)), object, object, | |||||
1683 | MACH_MSG_TYPE_MAKE_SEND20); | |||||
1684 | assert_perror (err)(!(err) ? (void) (0) : __assert_perror_fail ((err), "../../boot/boot.c" , 1684, __PRETTY_FUNCTION__)); | |||||
1685 | ||||||
1686 | if (! auth_server_authenticate (authserver, | |||||
1687 | rend, MACH_MSG_TYPE_COPY_SEND19, | |||||
1688 | object, MACH_MSG_TYPE_COPY_SEND19, | |||||
1689 | &gu, &gulen, | |||||
1690 | &au, &aulen, | |||||
1691 | &gg, &gglen, | |||||
1692 | &ag, &aglen)) | |||||
1693 | { | |||||
1694 | mig_deallocate ((vm_address_t) gu, gulen * sizeof *gu); | |||||
1695 | mig_deallocate ((vm_address_t) au, aulen * sizeof *gu); | |||||
1696 | mig_deallocate ((vm_address_t) gg, gglen * sizeof *gu); | |||||
1697 | mig_deallocate ((vm_address_t) au, aulen * sizeof *gu); | |||||
1698 | } | |||||
1699 | mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), rend); | |||||
1700 | mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), object); | |||||
1701 | ||||||
1702 | return 0; | |||||
1703 | } | |||||
1704 | ||||||
1705 | kern_return_t | |||||
1706 | S_io_restrict_auth (mach_port_t object, | |||||
1707 | mach_port_t reply_port, | |||||
1708 | mach_msg_type_name_t reply_type, | |||||
1709 | mach_port_t *newobject, | |||||
1710 | mach_msg_type_name_t *newobjtype, | |||||
1711 | uid_t *uids, | |||||
1712 | size_t nuids, | |||||
1713 | uid_t *gids, | |||||
1714 | size_t ngids) | |||||
1715 | { | |||||
1716 | if (object != pseudo_console) | |||||
1717 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1718 | *newobject = pseudo_console; | |||||
1719 | *newobjtype = MACH_MSG_TYPE_MAKE_SEND20; | |||||
1720 | console_mscount++; | |||||
1721 | return 0; | |||||
1722 | } | |||||
1723 | ||||||
1724 | kern_return_t | |||||
1725 | S_io_duplicate (mach_port_t object, | |||||
1726 | mach_port_t reply_port, | |||||
1727 | mach_msg_type_name_t reply_type, | |||||
1728 | mach_port_t *newobj, | |||||
1729 | mach_msg_type_name_t *newobjtype) | |||||
1730 | { | |||||
1731 | if (object != pseudo_console) | |||||
1732 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1733 | *newobj = pseudo_console; | |||||
1734 | *newobjtype = MACH_MSG_TYPE_MAKE_SEND20; | |||||
1735 | console_mscount++; | |||||
1736 | return 0; | |||||
1737 | } | |||||
1738 | ||||||
1739 | kern_return_t | |||||
1740 | S_io_server_version (mach_port_t object, | |||||
1741 | mach_port_t reply_port, | |||||
1742 | mach_msg_type_name_t reply_type, | |||||
1743 | char *name, | |||||
1744 | int *maj, | |||||
1745 | int *min, | |||||
1746 | int *edit) | |||||
1747 | { | |||||
1748 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1749 | } | |||||
1750 | ||||||
1751 | kern_return_t | |||||
1752 | S_io_map (mach_port_t obj, | |||||
1753 | mach_port_t reply_port, | |||||
1754 | mach_msg_type_name_t reply_type, | |||||
1755 | mach_port_t *rd, | |||||
1756 | mach_msg_type_name_t *rdtype, | |||||
1757 | mach_port_t *wr, | |||||
1758 | mach_msg_type_name_t *wrtype) | |||||
1759 | { | |||||
1760 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1761 | } | |||||
1762 | ||||||
1763 | kern_return_t | |||||
1764 | S_io_map_cntl (mach_port_t obj, | |||||
1765 | mach_port_t reply_port, | |||||
1766 | mach_msg_type_name_t reply_type, | |||||
1767 | mach_port_t *mem, | |||||
1768 | mach_msg_type_name_t *memtype) | |||||
1769 | { | |||||
1770 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1771 | } | |||||
1772 | ||||||
1773 | kern_return_t | |||||
1774 | S_io_get_conch (mach_port_t obj, | |||||
1775 | mach_port_t reply_port, | |||||
1776 | mach_msg_type_name_t reply_type) | |||||
1777 | { | |||||
1778 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1779 | } | |||||
1780 | ||||||
1781 | kern_return_t | |||||
1782 | S_io_release_conch (mach_port_t obj, | |||||
1783 | mach_port_t reply_port, | |||||
1784 | mach_msg_type_name_t reply_type) | |||||
1785 | { | |||||
1786 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1787 | } | |||||
1788 | ||||||
1789 | kern_return_t | |||||
1790 | S_io_eofnotify (mach_port_t obj, | |||||
1791 | mach_port_t reply_port, | |||||
1792 | mach_msg_type_name_t reply_type) | |||||
1793 | ||||||
1794 | { | |||||
1795 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1796 | } | |||||
1797 | ||||||
1798 | kern_return_t | |||||
1799 | S_io_prenotify (mach_port_t obj, | |||||
1800 | mach_port_t reply_port, | |||||
1801 | mach_msg_type_name_t reply_type, | |||||
1802 | vm_offset_t start, | |||||
1803 | vm_offset_t end) | |||||
1804 | { | |||||
1805 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1806 | } | |||||
1807 | ||||||
1808 | kern_return_t | |||||
1809 | S_io_postnotify (mach_port_t obj, | |||||
1810 | mach_port_t reply_port, | |||||
1811 | mach_msg_type_name_t reply_type, | |||||
1812 | vm_offset_t start, | |||||
1813 | vm_offset_t end) | |||||
1814 | { | |||||
1815 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1816 | } | |||||
1817 | ||||||
1818 | kern_return_t | |||||
1819 | S_io_readsleep (mach_port_t obj, | |||||
1820 | mach_port_t reply_port, | |||||
1821 | mach_msg_type_name_t reply_type) | |||||
1822 | { | |||||
1823 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1824 | } | |||||
1825 | ||||||
1826 | kern_return_t | |||||
1827 | S_io_readnotify (mach_port_t obj, | |||||
1828 | mach_port_t reply_port, | |||||
1829 | mach_msg_type_name_t reply_type) | |||||
1830 | { | |||||
1831 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1832 | } | |||||
1833 | ||||||
1834 | ||||||
1835 | kern_return_t | |||||
1836 | S_io_sigio (mach_port_t obj, | |||||
1837 | mach_port_t reply_port, | |||||
1838 | mach_msg_type_name_t reply_type) | |||||
1839 | { | |||||
1840 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1841 | } | |||||
1842 | ||||||
1843 | ||||||
1844 | kern_return_t | |||||
1845 | S_io_pathconf (mach_port_t obj, | |||||
1846 | mach_port_t reply_port, | |||||
1847 | mach_msg_type_name_t reply_type, | |||||
1848 | int name, int *value) | |||||
1849 | { | |||||
1850 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1851 | } | |||||
1852 | ||||||
1853 | kern_return_t | |||||
1854 | S_io_identity (mach_port_t obj, | |||||
1855 | mach_port_t reply, | |||||
1856 | mach_msg_type_name_t replytype, | |||||
1857 | mach_port_t *id, | |||||
1858 | mach_msg_type_name_t *idtype, | |||||
1859 | mach_port_t *fsid, | |||||
1860 | mach_msg_type_name_t *fsidtype, | |||||
1861 | ino_t *fileno) | |||||
1862 | { | |||||
1863 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1864 | } | |||||
1865 | ||||||
1866 | kern_return_t | |||||
1867 | S_io_revoke (mach_port_t obj, | |||||
1868 | mach_port_t reply, mach_msg_type_name_t replyPoly) | |||||
1869 | { | |||||
1870 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1871 | } | |||||
1872 | ||||||
1873 | ||||||
1874 | ||||||
1875 | /* Implementation of the Hurd terminal driver interface, which we only | |||||
1876 | support on the console device. */ | |||||
1877 | ||||||
1878 | kern_return_t | |||||
1879 | S_termctty_open_terminal (mach_port_t object, | |||||
1880 | int flags, | |||||
1881 | mach_port_t *result, | |||||
1882 | mach_msg_type_name_t *restype) | |||||
1883 | { | |||||
1884 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1885 | } | |||||
1886 | ||||||
1887 | kern_return_t | |||||
1888 | S_term_getctty (mach_port_t object, | |||||
1889 | mach_port_t *cttyid, mach_msg_type_name_t *cttyPoly) | |||||
1890 | { | |||||
1891 | static mach_port_t id = MACH_PORT_NULL((mach_port_t) 0); | |||||
1892 | ||||||
1893 | if (object != pseudo_console) | |||||
1894 | return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); | |||||
1895 | ||||||
1896 | if (id == MACH_PORT_NULL((mach_port_t) 0)) | |||||
1897 | mach_port_allocate (mach_task_self ()((__mach_task_self_ + 0)), MACH_PORT_RIGHT_DEAD_NAME((mach_port_right_t) 4), &id); | |||||
1898 | ||||||
1899 | *cttyid = id; | |||||
1900 | *cttyPoly = MACH_MSG_TYPE_COPY_SEND19; | |||||
1901 | return 0; | |||||
1902 | } | |||||
1903 | ||||||
1904 | ||||||
1905 | kern_return_t S_term_open_ctty | |||||
1906 | ( | |||||
1907 | io_t terminal, | |||||
1908 | pid_t pid, | |||||
1909 | pid_t pgrp, | |||||
1910 | mach_port_t *newtty, | |||||
1911 | mach_msg_type_name_t *newttytype | |||||
1912 | ) | |||||
1913 | { return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); } | |||||
1914 | ||||||
1915 | kern_return_t S_term_set_nodename | |||||
1916 | ( | |||||
1917 | io_t terminal, | |||||
1918 | string_t name | |||||
1919 | ) | |||||
1920 | { return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); } | |||||
1921 | ||||||
1922 | kern_return_t S_term_get_nodename | |||||
1923 | ( | |||||
1924 | io_t terminal, | |||||
1925 | string_t name | |||||
1926 | ) | |||||
1927 | { return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); } | |||||
1928 | ||||||
1929 | kern_return_t S_term_get_peername | |||||
1930 | ( | |||||
1931 | io_t terminal, | |||||
1932 | string_t name | |||||
1933 | ) | |||||
1934 | { return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); } | |||||
1935 | ||||||
1936 | kern_return_t S_term_set_filenode | |||||
1937 | ( | |||||
1938 | io_t terminal, | |||||
1939 | file_t filenode | |||||
1940 | ) | |||||
1941 | { return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); } | |||||
1942 | ||||||
1943 | kern_return_t S_term_get_bottom_type | |||||
1944 | ( | |||||
1945 | io_t terminal, | |||||
1946 | int *ttype | |||||
1947 | ) | |||||
1948 | { return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); } | |||||
1949 | ||||||
1950 | kern_return_t S_term_on_machdev | |||||
1951 | ( | |||||
1952 | io_t terminal, | |||||
1953 | mach_port_t machdev | |||||
1954 | ) | |||||
1955 | { return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); } | |||||
1956 | ||||||
1957 | kern_return_t S_term_on_hurddev | |||||
1958 | ( | |||||
1959 | io_t terminal, | |||||
1960 | io_t hurddev | |||||
1961 | ) | |||||
1962 | { return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); } | |||||
1963 | ||||||
1964 | kern_return_t S_term_on_pty | |||||
1965 | ( | |||||
1966 | io_t terminal, | |||||
1967 | io_t *ptymaster | |||||
1968 | ) | |||||
1969 | { return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff)); } |