--- memswap.c 2005-03-05 19:08:53.180318960 -0700 +++ memswap.c.mod 2005-03-05 19:08:53.180318960 -0700 @@ -48,6 +48,7 @@ static unsigned long MTotal = 0; static unsigned long MFree = 0; static unsigned long MCached = 0; +static unsigned long MBuffers = 0; static unsigned long MUsed = 0; static unsigned long STotal = 0; static unsigned long SFree = 0; @@ -57,8 +58,8 @@ { int fd; size_t n; - int o_MTotal, o_MFree, o_MCached, o_STotal, o_SFree; - char *b_MTotal, *b_MFree, *b_MCached, *b_STotal, *b_SFree; + int o_MTotal, o_MFree, o_MCached, o_MBuffers, o_STotal, o_SFree; + char *b_MTotal, *b_MFree, *b_MCached, *b_MBuffers, *b_STotal, *b_SFree; if ((fd = open("/proc/meminfo", O_RDONLY)) < 0) { @@ -87,6 +88,10 @@ if (b_MCached) o_MCached = sscanf(b_MCached + strlen("Cached"), ": %lu", &MCached); + b_MBuffers = strstr(MemInfoBuf, "Buffers"); + if (b_MBuffers) + o_MBuffers = sscanf(b_MBuffers + strlen("Buffers"), ": %lu", &MBuffers); + b_STotal = strstr(MemInfoBuf, "SwapTotal"); if (b_STotal) o_STotal = sscanf(b_STotal + strlen("SwapTotal"), ": %lu", &STotal); @@ -95,7 +100,7 @@ if (b_SFree) o_SFree = sscanf(b_SFree + strlen("SwapFree"), ": %lu", &SFree); - MFree += MCached; + MFree += MCached + MBuffers; MUsed = MTotal - MFree; SUsed = STotal - SFree; *mem = MUsed * 100 / MTotal;