OpenSDE Packages Database (without history before r20070)
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.

124 lines
3.6 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../embutils/free.patch
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- T2-COPYRIGHT-NOTE-END ---
  16. A memory foodprint overview can be quite handy.
  17. Rene Rebe <rene@exactcode.de>
  18. --- embutils-0.17/Makefile 2005-01-31 19:06:38.000000000 +0100
  19. +++ embutils-0.17-free/Makefile 2005-02-07 01:38:31.322742920 +0100
  20. @@ -13,7 +13,7 @@
  21. install sosrm soscp sosmv sosln soslns md5sum sleep2 allinone kill uniq \
  22. dd tr mesg write touch du tail uuencode uudecode nohup nice cmp mktemp \
  23. truncate strings test date mount printenv umount pivot_root insmod rmmod \
  24. -lsmod
  25. +lsmod free
  26. ARCH:=$(shell uname -m | sed 's/i[4-9]86/i386/')
  27. --- /dev/null 2005-02-03 08:15:19.790903464 +0100
  28. +++ embutils-0.17-free/free.c 2005-02-07 01:35:28.941469088 +0100
  29. @@ -0,0 +1,90 @@
  30. +#include <unistd.h>
  31. +#include <fcntl.h>
  32. +#include <sys/vfs.h>
  33. +#include <stdlib.h>
  34. +
  35. +/* Rene Rebe <rene@exactcode.de>
  36. +
  37. +/* TODO: maybe support some options ... */
  38. +
  39. +#include "fmt_str.c"
  40. +#include "fmt_ulong.c"
  41. +#include "fmt_ulongpadright.c"
  42. +
  43. +int main(int argc, char* argv[]) {
  44. + int fd=open("/proc/meminfo",O_RDONLY);
  45. + char buf[4096];
  46. + int len=read(fd,buf,4096);
  47. + char *line, *max;
  48. +
  49. + struct meminfo_t {
  50. + const char* tag;
  51. + int val;} meminfo [] = {
  52. + "MemTotal", 0,
  53. + "MemFree", 0,
  54. + "Buffers", 0,
  55. + "Cached", 0,
  56. + "SwapTotal", 0,
  57. + "SwapFree", 0,
  58. + 0, 0};
  59. +
  60. + line = buf;
  61. + max = buf + len;
  62. + while (line < max)
  63. + {
  64. + struct meminfo_t* i = &meminfo[0];
  65. + char* tmp2 = strchr(line, ' ');
  66. + *(--tmp2) = 0;
  67. +
  68. + for (;i->tag; i++) {
  69. + if ( strcmp(line, i->tag) == 0 ) {
  70. + tmp2++; while (*tmp2 == ' ') tmp2++;
  71. + line = tmp2;
  72. + tmp2 = strchr(tmp2, '\n');
  73. + *tmp2 = 0;
  74. + i->val = atol(line);
  75. + line = tmp2 + 1;
  76. + break;
  77. + }
  78. + }
  79. + if (i->tag == 0)
  80. + line = strchr(tmp2 + 1, '\n') + 1;
  81. + }
  82. +
  83. + len = 0;
  84. + len+=fmt_str (buf+len," total used free shared buffers cached\n");
  85. +
  86. + len+=fmt_str (buf+len, "Mem: ");
  87. + len+=fmt_ulongpadright(buf+len,meminfo[0].val,10);
  88. + buf[len]=' '; ++len;
  89. + len+=fmt_ulongpadright(buf+len,meminfo[0].val - meminfo[1].val,10);
  90. + buf[len]=' '; ++len;
  91. + len+=fmt_ulongpadright(buf+len,meminfo[1].val,10);
  92. + buf[len]=' '; ++len;
  93. + len+=fmt_ulongpadright(buf+len,0,10);
  94. + buf[len]=' '; ++len;
  95. + len+=fmt_ulongpadright(buf+len,meminfo[2].val,10);
  96. + buf[len]=' '; ++len;
  97. + len+=fmt_ulongpadright(buf+len,meminfo[3].val,10);
  98. + buf[len]='\n'; ++len;
  99. +
  100. + len += fmt_str (buf+len, "-/+ buffers/cache: ");
  101. + {
  102. + int bc = meminfo[2].val + meminfo[3].val;
  103. + len+=fmt_ulongpadright(buf+len,meminfo[0].val - meminfo[1].val - bc,10);
  104. + buf[len]=' '; ++len;
  105. + len+=fmt_ulongpadright(buf+len,meminfo[2].val + bc,10);
  106. + buf[len]='\n'; ++len;
  107. + }
  108. +
  109. + len+=fmt_str (buf+len, "Swap: ");
  110. + len+=fmt_ulongpadright(buf+len,meminfo[4].val,10);
  111. + buf[len]=' '; ++len;
  112. + len+=fmt_ulongpadright(buf+len,meminfo[4].val - meminfo[5].val,10);
  113. + buf[len]=' '; ++len;
  114. + len+=fmt_ulongpadright(buf+len,meminfo[5].val,10);
  115. + buf[len] = 0;
  116. + puts(buf);
  117. +
  118. + return 0;
  119. +}