Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sysinfo.c 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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-2018 The strace developers.
  11. * All rights reserved.
  12. *
  13. * SPDX-License-Identifier: LGPL-2.1-or-later
  14. */
  15. #include "defs.h"
  16. #include DEF_MPERS_TYPE(sysinfo_t)
  17. #include <sys/sysinfo.h>
  18. typedef struct sysinfo sysinfo_t;
  19. #include MPERS_DEFS
  20. SYS_FUNC(sysinfo)
  21. {
  22. sysinfo_t si;
  23. if (entering(tcp))
  24. return 0;
  25. if (!umove_or_printaddr(tcp, tcp->u_arg[0], &si)) {
  26. tprintf("{uptime=%llu"
  27. ", loads=[%llu, %llu, %llu]"
  28. ", totalram=%llu"
  29. ", freeram=%llu"
  30. ", sharedram=%llu"
  31. ", bufferram=%llu"
  32. ", totalswap=%llu"
  33. ", freeswap=%llu"
  34. ", procs=%u"
  35. ", totalhigh=%llu"
  36. ", freehigh=%llu"
  37. ", mem_unit=%u"
  38. "}",
  39. zero_extend_signed_to_ull(si.uptime)
  40. , zero_extend_signed_to_ull(si.loads[0])
  41. , zero_extend_signed_to_ull(si.loads[1])
  42. , zero_extend_signed_to_ull(si.loads[2])
  43. , zero_extend_signed_to_ull(si.totalram)
  44. , zero_extend_signed_to_ull(si.freeram)
  45. , zero_extend_signed_to_ull(si.sharedram)
  46. , zero_extend_signed_to_ull(si.bufferram)
  47. , zero_extend_signed_to_ull(si.totalswap)
  48. , zero_extend_signed_to_ull(si.freeswap)
  49. , (unsigned) si.procs
  50. , zero_extend_signed_to_ull(si.totalhigh)
  51. , zero_extend_signed_to_ull(si.freehigh)
  52. , si.mem_unit
  53. );
  54. }
  55. return 0;
  56. }