blob: 09744d746518e3be5cfcacb7c5575d93413dbf43 [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>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000036#include <sys/times.h>
37#include <linux/kernel.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000038
John Hughes70623be2001-03-08 13:59:00 +000039#if HAVE_LONG_LONG_RLIM_T
40/*
41 * Hacks for systems that have a long long rlim_t
42 */
43
44#define rlimit64 rlimit /* Ugly hack */
45#define rlim64_t rlim_t /* Ugly hack */
H.J. Lud6025422012-02-03 10:17:01 -080046#ifndef RLIM64_INFINITY
John Hughes70623be2001-03-08 13:59:00 +000047#define RLIM64_INFINITY RLIM_INFINITY /* You guessed it */
H.J. Lud6025422012-02-03 10:17:01 -080048#endif
John Hughes70623be2001-03-08 13:59:00 +000049
50#define sys_getrlimit64 sys_getrlimit
51#define sys_setrlimit64 sys_setrlimit
52#endif
53
Roland McGrathd9f816f2004-09-04 03:39:20 +000054static const struct xlat resources[] = {
Roland McGrath70d99092005-12-02 04:08:27 +000055#ifdef RLIMIT_AS
56 { RLIMIT_AS, "RLIMIT_AS" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000057#endif
58#ifdef RLIMIT_CORE
59 { RLIMIT_CORE, "RLIMIT_CORE" },
60#endif
Roland McGrath70d99092005-12-02 04:08:27 +000061#ifdef RLIMIT_CPU
62 { RLIMIT_CPU, "RLIMIT_CPU" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000063#endif
Roland McGrath70d99092005-12-02 04:08:27 +000064#ifdef RLIMIT_DATA
65 { RLIMIT_DATA, "RLIMIT_DATA" },
Wichert Akkermanc7926982000-04-10 22:22:31 +000066#endif
Roland McGrath70d99092005-12-02 04:08:27 +000067#ifdef RLIMIT_FSIZE
68 { RLIMIT_FSIZE, "RLIMIT_FSIZE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000069#endif
Roland McGrath566ce1f2004-10-06 22:14:53 +000070#ifdef RLIMIT_LOCKS
71 { RLIMIT_LOCKS, "RLIMIT_LOCKS" },
72#endif
Roland McGrath70d99092005-12-02 04:08:27 +000073#ifdef RLIMIT_MEMLOCK
74 { RLIMIT_MEMLOCK, "RLIMIT_MEMLOCK" },
Roland McGrath566ce1f2004-10-06 22:14:53 +000075#endif
76#ifdef RLIMIT_MSGQUEUE
77 { RLIMIT_MSGQUEUE, "RLIMIT_MSGQUEUE" },
78#endif
Roland McGrath70d99092005-12-02 04:08:27 +000079#ifdef RLIMIT_NICE
80 { RLIMIT_NICE, "RLIMIT_NICE" },
81#endif
82#ifdef RLIMIT_NOFILE
83 { RLIMIT_NOFILE, "RLIMIT_NOFILE" },
84#endif
85#ifdef RLIMIT_NPROC
86 { RLIMIT_NPROC, "RLIMIT_NPROC" },
87#endif
88#ifdef RLIMIT_RSS
89 { RLIMIT_RSS, "RLIMIT_RSS" },
90#endif
91#ifdef RLIMIT_RTPRIO
92 { RLIMIT_RTPRIO, "RLIMIT_RTPRIO" },
93#endif
94#ifdef RLIMIT_SIGPENDING
95 { RLIMIT_SIGPENDING, "RLIMIT_SIGPENDING" },
96#endif
97#ifdef RLIMIT_STACK
98 { RLIMIT_STACK, "RLIMIT_STACK" },
99#endif
100#ifdef RLIMIT_VMEM
101 { RLIMIT_VMEM, "RLIMIT_VMEM" },
102#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000103 { 0, NULL },
104};
105
John Hughes70623be2001-03-08 13:59:00 +0000106#if !HAVE_LONG_LONG_RLIM_T
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000107static char *
Denys Vlasenko1d632462009-04-14 12:51:00 +0000108sprintrlim(long lim)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000109{
110 static char buf[32];
111
112 if (lim == RLIM_INFINITY)
113 sprintf(buf, "RLIM_INFINITY");
114 else if (lim > 1024 && lim%1024 == 0)
115 sprintf(buf, "%ld*1024", lim/1024);
116 else
117 sprintf(buf, "%ld", lim);
118 return buf;
119}
120
Denys Vlasenkoaa925db2012-02-25 15:19:02 +0100121# if defined(POWERPC64) || defined(X86_64)
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200122static void
123print_rlimit32(struct tcb *tcp)
124{
125 struct rlimit32 {
126 unsigned int rlim_cur;
127 unsigned int rlim_max;
128 } rlim;
129
130 if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200131 tprints("{...}");
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200132 else {
133 tprintf("{rlim_cur=%s,",
134 sprintrlim(rlim.rlim_cur == -1 ? RLIM_INFINITY
135 : rlim.rlim_cur));
136 tprintf(" rlim_max=%s}",
137 sprintrlim(rlim.rlim_max == -1 ? RLIM_INFINITY
138 : rlim.rlim_max));
139 }
140}
141# endif
142
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000143int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000144sys_getrlimit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000145{
146 struct rlimit rlim;
147
148 if (entering(tcp)) {
149 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200150 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000151 }
152 else {
153 if (syserror(tcp) || !verbose(tcp))
154 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenkoaa925db2012-02-25 15:19:02 +0100155# if defined(POWERPC64) || defined(X86_64)
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200156 else if (current_personality == 1)
157 print_rlimit32(tcp);
158# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000159 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200160 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000161 else {
162 tprintf("{rlim_cur=%s,", sprintrlim(rlim.rlim_cur));
163 tprintf(" rlim_max=%s}", sprintrlim(rlim.rlim_max));
164 }
165 }
166 return 0;
167}
168
169int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000170sys_setrlimit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000171{
172 struct rlimit rlim;
173
174 if (entering(tcp)) {
175 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200176 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000177 if (!verbose(tcp))
178 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenkoaa925db2012-02-25 15:19:02 +0100179# if defined(POWERPC64) || defined(X86_64)
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200180 else if (current_personality == 1)
181 print_rlimit32(tcp);
182# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000183 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200184 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000185 else {
186 tprintf("{rlim_cur=%s,", sprintrlim(rlim.rlim_cur));
187 tprintf(" rlim_max=%s}", sprintrlim(rlim.rlim_max));
188 }
189 }
190 return 0;
191}
John Hughes70623be2001-03-08 13:59:00 +0000192#endif /* !HAVE_LONG_LONG_RLIM_T */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000193
John Hughes70623be2001-03-08 13:59:00 +0000194#if _LFS64_LARGEFILE || HAVE_LONG_LONG_RLIM_T
John Hughesbdf48f52001-03-06 15:08:09 +0000195static char *
Denys Vlasenko1d632462009-04-14 12:51:00 +0000196sprintrlim64(rlim64_t lim)
John Hughesbdf48f52001-03-06 15:08:09 +0000197{
198 static char buf[64];
199
200 if (lim == RLIM64_INFINITY)
201 sprintf(buf, "RLIM64_INFINITY");
202 else if (lim > 1024 && lim%1024 == 0)
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000203 sprintf(buf, "%lld*1024", (long long) lim/1024);
John Hughesbdf48f52001-03-06 15:08:09 +0000204 else
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000205 sprintf(buf, "%lld", (long long) lim);
John Hughesbdf48f52001-03-06 15:08:09 +0000206 return buf;
207}
208
209int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000210sys_getrlimit64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000211{
212 struct rlimit64 rlim;
213
214 if (entering(tcp)) {
215 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200216 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +0000217 }
218 else {
219 if (syserror(tcp) || !verbose(tcp))
220 tprintf("%#lx", tcp->u_arg[1]);
221 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200222 tprints("{...}");
John Hughesbdf48f52001-03-06 15:08:09 +0000223 else {
224 tprintf("{rlim_cur=%s,", sprintrlim64(rlim.rlim_cur));
225 tprintf(" rlim_max=%s}", sprintrlim64(rlim.rlim_max));
226 }
227 }
228 return 0;
229}
230
231int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000232sys_setrlimit64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000233{
234 struct rlimit64 rlim;
235
236 if (entering(tcp)) {
237 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200238 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +0000239 if (!verbose(tcp))
240 tprintf("%#lx", tcp->u_arg[1]);
241 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200242 tprints("{...}");
John Hughesbdf48f52001-03-06 15:08:09 +0000243 else {
244 tprintf("{rlim_cur=%s,", sprintrlim64(rlim.rlim_cur));
245 tprintf(" rlim_max=%s}", sprintrlim64(rlim.rlim_max));
246 }
247 }
248 return 0;
249}
John Hughes70623be2001-03-08 13:59:00 +0000250#endif /* _LFS64_LARGEFILES || HAVE_LONG_LONG_RLIM_T */
John Hughesbdf48f52001-03-06 15:08:09 +0000251
Roland McGrathd9f816f2004-09-04 03:39:20 +0000252static const struct xlat usagewho[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000253 { RUSAGE_SELF, "RUSAGE_SELF" },
254 { RUSAGE_CHILDREN, "RUSAGE_CHILDREN" },
Wichert Akkermanc7926982000-04-10 22:22:31 +0000255#ifdef RUSAGE_BOTH
256 { RUSAGE_BOTH, "RUSAGE_BOTH" },
257#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000258 { 0, NULL },
259};
260
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000261#ifdef ALPHA
262void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000263printrusage32(struct tcb *tcp, long addr)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000264{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000265 struct timeval32 {
266 unsigned tv_sec;
267 unsigned tv_usec;
268 };
269 struct rusage32 {
270 struct timeval32 ru_utime; /* user time used */
271 struct timeval32 ru_stime; /* system time used */
272 long ru_maxrss; /* maximum resident set size */
273 long ru_ixrss; /* integral shared memory size */
274 long ru_idrss; /* integral unshared data size */
275 long ru_isrss; /* integral unshared stack size */
276 long ru_minflt; /* page reclaims */
277 long ru_majflt; /* page faults */
278 long ru_nswap; /* swaps */
279 long ru_inblock; /* block input operations */
280 long ru_oublock; /* block output operations */
281 long ru_msgsnd; /* messages sent */
282 long ru_msgrcv; /* messages received */
283 long ru_nsignals; /* signals received */
284 long ru_nvcsw; /* voluntary context switches */
285 long ru_nivcsw; /* involuntary " */
286 } ru;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000287
Denys Vlasenko1d632462009-04-14 12:51:00 +0000288 if (!addr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200289 tprints("NULL");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000290 else if (syserror(tcp) || !verbose(tcp))
291 tprintf("%#lx", addr);
292 else if (umove(tcp, addr, &ru) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200293 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000294 else if (!abbrev(tcp)) {
295 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
296 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
297 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
298 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
299 ru.ru_maxrss, ru.ru_ixrss);
300 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
301 ru.ru_idrss, ru.ru_isrss);
302 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
303 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
304 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
305 ru.ru_inblock, ru.ru_oublock);
306 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
307 ru.ru_msgsnd, ru.ru_msgrcv);
308 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
309 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
310 }
311 else {
312 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
313 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
314 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
315 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000316}
317#endif
318
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000319void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000320printrusage(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000321{
322 struct rusage ru;
323
324 if (!addr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200325 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000326 else if (syserror(tcp) || !verbose(tcp))
327 tprintf("%#lx", addr);
328 else if (umove(tcp, addr, &ru) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200329 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000330 else if (!abbrev(tcp)) {
331 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
332 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
333 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
334 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
335 ru.ru_maxrss, ru.ru_ixrss);
336 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
337 ru.ru_idrss, ru.ru_isrss);
338 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
339 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
340 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
341 ru.ru_inblock, ru.ru_oublock);
342 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
343 ru.ru_msgsnd, ru.ru_msgrcv);
344 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
345 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
346 }
347 else {
348 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
349 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
350 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
351 }
352}
353
354int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000355sys_getrusage(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000356{
357 if (entering(tcp)) {
358 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200359 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000360 }
361 else
362 printrusage(tcp, tcp->u_arg[1]);
363 return 0;
364}
365
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000366#ifdef ALPHA
367int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000368sys_osf_getrusage(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000369{
Denys Vlasenko59432db2009-01-26 19:09:35 +0000370 if (entering(tcp)) {
371 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200372 tprints(", ");
Denys Vlasenko59432db2009-01-26 19:09:35 +0000373 }
374 else
375 printrusage32(tcp, tcp->u_arg[1]);
376 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000377}
378#endif /* ALPHA */
379
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000380int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000381sys_sysinfo(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000382{
383 struct sysinfo si;
384
385 if (exiting(tcp)) {
386 if (syserror(tcp) || !verbose(tcp))
387 tprintf("%#lx", tcp->u_arg[0]);
388 else if (umove(tcp, tcp->u_arg[0], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200389 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000390 else {
391 tprintf("{uptime=%lu, loads=[%lu, %lu, %lu] ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800392 (long) si.uptime, (long) si.loads[0],
393 (long) si.loads[1], (long) si.loads[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000394 tprintf("totalram=%lu, freeram=%lu, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800395 (long) si.totalram, (long) si.freeram);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000396 tprintf("sharedram=%lu, bufferram=%lu} ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800397 (long) si.sharedram, (long) si.bufferram);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000398 tprintf("totalswap=%lu, freeswap=%lu, procs=%hu}",
H.J. Lu0b315b62012-02-03 10:16:03 -0800399 (long) si.totalswap, (long) si.freeswap,
400 si.procs);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000401 }
402 }
403 return 0;
404}
405
Roland McGrathd9f816f2004-09-04 03:39:20 +0000406static const struct xlat priorities[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000407 { PRIO_PROCESS, "PRIO_PROCESS" },
408 { PRIO_PGRP, "PRIO_PGRP" },
409 { PRIO_USER, "PRIO_USER" },
410 { 0, NULL },
411};
412
413int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000414sys_getpriority(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000415{
416 if (entering(tcp)) {
417 printxval(priorities, tcp->u_arg[0], "PRIO_???");
418 tprintf(", %lu", tcp->u_arg[1]);
419 }
420 return 0;
421}
422
423int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000424sys_setpriority(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000425{
426 if (entering(tcp)) {
427 printxval(priorities, tcp->u_arg[0], "PRIO_???");
428 tprintf(", %lu, %ld", tcp->u_arg[1], tcp->u_arg[2]);
429 }
430 return 0;
431}
432
433int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000434sys_times(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000435{
436 struct tms tbuf;
437
438 if (exiting(tcp)) {
439 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200440 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000441 else if (syserror(tcp))
442 tprintf("%#lx", tcp->u_arg[0]);
443 else if (umove(tcp, tcp->u_arg[0], &tbuf) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200444 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000445 else {
446 tprintf("{tms_utime=%lu, tms_stime=%lu, ",
447 tbuf.tms_utime, tbuf.tms_stime);
448 tprintf("tms_cutime=%lu, tms_cstime=%lu}",
449 tbuf.tms_cutime, tbuf.tms_cstime);
450 }
451 }
452 return 0;
453}