1 /* $NetBSD: irix_misc.c,v 1.11 2007/12/20 23:02:50 dsl Exp $ */
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: irix_misc.c,v 1.11 2007/12/20 23:02:50 dsl Exp $");
35 #include <sys/types.h>
36 #include <sys/signal.h>
37 #include <sys/systm.h>
38 #include <sys/param.h>
39 #include <sys/kernel.h>
41 #include <sys/mount.h>
42 #include <sys/syscallargs.h>
44 #include <compat/svr4/svr4_types.h>
45 #include <compat/svr4/svr4_lwp.h>
46 #include <compat/svr4/svr4_signal.h>
47 #include <compat/svr4/svr4_ucontext.h>
48 #include <compat/svr4/svr4_utsname.h>
49 #include <compat/svr4/svr4_syscallargs.h>
51 #include <compat/irix/irix_types.h>
52 #include <compat/irix/irix_signal.h>
53 #include <compat/irix/irix_exec.h>
54 #include <compat/irix/irix_sysctl.h>
55 #include <compat/irix/irix_syscallargs.h>
58 * This is copied from sys/compat/sunos/sunos_misc.c:sunos_sys_setpgrp()
59 * Maybe consider moving this to sys/compat/common/compat_util.c?
62 irix_sys_setpgrp(struct lwp
*l
, const struct irix_sys_setpgrp_args
*uap
, register_t
*retval
)
68 struct proc
*p
= l
->l_proc
;
71 * difference to our setpgid call is to include backwards
72 * compatibility to pre-setsid() binaries. Do setsid()
73 * instead of setpgid() in those cases where the process
74 * tries to create a new session the old way.
76 if (!SCARG(uap
, pgid
) &&
77 (!SCARG(uap
, pid
) || SCARG(uap
, pid
) == p
->p_pid
))
78 return sys_setsid(l
, uap
, retval
);
80 return sys_setpgid(l
, (const void *)uap
, retval
);
86 irix_sys_uname(struct lwp
*l
, const struct irix_sys_uname_args
*uap
, register_t
*retval
)
89 syscallarg(struct irix_utsname *) name;
91 struct irix_utsname sut
;
92 char irix_release
[BUF_SIZE
+ 1];
94 snprintf(irix_release
, sizeof(irix_release
), "%s.%s",
95 irix_si_osrel_maj
, irix_si_osrel_min
);
96 memset(&sut
, 0, sizeof(sut
));
98 strncpy(sut
.sysname
, irix_si_os_name
, sizeof(sut
.sysname
));
99 sut
.sysname
[sizeof(sut
.sysname
) - 1] = '\0';
101 strncpy(sut
.nodename
, hostname
, sizeof(sut
.nodename
));
102 sut
.nodename
[sizeof(sut
.nodename
) - 1] = '\0';
104 strncpy(sut
.release
, irix_release
, sizeof(sut
.release
));
105 sut
.release
[sizeof(sut
.release
) - 1] = '\0';
107 strncpy(sut
.version
, irix_si_version
, sizeof(sut
.version
));
108 sut
.version
[sizeof(sut
.version
) - 1] = '\0';
110 strncpy(sut
.machine
, irix_si_hw_name
, sizeof(sut
.machine
));
111 sut
.machine
[sizeof(sut
.machine
) - 1] = '\0';
113 return copyout((void *) &sut
, (void *) SCARG(uap
, name
),
114 sizeof(struct irix_utsname
));
118 irix_sys_utssys(struct lwp
*l
, const struct irix_sys_utssys_args
*uap
, register_t
*retval
)
121 syscallarg(void *) a1;
122 syscallarg(void *) a2;
127 switch (SCARG(uap
, sel
)) {
128 case 0: { /* uname(2) */
129 struct irix_sys_uname_args ua
;
130 SCARG(&ua
, name
) = SCARG(uap
, a1
);
131 return irix_sys_uname(l
, &ua
, retval
);
136 return(svr4_sys_utssys(l
, (const void *)uap
, retval
));