Branch data Line data Source code
1 : : /*
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-1996 Rick Sladkey <jrs@world.std.com>
5 : : * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6 : : * Copyright (c) 2012 H.J. Lu <hongjiu.lu@intel.com>
7 : : * Copyright (c) 2012 Denys Vlasenko <vda.linux@googlemail.com>
8 : : * Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org>
9 : : * Copyright (c) 2015 Elvira Khabirova <lineprinter0@gmail.com>
10 : : * Copyright (c) 2014-2017 The strace developers.
11 : : * All rights reserved.
12 : : *
13 : : * Redistribution and use in source and binary forms, with or without
14 : : * modification, are permitted provided that the following conditions
15 : : * are met:
16 : : * 1. Redistributions of source code must retain the above copyright
17 : : * notice, this list of conditions and the following disclaimer.
18 : : * 2. Redistributions in binary form must reproduce the above copyright
19 : : * notice, this list of conditions and the following disclaimer in the
20 : : * documentation and/or other materials provided with the distribution.
21 : : * 3. The name of the author may not be used to endorse or promote products
22 : : * derived from this software without specific prior written permission.
23 : : *
24 : : * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25 : : * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 : : * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 : : * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 : : * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 : : * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 : : * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 : : * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 : : * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 : : * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 : : */
35 : :
36 : : #include "defs.h"
37 : : #include DEF_MPERS_TYPE(sysinfo_t)
38 : : #include <sys/sysinfo.h>
39 : : typedef struct sysinfo sysinfo_t;
40 : : #include MPERS_DEFS
41 : :
42 : 8 : SYS_FUNC(sysinfo)
43 : : {
44 : : sysinfo_t si;
45 : :
46 [ + + ]: 8 : if (entering(tcp))
47 : : return 0;
48 : :
49 [ + + ]: 4 : if (!umove_or_printaddr(tcp, tcp->u_arg[0], &si)) {
50 : 2 : tprintf("{uptime=%llu"
51 : : ", loads=[%llu, %llu, %llu]"
52 : : ", totalram=%llu"
53 : : ", freeram=%llu"
54 : : ", sharedram=%llu"
55 : : ", bufferram=%llu"
56 : : ", totalswap=%llu"
57 : : ", freeswap=%llu"
58 : : ", procs=%u"
59 : : ", totalhigh=%llu"
60 : : ", freehigh=%llu"
61 : : ", mem_unit=%u"
62 : : "}",
63 : 2 : zero_extend_signed_to_ull(si.uptime)
64 : 2 : , zero_extend_signed_to_ull(si.loads[0])
65 : 2 : , zero_extend_signed_to_ull(si.loads[1])
66 : 2 : , zero_extend_signed_to_ull(si.loads[2])
67 : 2 : , zero_extend_signed_to_ull(si.totalram)
68 : 2 : , zero_extend_signed_to_ull(si.freeram)
69 : 2 : , zero_extend_signed_to_ull(si.sharedram)
70 : 2 : , zero_extend_signed_to_ull(si.bufferram)
71 : 2 : , zero_extend_signed_to_ull(si.totalswap)
72 : 2 : , zero_extend_signed_to_ull(si.freeswap)
73 : 2 : , (unsigned) si.procs
74 : 2 : , zero_extend_signed_to_ull(si.totalhigh)
75 : 2 : , zero_extend_signed_to_ull(si.freehigh)
76 : : , si.mem_unit
77 : : );
78 : : }
79 : :
80 : : return 0;
81 : : }
|