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 2
2
#include "common/sysctl.h"
3
3
4
4
#include <vm/vm_param.h>
5
+ #include <sys/stat.h>
5
6
6
- const char * ffDetectSwap (FFSwapResult * swap )
7
+ const char * ffDetectSwap (FFlist * result )
7
8
{
8
9
int mib [16 ];
9
10
size_t mibsize = ARRAY_SIZE (mib );
10
11
if (sysctlnametomib ("vm.swap_info" , mib , & mibsize ) < 0 )
11
12
return "sysctlnametomib(\"vm.swap_info\") failed" ;
12
13
13
- swap -> bytesUsed = swap -> bytesTotal = 0 ;
14
-
14
+ uint32_t pageSize = instance . state . platform . sysinfo . pageSize ;
15
+
15
16
for (int n = 0 ; ; ++ n )
16
17
{
17
18
mib [mibsize ] = n ;
@@ -21,12 +22,12 @@ const char* ffDetectSwap(FFSwapResult* swap)
21
22
break ;
22
23
if (xsw .xsw_version != XSWDEV_VERSION )
23
24
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 ;
26
30
}
27
31
28
- swap -> bytesUsed *= instance .state .platform .sysinfo .pageSize ;
29
- swap -> bytesTotal *= instance .state .platform .sysinfo .pageSize ;
30
-
31
32
return NULL ;
32
33
}
You can’t perform that action at this time.
0 commit comments