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>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/resource.h>
36 #include <sys/times.h>
37 #include <linux/kernel.h>
40 #include <ufs/quota.h>
43 #include <sys/times.h>
47 static struct xlat resources[] = {
49 { RLIMIT_CPU, "RLIMIT_CPU" },
52 { RLIMIT_FSIZE, "RLIMIT_FSIZE" },
55 { RLIMIT_DATA, "RLIMIT_DATA" },
58 { RLIMIT_STACK, "RLIMIT_STACK" },
61 { RLIMIT_CORE, "RLIMIT_CORE" },
64 { RLIMIT_RSS, "RLIMIT_RSS" },
67 { RLIMIT_NOFILE,"RLIMIT_NOFILE" },
70 { RLIMIT_VMEM, "RLIMIT_VMEM" },
73 { RLIMIT_AS, "RLIMIT_AS" },
84 if (lim == RLIM_INFINITY)
85 sprintf(buf, "RLIM_INFINITY");
86 else if (lim > 1024 && lim%1024 == 0)
87 sprintf(buf, "%ld*1024", lim/1024);
89 sprintf(buf, "%ld", lim);
100 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
104 if (syserror(tcp) || !verbose(tcp))
105 tprintf("%#lx", tcp->u_arg[1]);
106 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
109 tprintf("{rlim_cur=%s,", sprintrlim(rlim.rlim_cur));
110 tprintf(" rlim_max=%s}", sprintrlim(rlim.rlim_max));
123 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
126 tprintf("%#lx", tcp->u_arg[1]);
127 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
130 tprintf("{rlim_cur=%s,", sprintrlim(rlim.rlim_cur));
131 tprintf(" rlim_max=%s}", sprintrlim(rlim.rlim_max));
139 static struct xlat usagewho[] = {
140 { RUSAGE_SELF, "RUSAGE_SELF" },
141 { RUSAGE_CHILDREN, "RUSAGE_CHILDREN" },
146 printrusage(tcp, addr)
154 else if (syserror(tcp) || !verbose(tcp))
155 tprintf("%#lx", addr);
156 else if (umove(tcp, addr, &ru) < 0)
158 else if (!abbrev(tcp)) {
159 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
160 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
161 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
162 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
163 ru.ru_maxrss, ru.ru_ixrss);
164 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
165 ru.ru_idrss, ru.ru_isrss);
166 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
167 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
168 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
169 ru.ru_inblock, ru.ru_oublock);
170 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
171 ru.ru_msgsnd, ru.ru_msgrcv);
172 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
173 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
176 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
177 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
178 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
187 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
191 printrusage(tcp, tcp->u_arg[1]);
206 if (syserror(tcp) || !verbose(tcp))
207 tprintf("%#lx", tcp->u_arg[0]);
208 else if (umove(tcp, tcp->u_arg[0], &si) < 0)
211 tprintf("{uptime=%lu, loads=[%lu, %lu, %lu] ",
212 si.uptime, si.loads[0], si.loads[1],
214 tprintf("totalram=%lu, freeram=%lu, ",
215 si.totalram, si.freeram);
216 tprintf("sharedram=%lu, bufferram=%lu} ",
217 si.sharedram, si.bufferram);
218 tprintf("totalswap=%lu, freeswap=%lu, procs=%hu}",
219 si.totalswap, si.freeswap, si.procs);
227 static struct xlat priorities[] = {
228 { PRIO_PROCESS, "PRIO_PROCESS" },
229 { PRIO_PGRP, "PRIO_PGRP" },
230 { PRIO_USER, "PRIO_USER" },
239 printxval(priorities, tcp->u_arg[0], "PRIO_???");
240 tprintf(", %lu", tcp->u_arg[1]);
250 printxval(priorities, tcp->u_arg[0], "PRIO_???");
251 tprintf(", %lu, %ld", tcp->u_arg[1], tcp->u_arg[2]);
261 tprintf("%ld", tcp->u_arg[0]);
274 if (tcp->u_arg[0] == 0)
276 else if (syserror(tcp))
277 tprintf("%#lx", tcp->u_arg[0]);
278 else if (umove(tcp, tcp->u_arg[0], &tbuf) < 0)
281 tprintf("{tms_utime=%lu, tms_stime=%lu, ",
282 tbuf.tms_utime, tbuf.tms_stime);
283 tprintf("tms_cutime=%lu, tms_cstime=%lu}",
284 tbuf.tms_cutime, tbuf.tms_cstime);
294 static struct xlat quotacmds[] = {
295 { Q_QUOTAON, "Q_QUOTAON" },
296 { Q_QUOTAOFF, "Q_QUOTAOFF" },
297 { Q_GETQUOTA, "Q_GETQUOTA" },
298 { Q_SETQUOTA, "Q_SETQUOTA" },
299 { Q_SETQLIM, "Q_SETQLIM" },
300 { Q_SYNC, "Q_SYNC" },
308 /* fourth arg (addr) not interpreted here */
310 printxval(quotacmds, tcp->u_arg[0], "Q_???");
312 printstr(tcp, tcp->u_arg[1], -1);
313 tprintf(", %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]);