blob: 77a94a29625c43e47d6748f6e7c85a7da1908ee9 [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
Roland McGrathd9f816f2004-09-04 03:39:20 +000036static const struct xlat resources[] = {
Roland McGrath70d99092005-12-02 04:08:27 +000037#ifdef RLIMIT_AS
Dmitry V. Levinb468f232012-03-16 23:05:21 +040038 { RLIMIT_AS, "RLIMIT_AS" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000039#endif
40#ifdef RLIMIT_CORE
Dmitry V. Levinb468f232012-03-16 23:05:21 +040041 { RLIMIT_CORE, "RLIMIT_CORE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000042#endif
Roland McGrath70d99092005-12-02 04:08:27 +000043#ifdef RLIMIT_CPU
Dmitry V. Levinb468f232012-03-16 23:05:21 +040044 { RLIMIT_CPU, "RLIMIT_CPU" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000045#endif
Roland McGrath70d99092005-12-02 04:08:27 +000046#ifdef RLIMIT_DATA
Dmitry V. Levinb468f232012-03-16 23:05:21 +040047 { RLIMIT_DATA, "RLIMIT_DATA" },
Wichert Akkermanc7926982000-04-10 22:22:31 +000048#endif
Roland McGrath70d99092005-12-02 04:08:27 +000049#ifdef RLIMIT_FSIZE
Dmitry V. Levinb468f232012-03-16 23:05:21 +040050 { RLIMIT_FSIZE, "RLIMIT_FSIZE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000051#endif
Roland McGrath566ce1f2004-10-06 22:14:53 +000052#ifdef RLIMIT_LOCKS
Dmitry V. Levinb468f232012-03-16 23:05:21 +040053 { RLIMIT_LOCKS, "RLIMIT_LOCKS" },
Roland McGrath566ce1f2004-10-06 22:14:53 +000054#endif
Roland McGrath70d99092005-12-02 04:08:27 +000055#ifdef RLIMIT_MEMLOCK
56 { RLIMIT_MEMLOCK, "RLIMIT_MEMLOCK" },
Roland McGrath566ce1f2004-10-06 22:14:53 +000057#endif
58#ifdef RLIMIT_MSGQUEUE
59 { RLIMIT_MSGQUEUE, "RLIMIT_MSGQUEUE" },
60#endif
Roland McGrath70d99092005-12-02 04:08:27 +000061#ifdef RLIMIT_NICE
Dmitry V. Levinb468f232012-03-16 23:05:21 +040062 { RLIMIT_NICE, "RLIMIT_NICE" },
Roland McGrath70d99092005-12-02 04:08:27 +000063#endif
64#ifdef RLIMIT_NOFILE
Dmitry V. Levinb468f232012-03-16 23:05:21 +040065 { RLIMIT_NOFILE, "RLIMIT_NOFILE" },
Roland McGrath70d99092005-12-02 04:08:27 +000066#endif
67#ifdef RLIMIT_NPROC
Dmitry V. Levinb468f232012-03-16 23:05:21 +040068 { RLIMIT_NPROC, "RLIMIT_NPROC" },
Roland McGrath70d99092005-12-02 04:08:27 +000069#endif
70#ifdef RLIMIT_RSS
Dmitry V. Levinb468f232012-03-16 23:05:21 +040071 { RLIMIT_RSS, "RLIMIT_RSS" },
Roland McGrath70d99092005-12-02 04:08:27 +000072#endif
73#ifdef RLIMIT_RTPRIO
Dmitry V. Levinb468f232012-03-16 23:05:21 +040074 { RLIMIT_RTPRIO, "RLIMIT_RTPRIO" },
75#endif
76#ifdef RLIMIT_RTTIME
77 { RLIMIT_RTTIME, "RLIMIT_RTTIME" },
Roland McGrath70d99092005-12-02 04:08:27 +000078#endif
79#ifdef RLIMIT_SIGPENDING
80 { RLIMIT_SIGPENDING, "RLIMIT_SIGPENDING" },
81#endif
82#ifdef RLIMIT_STACK
Dmitry V. Levinb468f232012-03-16 23:05:21 +040083 { RLIMIT_STACK, "RLIMIT_STACK" },
Roland McGrath70d99092005-12-02 04:08:27 +000084#endif
85#ifdef RLIMIT_VMEM
Dmitry V. Levinb468f232012-03-16 23:05:21 +040086 { RLIMIT_VMEM, "RLIMIT_VMEM" },
Roland McGrath70d99092005-12-02 04:08:27 +000087#endif
Dmitry V. Levinb468f232012-03-16 23:05:21 +040088 { 0, NULL }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000089};
90
Dmitry V. Levinb468f232012-03-16 23:05:21 +040091#if !(SIZEOF_RLIM_T == 4 || SIZEOF_RLIM_T == 8)
92# error "Unsupported SIZEOF_RLIM_T value"
93#endif
94
Denys Vlasenko1945ccc2012-02-27 14:37:48 +010095static const char *
Dmitry V. Levinb468f232012-03-16 23:05:21 +040096sprint_rlim64(uint64_t lim)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000097{
Dmitry V. Levinb468f232012-03-16 23:05:21 +040098 static char buf[sizeof(uint64_t)*3 + sizeof("*1024")];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000099
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400100 if (lim == UINT64_MAX)
101 return "RLIM64_INFINITY";
Denys Vlasenko1945ccc2012-02-27 14:37:48 +0100102
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400103 if (lim > 1024 && lim % 1024 == 0)
104 sprintf(buf, "%" PRIu64 "*1024", lim / 1024);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000105 else
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400106 sprintf(buf, "%" PRIu64, lim);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000107 return buf;
108}
109
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200110static void
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400111print_rlimit64(struct tcb *tcp, unsigned long addr)
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200112{
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400113 struct rlimit_64 {
114 uint64_t rlim_cur;
115 uint64_t rlim_max;
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200116 } rlim;
117
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400118 if (umove(tcp, addr, &rlim) < 0)
119 tprintf("%#lx", addr);
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200120 else {
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400121 tprintf("{rlim_cur=%s,", sprint_rlim64(rlim.rlim_cur));
122 tprintf(" rlim_max=%s}", sprint_rlim64(rlim.rlim_max));
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200123 }
124}
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400125
126static void
127decode_rlimit64(struct tcb *tcp, unsigned long addr)
128{
129 if (!addr)
130 tprints("NULL");
131 else if (!verbose(tcp) ||
132 (exiting(tcp) && syserror(tcp)))
133 tprintf("%#lx", addr);
134 else
135 print_rlimit64(tcp, addr);
136}
137
138#if SIZEOF_RLIM_T == 4 || SUPPORTED_PERSONALITIES > 1
139
140static const char *
141sprint_rlim32(uint32_t lim)
142{
143 static char buf[sizeof(uint32_t)*3 + sizeof("*1024")];
144
145 if (lim == UINT32_MAX)
146 return "RLIM_INFINITY";
147
148 if (lim > 1024 && lim % 1024 == 0)
149 sprintf(buf, "%" PRIu32 "*1024", lim / 1024);
150 else
151 sprintf(buf, "%" PRIu32, lim);
152 return buf;
153}
154
155static void
156print_rlimit32(struct tcb *tcp, unsigned long addr)
157{
158 struct rlimit_32 {
159 uint32_t rlim_cur;
160 uint32_t rlim_max;
161 } rlim;
162
163 if (umove(tcp, addr, &rlim) < 0)
164 tprintf("%#lx", addr);
165 else {
166 tprintf("{rlim_cur=%s,", sprint_rlim32(rlim.rlim_cur));
167 tprintf(" rlim_max=%s}", sprint_rlim32(rlim.rlim_max));
168 }
169}
170
171static void
172decode_rlimit(struct tcb *tcp, unsigned long addr)
173{
174 if (!addr)
175 tprints("NULL");
176 else if (!verbose(tcp) ||
177 (exiting(tcp) && syserror(tcp)))
178 tprintf("%#lx", addr);
179 else {
180# if SIZEOF_RLIM_T == 4
181 print_rlimit32(tcp, addr);
182# else
183 if (personality_wordsize[current_personality] == 4)
184 print_rlimit32(tcp, addr);
185 else
186 print_rlimit64(tcp, addr);
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200187# endif
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400188 }
189}
190
191#else /* SIZEOF_RLIM_T == 8 && SUPPORTED_PERSONALITIES == 1 */
192
193# define decode_rlimit decode_rlimit64
194
195#endif /* SIZEOF_RLIM_T == 4 || SUPPORTED_PERSONALITIES > 1 */
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200196
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000197int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000198sys_getrlimit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000199{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000200 if (entering(tcp)) {
201 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200202 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000203 }
204 else {
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400205 decode_rlimit(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000206 }
207 return 0;
208}
209
210int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000211sys_setrlimit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000212{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000213 if (entering(tcp)) {
214 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200215 tprints(", ");
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400216 decode_rlimit(tcp, tcp->u_arg[1]);
John Hughesbdf48f52001-03-06 15:08:09 +0000217 }
218 return 0;
219}
220
221int
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400222sys_prlimit64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000223{
John Hughesbdf48f52001-03-06 15:08:09 +0000224 if (entering(tcp)) {
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400225 tprintf("%ld, ", tcp->u_arg[0]);
226 printxval(resources, tcp->u_arg[1], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200227 tprints(", ");
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400228 decode_rlimit64(tcp, tcp->u_arg[2]);
229 tprints(", ");
230 } else {
231 decode_rlimit64(tcp, tcp->u_arg[3]);
John Hughesbdf48f52001-03-06 15:08:09 +0000232 }
233 return 0;
234}
John Hughesbdf48f52001-03-06 15:08:09 +0000235
Roland McGrathd9f816f2004-09-04 03:39:20 +0000236static const struct xlat usagewho[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000237 { RUSAGE_SELF, "RUSAGE_SELF" },
238 { RUSAGE_CHILDREN, "RUSAGE_CHILDREN" },
Wichert Akkermanc7926982000-04-10 22:22:31 +0000239#ifdef RUSAGE_BOTH
240 { RUSAGE_BOTH, "RUSAGE_BOTH" },
241#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000242 { 0, NULL },
243};
244
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000245#ifdef ALPHA
246void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000247printrusage32(struct tcb *tcp, long addr)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000248{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000249 struct timeval32 {
250 unsigned tv_sec;
251 unsigned tv_usec;
252 };
253 struct rusage32 {
254 struct timeval32 ru_utime; /* user time used */
255 struct timeval32 ru_stime; /* system time used */
256 long ru_maxrss; /* maximum resident set size */
257 long ru_ixrss; /* integral shared memory size */
258 long ru_idrss; /* integral unshared data size */
259 long ru_isrss; /* integral unshared stack size */
260 long ru_minflt; /* page reclaims */
261 long ru_majflt; /* page faults */
262 long ru_nswap; /* swaps */
263 long ru_inblock; /* block input operations */
264 long ru_oublock; /* block output operations */
265 long ru_msgsnd; /* messages sent */
266 long ru_msgrcv; /* messages received */
267 long ru_nsignals; /* signals received */
268 long ru_nvcsw; /* voluntary context switches */
269 long ru_nivcsw; /* involuntary " */
270 } ru;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000271
Denys Vlasenko1d632462009-04-14 12:51:00 +0000272 if (!addr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200273 tprints("NULL");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000274 else if (syserror(tcp) || !verbose(tcp))
275 tprintf("%#lx", addr);
276 else if (umove(tcp, addr, &ru) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200277 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000278 else if (!abbrev(tcp)) {
279 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
280 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
281 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
282 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
283 ru.ru_maxrss, ru.ru_ixrss);
284 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
285 ru.ru_idrss, ru.ru_isrss);
286 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
287 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
288 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
289 ru.ru_inblock, ru.ru_oublock);
290 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
291 ru.ru_msgsnd, ru.ru_msgrcv);
292 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
293 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
294 }
295 else {
296 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
297 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
298 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
299 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000300}
301#endif
302
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000303void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000304printrusage(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000305{
306 struct rusage ru;
307
308 if (!addr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200309 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000310 else if (syserror(tcp) || !verbose(tcp))
311 tprintf("%#lx", addr);
312 else if (umove(tcp, addr, &ru) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200313 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000314 else if (!abbrev(tcp)) {
315 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
316 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
317 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
318 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
319 ru.ru_maxrss, ru.ru_ixrss);
320 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
321 ru.ru_idrss, ru.ru_isrss);
322 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
323 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
324 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
325 ru.ru_inblock, ru.ru_oublock);
326 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
327 ru.ru_msgsnd, ru.ru_msgrcv);
328 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
329 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
330 }
331 else {
332 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ...}",
333 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
334 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
335 }
336}
337
338int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000339sys_getrusage(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000340{
341 if (entering(tcp)) {
342 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200343 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000344 }
345 else
346 printrusage(tcp, tcp->u_arg[1]);
347 return 0;
348}
349
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000350#ifdef ALPHA
351int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000352sys_osf_getrusage(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000353{
Denys Vlasenko59432db2009-01-26 19:09:35 +0000354 if (entering(tcp)) {
355 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200356 tprints(", ");
Denys Vlasenko59432db2009-01-26 19:09:35 +0000357 }
358 else
359 printrusage32(tcp, tcp->u_arg[1]);
360 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000361}
362#endif /* ALPHA */
363
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000364int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000365sys_sysinfo(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000366{
367 struct sysinfo si;
368
369 if (exiting(tcp)) {
370 if (syserror(tcp) || !verbose(tcp))
371 tprintf("%#lx", tcp->u_arg[0]);
372 else if (umove(tcp, tcp->u_arg[0], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200373 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000374 else {
375 tprintf("{uptime=%lu, loads=[%lu, %lu, %lu] ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800376 (long) si.uptime, (long) si.loads[0],
377 (long) si.loads[1], (long) si.loads[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000378 tprintf("totalram=%lu, freeram=%lu, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800379 (long) si.totalram, (long) si.freeram);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000380 tprintf("sharedram=%lu, bufferram=%lu} ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800381 (long) si.sharedram, (long) si.bufferram);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000382 tprintf("totalswap=%lu, freeswap=%lu, procs=%hu}",
H.J. Lu0b315b62012-02-03 10:16:03 -0800383 (long) si.totalswap, (long) si.freeswap,
384 si.procs);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000385 }
386 }
387 return 0;
388}
389
Roland McGrathd9f816f2004-09-04 03:39:20 +0000390static const struct xlat priorities[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000391 { PRIO_PROCESS, "PRIO_PROCESS" },
392 { PRIO_PGRP, "PRIO_PGRP" },
393 { PRIO_USER, "PRIO_USER" },
394 { 0, NULL },
395};
396
397int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000398sys_getpriority(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000399{
400 if (entering(tcp)) {
401 printxval(priorities, tcp->u_arg[0], "PRIO_???");
402 tprintf(", %lu", tcp->u_arg[1]);
403 }
404 return 0;
405}
406
407int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000408sys_setpriority(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000409{
410 if (entering(tcp)) {
411 printxval(priorities, tcp->u_arg[0], "PRIO_???");
412 tprintf(", %lu, %ld", tcp->u_arg[1], tcp->u_arg[2]);
413 }
414 return 0;
415}
416
417int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000418sys_times(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000419{
420 struct tms tbuf;
421
422 if (exiting(tcp)) {
423 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200424 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000425 else if (syserror(tcp))
426 tprintf("%#lx", tcp->u_arg[0]);
427 else if (umove(tcp, tcp->u_arg[0], &tbuf) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200428 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000429 else {
430 tprintf("{tms_utime=%lu, tms_stime=%lu, ",
431 tbuf.tms_utime, tbuf.tms_stime);
432 tprintf("tms_cutime=%lu, tms_cstime=%lu}",
433 tbuf.tms_cutime, tbuf.tms_cstime);
434 }
435 }
436 return 0;
437}