Skip to content

Commit 6a42588

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

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/detection/swap/swap_sunos.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
enum { FFMaxNSwap = 8 };
77

8-
const char* ffDetectSwap(FFSwapResult* swap)
8+
const char* ffDetectSwap(FFlist* result)
99
{
1010
char strings[FFMaxNSwap][PATH_MAX];
1111
uint8_t buffer[sizeof(swaptbl_t) + sizeof(swapent_t) * (FFMaxNSwap - 1)] = {};
@@ -18,16 +18,14 @@ const char* ffDetectSwap(FFSwapResult* swap)
1818
if (size < 0)
1919
return "swapctl() failed";
2020

21-
swap->bytesTotal = swap->bytesUsed = 0;
22-
21+
uint32_t pageSize = instance.state.platform.sysinfo.pageSize;
2322
for (int i = 0; i < size; ++i)
2423
{
25-
swap->bytesTotal += (uint64_t) table->swt_ent[i].ste_pages;
26-
swap->bytesUsed += (uint64_t) table->swt_ent[i].ste_free;
24+
FFSwapResult* swap = ffListAdd(result);
25+
ffStrbufInitS(&swap->name, table->swt_ent[i].ste_path);
26+
swap->bytesTotal = (uint64_t) table->swt_ent[i].ste_pages * pageSize;
27+
swap->bytesUsed = swap->bytesTotal - (uint64_t) table->swt_ent[i].ste_free * pageSize;
2728
}
28-
swap->bytesUsed = swap->bytesTotal - swap->bytesUsed;
29-
swap->bytesTotal *= instance.state.platform.sysinfo.pageSize;
30-
swap->bytesUsed *= instance.state.platform.sysinfo.pageSize;
3129

3230
return NULL;
3331
}

0 commit comments

Comments
 (0)