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.

125 lines
3.6 KiB

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