1 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
2
3 #include <sys/param.h>
4 #include <sys/types.h>
5
6 #include <sys/statvfs.h>
7
8 #include <assert.h>
9 #include <fcntl.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <unistd.h>
13
test_statvfs1()14 void test_statvfs1() {
15 printf("statvfs1\n");
16
17 struct statvfs buf;
18 int rv = statvfs1("/etc/fstab", &buf, ST_WAIT);
19 assert(rv != -1);
20
21 printf("fstypename='%s'\n", buf.f_fstypename);
22 printf("mntonname='%s'\n", buf.f_mntonname);
23 printf("mntfromname='%s'\n", buf.f_mntfromname);
24 }
25
test_fstatvfs1()26 void test_fstatvfs1() {
27 printf("fstatvfs1\n");
28
29 int fd = open("/etc/fstab", O_RDONLY);
30 assert(fd > 0);
31
32 struct statvfs buf;
33 int rv = fstatvfs1(fd, &buf, ST_WAIT);
34 assert(rv != -1);
35
36 printf("fstypename='%s'\n", buf.f_fstypename);
37 printf("mntonname='%s'\n", buf.f_mntonname);
38 printf("mntfromname='%s'\n", buf.f_mntfromname);
39
40 rv = close(fd);
41 assert(rv != -1);
42 }
43
main(void)44 int main(void) {
45 test_statvfs1();
46 test_fstatvfs1();
47
48 // CHECK: statvfs1
49 // CHECK: fstypename='{{.*}}'
50 // CHECK: mntonname='{{.*}}'
51 // CHECK: mntfromname='{{.*}}'
52 // CHECK: fstatvfs1
53 // CHECK: fstypename='{{.*}}'
54 // CHECK: mntonname='{{.*}}'
55 // CHECK: mntfromname='{{.*}}'
56
57 return 0;
58 }
59