Accounting patch:
[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
RG
33 * from: @(#)kern_xxx.c 7.17 (Berkeley) 4/20/91
34 * $Id$
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 */
45gethostid(p, uap, retval)
46 struct proc *p;
47 void *uap;
48 long *retval;
49{
50
51 *retval = hostid;
52 return (0);
53}
54
3c7eb27c
DG
55struct sethostid_args {
56 long hostid;
57};
58
15637ed4
RG
59/* ARGSUSED */
60sethostid(p, uap, retval)
61 struct proc *p;
3c7eb27c 62 struct sethostid_args *uap;
15637ed4
RG
63 int *retval;
64{
65 int error;
66
67 if (error = suser(p->p_ucred, &p->p_acflag))
68 return (error);
69 hostid = uap->hostid;
70 return (0);
71}
72
3c7eb27c
DG
73struct gethostname_args {
74 char *hostname;
75 u_int len;
76};
77
15637ed4
RG
78/* ARGSUSED */
79gethostname(p, uap, retval)
80 struct proc *p;
3c7eb27c 81 struct gethostname_args *uap;
15637ed4
RG
82 int *retval;
83{
84
85 if (uap->len > hostnamelen + 1)
86 uap->len = hostnamelen + 1;
87 return (copyout((caddr_t)hostname, (caddr_t)uap->hostname, uap->len));
88}
89
3c7eb27c
DG
90struct sethostname_args {
91 char *hostname;
92 u_int len;
93};
94
15637ed4
RG
95/* ARGSUSED */
96sethostname(p, uap, retval)
97 struct proc *p;
3c7eb27c 98 register struct sethostname_args *uap;
15637ed4
RG
99 int *retval;
100{
101 int error;
102
103 if (error = suser(p->p_ucred, &p->p_acflag))
104 return (error);
105 if (uap->len > sizeof (hostname) - 1)
106 return (EINVAL);
107 hostnamelen = uap->len;
108 error = copyin((caddr_t)uap->hostname, hostname, uap->len);
109 hostname[hostnamelen] = 0;
110 return (error);
111}
112
5da574a1
JH
113struct uname_args {
114 struct utsname *name;
115};
116
117/* ARGSUSED */
118int
119uname(p, uap, retval)
120 struct proc *p;
121 struct uname_args *uap;
122 int *retval;
123{
124 bcopy(hostname, utsname.nodename, sizeof(utsname.nodename));
125 utsname.nodename[sizeof(utsname.nodename)-1] = '\0';
126 return (copyout((caddr_t)&utsname, (caddr_t)uap->name,
127 sizeof(struct utsname)));
128}
129
3c7eb27c
DG
130struct reboot_args {
131 int opt;
132};
133
15637ed4
RG
134/* ARGSUSED */
135reboot(p, uap, retval)
136 struct proc *p;
3c7eb27c 137 struct reboot_args *uap;
15637ed4
RG
138 int *retval;
139{
140 int error;
141
142 if (error = suser(p->p_ucred, &p->p_acflag))
143 return (error);
144 boot(uap->opt);
145 return (0);
146}
147
148#ifdef COMPAT_43
149oquota()
150{
151
152 return (ENOSYS);
153}
154#endif