blob: f5cec21583480a8719085f70a2431de35d0fb0e9 [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
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100107static const char *
Denys Vlasenko1d632462009-04-14 12:51:00 +0000108sprintrlim(long lim)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000109{
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100110 static char buf[sizeof(long)*3 + sizeof("%ld*1024")];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000111
112 if (lim == RLIM_INFINITY)
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100113 return "RLIM_INFINITY";
114
115 if (lim > 1024 && lim%1024 == 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000116 sprintf(buf, "%ld*1024", lim/1024);
117 else
118 sprintf(buf, "%ld", lim);
119 return buf;
120}
121
Denys Vlasenkoaa925db2012-02-25 15:19:02 +0100122# if defined(POWERPC64) || defined(X86_64)
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200123static void
124print_rlimit32(struct tcb *tcp)
125{
126 struct rlimit32 {
127 unsigned int rlim_cur;
128 unsigned int rlim_max;
129 } rlim;
130
131 if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200132 tprints("{...}");
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200133 else {
134 tprintf("{rlim_cur=%s,",
135 sprintrlim(rlim.rlim_cur == -1 ? RLIM_INFINITY
136 : rlim.rlim_cur));
137 tprintf(" rlim_max=%s}",
138 sprintrlim(rlim.rlim_max == -1 ? RLIM_INFINITY
139 : rlim.rlim_max));
140 }
141}
142# endif
143
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000144int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000145sys_getrlimit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000146{
147 struct rlimit rlim;
148
149 if (entering(tcp)) {
150 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200151 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000152 }
153 else {
154 if (syserror(tcp) || !verbose(tcp))
155 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenkoaa925db2012-02-25 15:19:02 +0100156# if defined(POWERPC64) || defined(X86_64)
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200157 else if (current_personality == 1)
158 print_rlimit32(tcp);
159# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000160 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200161 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000162 else {
163 tprintf("{rlim_cur=%s,", sprintrlim(rlim.rlim_cur));
164 tprintf(" rlim_max=%s}", sprintrlim(rlim.rlim_max));
165 }
166 }
167 return 0;
168}
169
170int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000171sys_setrlimit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000172{
173 struct rlimit rlim;
174
175 if (entering(tcp)) {
176 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200177 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000178 if (!verbose(tcp))
179 tprintf("%#lx", tcp->u_arg[1]);
Denys Vlasenkoaa925db2012-02-25 15:19:02 +0100180# if defined(POWERPC64) || defined(X86_64)
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200181 else if (current_personality == 1)
182 print_rlimit32(tcp);
183# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000184 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200185 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000186 else {
187 tprintf("{rlim_cur=%s,", sprintrlim(rlim.rlim_cur));
188 tprintf(" rlim_max=%s}", sprintrlim(rlim.rlim_max));
189 }
190 }
191 return 0;
192}
John Hughes70623be2001-03-08 13:59:00 +0000193#endif /* !HAVE_LONG_LONG_RLIM_T */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000194
John Hughes70623be2001-03-08 13:59:00 +0000195#if _LFS64_LARGEFILE || HAVE_LONG_LONG_RLIM_T
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100196static const char *
Denys Vlasenko1d632462009-04-14 12:51:00 +0000197sprintrlim64(rlim64_t lim)
John Hughesbdf48f52001-03-06 15:08:09 +0000198{
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100199 static char buf[sizeof(long long)*3 + sizeof("%lld*1024")];
John Hughesbdf48f52001-03-06 15:08:09 +0000200
201 if (lim == RLIM64_INFINITY)
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100202 return "RLIM64_INFINITY";
203
204 if (lim > 1024 && lim%1024 == 0)
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000205 sprintf(buf, "%lld*1024", (long long) lim/1024);
John Hughesbdf48f52001-03-06 15:08:09 +0000206 else
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000207 sprintf(buf, "%lld", (long long) lim);
John Hughesbdf48f52001-03-06 15:08:09 +0000208 return buf;
209}
210
211int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000212sys_getrlimit64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000213{
214 struct rlimit64 rlim;
215
216 if (entering(tcp)) {
217 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200218 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +0000219 }
220 else {
221 if (syserror(tcp) || !verbose(tcp))
222 tprintf("%#lx", tcp->u_arg[1]);
223 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200224 tprints("{...}");
John Hughesbdf48f52001-03-06 15:08:09 +0000225 else {
226 tprintf("{rlim_cur=%s,", sprintrlim64(rlim.rlim_cur));
227 tprintf(" rlim_max=%s}", sprintrlim64(rlim.rlim_max));
228 }
229 }
230 return 0;
231}
232
233int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000234sys_setrlimit64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000235{
236 struct rlimit64 rlim;
237
238 if (entering(tcp)) {
239 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200240 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +0000241 if (!verbose(tcp))
242 tprintf("%#lx", tcp->u_arg[1]);
243 else if (umove(tcp, tcp->u_arg[1], &rlim) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200244 tprints("{...}");
John Hughesbdf48f52001-03-06 15:08:09 +0000245 else {
246 tprintf("{rlim_cur=%s,", sprintrlim64(rlim.rlim_cur));
247 tprintf(" rlim_max=%s}", sprintrlim64(rlim.rlim_max));
248 }
249 }
250 return 0;
251}
John Hughes70623be2001-03-08 13:59:00 +0000252#endif /* _LFS64_LARGEFILES || HAVE_LONG_LONG_RLIM_T */
John Hughesbdf48f52001-03-06 15:08:09 +0000253
Roland McGrathd9f816f2004-09-04 03:39:20 +0000254static const struct xlat usagewho[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000255 { RUSAGE_SELF, "RUSAGE_SELF" },
256 { RUSAGE_CHILDREN, "RUSAGE_CHILDREN" },
Wichert Akkermanc7926982000-04-10 22:22:31 +0000257#ifdef RUSAGE_BOTH
258 { RUSAGE_BOTH, "RUSAGE_BOTH" },
259#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000260 { 0, NULL },
261};
262
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000263#ifdef ALPHA
264void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000265printrusage32(struct tcb *tcp, long addr)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000266{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000267 struct timeval32 {
268 unsigned tv_sec;
269 unsigned tv_usec;
270 };
271 struct rusage32 {
272 struct timeval32 ru_utime; /* user time used */
273 struct timeval32 ru_stime; /* system time used */
274 long ru_maxrss; /* maximum resident set size */
275 long ru_ixrss; /* integral shared memory size */
276 long ru_idrss; /* integral unshared data size */
277 long ru_isrss; /* integral unshared stack size */
278 long ru_minflt; /* page reclaims */
279 long ru_majflt; /* page faults */
280 long ru_nswap; /* swaps */
281 long ru_inblock; /* block input operations */
282 long ru_oublock; /* block output operations */
283 long ru_msgsnd; /* messages sent */
284 long ru_msgrcv; /* messages received */
285 long ru_nsignals; /* signals received */
286 long ru_nvcsw; /* voluntary context switches */
287 long ru_nivcsw; /* involuntary " */
288 } ru;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000289
Denys Vlasenko1d632462009-04-14 12:51:00 +0000290 if (!addr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200291 tprints("NULL");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000292 else if (syserror(tcp) || !verbose(tcp))
293 tprintf("%#lx", addr);
294 else if (umove(tcp, addr, &ru) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200295 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000296 else if (!abbrev(tcp)) {
297 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
298 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
299 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
300 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
301 ru.ru_maxrss, ru.ru_ixrss);
302 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
303 ru.ru_idrss, ru.ru_isrss);
304 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
305 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
306 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
307 ru.ru_inblock, ru.ru_oublock);
308 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
309 ru.ru_msgsnd, ru.ru_msgrcv);
310 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
311 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
312 }
313 else {
314 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
315 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
316 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
317 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000318}
319#endif
320
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000321void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000322printrusage(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000323{
324 struct rusage ru;
325
326 if (!addr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200327 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000328 else if (syserror(tcp) || !verbose(tcp))
329 tprintf("%#lx", addr);
330 else if (umove(tcp, addr, &ru) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200331 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000332 else if (!abbrev(tcp)) {
333 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
334 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
335 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
336 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
337 ru.ru_maxrss, ru.ru_ixrss);
338 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
339 ru.ru_idrss, ru.ru_isrss);
340 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
341 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
342 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
343 ru.ru_inblock, ru.ru_oublock);
344 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
345 ru.ru_msgsnd, ru.ru_msgrcv);
346 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
347 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
348 }
349 else {
350 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
351 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
352 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
353 }
354}
355
356int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000357sys_getrusage(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000358{
359 if (entering(tcp)) {
360 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200361 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000362 }
363 else
364 printrusage(tcp, tcp->u_arg[1]);
365 return 0;
366}
367
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000368#ifdef ALPHA
369int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000370sys_osf_getrusage(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000371{
Denys Vlasenko59432db2009-01-26 19:09:35 +0000372 if (entering(tcp)) {
373 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200374 tprints(", ");
Denys Vlasenko59432db2009-01-26 19:09:35 +0000375 }
376 else
377 printrusage32(tcp, tcp->u_arg[1]);
378 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000379}
380#endif /* ALPHA */
381
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000382int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000383sys_sysinfo(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000384{
385 struct sysinfo si;
386
387 if (exiting(tcp)) {
388 if (syserror(tcp) || !verbose(tcp))
389 tprintf("%#lx", tcp->u_arg[0]);
390 else if (umove(tcp, tcp->u_arg[0], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200391 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000392 else {
393 tprintf("{uptime=%lu, loads=[%lu, %lu, %lu] ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800394 (long) si.uptime, (long) si.loads[0],
395 (long) si.loads[1], (long) si.loads[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000396 tprintf("totalram=%lu, freeram=%lu, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800397 (long) si.totalram, (long) si.freeram);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000398 tprintf("sharedram=%lu, bufferram=%lu} ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800399 (long) si.sharedram, (long) si.bufferram);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000400 tprintf("totalswap=%lu, freeswap=%lu, procs=%hu}",
H.J. Lu0b315b62012-02-03 10:16:03 -0800401 (long) si.totalswap, (long) si.freeswap,
402 si.procs);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000403 }
404 }
405 return 0;
406}
407
Roland McGrathd9f816f2004-09-04 03:39:20 +0000408static const struct xlat priorities[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000409 { PRIO_PROCESS, "PRIO_PROCESS" },
410 { PRIO_PGRP, "PRIO_PGRP" },
411 { PRIO_USER, "PRIO_USER" },
412 { 0, NULL },
413};
414
415int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000416sys_getpriority(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000417{
418 if (entering(tcp)) {
419 printxval(priorities, tcp->u_arg[0], "PRIO_???");
420 tprintf(", %lu", tcp->u_arg[1]);
421 }
422 return 0;
423}
424
425int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000426sys_setpriority(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, %ld", tcp->u_arg[1], tcp->u_arg[2]);
431 }
432 return 0;
433}
434
435int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000436sys_times(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000437{
438 struct tms tbuf;
439
440 if (exiting(tcp)) {
441 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200442 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000443 else if (syserror(tcp))
444 tprintf("%#lx", tcp->u_arg[0]);
445 else if (umove(tcp, tcp->u_arg[0], &tbuf) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200446 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000447 else {
448 tprintf("{tms_utime=%lu, tms_stime=%lu, ",
449 tbuf.tms_utime, tbuf.tms_stime);
450 tprintf("tms_cutime=%lu, tms_cstime=%lu}",
451 tbuf.tms_cutime, tbuf.tms_cstime);
452 }
453 }
454 return 0;
455}