blob: b62f631677f98b9da0b187bb7e3bf47d7b82ff16 [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. Levinbce0cc62014-02-05 01:33:50 +000038 XLAT(RLIMIT_AS),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000039#endif
40#ifdef RLIMIT_CORE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000041 XLAT(RLIMIT_CORE),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000042#endif
Roland McGrath70d99092005-12-02 04:08:27 +000043#ifdef RLIMIT_CPU
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000044 XLAT(RLIMIT_CPU),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000045#endif
Roland McGrath70d99092005-12-02 04:08:27 +000046#ifdef RLIMIT_DATA
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000047 XLAT(RLIMIT_DATA),
Wichert Akkermanc7926982000-04-10 22:22:31 +000048#endif
Roland McGrath70d99092005-12-02 04:08:27 +000049#ifdef RLIMIT_FSIZE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000050 XLAT(RLIMIT_FSIZE),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000051#endif
Roland McGrath566ce1f2004-10-06 22:14:53 +000052#ifdef RLIMIT_LOCKS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000053 XLAT(RLIMIT_LOCKS),
Roland McGrath566ce1f2004-10-06 22:14:53 +000054#endif
Roland McGrath70d99092005-12-02 04:08:27 +000055#ifdef RLIMIT_MEMLOCK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000056 XLAT(RLIMIT_MEMLOCK),
Roland McGrath566ce1f2004-10-06 22:14:53 +000057#endif
58#ifdef RLIMIT_MSGQUEUE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000059 XLAT(RLIMIT_MSGQUEUE),
Roland McGrath566ce1f2004-10-06 22:14:53 +000060#endif
Roland McGrath70d99092005-12-02 04:08:27 +000061#ifdef RLIMIT_NICE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000062 XLAT(RLIMIT_NICE),
Roland McGrath70d99092005-12-02 04:08:27 +000063#endif
64#ifdef RLIMIT_NOFILE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000065 XLAT(RLIMIT_NOFILE),
Roland McGrath70d99092005-12-02 04:08:27 +000066#endif
67#ifdef RLIMIT_NPROC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000068 XLAT(RLIMIT_NPROC),
Roland McGrath70d99092005-12-02 04:08:27 +000069#endif
70#ifdef RLIMIT_RSS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000071 XLAT(RLIMIT_RSS),
Roland McGrath70d99092005-12-02 04:08:27 +000072#endif
73#ifdef RLIMIT_RTPRIO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000074 XLAT(RLIMIT_RTPRIO),
Dmitry V. Levinb468f232012-03-16 23:05:21 +040075#endif
76#ifdef RLIMIT_RTTIME
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000077 XLAT(RLIMIT_RTTIME),
Roland McGrath70d99092005-12-02 04:08:27 +000078#endif
79#ifdef RLIMIT_SIGPENDING
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000080 XLAT(RLIMIT_SIGPENDING),
Roland McGrath70d99092005-12-02 04:08:27 +000081#endif
82#ifdef RLIMIT_STACK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000083 XLAT(RLIMIT_STACK),
Roland McGrath70d99092005-12-02 04:08:27 +000084#endif
85#ifdef RLIMIT_VMEM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000086 XLAT(RLIMIT_VMEM),
Roland McGrath70d99092005-12-02 04:08:27 +000087#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +000088 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000089};
90
Denys Vlasenko1945ccc2012-02-27 14:37:48 +010091static const char *
Dmitry V. Levinb468f232012-03-16 23:05:21 +040092sprint_rlim64(uint64_t lim)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000093{
Dmitry V. Levinb468f232012-03-16 23:05:21 +040094 static char buf[sizeof(uint64_t)*3 + sizeof("*1024")];
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000095
Dmitry V. Levinb468f232012-03-16 23:05:21 +040096 if (lim == UINT64_MAX)
97 return "RLIM64_INFINITY";
Denys Vlasenko1945ccc2012-02-27 14:37:48 +010098
Dmitry V. Levinb468f232012-03-16 23:05:21 +040099 if (lim > 1024 && lim % 1024 == 0)
100 sprintf(buf, "%" PRIu64 "*1024", lim / 1024);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000101 else
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400102 sprintf(buf, "%" PRIu64, lim);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000103 return buf;
104}
105
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200106static void
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400107print_rlimit64(struct tcb *tcp, unsigned long addr)
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200108{
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400109 struct rlimit_64 {
110 uint64_t rlim_cur;
111 uint64_t rlim_max;
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200112 } rlim;
113
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400114 if (umove(tcp, addr, &rlim) < 0)
115 tprintf("%#lx", addr);
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200116 else {
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400117 tprintf("{rlim_cur=%s,", sprint_rlim64(rlim.rlim_cur));
118 tprintf(" rlim_max=%s}", sprint_rlim64(rlim.rlim_max));
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200119 }
120}
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400121
122static void
123decode_rlimit64(struct tcb *tcp, unsigned long addr)
124{
125 if (!addr)
126 tprints("NULL");
127 else if (!verbose(tcp) ||
128 (exiting(tcp) && syserror(tcp)))
129 tprintf("%#lx", addr);
130 else
131 print_rlimit64(tcp, addr);
132}
133
James Hogan3b09ebe2014-05-02 14:15:41 +0100134#if !defined(current_wordsize) || current_wordsize == 4
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400135
136static const char *
137sprint_rlim32(uint32_t lim)
138{
139 static char buf[sizeof(uint32_t)*3 + sizeof("*1024")];
140
141 if (lim == UINT32_MAX)
142 return "RLIM_INFINITY";
143
144 if (lim > 1024 && lim % 1024 == 0)
145 sprintf(buf, "%" PRIu32 "*1024", lim / 1024);
146 else
147 sprintf(buf, "%" PRIu32, lim);
148 return buf;
149}
150
151static void
152print_rlimit32(struct tcb *tcp, unsigned long addr)
153{
154 struct rlimit_32 {
155 uint32_t rlim_cur;
156 uint32_t rlim_max;
157 } rlim;
158
159 if (umove(tcp, addr, &rlim) < 0)
160 tprintf("%#lx", addr);
161 else {
162 tprintf("{rlim_cur=%s,", sprint_rlim32(rlim.rlim_cur));
163 tprintf(" rlim_max=%s}", sprint_rlim32(rlim.rlim_max));
164 }
165}
166
167static void
168decode_rlimit(struct tcb *tcp, unsigned long addr)
169{
170 if (!addr)
171 tprints("NULL");
Denys Vlasenkoe015d2d2013-02-15 14:58:52 +0100172 else if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)))
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400173 tprintf("%#lx", addr);
174 else {
James Hogan3b09ebe2014-05-02 14:15:41 +0100175# if defined(X86_64) || defined(X32)
176 /*
177 * i386 is the only personality on X86_64 and X32
178 * with 32-bit rlim_t.
179 * When current_personality is X32, current_wordsize
180 * equals to 4 but rlim_t is 64-bit.
181 */
182 if (current_personality == 1)
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400183# else
Denys Vlasenko9fd4f962012-03-19 09:36:42 +0100184 if (current_wordsize == 4)
James Hogan3b09ebe2014-05-02 14:15:41 +0100185# endif
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400186 print_rlimit32(tcp, addr);
187 else
188 print_rlimit64(tcp, addr);
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400189 }
190}
191
James Hogan3b09ebe2014-05-02 14:15:41 +0100192#else /* defined(current_wordsize) && current_wordsize != 4 */
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400193
194# define decode_rlimit decode_rlimit64
195
James Hogan3b09ebe2014-05-02 14:15:41 +0100196#endif
Andreas Schwabee81c8a2010-07-03 23:17:28 +0200197
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000198int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000199sys_getrlimit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000200{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000201 if (entering(tcp)) {
202 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200203 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000204 }
205 else {
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400206 decode_rlimit(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000207 }
208 return 0;
209}
210
211int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000212sys_setrlimit(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000213{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000214 if (entering(tcp)) {
215 printxval(resources, tcp->u_arg[0], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200216 tprints(", ");
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400217 decode_rlimit(tcp, tcp->u_arg[1]);
John Hughesbdf48f52001-03-06 15:08:09 +0000218 }
219 return 0;
220}
221
222int
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400223sys_prlimit64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000224{
John Hughesbdf48f52001-03-06 15:08:09 +0000225 if (entering(tcp)) {
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400226 tprintf("%ld, ", tcp->u_arg[0]);
227 printxval(resources, tcp->u_arg[1], "RLIMIT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200228 tprints(", ");
Dmitry V. Levinb468f232012-03-16 23:05:21 +0400229 decode_rlimit64(tcp, tcp->u_arg[2]);
230 tprints(", ");
231 } else {
232 decode_rlimit64(tcp, tcp->u_arg[3]);
John Hughesbdf48f52001-03-06 15:08:09 +0000233 }
234 return 0;
235}
John Hughesbdf48f52001-03-06 15:08:09 +0000236
Roland McGrathd9f816f2004-09-04 03:39:20 +0000237static const struct xlat usagewho[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000238 XLAT(RUSAGE_SELF),
239 XLAT(RUSAGE_CHILDREN),
Wichert Akkermanc7926982000-04-10 22:22:31 +0000240#ifdef RUSAGE_BOTH
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000241 XLAT(RUSAGE_BOTH),
Wichert Akkermanc7926982000-04-10 22:22:31 +0000242#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000243 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000244};
245
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000246#ifdef ALPHA
247void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000248printrusage32(struct tcb *tcp, long addr)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000249{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000250 struct timeval32 {
251 unsigned tv_sec;
252 unsigned tv_usec;
253 };
254 struct rusage32 {
255 struct timeval32 ru_utime; /* user time used */
256 struct timeval32 ru_stime; /* system time used */
257 long ru_maxrss; /* maximum resident set size */
258 long ru_ixrss; /* integral shared memory size */
259 long ru_idrss; /* integral unshared data size */
260 long ru_isrss; /* integral unshared stack size */
261 long ru_minflt; /* page reclaims */
262 long ru_majflt; /* page faults */
263 long ru_nswap; /* swaps */
264 long ru_inblock; /* block input operations */
265 long ru_oublock; /* block output operations */
266 long ru_msgsnd; /* messages sent */
267 long ru_msgrcv; /* messages received */
268 long ru_nsignals; /* signals received */
269 long ru_nvcsw; /* voluntary context switches */
270 long ru_nivcsw; /* involuntary " */
271 } ru;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000272
Denys Vlasenko1d632462009-04-14 12:51:00 +0000273 if (!addr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200274 tprints("NULL");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000275 else if (syserror(tcp) || !verbose(tcp))
276 tprintf("%#lx", addr);
277 else if (umove(tcp, addr, &ru) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200278 tprints("{...}");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000279 else if (!abbrev(tcp)) {
280 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
281 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
282 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
283 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
284 ru.ru_maxrss, ru.ru_ixrss);
285 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
286 ru.ru_idrss, ru.ru_isrss);
287 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
288 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
289 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
290 ru.ru_inblock, ru.ru_oublock);
291 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
292 ru.ru_msgsnd, ru.ru_msgrcv);
293 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
294 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
295 }
296 else {
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 }
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000301}
302#endif
303
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000304void
Denys Vlasenko1d632462009-04-14 12:51:00 +0000305printrusage(struct tcb *tcp, long addr)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000306{
307 struct rusage ru;
308
309 if (!addr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200310 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000311 else if (syserror(tcp) || !verbose(tcp))
312 tprintf("%#lx", addr);
313 else if (umove(tcp, addr, &ru) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200314 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000315 else if (!abbrev(tcp)) {
316 tprintf("{ru_utime={%lu, %lu}, ru_stime={%lu, %lu}, ",
317 (long) ru.ru_utime.tv_sec, (long) ru.ru_utime.tv_usec,
318 (long) ru.ru_stime.tv_sec, (long) ru.ru_stime.tv_usec);
319 tprintf("ru_maxrss=%lu, ru_ixrss=%lu, ",
320 ru.ru_maxrss, ru.ru_ixrss);
321 tprintf("ru_idrss=%lu, ru_isrss=%lu, ",
322 ru.ru_idrss, ru.ru_isrss);
323 tprintf("ru_minflt=%lu, ru_majflt=%lu, ru_nswap=%lu, ",
324 ru.ru_minflt, ru.ru_majflt, ru.ru_nswap);
325 tprintf("ru_inblock=%lu, ru_oublock=%lu, ",
326 ru.ru_inblock, ru.ru_oublock);
327 tprintf("ru_msgsnd=%lu, ru_msgrcv=%lu, ",
328 ru.ru_msgsnd, ru.ru_msgrcv);
329 tprintf("ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}",
330 ru.ru_nsignals, ru.ru_nvcsw, ru.ru_nivcsw);
331 }
332 else {
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 }
337}
338
339int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000340sys_getrusage(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000341{
342 if (entering(tcp)) {
343 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200344 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000345 }
346 else
347 printrusage(tcp, tcp->u_arg[1]);
348 return 0;
349}
350
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000351#ifdef ALPHA
352int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000353sys_osf_getrusage(struct tcb *tcp)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000354{
Denys Vlasenko59432db2009-01-26 19:09:35 +0000355 if (entering(tcp)) {
356 printxval(usagewho, tcp->u_arg[0], "RUSAGE_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200357 tprints(", ");
Denys Vlasenko59432db2009-01-26 19:09:35 +0000358 }
359 else
360 printrusage32(tcp, tcp->u_arg[1]);
361 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000362}
363#endif /* ALPHA */
364
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000365int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000366sys_sysinfo(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000367{
368 struct sysinfo si;
369
370 if (exiting(tcp)) {
371 if (syserror(tcp) || !verbose(tcp))
372 tprintf("%#lx", tcp->u_arg[0]);
373 else if (umove(tcp, tcp->u_arg[0], &si) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200374 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000375 else {
376 tprintf("{uptime=%lu, loads=[%lu, %lu, %lu] ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800377 (long) si.uptime, (long) si.loads[0],
378 (long) si.loads[1], (long) si.loads[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000379 tprintf("totalram=%lu, freeram=%lu, ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800380 (long) si.totalram, (long) si.freeram);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000381 tprintf("sharedram=%lu, bufferram=%lu} ",
H.J. Lu0b315b62012-02-03 10:16:03 -0800382 (long) si.sharedram, (long) si.bufferram);
Denys Vlasenko61d62cf2012-04-16 18:12:27 +0200383 tprintf("totalswap=%lu, freeswap=%lu, procs=%u}",
H.J. Lu0b315b62012-02-03 10:16:03 -0800384 (long) si.totalswap, (long) si.freeswap,
Denys Vlasenko61d62cf2012-04-16 18:12:27 +0200385 (unsigned)si.procs);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000386 }
387 }
388 return 0;
389}
390
Roland McGrathd9f816f2004-09-04 03:39:20 +0000391static const struct xlat priorities[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000392 XLAT(PRIO_PROCESS),
393 XLAT(PRIO_PGRP),
394 XLAT(PRIO_USER),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000395 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000396};
397
398int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000399sys_getpriority(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000400{
401 if (entering(tcp)) {
402 printxval(priorities, tcp->u_arg[0], "PRIO_???");
403 tprintf(", %lu", tcp->u_arg[1]);
404 }
405 return 0;
406}
407
408int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000409sys_setpriority(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000410{
411 if (entering(tcp)) {
412 printxval(priorities, tcp->u_arg[0], "PRIO_???");
413 tprintf(", %lu, %ld", tcp->u_arg[1], tcp->u_arg[2]);
414 }
415 return 0;
416}
417
418int
Denys Vlasenko1d632462009-04-14 12:51:00 +0000419sys_times(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000420{
421 struct tms tbuf;
422
423 if (exiting(tcp)) {
424 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200425 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000426 else if (syserror(tcp))
427 tprintf("%#lx", tcp->u_arg[0]);
428 else if (umove(tcp, tcp->u_arg[0], &tbuf) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200429 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000430 else {
H.J. Lu2bb45812012-04-15 11:17:13 -0700431 tprintf("{tms_utime=%llu, tms_stime=%llu, ",
432 (unsigned long long) tbuf.tms_utime,
433 (unsigned long long) tbuf.tms_stime);
434 tprintf("tms_cutime=%llu, tms_cstime=%llu}",
435 (unsigned long long) tbuf.tms_cutime,
436 (unsigned long long) tbuf.tms_cstime);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000437 }
438 }
439 return 0;
440}