New interrupt code from Bruce Evans. In additional to Bruce's attached
[unix-history] / sys / kern / kern_xxx.c
CommitLineData
15637ed4
RG
1/*
2 * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
600f7f07 33 * from: @(#)kern_xxx.c 7.17 (Berkeley) 4/20/91
83d9efdd 34 * $Id: kern_xxx.c,v 1.6 1993/11/25 01:33:15 wollman Exp $
15637ed4
RG
35 */
36
37#include "param.h"
38#include "systm.h"
39#include "kernel.h"
40#include "proc.h"
41#include "reboot.h"
5da574a1 42#include "utsname.h"
15637ed4
RG
43
44/* ARGSUSED */
4c45483e 45int
15637ed4
RG
46gethostid(p, uap, retval)
47 struct proc *p;
48 void *uap;
49 long *retval;
50{
51
52 *retval = hostid;
53 return (0);
54}
55
3c7eb27c
DG
56struct sethostid_args {
57 long hostid;
58};
59
15637ed4 60/* ARGSUSED */
4c45483e 61int
15637ed4
RG
62sethostid(p, uap, retval)
63 struct proc *p;
3c7eb27c 64 struct sethostid_args *uap;
15637ed4
RG
65 int *retval;
66{
67 int error;
68
69 if (error = suser(p->p_ucred, &p->p_acflag))
70 return (error);
71 hostid = uap->hostid;
72 return (0);
73}
74
3c7eb27c
DG
75struct gethostname_args {
76 char *hostname;
77 u_int len;
78};
79
15637ed4 80/* ARGSUSED */
4c45483e 81int
15637ed4
RG
82gethostname(p, uap, retval)
83 struct proc *p;
3c7eb27c 84 struct gethostname_args *uap;
15637ed4
RG
85 int *retval;
86{
87
88 if (uap->len > hostnamelen + 1)
89 uap->len = hostnamelen + 1;
90 return (copyout((caddr_t)hostname, (caddr_t)uap->hostname, uap->len));
91}
92
3c7eb27c
DG
93struct sethostname_args {
94 char *hostname;
95 u_int len;
96};
97
15637ed4 98/* ARGSUSED */
4c45483e 99int
15637ed4
RG
100sethostname(p, uap, retval)
101 struct proc *p;
3c7eb27c 102 register struct sethostname_args *uap;
15637ed4
RG
103 int *retval;
104{
105 int error;
106
107 if (error = suser(p->p_ucred, &p->p_acflag))
108 return (error);
109 if (uap->len > sizeof (hostname) - 1)
110 return (EINVAL);
111 hostnamelen = uap->len;
112 error = copyin((caddr_t)uap->hostname, hostname, uap->len);
113 hostname[hostnamelen] = 0;
114 return (error);
115}
116
d0b34ea8
PR
117struct getdomainname_args {
118 char *domainname;
119 u_int len;
120};
121
122/* ARGSUSED */
123int
124getdomainname(p, uap, retval)
125 struct proc *p;
126 struct getdomainname_args *uap;
127 int *retval;
128{
129 if (uap->len > domainnamelen + 1)
130 uap->len = domainnamelen + 1;
131 return (copyout((caddr_t)domainname, (caddr_t)uap->domainname, uap->len));
132}
133
134struct setdomainname_args {
135 char *domainname;
136 u_int len;
137};
138
139/* ARGSUSED */
140int
141setdomainname(p, uap, retval)
142 struct proc *p;
143 struct setdomainname_args *uap;
144 int *retval;
145{
146 int error;
147
148 if (error = suser(p->p_ucred, &p->p_acflag))
149 return (error);
150 if (uap->len > sizeof (domainname) - 1)
151 return EINVAL;
152 domainnamelen = uap->len;
153 error = copyin((caddr_t)uap->domainname, domainname, uap->len);
154 domainname[domainnamelen] = 0;
155 return (error);
156}
157
5da574a1
JH
158struct uname_args {
159 struct utsname *name;
160};
161
162/* ARGSUSED */
163int
164uname(p, uap, retval)
165 struct proc *p;
166 struct uname_args *uap;
167 int *retval;
168{
169 bcopy(hostname, utsname.nodename, sizeof(utsname.nodename));
170 utsname.nodename[sizeof(utsname.nodename)-1] = '\0';
171 return (copyout((caddr_t)&utsname, (caddr_t)uap->name,
172 sizeof(struct utsname)));
173}
174
3c7eb27c
DG
175struct reboot_args {
176 int opt;
177};
178
15637ed4 179/* ARGSUSED */
4c45483e 180int
15637ed4
RG
181reboot(p, uap, retval)
182 struct proc *p;
3c7eb27c 183 struct reboot_args *uap;
15637ed4
RG
184 int *retval;
185{
186 int error;
187
188 if (error = suser(p->p_ucred, &p->p_acflag))
189 return (error);
190 boot(uap->opt);
191 return (0);
192}
193
194#ifdef COMPAT_43
4c45483e 195int
15637ed4
RG
196oquota()
197{
198
199 return (ENOSYS);
200}
201#endif
83d9efdd
NW
202
203
204void
205shutdown_nice(void)
206{
207 register struct proc *p;
208
209 /* Send a signal to init(8) and have it shutdown the world */
210 p = pfind(1);
211 psignal(p, SIGINT);
212
213 return;
214}