blob: 631aa4a0184dc02ab7564231c6be913de578a943 [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.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000029 */
30
31#include "defs.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000032#include <sys/resource.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000033#include <sys/times.h>
34#include <linux/kernel.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000035
John Hughes70623be2001-03-08 13:59:00 +000036#if HAVE_LONG_LONG_RLIM_T
37/*
38 * Hacks for systems that have a long long rlim_t
39 */
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010040# define rlimit64 rlimit /* Ugly hack */
41# define rlim64_t rlim_t /* Ugly hack */
42# ifndef RLIM64_INFINITY
43# define RLIM64_INFINITY RLIM_INFINITY /* You guessed it */
44# endif
45# define sys_getrlimit64 sys_getrlimit
46# define sys_setrlimit64 sys_setrlimit
John Hughes70623be2001-03-08 13:59:00 +000047#endif
48
Roland McGrathd9f816f2004-09-04 03:39:20 +000049static const struct xlat resources[] = {
Roland McGrath70d99092005-12-02 04:08:27 +000050#ifdef RLIMIT_AS
51 { RLIMIT_AS, "RLIMIT_AS" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000052#endif
53#ifdef RLIMIT_CORE
54 { RLIMIT_CORE, "RLIMIT_CORE" },
55#endif
Roland McGrath70d99092005-12-02 04:08:27 +000056#ifdef RLIMIT_CPU
57 { RLIMIT_CPU, "RLIMIT_CPU" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000058#endif
Roland McGrath70d99092005-12-02 04:08:27 +000059#ifdef RLIMIT_DATA
60 { RLIMIT_DATA, "RLIMIT_DATA" },
Wichert Akkermanc7926982000-04-10 22:22:31 +000061#endif
Roland McGrath70d99092005-12-02 04:08:27 +000062#ifdef RLIMIT_FSIZE
63 { RLIMIT_FSIZE, "RLIMIT_FSIZE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000064#endif
Roland McGrath566ce1f2004-10-06 22:14:53 +000065#ifdef RLIMIT_LOCKS
66 { RLIMIT_LOCKS, "RLIMIT_LOCKS" },
67#endif
Roland McGrath70d99092005-12-02 04:08:27 +000068#ifdef RLIMIT_MEMLOCK
69 { RLIMIT_MEMLOCK, "RLIMIT_MEMLOCK" },
Roland McGrath566ce1f2004-10-06 22:14:53 +000070#endif
71#ifdef RLIMIT_MSGQUEUE
72 { RLIMIT_MSGQUEUE, "RLIMIT_MSGQUEUE" },
73#endif
Roland McGrath70d99092005-12-02 04:08:27 +000074#ifdef RLIMIT_NICE
75 { RLIMIT_NICE, "RLIMIT_NICE" },
76#endif
77#ifdef RLIMIT_NOFILE
78 { RLIMIT_NOFILE, "RLIMIT_NOFILE" },
79#endif
80#ifdef RLIMIT_NPROC
81 { RLIMIT_NPROC, "RLIMIT_NPROC" },
82#endif
83#ifdef RLIMIT_RSS
84 { RLIMIT_RSS, "RLIMIT_RSS" },
85#endif
86#ifdef RLIMIT_RTPRIO
87 { RLIMIT_RTPRIO, "RLIMIT_RTPRIO" },
88#endif
89#ifdef RLIMIT_SIGPENDING
90 { RLIMIT_SIGPENDING, "RLIMIT_SIGPENDING" },
91#endif
92#ifdef RLIMIT_STACK
93 { RLIMIT_STACK, "RLIMIT_STACK" },
94#endif
95#ifdef RLIMIT_VMEM
96 { RLIMIT_VMEM, "RLIMIT_VMEM" },
97#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000098 { 0, NULL },
99};
100
John Hughes70623be2001-03-08 13:59:00 +0000101#if !HAVE_LONG_LONG_RLIM_T
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100102static const char *
Denys Vlasenko1d632462009-04-14 12:51:00 +0000103sprintrlim(long lim)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000104{
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100105 static char buf[sizeof(long)*3 + sizeof("%ld*1024")];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000106
107 if (lim == RLIM_INFINITY)
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100108 return "RLIM_INFINITY";
109
110 if (lim > 1024 && lim%1024 == 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000111 sprintf(buf, "%ld*1024", lim/1024);
112 else
113 sprintf(buf, "%ld", lim);
114 return buf;
115}
116
Denys Vlasenkoaa925db2012-02-25 15:19:02 +0100117# if defined(POWERPC64) || defined(X86_64)
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200118static void
119print_rlimit32(struct tcb *tcp)
120{
121 struct rlimit32 {
122 unsigned int rlim_cur;
123 unsigned int rlim_max;
124 } rlim;
125
126 if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200127 tprints("{...}");
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200128 else {
129 tprintf("{rlim_cur=%s,",
130 sprintrlim(rlim.rlim_cur == -1 ? RLIM_INFINITY
131 : rlim.rlim_cur));
132 tprintf(" rlim_max=%s}",
133 sprintrlim(rlim.rlim_max == -1 ? RLIM_INFINITY
134 : rlim.rlim_max));
135 }
136}
137# endif
138
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000139int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000140sys_getrlimit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000141{
142 struct rlimit rlim;
143
144 if (entering(tcp)) {
145 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200146 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000147 }
148 else {
149 if (syserror(tcp) || !verbose(tcp))
150 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenkoaa925db2012-02-25 15:19:02 +0100151# if defined(POWERPC64) || defined(X86_64)
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200152 else if (current_personality == 1)
153 print_rlimit32(tcp);
154# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000155 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200156 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000157 else {
158 tprintf("{rlim_cur=%s,", sprintrlim(rlim.rlim_cur));
159 tprintf(" rlim_max=%s}", sprintrlim(rlim.rlim_max));
160 }
161 }
162 return 0;
163}
164
165int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000166sys_setrlimit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000167{
168 struct rlimit rlim;
169
170 if (entering(tcp)) {
171 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200172 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000173 if (!verbose(tcp))
174 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenkoaa925db2012-02-25 15:19:02 +0100175# if defined(POWERPC64) || defined(X86_64)
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200176 else if (current_personality == 1)
177 print_rlimit32(tcp);
178# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000179 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200180 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000181 else {
182 tprintf("{rlim_cur=%s,", sprintrlim(rlim.rlim_cur));
183 tprintf(" rlim_max=%s}", sprintrlim(rlim.rlim_max));
184 }
185 }
186 return 0;
187}
John Hughes70623be2001-03-08 13:59:00 +0000188#endif /* !HAVE_LONG_LONG_RLIM_T */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000189
John Hughes70623be2001-03-08 13:59:00 +0000190#if _LFS64_LARGEFILE || HAVE_LONG_LONG_RLIM_T
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100191static const char *
Denys Vlasenko1d632462009-04-14 12:51:00 +0000192sprintrlim64(rlim64_t lim)
John Hughesbdf48f52001-03-06 15:08:09 +0000193{
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100194 static char buf[sizeof(long long)*3 + sizeof("%lld*1024")];
John Hughesbdf48f52001-03-06 15:08:09 +0000195
196 if (lim == RLIM64_INFINITY)
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100197 return "RLIM64_INFINITY";
198
199 if (lim > 1024 && lim%1024 == 0)
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000200 sprintf(buf, "%lld*1024", (long long) lim/1024);
John Hughesbdf48f52001-03-06 15:08:09 +0000201 else
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000202 sprintf(buf, "%lld", (long long) lim);
John Hughesbdf48f52001-03-06 15:08:09 +0000203 return buf;
204}
205
206int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000207sys_getrlimit64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000208{
209 struct rlimit64 rlim;
210
211 if (entering(tcp)) {
212 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200213 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +0000214 }
215 else {
216 if (syserror(tcp) || !verbose(tcp))
217 tprintf("%#lx", tcp->u_arg[1]);
218 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200219 tprints("{...}");
John Hughesbdf48f52001-03-06 15:08:09 +0000220 else {
221 tprintf("{rlim_cur=%s,", sprintrlim64(rlim.rlim_cur));
222 tprintf(" rlim_max=%s}", sprintrlim64(rlim.rlim_max));
223 }
224 }
225 return 0;
226}
227
228int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000229sys_setrlimit64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000230{
231 struct rlimit64 rlim;
232
233 if (entering(tcp)) {
234 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200235 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +0000236 if (!verbose(tcp))
237 tprintf("%#lx", tcp->u_arg[1]);
238 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200239 tprints("{...}");
John Hughesbdf48f52001-03-06 15:08:09 +0000240 else {
241 tprintf("{rlim_cur=%s,", sprintrlim64(rlim.rlim_cur));
242 tprintf(" rlim_max=%s}", sprintrlim64(rlim.rlim_max));
243 }
244 }
245 return 0;
246}
John Hughes70623be2001-03-08 13:59:00 +0000247#endif /* _LFS64_LARGEFILES || HAVE_LONG_LONG_RLIM_T */
John Hughesbdf48f52001-03-06 15:08:09 +0000248
Roland McGrathd9f816f2004-09-04 03:39:20 +0000249static const struct xlat usagewho[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000250 { RUSAGE_SELF, "RUSAGE_SELF" },
251 { RUSAGE_CHILDREN, "RUSAGE_CHILDREN" },
Wichert Akkermanc7926982000-04-10 22:22:31 +0000252#ifdef RUSAGE_BOTH
253 { RUSAGE_BOTH, "RUSAGE_BOTH" },
254#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000255 { 0, NULL },
256};
257
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000258#ifdef ALPHA
259void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000260printrusage32(struct tcb *tcp, long addr)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000261{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000262 struct timeval32 {
263 unsigned tv_sec;
264 unsigned tv_usec;
265 };
266 struct rusage32 {
267 struct timeval32 ru_utime; /* user time used */
268 struct timeval32 ru_stime; /* system time used */
269 long ru_maxrss; /* maximum resident set size */
270 long ru_ixrss; /* integral shared memory size */
271 long ru_idrss; /* integral unshared data size */
272 long ru_isrss; /* integral unshared stack size */
273 long ru_minflt; /* page reclaims */
274 long ru_majflt; /* page faults */
275 long ru_nswap; /* swaps */
276 long ru_inblock; /* block input operations */
277 long ru_oublock; /* block output operations */
278 long ru_msgsnd; /* messages sent */
279 long ru_msgrcv; /* messages received */
280 long ru_nsignals; /* signals received */
281 long ru_nvcsw; /* voluntary context switches */
282 long ru_nivcsw; /* involuntary " */
283 } ru;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000284
Denys Vlasenko1d632462009-04-14 12:51:00 +0000285 if (!addr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200286 tprints("NULL");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000287 else if (syserror(tcp) || !verbose(tcp))
288 tprintf("%#lx", addr);
289 else if (umove(tcp, addr, &ru) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200290 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000291 else if (!abbrev(tcp)) {
292 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
293 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
294 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
295 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
296 ru.ru_maxrss, ru.ru_ixrss);
297 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
298 ru.ru_idrss, ru.ru_isrss);
299 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
300 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
301 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
302 ru.ru_inblock, ru.ru_oublock);
303 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
304 ru.ru_msgsnd, ru.ru_msgrcv);
305 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
306 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
307 }
308 else {
309 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
310 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
311 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
312 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000313}
314#endif
315
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000316void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000317printrusage(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000318{
319 struct rusage ru;
320
321 if (!addr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200322 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000323 else if (syserror(tcp) || !verbose(tcp))
324 tprintf("%#lx", addr);
325 else if (umove(tcp, addr, &ru) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200326 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000327 else if (!abbrev(tcp)) {
328 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
329 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
330 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
331 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
332 ru.ru_maxrss, ru.ru_ixrss);
333 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
334 ru.ru_idrss, ru.ru_isrss);
335 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
336 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
337 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
338 ru.ru_inblock, ru.ru_oublock);
339 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
340 ru.ru_msgsnd, ru.ru_msgrcv);
341 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
342 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
343 }
344 else {
345 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
346 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
347 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
348 }
349}
350
351int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000352sys_getrusage(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000353{
354 if (entering(tcp)) {
355 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200356 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000357 }
358 else
359 printrusage(tcp, tcp->u_arg[1]);
360 return 0;
361}
362
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000363#ifdef ALPHA
364int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000365sys_osf_getrusage(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000366{
Denys Vlasenko59432db2009-01-26 19:09:35 +0000367 if (entering(tcp)) {
368 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200369 tprints(", ");
Denys Vlasenko59432db2009-01-26 19:09:35 +0000370 }
371 else
372 printrusage32(tcp, tcp->u_arg[1]);
373 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000374}
375#endif /* ALPHA */
376
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000377int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000378sys_sysinfo(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000379{
380 struct sysinfo si;
381
382 if (exiting(tcp)) {
383 if (syserror(tcp) || !verbose(tcp))
384 tprintf("%#lx", tcp->u_arg[0]);
385 else if (umove(tcp, tcp->u_arg[0], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200386 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000387 else {
388 tprintf("{uptime=%lu, loads=[%lu, %lu, %lu] ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800389 (long) si.uptime, (long) si.loads[0],
390 (long) si.loads[1], (long) si.loads[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000391 tprintf("totalram=%lu, freeram=%lu, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800392 (long) si.totalram, (long) si.freeram);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000393 tprintf("sharedram=%lu, bufferram=%lu} ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800394 (long) si.sharedram, (long) si.bufferram);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000395 tprintf("totalswap=%lu, freeswap=%lu, procs=%hu}",
H.J. Lu0b315b62012-02-03 10:16:03 -0800396 (long) si.totalswap, (long) si.freeswap,
397 si.procs);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000398 }
399 }
400 return 0;
401}
402
Roland McGrathd9f816f2004-09-04 03:39:20 +0000403static const struct xlat priorities[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000404 { PRIO_PROCESS, "PRIO_PROCESS" },
405 { PRIO_PGRP, "PRIO_PGRP" },
406 { PRIO_USER, "PRIO_USER" },
407 { 0, NULL },
408};
409
410int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000411sys_getpriority(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000412{
413 if (entering(tcp)) {
414 printxval(priorities, tcp->u_arg[0], "PRIO_???");
415 tprintf(", %lu", tcp->u_arg[1]);
416 }
417 return 0;
418}
419
420int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000421sys_setpriority(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000422{
423 if (entering(tcp)) {
424 printxval(priorities, tcp->u_arg[0], "PRIO_???");
425 tprintf(", %lu, %ld", tcp->u_arg[1], tcp->u_arg[2]);
426 }
427 return 0;
428}
429
430int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000431sys_times(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000432{
433 struct tms tbuf;
434
435 if (exiting(tcp)) {
436 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200437 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000438 else if (syserror(tcp))
439 tprintf("%#lx", tcp->u_arg[0]);
440 else if (umove(tcp, tcp->u_arg[0], &tbuf) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200441 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000442 else {
443 tprintf("{tms_utime=%lu, tms_stime=%lu, ",
444 tbuf.tms_utime, tbuf.tms_stime);
445 tprintf("tms_cutime=%lu, tms_cstime=%lu}",
446 tbuf.tms_cutime, tbuf.tms_cstime);
447 }
448 }
449 return 0;
450}