| 1 |
// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s |
| 2 |
|
| 3 |
#include <sys/types.h> |
| 4 |
|
| 5 |
#include <sys/statvfs.h> |
| 6 |
|
| 7 |
#include <assert.h> |
| 8 |
#include <stdio.h> |
| 9 |
#include <stdlib.h> |
| 10 |
|
| 11 |
int main(void) { |
| 12 |
printf("getvfsstat\n"); |
| 13 |
|
| 14 |
int rv = getvfsstat(NULL, 0, ST_WAIT); |
| 15 |
assert(rv != -1); |
| 16 |
|
| 17 |
size_t sz = rv * sizeof(struct statvfs); |
| 18 |
struct statvfs *buf = (struct statvfs *)malloc(sz); |
| 19 |
assert(buf); |
| 20 |
|
| 21 |
rv = getvfsstat(buf, sz, ST_WAIT); |
| 22 |
assert(rv != -1); |
| 23 |
|
| 24 |
for (int i = 0; i < rv; i++) { |
| 25 |
printf("Filesystem %d\n", i); |
| 26 |
printf("\tfstypename=%s\n", buf[i].f_fstypename); |
| 27 |
printf("\tmntonname=%s\n", buf[i].f_mntonname); |
| 28 |
printf("\tmntfromname=%s\n", buf[i].f_mntfromname); |
| 29 |
} |
| 30 |
|
| 31 |
free(buf); |
| 32 |
|
| 33 |
// CHECK: getvfsstat |
| 34 |
|
| 35 |
return 0; |
| 36 |
} |