ultrix_misc.c revision 1.31 1 1.31 jonathan /* $NetBSD: ultrix_misc.c,v 1.31 1997/04/26 02:00:11 jonathan Exp $ */
2 1.5 cgd
3 1.1 glass /*
4 1.30 jonathan * Copyright (c) 1995, 1997 Jonathan Stone (hereinafter referred to as the author)
5 1.30 jonathan * All rights reserved.
6 1.23 jonathan *
7 1.23 jonathan * Redistribution and use in source and binary forms, with or without
8 1.23 jonathan * modification, are permitted provided that the following conditions
9 1.23 jonathan * are met:
10 1.23 jonathan * 1. Redistributions of source code must retain the above copyright
11 1.23 jonathan * notice, this list of conditions and the following disclaimer.
12 1.23 jonathan * 2. Redistributions in binary form must reproduce the above copyright
13 1.23 jonathan * notice, this list of conditions and the following disclaimer in the
14 1.23 jonathan * documentation and/or other materials provided with the distribution.
15 1.28 jonathan * 3. All advertising materials mentioning features or use of this software
16 1.28 jonathan * must display the following acknowledgement:
17 1.28 jonathan * This product includes software developed by Matthew R. Green for
18 1.28 jonathan * the NetBSD Project.
19 1.28 jonathan * 4. The name of the author may not be used to endorse or promote products
20 1.23 jonathan * derived from this software without specific prior written permission.
21 1.23 jonathan *
22 1.23 jonathan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
23 1.23 jonathan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.23 jonathan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.23 jonathan * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
26 1.23 jonathan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.23 jonathan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.23 jonathan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.23 jonathan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.23 jonathan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.23 jonathan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.23 jonathan * SUCH DAMAGE.
33 1.23 jonathan */
34 1.23 jonathan
35 1.23 jonathan /*
36 1.1 glass * Copyright (c) 1992, 1993
37 1.1 glass * The Regents of the University of California. All rights reserved.
38 1.1 glass *
39 1.1 glass * This software was developed by the Computer Systems Engineering group
40 1.1 glass * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
41 1.1 glass * contributed to Berkeley.
42 1.1 glass *
43 1.1 glass * All advertising materials mentioning features or use of this software
44 1.1 glass * must display the following acknowledgement:
45 1.1 glass * This product includes software developed by the University of
46 1.1 glass * California, Lawrence Berkeley Laboratory.
47 1.1 glass *
48 1.1 glass * Redistribution and use in source and binary forms, with or without
49 1.1 glass * modification, are permitted provided that the following conditions
50 1.1 glass * are met:
51 1.1 glass * 1. Redistributions of source code must retain the above copyright
52 1.1 glass * notice, this list of conditions and the following disclaimer.
53 1.1 glass * 2. Redistributions in binary form must reproduce the above copyright
54 1.1 glass * notice, this list of conditions and the following disclaimer in the
55 1.1 glass * documentation and/or other materials provided with the distribution.
56 1.1 glass * 3. All advertising materials mentioning features or use of this software
57 1.1 glass * must display the following acknowledgement:
58 1.1 glass * This product includes software developed by the University of
59 1.1 glass * California, Berkeley and its contributors.
60 1.1 glass * 4. Neither the name of the University nor the names of its contributors
61 1.1 glass * may be used to endorse or promote products derived from this software
62 1.1 glass * without specific prior written permission.
63 1.1 glass *
64 1.1 glass * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
65 1.1 glass * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
66 1.1 glass * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
67 1.1 glass * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
68 1.1 glass * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
69 1.1 glass * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
70 1.1 glass * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
71 1.1 glass * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
72 1.1 glass * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
73 1.1 glass * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
74 1.1 glass * SUCH DAMAGE.
75 1.1 glass *
76 1.5 cgd *
77 1.1 glass * @(#)sun_misc.c 8.1 (Berkeley) 6/18/93
78 1.1 glass *
79 1.1 glass * from: Header: sun_misc.c,v 1.16 93/04/07 02:46:27 torek Exp
80 1.1 glass */
81 1.1 glass
82 1.1 glass /*
83 1.1 glass * SunOS compatibility module.
84 1.1 glass *
85 1.1 glass * SunOS system calls that are implemented differently in BSD are
86 1.1 glass * handled here.
87 1.1 glass */
88 1.1 glass
89 1.1 glass #include <sys/param.h>
90 1.1 glass #include <sys/systm.h>
91 1.1 glass #include <sys/namei.h>
92 1.25 mycroft #include <sys/dirent.h>
93 1.1 glass #include <sys/proc.h>
94 1.1 glass #include <sys/file.h>
95 1.1 glass #include <sys/filedesc.h>
96 1.20 jonathan /*#include <sys/stat.h>*/
97 1.20 jonathan /*#include <sys/ioctl.h>*/
98 1.1 glass #include <sys/kernel.h>
99 1.1 glass #include <sys/exec.h>
100 1.1 glass #include <sys/malloc.h>
101 1.1 glass #include <sys/mbuf.h>
102 1.1 glass #include <sys/mman.h>
103 1.1 glass #include <sys/mount.h>
104 1.1 glass #include <sys/resource.h>
105 1.1 glass #include <sys/resourcevar.h>
106 1.1 glass #include <sys/signal.h>
107 1.1 glass #include <sys/signalvar.h>
108 1.1 glass #include <sys/socket.h>
109 1.1 glass #include <sys/vnode.h>
110 1.1 glass #include <sys/uio.h>
111 1.1 glass #include <sys/wait.h>
112 1.1 glass #include <sys/utsname.h>
113 1.1 glass #include <sys/unistd.h>
114 1.30 jonathan #include <sys/ipc.h>
115 1.20 jonathan
116 1.16 mycroft #include <sys/syscallargs.h>
117 1.16 mycroft
118 1.16 mycroft #include <compat/ultrix/ultrix_syscall.h>
119 1.16 mycroft #include <compat/ultrix/ultrix_syscallargs.h>
120 1.30 jonathan #include <compat/common/compat_util.h>
121 1.1 glass
122 1.1 glass #include <netinet/in.h>
123 1.1 glass
124 1.1 glass #include <miscfs/specfs/specdev.h>
125 1.1 glass
126 1.3 glass #include <nfs/rpcv2.h>
127 1.21 pk #include <nfs/nfsproto.h>
128 1.3 glass #include <nfs/nfs.h>
129 1.3 glass
130 1.1 glass #include <vm/vm.h>
131 1.11 christos
132 1.23 jonathan #include <sys/conf.h> /* iszerodev() */
133 1.23 jonathan #include <sys/socketvar.h> /* sosetopt() */
134 1.23 jonathan
135 1.11 christos extern struct sysent ultrix_sysent[];
136 1.11 christos extern char *ultrix_syscallnames[];
137 1.22 jonathan
138 1.22 jonathan /*
139 1.22 jonathan * Select the appropriate setregs callback for the target architecture.
140 1.22 jonathan */
141 1.22 jonathan #ifdef mips
142 1.22 jonathan #define ULTRIX_EXEC_SETREGS cpu_exec_ecoff_setregs
143 1.22 jonathan #endif /* mips */
144 1.22 jonathan
145 1.22 jonathan #ifdef vax
146 1.22 jonathan #define ULTRIX_EXEC_SETREGS setregs
147 1.22 jonathan #endif /* mips */
148 1.22 jonathan
149 1.22 jonathan
150 1.22 jonathan extern void ULTRIX_EXEC_SETREGS __P((struct proc *, struct exec_package *,
151 1.11 christos u_long, register_t *));
152 1.19 jonathan extern char sigcode[], esigcode[];
153 1.19 jonathan
154 1.11 christos struct emul emul_ultrix = {
155 1.11 christos "ultrix",
156 1.11 christos NULL,
157 1.11 christos sendsig,
158 1.11 christos ULTRIX_SYS_syscall,
159 1.11 christos ULTRIX_SYS_MAXSYSCALL,
160 1.11 christos ultrix_sysent,
161 1.11 christos ultrix_syscallnames,
162 1.11 christos 0,
163 1.11 christos copyargs,
164 1.22 jonathan ULTRIX_EXEC_SETREGS,
165 1.19 jonathan sigcode,
166 1.19 jonathan esigcode,
167 1.11 christos };
168 1.1 glass
169 1.6 glass #define GSI_PROG_ENV 1
170 1.6 glass
171 1.23 jonathan int
172 1.16 mycroft ultrix_sys_getsysinfo(p, v, retval)
173 1.6 glass struct proc *p;
174 1.15 thorpej void *v;
175 1.16 mycroft register_t *retval;
176 1.6 glass {
177 1.16 mycroft struct ultrix_sys_getsysinfo_args *uap = v;
178 1.6 glass static short progenv = 0;
179 1.6 glass
180 1.16 mycroft switch (SCARG(uap, op)) {
181 1.6 glass /* operations implemented: */
182 1.6 glass case GSI_PROG_ENV:
183 1.16 mycroft if (SCARG(uap, nbytes) < sizeof(short))
184 1.6 glass return EINVAL;
185 1.6 glass *retval = 1;
186 1.16 mycroft return (copyout(&progenv, SCARG(uap, buffer), sizeof(short)));
187 1.6 glass default:
188 1.6 glass *retval = 0; /* info unavail */
189 1.6 glass return 0;
190 1.6 glass }
191 1.6 glass }
192 1.6 glass
193 1.23 jonathan int
194 1.16 mycroft ultrix_sys_setsysinfo(p, v, retval)
195 1.6 glass struct proc *p;
196 1.15 thorpej void *v;
197 1.16 mycroft register_t *retval;
198 1.6 glass {
199 1.23 jonathan
200 1.23 jonathan #ifdef notyet
201 1.16 mycroft struct ultrix_sys_setsysinfo_args *uap = v;
202 1.23 jonathan #endif
203 1.23 jonathan
204 1.6 glass *retval = 0;
205 1.6 glass return 0;
206 1.6 glass }
207 1.6 glass
208 1.23 jonathan int
209 1.16 mycroft ultrix_sys_waitpid(p, v, retval)
210 1.1 glass struct proc *p;
211 1.15 thorpej void *v;
212 1.7 cgd register_t *retval;
213 1.1 glass {
214 1.16 mycroft struct ultrix_sys_waitpid_args *uap = v;
215 1.16 mycroft struct sys_wait4_args ua;
216 1.1 glass
217 1.16 mycroft SCARG(&ua, pid) = SCARG(uap, pid);
218 1.16 mycroft SCARG(&ua, status) = SCARG(uap, status);
219 1.16 mycroft SCARG(&ua, options) = SCARG(uap, options);
220 1.16 mycroft SCARG(&ua, rusage) = 0;
221 1.1 glass
222 1.16 mycroft return (sys_wait4(p, &ua, retval));
223 1.2 glass }
224 1.2 glass
225 1.23 jonathan int
226 1.16 mycroft ultrix_sys_wait3(p, v, retval)
227 1.2 glass struct proc *p;
228 1.15 thorpej void *v;
229 1.7 cgd register_t *retval;
230 1.2 glass {
231 1.16 mycroft struct ultrix_sys_wait3_args *uap = v;
232 1.16 mycroft struct sys_wait4_args ua;
233 1.2 glass
234 1.16 mycroft SCARG(&ua, pid) = -1;
235 1.16 mycroft SCARG(&ua, status) = SCARG(uap, status);
236 1.16 mycroft SCARG(&ua, options) = SCARG(uap, options);
237 1.16 mycroft SCARG(&ua, rusage) = SCARG(uap, rusage);
238 1.1 glass
239 1.16 mycroft return (sys_wait4(p, &ua, retval));
240 1.1 glass }
241 1.1 glass
242 1.20 jonathan /*
243 1.20 jonathan * Ultrix binaries pass in FD_MAX as the first arg to select().
244 1.23 jonathan * On Ultrix, FD_MAX is 4096, which is more than the NetBSD sys_select()
245 1.20 jonathan * can handle.
246 1.23 jonathan * Since we can't have more than the (native) FD_MAX descriptors open,
247 1.23 jonathan * limit nfds to at most FD_MAX.
248 1.20 jonathan */
249 1.23 jonathan int
250 1.18 jonathan ultrix_sys_select(p, v, retval)
251 1.18 jonathan struct proc *p;
252 1.18 jonathan void *v;
253 1.18 jonathan register_t *retval;
254 1.18 jonathan {
255 1.18 jonathan struct sys_select_args *uap = v;
256 1.23 jonathan struct timeval atv;
257 1.18 jonathan int error;
258 1.18 jonathan
259 1.18 jonathan /* Limit number of FDs selected on to the native maximum */
260 1.18 jonathan
261 1.18 jonathan if (SCARG(uap, nd) > FD_SETSIZE)
262 1.18 jonathan SCARG(uap, nd) = FD_SETSIZE;
263 1.18 jonathan
264 1.18 jonathan /* Check for negative timeval */
265 1.18 jonathan if (SCARG(uap, tv)) {
266 1.18 jonathan error = copyin((caddr_t)SCARG(uap, tv), (caddr_t)&atv,
267 1.18 jonathan sizeof(atv));
268 1.18 jonathan if (error)
269 1.18 jonathan goto done;
270 1.18 jonathan #ifdef DEBUG
271 1.18 jonathan /* Ultrix clients sometimes give negative timeouts? */
272 1.18 jonathan if (atv.tv_sec < 0 || atv.tv_usec < 0)
273 1.27 christos printf("ultrix select( %ld, %ld): negative timeout\n",
274 1.26 christos atv.tv_sec, atv.tv_usec);
275 1.18 jonathan /*tvp = (timeval *)STACKGAPBASE;*/
276 1.18 jonathan #endif
277 1.18 jonathan
278 1.18 jonathan }
279 1.18 jonathan error = sys_select(p, (void*) uap, retval);
280 1.18 jonathan if (error == EINVAL)
281 1.27 christos printf("ultrix select: bad args?\n");
282 1.18 jonathan
283 1.18 jonathan done:
284 1.18 jonathan return error;
285 1.1 glass }
286 1.1 glass
287 1.29 thorpej #if defined(NFS)
288 1.23 jonathan int
289 1.16 mycroft async_daemon(p, v, retval)
290 1.1 glass struct proc *p;
291 1.15 thorpej void *v;
292 1.7 cgd register_t *retval;
293 1.1 glass {
294 1.16 mycroft struct sys_nfssvc_args ouap;
295 1.1 glass
296 1.16 mycroft SCARG(&ouap, flag) = NFSSVC_BIOD;
297 1.16 mycroft SCARG(&ouap, argp) = NULL;
298 1.3 glass
299 1.16 mycroft return (sys_nfssvc(p, &ouap, retval));
300 1.3 glass }
301 1.29 thorpej #endif /* NFS */
302 1.3 glass
303 1.1 glass
304 1.1 glass #define SUN__MAP_NEW 0x80000000 /* if not, old mmap & cannot handle */
305 1.1 glass
306 1.20 jonathan int
307 1.16 mycroft ultrix_sys_mmap(p, v, retval)
308 1.1 glass register struct proc *p;
309 1.15 thorpej void *v;
310 1.7 cgd register_t *retval;
311 1.1 glass {
312 1.16 mycroft register struct ultrix_sys_mmap_args *uap = v;
313 1.16 mycroft struct sys_mmap_args ouap;
314 1.1 glass register struct filedesc *fdp;
315 1.1 glass register struct file *fp;
316 1.1 glass register struct vnode *vp;
317 1.1 glass
318 1.1 glass /*
319 1.1 glass * Verify the arguments.
320 1.1 glass */
321 1.16 mycroft if (SCARG(uap, prot) & ~(PROT_READ|PROT_WRITE|PROT_EXEC))
322 1.1 glass return (EINVAL); /* XXX still needed? */
323 1.1 glass
324 1.16 mycroft if ((SCARG(uap, flags) & SUN__MAP_NEW) == 0)
325 1.1 glass return (EINVAL);
326 1.1 glass
327 1.16 mycroft SCARG(&ouap, flags) = SCARG(uap, flags) & ~SUN__MAP_NEW;
328 1.16 mycroft SCARG(&ouap, addr) = SCARG(uap, addr);
329 1.16 mycroft
330 1.16 mycroft if ((SCARG(&ouap, flags) & MAP_FIXED) == 0 &&
331 1.16 mycroft SCARG(&ouap, addr) != 0 &&
332 1.16 mycroft SCARG(&ouap, addr) < (caddr_t)round_page(p->p_vmspace->vm_daddr+MAXDSIZ))
333 1.16 mycroft SCARG(&ouap, addr) = (caddr_t)round_page(p->p_vmspace->vm_daddr+MAXDSIZ);
334 1.16 mycroft
335 1.16 mycroft SCARG(&ouap, len) = SCARG(uap, len);
336 1.16 mycroft SCARG(&ouap, prot) = SCARG(uap, prot);
337 1.16 mycroft SCARG(&ouap, fd) = SCARG(uap, fd);
338 1.16 mycroft SCARG(&ouap, pos) = SCARG(uap, pos);
339 1.1 glass
340 1.1 glass /*
341 1.1 glass * Special case: if fd refers to /dev/zero, map as MAP_ANON. (XXX)
342 1.1 glass */
343 1.1 glass fdp = p->p_fd;
344 1.16 mycroft if ((unsigned)SCARG(&ouap, fd) < fdp->fd_nfiles && /*XXX*/
345 1.16 mycroft (fp = fdp->fd_ofiles[SCARG(&ouap, fd)]) != NULL && /*XXX*/
346 1.1 glass fp->f_type == DTYPE_VNODE && /*XXX*/
347 1.1 glass (vp = (struct vnode *)fp->f_data)->v_type == VCHR && /*XXX*/
348 1.1 glass iszerodev(vp->v_rdev)) { /*XXX*/
349 1.16 mycroft SCARG(&ouap, flags) |= MAP_ANON;
350 1.16 mycroft SCARG(&ouap, fd) = -1;
351 1.1 glass }
352 1.1 glass
353 1.16 mycroft return (sys_mmap(p, &ouap, retval));
354 1.1 glass }
355 1.1 glass
356 1.23 jonathan int
357 1.16 mycroft ultrix_sys_setsockopt(p, v, retval)
358 1.1 glass struct proc *p;
359 1.15 thorpej void *v;
360 1.7 cgd register_t *retval;
361 1.1 glass {
362 1.16 mycroft register struct ultrix_sys_setsockopt_args *uap = v;
363 1.1 glass struct file *fp;
364 1.1 glass struct mbuf *m = NULL;
365 1.1 glass int error;
366 1.1 glass
367 1.23 jonathan if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
368 1.1 glass return (error);
369 1.1 glass #define SO_DONTLINGER (~SO_LINGER)
370 1.16 mycroft if (SCARG(uap, name) == SO_DONTLINGER) {
371 1.1 glass m = m_get(M_WAIT, MT_SOOPTS);
372 1.1 glass mtod(m, struct linger *)->l_onoff = 0;
373 1.1 glass m->m_len = sizeof(struct linger);
374 1.16 mycroft return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
375 1.1 glass SO_LINGER, m));
376 1.1 glass }
377 1.30 jonathan if (SCARG(uap, level) == IPPROTO_IP) {
378 1.30 jonathan #define EMUL_IP_MULTICAST_IF 2
379 1.30 jonathan #define EMUL_IP_MULTICAST_TTL 3
380 1.30 jonathan #define EMUL_IP_MULTICAST_LOOP 4
381 1.30 jonathan #define EMUL_IP_ADD_MEMBERSHIP 5
382 1.30 jonathan #define EMUL_IP_DROP_MEMBERSHIP 6
383 1.30 jonathan static int ipoptxlat[] = {
384 1.30 jonathan IP_MULTICAST_IF,
385 1.30 jonathan IP_MULTICAST_TTL,
386 1.30 jonathan IP_MULTICAST_LOOP,
387 1.30 jonathan IP_ADD_MEMBERSHIP,
388 1.30 jonathan IP_DROP_MEMBERSHIP
389 1.30 jonathan };
390 1.30 jonathan if (SCARG(uap, name) >= EMUL_IP_MULTICAST_IF &&
391 1.30 jonathan SCARG(uap, name) <= EMUL_IP_DROP_MEMBERSHIP) {
392 1.30 jonathan SCARG(uap, name) =
393 1.30 jonathan ipoptxlat[SCARG(uap, name) - EMUL_IP_MULTICAST_IF];
394 1.30 jonathan }
395 1.30 jonathan }
396 1.16 mycroft if (SCARG(uap, valsize) > MLEN)
397 1.1 glass return (EINVAL);
398 1.16 mycroft if (SCARG(uap, val)) {
399 1.1 glass m = m_get(M_WAIT, MT_SOOPTS);
400 1.30 jonathan error = copyin(SCARG(uap, val), mtod(m, caddr_t),
401 1.30 jonathan (u_int)SCARG(uap, valsize));
402 1.30 jonathan if (error) {
403 1.1 glass (void) m_free(m);
404 1.1 glass return (error);
405 1.1 glass }
406 1.16 mycroft m->m_len = SCARG(uap, valsize);
407 1.1 glass }
408 1.16 mycroft return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
409 1.16 mycroft SCARG(uap, name), m));
410 1.1 glass }
411 1.1 glass
412 1.16 mycroft struct ultrix_utsname {
413 1.1 glass char sysname[9];
414 1.1 glass char nodename[9];
415 1.1 glass char nodeext[65-9];
416 1.1 glass char release[9];
417 1.1 glass char version[9];
418 1.1 glass char machine[9];
419 1.1 glass };
420 1.1 glass
421 1.20 jonathan int
422 1.16 mycroft ultrix_sys_uname(p, v, retval)
423 1.1 glass struct proc *p;
424 1.15 thorpej void *v;
425 1.7 cgd register_t *retval;
426 1.1 glass {
427 1.16 mycroft struct ultrix_sys_uname_args *uap = v;
428 1.16 mycroft struct ultrix_utsname sut;
429 1.1 glass extern char ostype[], machine[], osrelease[];
430 1.1 glass
431 1.1 glass bzero(&sut, sizeof(sut));
432 1.1 glass
433 1.1 glass bcopy(ostype, sut.sysname, sizeof(sut.sysname) - 1);
434 1.1 glass bcopy(hostname, sut.nodename, sizeof(sut.nodename));
435 1.1 glass sut.nodename[sizeof(sut.nodename)-1] = '\0';
436 1.1 glass bcopy(osrelease, sut.release, sizeof(sut.release) - 1);
437 1.1 glass bcopy("1", sut.version, sizeof(sut.version) - 1);
438 1.1 glass bcopy(machine, sut.machine, sizeof(sut.machine) - 1);
439 1.1 glass
440 1.16 mycroft return copyout((caddr_t)&sut, (caddr_t)SCARG(uap, name),
441 1.16 mycroft sizeof(struct ultrix_utsname));
442 1.1 glass }
443 1.1 glass
444 1.1 glass int
445 1.16 mycroft ultrix_sys_setpgrp(p, v, retval)
446 1.1 glass struct proc *p;
447 1.15 thorpej void *v;
448 1.7 cgd register_t *retval;
449 1.1 glass {
450 1.16 mycroft struct ultrix_sys_setpgrp_args *uap = v;
451 1.15 thorpej
452 1.1 glass /*
453 1.1 glass * difference to our setpgid call is to include backwards
454 1.1 glass * compatibility to pre-setsid() binaries. Do setsid()
455 1.1 glass * instead of setpgid() in those cases where the process
456 1.1 glass * tries to create a new session the old way.
457 1.1 glass */
458 1.16 mycroft if (!SCARG(uap, pgid) &&
459 1.16 mycroft (!SCARG(uap, pid) || SCARG(uap, pid) == p->p_pid))
460 1.16 mycroft return sys_setsid(p, uap, retval);
461 1.1 glass else
462 1.16 mycroft return sys_setpgid(p, uap, retval);
463 1.1 glass }
464 1.1 glass
465 1.1 glass #if defined (NFSSERVER)
466 1.20 jonathan int
467 1.16 mycroft ultrix_sys_nfssvc(p, v, retval)
468 1.1 glass struct proc *p;
469 1.15 thorpej void *v;
470 1.7 cgd register_t *retval;
471 1.1 glass {
472 1.23 jonathan
473 1.23 jonathan #if 0 /* XXX */
474 1.16 mycroft struct ultrix_sys_nfssvc_args *uap = v;
475 1.16 mycroft struct emul *e = p->p_emul;
476 1.16 mycroft struct sys_nfssvc_args outuap;
477 1.1 glass struct sockaddr sa;
478 1.1 glass int error;
479 1.1 glass
480 1.1 glass bzero(&outuap, sizeof outuap);
481 1.16 mycroft SCARG(&outuap, fd) = SCARG(uap, fd);
482 1.16 mycroft SCARG(&outuap, mskval) = STACKGAPBASE;
483 1.16 mycroft SCARG(&outuap, msklen) = sizeof sa;
484 1.16 mycroft SCARG(&outuap, mtchval) = outuap.mskval + sizeof sa;
485 1.16 mycroft SCARG(&outuap, mtchlen) = sizeof sa;
486 1.1 glass
487 1.1 glass bzero(&sa, sizeof sa);
488 1.16 mycroft if (error = copyout(&sa, SCARG(&outuap, mskval), SCARG(&outuap, msklen)))
489 1.1 glass return (error);
490 1.16 mycroft if (error = copyout(&sa, SCARG(&outuap, mtchval), SCARG(&outuap, mtchlen)))
491 1.1 glass return (error);
492 1.1 glass
493 1.1 glass return nfssvc(p, &outuap, retval);
494 1.16 mycroft #else
495 1.16 mycroft return (ENOSYS);
496 1.16 mycroft #endif
497 1.1 glass }
498 1.1 glass #endif /* NFSSERVER */
499 1.1 glass
500 1.16 mycroft struct ultrix_ustat {
501 1.1 glass daddr_t f_tfree; /* total free */
502 1.1 glass ino_t f_tinode; /* total inodes free */
503 1.1 glass char f_fname[6]; /* filsys name */
504 1.1 glass char f_fpack[6]; /* filsys pack name */
505 1.1 glass };
506 1.16 mycroft
507 1.20 jonathan int
508 1.16 mycroft ultrix_sys_ustat(p, v, retval)
509 1.1 glass struct proc *p;
510 1.15 thorpej void *v;
511 1.7 cgd register_t *retval;
512 1.1 glass {
513 1.16 mycroft struct ultrix_sys_ustat_args *uap = v;
514 1.16 mycroft struct ultrix_ustat us;
515 1.1 glass int error;
516 1.1 glass
517 1.1 glass bzero(&us, sizeof us);
518 1.1 glass
519 1.1 glass /*
520 1.1 glass * XXX: should set f_tfree and f_tinode at least
521 1.16 mycroft * How do we translate dev -> fstat? (and then to ultrix_ustat)
522 1.1 glass */
523 1.1 glass
524 1.23 jonathan if ((error = copyout(&us, SCARG(uap, buf), sizeof us)) != 0)
525 1.1 glass return (error);
526 1.1 glass return 0;
527 1.1 glass }
528 1.1 glass
529 1.20 jonathan int
530 1.16 mycroft ultrix_sys_quotactl(p, v, retval)
531 1.1 glass struct proc *p;
532 1.15 thorpej void *v;
533 1.7 cgd register_t *retval;
534 1.1 glass {
535 1.23 jonathan
536 1.23 jonathan #ifdef notyet
537 1.16 mycroft struct ultrix_sys_quotactl_args *uap = v;
538 1.23 jonathan #endif
539 1.15 thorpej
540 1.1 glass return EINVAL;
541 1.1 glass }
542 1.1 glass
543 1.20 jonathan int
544 1.16 mycroft ultrix_sys_vhangup(p, v, retval)
545 1.1 glass struct proc *p;
546 1.16 mycroft void *v;
547 1.7 cgd register_t *retval;
548 1.1 glass {
549 1.16 mycroft
550 1.1 glass return 0;
551 1.1 glass }
552 1.1 glass
553 1.20 jonathan int
554 1.16 mycroft ultrix_sys_exportfs(p, v, retval)
555 1.1 glass struct proc *p;
556 1.15 thorpej void *v;
557 1.7 cgd register_t *retval;
558 1.1 glass {
559 1.23 jonathan #ifdef notyet
560 1.16 mycroft struct ultrix_sys_exportfs_args *uap = v;
561 1.23 jonathan #endif
562 1.15 thorpej
563 1.1 glass /*
564 1.1 glass * XXX: should perhaps translate into a mount(2)
565 1.1 glass * with MOUNT_EXPORT?
566 1.1 glass */
567 1.1 glass return 0;
568 1.1 glass }
569 1.1 glass
570 1.16 mycroft int
571 1.19 jonathan ultrix_sys_sigpending(p, v, retval)
572 1.19 jonathan struct proc *p;
573 1.19 jonathan void *v;
574 1.19 jonathan register_t *retval;
575 1.19 jonathan {
576 1.19 jonathan struct ultrix_sys_sigpending_args *uap = v;
577 1.19 jonathan int mask = p->p_siglist & p->p_sigmask;
578 1.19 jonathan
579 1.19 jonathan return (copyout((caddr_t)&mask, (caddr_t)SCARG(uap, mask), sizeof(int)));
580 1.19 jonathan }
581 1.19 jonathan
582 1.19 jonathan int
583 1.16 mycroft ultrix_sys_sigcleanup(p, v, retval)
584 1.13 mellon struct proc *p;
585 1.15 thorpej void *v;
586 1.13 mellon register_t *retval;
587 1.13 mellon {
588 1.16 mycroft struct ultrix_sys_sigcleanup_args *uap = v;
589 1.15 thorpej
590 1.16 mycroft return sys_sigreturn(p, (struct sys_sigreturn_args *)uap, retval);
591 1.19 jonathan }
592 1.19 jonathan
593 1.19 jonathan int
594 1.19 jonathan ultrix_sys_sigreturn(p, v, retval)
595 1.19 jonathan struct proc *p;
596 1.19 jonathan void *v;
597 1.19 jonathan register_t *retval;
598 1.19 jonathan {
599 1.19 jonathan struct ultrix_sys_sigcleanup_args *uap = v;
600 1.19 jonathan
601 1.19 jonathan #ifdef DEBUG
602 1.27 christos printf("ultrix sigreturn\n");
603 1.19 jonathan #endif
604 1.19 jonathan return sys_sigreturn(p, (struct sys_sigreturn_args *)uap, retval);
605 1.30 jonathan }
606 1.30 jonathan
607 1.30 jonathan ultrix_sys_shmsys(p, v, retval)
608 1.30 jonathan struct proc *p;
609 1.30 jonathan void *v;
610 1.30 jonathan register_t *retval;
611 1.30 jonathan {
612 1.30 jonathan
613 1.30 jonathan #ifdef SYSVSHM
614 1.30 jonathan
615 1.30 jonathan /* Ultrix SVSHM weirndess: */
616 1.30 jonathan struct ultrix_sys_shmsys_args *uap = v;
617 1.30 jonathan struct sys_shmat_args shmat_args;
618 1.30 jonathan struct sys_shmctl_args shmctl_args;
619 1.30 jonathan struct sys_shmdt_args shmdt_args;
620 1.30 jonathan struct sys_shmget_args shmget_args;
621 1.30 jonathan
622 1.30 jonathan
623 1.30 jonathan switch (SCARG(uap, shmop)) {
624 1.30 jonathan case 0: /* Ultrix shmat() */
625 1.30 jonathan SCARG(&shmat_args, shmid) = SCARG(uap, a2);
626 1.30 jonathan SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a3);
627 1.30 jonathan SCARG(&shmat_args, shmflg) = SCARG(uap, a4);
628 1.30 jonathan return (sys_shmat(p, &shmat_args, retval));
629 1.30 jonathan
630 1.30 jonathan case 1: /* Ultrix shmctl() */
631 1.30 jonathan SCARG(&shmctl_args, shmid) = SCARG(uap, a2);
632 1.30 jonathan SCARG(&shmctl_args, cmd) = SCARG(uap, a3);
633 1.30 jonathan SCARG(&shmctl_args, buf) = (struct shmid_ds *)SCARG(uap, a4);
634 1.30 jonathan return (sys_shmctl(p, &shmctl_args, retval));
635 1.30 jonathan
636 1.30 jonathan case 2: /* Ultrix shmdt() */
637 1.30 jonathan SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a2);
638 1.30 jonathan return (sys_shmdt(p, &shmdt_args, retval));
639 1.30 jonathan
640 1.30 jonathan case 3: /* Ultrix shmget() */
641 1.30 jonathan SCARG(&shmget_args, key) = SCARG(uap, a2);
642 1.30 jonathan SCARG(&shmget_args, size) = SCARG(uap, a3);
643 1.30 jonathan SCARG(&shmget_args, shmflg) = SCARG(uap, a4)
644 1.30 jonathan & (IPC_CREAT|IPC_EXCL|IPC_NOWAIT);
645 1.30 jonathan return (sys_shmget(p, &shmget_args, retval));
646 1.30 jonathan
647 1.30 jonathan default:
648 1.30 jonathan return (EINVAL);
649 1.30 jonathan }
650 1.31 jonathan #else
651 1.31 jonathan return (EOPNOTSUPP);
652 1.30 jonathan #endif /* SYSVSHM */
653 1.1 glass }
654