2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include <sys/resource.h>
37 #include <sys/times.h>
38 #include <linux/kernel.h>
41 #include <ufs/quota.h>
44 #include <sys/times.h>
48 static struct xlat resources[] = {
50 { RLIMIT_CPU, "RLIMIT_CPU" },
53 { RLIMIT_FSIZE, "RLIMIT_FSIZE" },
56 { RLIMIT_DATA, "RLIMIT_DATA" },
59 { RLIMIT_STACK, "RLIMIT_STACK" },
62 { RLIMIT_CORE, "RLIMIT_CORE" },
65 { RLIMIT_RSS, "RLIMIT_RSS" },
68 { RLIMIT_NOFILE,"RLIMIT_NOFILE" },
71 { RLIMIT_VMEM, "RLIMIT_VMEM" },
74 { RLIMIT_AS, "RLIMIT_AS" },
85 if (lim == RLIM_INFINITY)
86 sprintf(buf, "RLIM_INFINITY");
87 else if (lim > 1024 && lim%1024 == 0)
88 sprintf(buf, "%ld*1024", lim/1024);
90 sprintf(buf, "%ld", lim);
101 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
105 if (syserror(tcp) || !verbose(tcp))
106 tprintf("%#lx", tcp->u_arg[1]);
107 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
110 tprintf("{rlim_cur=%s,", sprintrlim(rlim.rlim_cur));
111 tprintf(" rlim_max=%s}", sprintrlim(rlim.rlim_max));
124 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
127 tprintf("%#lx", tcp->u_arg[1]);
128 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
131 tprintf("{rlim_cur=%s,", sprintrlim(rlim.rlim_cur));
132 tprintf(" rlim_max=%s}", sprintrlim(rlim.rlim_max));
140 static struct xlat usagewho[] = {
141 { RUSAGE_SELF, "RUSAGE_SELF" },
142 { RUSAGE_CHILDREN, "RUSAGE_CHILDREN" },
148 printrusage32(tcp, addr)
159 struct timeval32 ru_utime; /* user time used */
160 struct timeval32 ru_stime; /* system time used */
161 long ru_maxrss; /* maximum resident set size */
162 long ru_ixrss; /* integral shared memory size */
163 long ru_idrss; /* integral unshared data size */
164 long ru_isrss; /* integral unshared stack size */
165 long ru_minflt; /* page reclaims */
166 long ru_majflt; /* page faults */
167 long ru_nswap; /* swaps */
168 long ru_inblock; /* block input operations */
169 long ru_oublock; /* block output operations */
170 long ru_msgsnd; /* messages sent */
171 long ru_msgrcv; /* messages received */
172 long ru_nsignals; /* signals received */
173 long ru_nvcsw; /* voluntary context switches */
174 long ru_nivcsw; /* involuntary " */
179 else if (syserror(tcp) || !verbose(tcp))
180 tprintf("%#lx", addr);
181 else if (umove(tcp, addr, &ru) < 0)
183 else if (!abbrev(tcp)) {
184 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
185 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
186 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
187 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
188 ru.ru_maxrss, ru.ru_ixrss);
189 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
190 ru.ru_idrss, ru.ru_isrss);
191 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
192 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
193 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
194 ru.ru_inblock, ru.ru_oublock);
195 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
196 ru.ru_msgsnd, ru.ru_msgrcv);
197 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
198 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
201 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
202 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
203 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
209 printrusage(tcp, addr)
217 else if (syserror(tcp) || !verbose(tcp))
218 tprintf("%#lx", addr);
219 else if (umove(tcp, addr, &ru) < 0)
221 else if (!abbrev(tcp)) {
222 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
223 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
224 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
225 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
226 ru.ru_maxrss, ru.ru_ixrss);
227 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
228 ru.ru_idrss, ru.ru_isrss);
229 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
230 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
231 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
232 ru.ru_inblock, ru.ru_oublock);
233 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
234 ru.ru_msgsnd, ru.ru_msgrcv);
235 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
236 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
239 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
240 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
241 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
250 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
254 printrusage(tcp, tcp->u_arg[1]);
260 sys_osf_getrusage(tcp)
264 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
268 printrusage32(tcp, tcp->u_arg[1]);
284 if (syserror(tcp) || !verbose(tcp))
285 tprintf("%#lx", tcp->u_arg[0]);
286 else if (umove(tcp, tcp->u_arg[0], &si) < 0)
289 tprintf("{uptime=%lu, loads=[%lu, %lu, %lu] ",
290 si.uptime, si.loads[0], si.loads[1],
292 tprintf("totalram=%lu, freeram=%lu, ",
293 si.totalram, si.freeram);
294 tprintf("sharedram=%lu, bufferram=%lu} ",
295 si.sharedram, si.bufferram);
296 tprintf("totalswap=%lu, freeswap=%lu, procs=%hu}",
297 si.totalswap, si.freeswap, si.procs);
305 static struct xlat priorities[] = {
306 { PRIO_PROCESS, "PRIO_PROCESS" },
307 { PRIO_PGRP, "PRIO_PGRP" },
308 { PRIO_USER, "PRIO_USER" },
317 printxval(priorities, tcp->u_arg[0], "PRIO_???");
318 tprintf(", %lu", tcp->u_arg[1]);
328 printxval(priorities, tcp->u_arg[0], "PRIO_???");
329 tprintf(", %lu, %ld", tcp->u_arg[1], tcp->u_arg[2]);
339 tprintf("%ld", tcp->u_arg[0]);
352 if (tcp->u_arg[0] == 0)
354 else if (syserror(tcp))
355 tprintf("%#lx", tcp->u_arg[0]);
356 else if (umove(tcp, tcp->u_arg[0], &tbuf) < 0)
359 tprintf("{tms_utime=%lu, tms_stime=%lu, ",
360 tbuf.tms_utime, tbuf.tms_stime);
361 tprintf("tms_cutime=%lu, tms_cstime=%lu}",
362 tbuf.tms_cutime, tbuf.tms_cstime);
372 static struct xlat quotacmds[] = {
373 { Q_QUOTAON, "Q_QUOTAON" },
374 { Q_QUOTAOFF, "Q_QUOTAOFF" },
375 { Q_GETQUOTA, "Q_GETQUOTA" },
376 { Q_SETQUOTA, "Q_SETQUOTA" },
377 { Q_SETQLIM, "Q_SETQLIM" },
378 { Q_SYNC, "Q_SYNC" },
386 /* fourth arg (addr) not interpreted here */
388 printxval(quotacmds, tcp->u_arg[0], "Q_???");
390 printstr(tcp, tcp->u_arg[1], -1);
391 tprintf(", %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);