blob: 199ddf8f5d1186b4b9dfe039edb168ec595ec553 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
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>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00006 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
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.
18 *
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.
29 *
30 * $Id$
31 */
32
33#include "defs.h"
34
35#include <sys/resource.h>
36#ifdef LINUX
37#include <sys/times.h>
38#include <linux/kernel.h>
39#endif /* LINUX */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000040#if defined(SVR4) || defined(FREEBSD)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000041#include <sys/times.h>
42#include <sys/time.h>
43#endif
44
John Hughes70623be2001-03-08 13:59:00 +000045#if HAVE_LONG_LONG_RLIM_T
46/*
47 * Hacks for systems that have a long long rlim_t
48 */
49
50#define rlimit64 rlimit /* Ugly hack */
51#define rlim64_t rlim_t /* Ugly hack */
52#define RLIM64_INFINITY RLIM_INFINITY /* You guessed it */
53
54#define sys_getrlimit64 sys_getrlimit
55#define sys_setrlimit64 sys_setrlimit
56#endif
57
Roland McGrathd9f816f2004-09-04 03:39:20 +000058static const struct xlat resources[] = {
Roland McGrath70d99092005-12-02 04:08:27 +000059#ifdef RLIMIT_AS
60 { RLIMIT_AS, "RLIMIT_AS" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000061#endif
62#ifdef RLIMIT_CORE
63 { RLIMIT_CORE, "RLIMIT_CORE" },
64#endif
Roland McGrath70d99092005-12-02 04:08:27 +000065#ifdef RLIMIT_CPU
66 { RLIMIT_CPU, "RLIMIT_CPU" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000067#endif
Roland McGrath70d99092005-12-02 04:08:27 +000068#ifdef RLIMIT_DATA
69 { RLIMIT_DATA, "RLIMIT_DATA" },
Wichert Akkermanc7926982000-04-10 22:22:31 +000070#endif
Roland McGrath70d99092005-12-02 04:08:27 +000071#ifdef RLIMIT_FSIZE
72 { RLIMIT_FSIZE, "RLIMIT_FSIZE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000073#endif
Roland McGrath566ce1f2004-10-06 22:14:53 +000074#ifdef RLIMIT_LOCKS
75 { RLIMIT_LOCKS, "RLIMIT_LOCKS" },
76#endif
Roland McGrath70d99092005-12-02 04:08:27 +000077#ifdef RLIMIT_MEMLOCK
78 { RLIMIT_MEMLOCK, "RLIMIT_MEMLOCK" },
Roland McGrath566ce1f2004-10-06 22:14:53 +000079#endif
80#ifdef RLIMIT_MSGQUEUE
81 { RLIMIT_MSGQUEUE, "RLIMIT_MSGQUEUE" },
82#endif
Roland McGrath70d99092005-12-02 04:08:27 +000083#ifdef RLIMIT_NICE
84 { RLIMIT_NICE, "RLIMIT_NICE" },
85#endif
86#ifdef RLIMIT_NOFILE
87 { RLIMIT_NOFILE, "RLIMIT_NOFILE" },
88#endif
89#ifdef RLIMIT_NPROC
90 { RLIMIT_NPROC, "RLIMIT_NPROC" },
91#endif
92#ifdef RLIMIT_RSS
93 { RLIMIT_RSS, "RLIMIT_RSS" },
94#endif
95#ifdef RLIMIT_RTPRIO
96 { RLIMIT_RTPRIO, "RLIMIT_RTPRIO" },
97#endif
98#ifdef RLIMIT_SIGPENDING
99 { RLIMIT_SIGPENDING, "RLIMIT_SIGPENDING" },
100#endif
101#ifdef RLIMIT_STACK
102 { RLIMIT_STACK, "RLIMIT_STACK" },
103#endif
104#ifdef RLIMIT_VMEM
105 { RLIMIT_VMEM, "RLIMIT_VMEM" },
106#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000107 { 0, NULL },
108};
109
John Hughes70623be2001-03-08 13:59:00 +0000110#if !HAVE_LONG_LONG_RLIM_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000111static char *
Denys Vlasenko1d632462009-04-14 12:51:00 +0000112sprintrlim(long lim)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000113{
114 static char buf[32];
115
116 if (lim == RLIM_INFINITY)
117 sprintf(buf, "RLIM_INFINITY");
118 else if (lim > 1024 && lim%1024 == 0)
119 sprintf(buf, "%ld*1024", lim/1024);
120 else
121 sprintf(buf, "%ld", lim);
122 return buf;
123}
124
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200125# if defined LINUX && (defined POWERPC64 || defined X86_64)
126static void
127print_rlimit32(struct tcb *tcp)
128{
129 struct rlimit32 {
130 unsigned int rlim_cur;
131 unsigned int rlim_max;
132 } rlim;
133
134 if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200135 tprints("{...}");
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200136 else {
137 tprintf("{rlim_cur=%s,",
138 sprintrlim(rlim.rlim_cur == -1 ? RLIM_INFINITY
139 : rlim.rlim_cur));
140 tprintf(" rlim_max=%s}",
141 sprintrlim(rlim.rlim_max == -1 ? RLIM_INFINITY
142 : rlim.rlim_max));
143 }
144}
145# endif
146
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000147int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000148sys_getrlimit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000149{
150 struct rlimit rlim;
151
152 if (entering(tcp)) {
153 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200154 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000155 }
156 else {
157 if (syserror(tcp) || !verbose(tcp))
158 tprintf("%#lx", tcp->u_arg[1]);
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200159# if defined LINUX && (defined POWERPC64 || defined X86_64)
160 else if (current_personality == 1)
161 print_rlimit32(tcp);
162# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000163 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200164 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000165 else {
166 tprintf("{rlim_cur=%s,", sprintrlim(rlim.rlim_cur));
167 tprintf(" rlim_max=%s}", sprintrlim(rlim.rlim_max));
168 }
169 }
170 return 0;
171}
172
173int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000174sys_setrlimit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000175{
176 struct rlimit rlim;
177
178 if (entering(tcp)) {
179 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200180 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000181 if (!verbose(tcp))
182 tprintf("%#lx", tcp->u_arg[1]);
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200183# if defined LINUX && (defined POWERPC64 || defined X86_64)
184 else if (current_personality == 1)
185 print_rlimit32(tcp);
186# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000187 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200188 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000189 else {
190 tprintf("{rlim_cur=%s,", sprintrlim(rlim.rlim_cur));
191 tprintf(" rlim_max=%s}", sprintrlim(rlim.rlim_max));
192 }
193 }
194 return 0;
195}
John Hughes70623be2001-03-08 13:59:00 +0000196#endif /* !HAVE_LONG_LONG_RLIM_T */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000197
John Hughes70623be2001-03-08 13:59:00 +0000198#if _LFS64_LARGEFILE || HAVE_LONG_LONG_RLIM_T
John Hughesbdf48f52001-03-06 15:08:09 +0000199static char *
Denys Vlasenko1d632462009-04-14 12:51:00 +0000200sprintrlim64(rlim64_t lim)
John Hughesbdf48f52001-03-06 15:08:09 +0000201{
202 static char buf[64];
203
204 if (lim == RLIM64_INFINITY)
205 sprintf(buf, "RLIM64_INFINITY");
206 else if (lim > 1024 && lim%1024 == 0)
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000207 sprintf(buf, "%lld*1024", (long long) lim/1024);
John Hughesbdf48f52001-03-06 15:08:09 +0000208 else
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000209 sprintf(buf, "%lld", (long long) lim);
John Hughesbdf48f52001-03-06 15:08:09 +0000210 return buf;
211}
212
213int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000214sys_getrlimit64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000215{
216 struct rlimit64 rlim;
217
218 if (entering(tcp)) {
219 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200220 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +0000221 }
222 else {
223 if (syserror(tcp) || !verbose(tcp))
224 tprintf("%#lx", tcp->u_arg[1]);
225 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200226 tprints("{...}");
John Hughesbdf48f52001-03-06 15:08:09 +0000227 else {
228 tprintf("{rlim_cur=%s,", sprintrlim64(rlim.rlim_cur));
229 tprintf(" rlim_max=%s}", sprintrlim64(rlim.rlim_max));
230 }
231 }
232 return 0;
233}
234
235int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000236sys_setrlimit64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000237{
238 struct rlimit64 rlim;
239
240 if (entering(tcp)) {
241 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200242 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +0000243 if (!verbose(tcp))
244 tprintf("%#lx", tcp->u_arg[1]);
245 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200246 tprints("{...}");
John Hughesbdf48f52001-03-06 15:08:09 +0000247 else {
248 tprintf("{rlim_cur=%s,", sprintrlim64(rlim.rlim_cur));
249 tprintf(" rlim_max=%s}", sprintrlim64(rlim.rlim_max));
250 }
251 }
252 return 0;
253}
John Hughes70623be2001-03-08 13:59:00 +0000254#endif /* _LFS64_LARGEFILES || HAVE_LONG_LONG_RLIM_T */
John Hughesbdf48f52001-03-06 15:08:09 +0000255
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000256#ifndef SVR4
257
Roland McGrathd9f816f2004-09-04 03:39:20 +0000258static const struct xlat usagewho[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000259 { RUSAGE_SELF, "RUSAGE_SELF" },
260 { RUSAGE_CHILDREN, "RUSAGE_CHILDREN" },
Wichert Akkermanc7926982000-04-10 22:22:31 +0000261#ifdef RUSAGE_BOTH
262 { RUSAGE_BOTH, "RUSAGE_BOTH" },
263#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000264 { 0, NULL },
265};
266
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000267#ifdef ALPHA
268void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000269printrusage32(struct tcb *tcp, long addr)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000270{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000271 struct timeval32 {
272 unsigned tv_sec;
273 unsigned tv_usec;
274 };
275 struct rusage32 {
276 struct timeval32 ru_utime; /* user time used */
277 struct timeval32 ru_stime; /* system time used */
278 long ru_maxrss; /* maximum resident set size */
279 long ru_ixrss; /* integral shared memory size */
280 long ru_idrss; /* integral unshared data size */
281 long ru_isrss; /* integral unshared stack size */
282 long ru_minflt; /* page reclaims */
283 long ru_majflt; /* page faults */
284 long ru_nswap; /* swaps */
285 long ru_inblock; /* block input operations */
286 long ru_oublock; /* block output operations */
287 long ru_msgsnd; /* messages sent */
288 long ru_msgrcv; /* messages received */
289 long ru_nsignals; /* signals received */
290 long ru_nvcsw; /* voluntary context switches */
291 long ru_nivcsw; /* involuntary " */
292 } ru;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000293
Denys Vlasenko1d632462009-04-14 12:51:00 +0000294 if (!addr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200295 tprints("NULL");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000296 else if (syserror(tcp) || !verbose(tcp))
297 tprintf("%#lx", addr);
298 else if (umove(tcp, addr, &ru) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200299 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000300 else if (!abbrev(tcp)) {
301 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
302 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
303 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
304 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
305 ru.ru_maxrss, ru.ru_ixrss);
306 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
307 ru.ru_idrss, ru.ru_isrss);
308 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
309 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
310 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
311 ru.ru_inblock, ru.ru_oublock);
312 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
313 ru.ru_msgsnd, ru.ru_msgrcv);
314 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
315 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
316 }
317 else {
318 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
319 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
320 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
321 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000322}
323#endif
324
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000325void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000326printrusage(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000327{
328 struct rusage ru;
329
330 if (!addr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200331 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000332 else if (syserror(tcp) || !verbose(tcp))
333 tprintf("%#lx", addr);
334 else if (umove(tcp, addr, &ru) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200335 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000336 else if (!abbrev(tcp)) {
337 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
338 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
339 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
340 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
341 ru.ru_maxrss, ru.ru_ixrss);
342 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
343 ru.ru_idrss, ru.ru_isrss);
344 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
345 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
346 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
347 ru.ru_inblock, ru.ru_oublock);
348 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
349 ru.ru_msgsnd, ru.ru_msgrcv);
350 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
351 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
352 }
353 else {
354 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
355 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
356 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
357 }
358}
359
360int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000361sys_getrusage(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000362{
363 if (entering(tcp)) {
364 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200365 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000366 }
367 else
368 printrusage(tcp, tcp->u_arg[1]);
369 return 0;
370}
371
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000372#ifdef ALPHA
373int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000374sys_osf_getrusage(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000375{
Denys Vlasenko59432db2009-01-26 19:09:35 +0000376 if (entering(tcp)) {
377 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200378 tprints(", ");
Denys Vlasenko59432db2009-01-26 19:09:35 +0000379 }
380 else
381 printrusage32(tcp, tcp->u_arg[1]);
382 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000383}
384#endif /* ALPHA */
385
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000386#endif /* !SVR4 */
387
388#ifdef LINUX
389
390int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000391sys_sysinfo(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000392{
393 struct sysinfo si;
394
395 if (exiting(tcp)) {
396 if (syserror(tcp) || !verbose(tcp))
397 tprintf("%#lx", tcp->u_arg[0]);
398 else if (umove(tcp, tcp->u_arg[0], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200399 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000400 else {
401 tprintf("{uptime=%lu, loads=[%lu, %lu, %lu] ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800402 (long) si.uptime, (long) si.loads[0],
403 (long) si.loads[1], (long) si.loads[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000404 tprintf("totalram=%lu, freeram=%lu, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800405 (long) si.totalram, (long) si.freeram);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000406 tprintf("sharedram=%lu, bufferram=%lu} ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800407 (long) si.sharedram, (long) si.bufferram);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000408 tprintf("totalswap=%lu, freeswap=%lu, procs=%hu}",
H.J. Lu0b315b62012-02-03 10:16:03 -0800409 (long) si.totalswap, (long) si.freeswap,
410 si.procs);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000411 }
412 }
413 return 0;
414}
415
416#endif /* LINUX */
417
Roland McGrathd9f816f2004-09-04 03:39:20 +0000418static const struct xlat priorities[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000419 { PRIO_PROCESS, "PRIO_PROCESS" },
420 { PRIO_PGRP, "PRIO_PGRP" },
421 { PRIO_USER, "PRIO_USER" },
422 { 0, NULL },
423};
424
425int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000426sys_getpriority(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000427{
428 if (entering(tcp)) {
429 printxval(priorities, tcp->u_arg[0], "PRIO_???");
430 tprintf(", %lu", tcp->u_arg[1]);
431 }
432 return 0;
433}
434
435int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000436sys_setpriority(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000437{
438 if (entering(tcp)) {
439 printxval(priorities, tcp->u_arg[0], "PRIO_???");
440 tprintf(", %lu, %ld", tcp->u_arg[1], tcp->u_arg[2]);
441 }
442 return 0;
443}
444
445int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000446sys_nice(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000447{
448 if (entering(tcp))
449 tprintf("%ld", tcp->u_arg[0]);
450 return 0;
451}
452
453#ifndef SUNOS4
454
455int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000456sys_times(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000457{
458 struct tms tbuf;
459
460 if (exiting(tcp)) {
461 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200462 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000463 else if (syserror(tcp))
464 tprintf("%#lx", tcp->u_arg[0]);
465 else if (umove(tcp, tcp->u_arg[0], &tbuf) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200466 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000467 else {
468 tprintf("{tms_utime=%lu, tms_stime=%lu, ",
469 tbuf.tms_utime, tbuf.tms_stime);
470 tprintf("tms_cutime=%lu, tms_cstime=%lu}",
471 tbuf.tms_cutime, tbuf.tms_cstime);
472 }
473 }
474 return 0;
475}
476
477#endif /* !SUNOS4 */