File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change 22#include "common/sysctl.h"
33
44#include <vm/vm_param.h>
5+ #include <sys/stat.h>
56
6- const char * ffDetectSwap (FFSwapResult * swap )
7+ const char * ffDetectSwap (FFlist * result )
78{
89 int mib [16 ];
910 size_t mibsize = ARRAY_SIZE (mib );
1011 if (sysctlnametomib ("vm.swap_info" , mib , & mibsize ) < 0 )
1112 return "sysctlnametomib(\"vm.swap_info\") failed" ;
1213
13- swap -> bytesUsed = swap -> bytesTotal = 0 ;
14-
14+ uint32_t pageSize = instance . state . platform . sysinfo . pageSize ;
15+
1516 for (int n = 0 ; ; ++ n )
1617 {
1718 mib [mibsize ] = n ;
@@ -21,12 +22,12 @@ const char* ffDetectSwap(FFSwapResult* swap)
2122 break ;
2223 if (xsw .xsw_version != XSWDEV_VERSION )
2324 return "xswdev version mismatch" ;
24- swap -> bytesUsed += (uint64_t ) xsw .xsw_used ;
25- swap -> bytesTotal += (uint64_t ) xsw .xsw_nblks ;
25+
26+ FFSwapResult * swap = ffListAdd (result );
27+ ffStrbufInitF (& swap -> name , "/dev/%s" , devname (xsw .xsw_dev , S_IFCHR ));
28+ swap -> bytesUsed = (uint64_t ) xsw .xsw_used * pageSize ;
29+ swap -> bytesTotal = (uint64_t ) xsw .xsw_nblks * pageSize ;
2630 }
2731
28- swap -> bytesUsed *= instance .state .platform .sysinfo .pageSize ;
29- swap -> bytesTotal *= instance .state .platform .sysinfo .pageSize ;
30-
3132 return NULL ;
3233}
You can’t perform that action at this time.
0 commit comments