Skip to content

Commit 5883bf3

Browse files
committed
Swap (OpenBSD): detect detailed info
1 parent 6a6b407 commit 5883bf3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/detection/swap/swap_obsd.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#include "swap.h"
2+
#include "util/FFlist.h"
23
#include "util/mallocHelper.h"
34

45
#include <sys/types.h>
56
#include <sys/swap.h>
67
#include <sys/param.h>
78
#include <unistd.h>
89

9-
const char* ffDetectSwap(FFSwapResult* swap)
10+
const char* ffDetectSwap(FFlist* result)
1011
{
1112
int nswap = swapctl(SWAP_NSWAP, 0, 0);
1213
if (nswap < 0) return "swapctl(SWAP_NSWAP) failed";
@@ -17,17 +18,16 @@ const char* ffDetectSwap(FFSwapResult* swap)
1718
if (swapctl(SWAP_STATS, swdev, nswap) < 0)
1819
return "swapctl(SWAP_STATS) failed";
1920

20-
uint64_t swapTotal = 0, swapUsed = 0;
2121
for (int i = 0; i < nswap; i++)
2222
{
2323
if (swdev[i].se_flags & SWF_ENABLE)
2424
{
25-
swapUsed += (uint64_t) swdev[i].se_inuse;
26-
swapTotal += (uint64_t) swdev[i].se_nblks;
25+
FFSwapResult* swap = ffListAdd(result);
26+
ffStrbufInitS(&swap->name, swdev[i].se_path);
27+
swap->bytesUsed = (uint64_t) swdev[i].se_inuse * DEV_BSIZE;
28+
swap->bytesTotal = (uint64_t) swdev[i].se_nblks * DEV_BSIZE;
2729
}
2830
}
29-
swap->bytesUsed = swapUsed * DEV_BSIZE;
30-
swap->bytesTotal = swapTotal * DEV_BSIZE;
3131

3232
return NULL;
3333
}

0 commit comments

Comments
 (0)