File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 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}
You can’t perform that action at this time.
0 commit comments