blob: f83ced0589f75ae5e8a334ae2c62ec8ef593ee58 [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 */
H.J. Lud6025422012-02-03 10:17:01 -080052#ifndef RLIM64_INFINITY
John Hughes70623be2001-03-08 13:59:00 +000053#define RLIM64_INFINITY RLIM_INFINITY /* You guessed it */
H.J. Lud6025422012-02-03 10:17:01 -080054#endif
John Hughes70623be2001-03-08 13:59:00 +000055
56#define sys_getrlimit64 sys_getrlimit
57#define sys_setrlimit64 sys_setrlimit
58#endif
59
Roland McGrathd9f816f2004-09-04 03:39:20 +000060static const struct xlat resources[] = {
Roland McGrath70d99092005-12-02 04:08:27 +000061#ifdef RLIMIT_AS
62 { RLIMIT_AS, "RLIMIT_AS" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000063#endif
64#ifdef RLIMIT_CORE
65 { RLIMIT_CORE, "RLIMIT_CORE" },
66#endif
Roland McGrath70d99092005-12-02 04:08:27 +000067#ifdef RLIMIT_CPU
68 { RLIMIT_CPU, "RLIMIT_CPU" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000069#endif
Roland McGrath70d99092005-12-02 04:08:27 +000070#ifdef RLIMIT_DATA
71 { RLIMIT_DATA, "RLIMIT_DATA" },
Wichert Akkermanc7926982000-04-10 22:22:31 +000072#endif
Roland McGrath70d99092005-12-02 04:08:27 +000073#ifdef RLIMIT_FSIZE
74 { RLIMIT_FSIZE, "RLIMIT_FSIZE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000075#endif
Roland McGrath566ce1f2004-10-06 22:14:53 +000076#ifdef RLIMIT_LOCKS
77 { RLIMIT_LOCKS, "RLIMIT_LOCKS" },
78#endif
Roland McGrath70d99092005-12-02 04:08:27 +000079#ifdef RLIMIT_MEMLOCK
80 { RLIMIT_MEMLOCK, "RLIMIT_MEMLOCK" },
Roland McGrath566ce1f2004-10-06 22:14:53 +000081#endif
82#ifdef RLIMIT_MSGQUEUE
83 { RLIMIT_MSGQUEUE, "RLIMIT_MSGQUEUE" },
84#endif
Roland McGrath70d99092005-12-02 04:08:27 +000085#ifdef RLIMIT_NICE
86 { RLIMIT_NICE, "RLIMIT_NICE" },
87#endif
88#ifdef RLIMIT_NOFILE
89 { RLIMIT_NOFILE, "RLIMIT_NOFILE" },
90#endif
91#ifdef RLIMIT_NPROC
92 { RLIMIT_NPROC, "RLIMIT_NPROC" },
93#endif
94#ifdef RLIMIT_RSS
95 { RLIMIT_RSS, "RLIMIT_RSS" },
96#endif
97#ifdef RLIMIT_RTPRIO
98 { RLIMIT_RTPRIO, "RLIMIT_RTPRIO" },
99#endif
100#ifdef RLIMIT_SIGPENDING
101 { RLIMIT_SIGPENDING, "RLIMIT_SIGPENDING" },
102#endif
103#ifdef RLIMIT_STACK
104 { RLIMIT_STACK, "RLIMIT_STACK" },
105#endif
106#ifdef RLIMIT_VMEM
107 { RLIMIT_VMEM, "RLIMIT_VMEM" },
108#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000109 { 0, NULL },
110};
111
John Hughes70623be2001-03-08 13:59:00 +0000112#if !HAVE_LONG_LONG_RLIM_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000113static char *
Denys Vlasenko1d632462009-04-14 12:51:00 +0000114sprintrlim(long lim)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000115{
116 static char buf[32];
117
118 if (lim == RLIM_INFINITY)
119 sprintf(buf, "RLIM_INFINITY");
120 else if (lim > 1024 && lim%1024 == 0)
121 sprintf(buf, "%ld*1024", lim/1024);
122 else
123 sprintf(buf, "%ld", lim);
124 return buf;
125}
126
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200127# if defined LINUX && (defined POWERPC64 || defined X86_64)
128static void
129print_rlimit32(struct tcb *tcp)
130{
131 struct rlimit32 {
132 unsigned int rlim_cur;
133 unsigned int rlim_max;
134 } rlim;
135
136 if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200137 tprints("{...}");
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200138 else {
139 tprintf("{rlim_cur=%s,",
140 sprintrlim(rlim.rlim_cur == -1 ? RLIM_INFINITY
141 : rlim.rlim_cur));
142 tprintf(" rlim_max=%s}",
143 sprintrlim(rlim.rlim_max == -1 ? RLIM_INFINITY
144 : rlim.rlim_max));
145 }
146}
147# endif
148
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000149int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000150sys_getrlimit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000151{
152 struct rlimit rlim;
153
154 if (entering(tcp)) {
155 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200156 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000157 }
158 else {
159 if (syserror(tcp) || !verbose(tcp))
160 tprintf("%#lx", tcp->u_arg[1]);
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200161# if defined LINUX && (defined POWERPC64 || defined X86_64)
162 else if (current_personality == 1)
163 print_rlimit32(tcp);
164# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000165 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200166 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000167 else {
168 tprintf("{rlim_cur=%s,", sprintrlim(rlim.rlim_cur));
169 tprintf(" rlim_max=%s}", sprintrlim(rlim.rlim_max));
170 }
171 }
172 return 0;
173}
174
175int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000176sys_setrlimit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000177{
178 struct rlimit rlim;
179
180 if (entering(tcp)) {
181 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200182 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000183 if (!verbose(tcp))
184 tprintf("%#lx", tcp->u_arg[1]);
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200185# if defined LINUX && (defined POWERPC64 || defined X86_64)
186 else if (current_personality == 1)
187 print_rlimit32(tcp);
188# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000189 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200190 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000191 else {
192 tprintf("{rlim_cur=%s,", sprintrlim(rlim.rlim_cur));
193 tprintf(" rlim_max=%s}", sprintrlim(rlim.rlim_max));
194 }
195 }
196 return 0;
197}
John Hughes70623be2001-03-08 13:59:00 +0000198#endif /* !HAVE_LONG_LONG_RLIM_T */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000199
John Hughes70623be2001-03-08 13:59:00 +0000200#if _LFS64_LARGEFILE || HAVE_LONG_LONG_RLIM_T
John Hughesbdf48f52001-03-06 15:08:09 +0000201static char *
Denys Vlasenko1d632462009-04-14 12:51:00 +0000202sprintrlim64(rlim64_t lim)
John Hughesbdf48f52001-03-06 15:08:09 +0000203{
204 static char buf[64];
205
206 if (lim == RLIM64_INFINITY)
207 sprintf(buf, "RLIM64_INFINITY");
208 else if (lim > 1024 && lim%1024 == 0)
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000209 sprintf(buf, "%lld*1024", (long long) lim/1024);
John Hughesbdf48f52001-03-06 15:08:09 +0000210 else
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000211 sprintf(buf, "%lld", (long long) lim);
John Hughesbdf48f52001-03-06 15:08:09 +0000212 return buf;
213}
214
215int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000216sys_getrlimit64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000217{
218 struct rlimit64 rlim;
219
220 if (entering(tcp)) {
221 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200222 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +0000223 }
224 else {
225 if (syserror(tcp) || !verbose(tcp))
226 tprintf("%#lx", tcp->u_arg[1]);
227 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200228 tprints("{...}");
John Hughesbdf48f52001-03-06 15:08:09 +0000229 else {
230 tprintf("{rlim_cur=%s,", sprintrlim64(rlim.rlim_cur));
231 tprintf(" rlim_max=%s}", sprintrlim64(rlim.rlim_max));
232 }
233 }
234 return 0;
235}
236
237int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000238sys_setrlimit64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000239{
240 struct rlimit64 rlim;
241
242 if (entering(tcp)) {
243 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200244 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +0000245 if (!verbose(tcp))
246 tprintf("%#lx", tcp->u_arg[1]);
247 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200248 tprints("{...}");
John Hughesbdf48f52001-03-06 15:08:09 +0000249 else {
250 tprintf("{rlim_cur=%s,", sprintrlim64(rlim.rlim_cur));
251 tprintf(" rlim_max=%s}", sprintrlim64(rlim.rlim_max));
252 }
253 }
254 return 0;
255}
John Hughes70623be2001-03-08 13:59:00 +0000256#endif /* _LFS64_LARGEFILES || HAVE_LONG_LONG_RLIM_T */
John Hughesbdf48f52001-03-06 15:08:09 +0000257
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000258#ifndef SVR4
259
Roland McGrathd9f816f2004-09-04 03:39:20 +0000260static const struct xlat usagewho[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000261 { RUSAGE_SELF, "RUSAGE_SELF" },
262 { RUSAGE_CHILDREN, "RUSAGE_CHILDREN" },
Wichert Akkermanc7926982000-04-10 22:22:31 +0000263#ifdef RUSAGE_BOTH
264 { RUSAGE_BOTH, "RUSAGE_BOTH" },
265#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000266 { 0, NULL },
267};
268
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000269#ifdef ALPHA
270void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000271printrusage32(struct tcb *tcp, long addr)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000272{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000273 struct timeval32 {
274 unsigned tv_sec;
275 unsigned tv_usec;
276 };
277 struct rusage32 {
278 struct timeval32 ru_utime; /* user time used */
279 struct timeval32 ru_stime; /* system time used */
280 long ru_maxrss; /* maximum resident set size */
281 long ru_ixrss; /* integral shared memory size */
282 long ru_idrss; /* integral unshared data size */
283 long ru_isrss; /* integral unshared stack size */
284 long ru_minflt; /* page reclaims */
285 long ru_majflt; /* page faults */
286 long ru_nswap; /* swaps */
287 long ru_inblock; /* block input operations */
288 long ru_oublock; /* block output operations */
289 long ru_msgsnd; /* messages sent */
290 long ru_msgrcv; /* messages received */
291 long ru_nsignals; /* signals received */
292 long ru_nvcsw; /* voluntary context switches */
293 long ru_nivcsw; /* involuntary " */
294 } ru;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000295
Denys Vlasenko1d632462009-04-14 12:51:00 +0000296 if (!addr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200297 tprints("NULL");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000298 else if (syserror(tcp) || !verbose(tcp))
299 tprintf("%#lx", addr);
300 else if (umove(tcp, addr, &ru) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200301 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000302 else if (!abbrev(tcp)) {
303 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
304 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
305 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
306 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
307 ru.ru_maxrss, ru.ru_ixrss);
308 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
309 ru.ru_idrss, ru.ru_isrss);
310 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
311 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
312 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
313 ru.ru_inblock, ru.ru_oublock);
314 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
315 ru.ru_msgsnd, ru.ru_msgrcv);
316 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
317 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
318 }
319 else {
320 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
321 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
322 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
323 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000324}
325#endif
326
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000327void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000328printrusage(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000329{
330 struct rusage ru;
331
332 if (!addr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200333 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000334 else if (syserror(tcp) || !verbose(tcp))
335 tprintf("%#lx", addr);
336 else if (umove(tcp, addr, &ru) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200337 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000338 else if (!abbrev(tcp)) {
339 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
340 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
341 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
342 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
343 ru.ru_maxrss, ru.ru_ixrss);
344 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
345 ru.ru_idrss, ru.ru_isrss);
346 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
347 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
348 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
349 ru.ru_inblock, ru.ru_oublock);
350 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
351 ru.ru_msgsnd, ru.ru_msgrcv);
352 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
353 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
354 }
355 else {
356 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
357 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
358 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
359 }
360}
361
362int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000363sys_getrusage(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000364{
365 if (entering(tcp)) {
366 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200367 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000368 }
369 else
370 printrusage(tcp, tcp->u_arg[1]);
371 return 0;
372}
373
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000374#ifdef ALPHA
375int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000376sys_osf_getrusage(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000377{
Denys Vlasenko59432db2009-01-26 19:09:35 +0000378 if (entering(tcp)) {
379 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200380 tprints(", ");
Denys Vlasenko59432db2009-01-26 19:09:35 +0000381 }
382 else
383 printrusage32(tcp, tcp->u_arg[1]);
384 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000385}
386#endif /* ALPHA */
387
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000388#endif /* !SVR4 */
389
390#ifdef LINUX
391
392int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000393sys_sysinfo(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000394{
395 struct sysinfo si;
396
397 if (exiting(tcp)) {
398 if (syserror(tcp) || !verbose(tcp))
399 tprintf("%#lx", tcp->u_arg[0]);
400 else if (umove(tcp, tcp->u_arg[0], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200401 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000402 else {
403 tprintf("{uptime=%lu, loads=[%lu, %lu, %lu] ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800404 (long) si.uptime, (long) si.loads[0],
405 (long) si.loads[1], (long) si.loads[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000406 tprintf("totalram=%lu, freeram=%lu, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800407 (long) si.totalram, (long) si.freeram);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000408 tprintf("sharedram=%lu, bufferram=%lu} ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800409 (long) si.sharedram, (long) si.bufferram);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000410 tprintf("totalswap=%lu, freeswap=%lu, procs=%hu}",
H.J. Lu0b315b62012-02-03 10:16:03 -0800411 (long) si.totalswap, (long) si.freeswap,
412 si.procs);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000413 }
414 }
415 return 0;
416}
417
418#endif /* LINUX */
419
Roland McGrathd9f816f2004-09-04 03:39:20 +0000420static const struct xlat priorities[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000421 { PRIO_PROCESS, "PRIO_PROCESS" },
422 { PRIO_PGRP, "PRIO_PGRP" },
423 { PRIO_USER, "PRIO_USER" },
424 { 0, NULL },
425};
426
427int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000428sys_getpriority(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000429{
430 if (entering(tcp)) {
431 printxval(priorities, tcp->u_arg[0], "PRIO_???");
432 tprintf(", %lu", tcp->u_arg[1]);
433 }
434 return 0;
435}
436
437int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000438sys_setpriority(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000439{
440 if (entering(tcp)) {
441 printxval(priorities, tcp->u_arg[0], "PRIO_???");
442 tprintf(", %lu, %ld", tcp->u_arg[1], tcp->u_arg[2]);
443 }
444 return 0;
445}
446
447int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000448sys_nice(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000449{
450 if (entering(tcp))
451 tprintf("%ld", tcp->u_arg[0]);
452 return 0;
453}
454
455#ifndef SUNOS4
456
457int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000458sys_times(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000459{
460 struct tms tbuf;
461
462 if (exiting(tcp)) {
463 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200464 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000465 else if (syserror(tcp))
466 tprintf("%#lx", tcp->u_arg[0]);
467 else if (umove(tcp, tcp->u_arg[0], &tbuf) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200468 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000469 else {
470 tprintf("{tms_utime=%lu, tms_stime=%lu, ",
471 tbuf.tms_utime, tbuf.tms_stime);
472 tprintf("tms_cutime=%lu, tms_cstime=%lu}",
473 tbuf.tms_cutime, tbuf.tms_cstime);
474 }
475 }
476 return 0;
477}
478
479#endif /* !SUNOS4 */