| .. | .. |
|---|
| 26 | 26 | #include <dirent.h> |
|---|
| 27 | 27 | #include <stdbool.h> |
|---|
| 28 | 28 | #include <stdlib.h> |
|---|
| 29 | +#include <stdio.h> |
|---|
| 29 | 30 | #include <string.h> |
|---|
| 30 | 31 | #include <sys/stat.h> |
|---|
| 32 | +#include <sys/vfs.h> |
|---|
| 31 | 33 | #include <fcntl.h> |
|---|
| 32 | 34 | #include <unistd.h> |
|---|
| 33 | 35 | |
|---|
| .. | .. |
|---|
| 123 | 125 | int main(void) |
|---|
| 124 | 126 | { |
|---|
| 125 | 127 | DIR *d; |
|---|
| 128 | + struct statfs sfs; |
|---|
| 126 | 129 | |
|---|
| 127 | 130 | d = opendir("/proc"); |
|---|
| 128 | 131 | if (!d) |
|---|
| 132 | + return 4; |
|---|
| 133 | + |
|---|
| 134 | + /* Ensure /proc is proc. */ |
|---|
| 135 | + if (fstatfs(dirfd(d), &sfs) == -1) { |
|---|
| 136 | + return 1; |
|---|
| 137 | + } |
|---|
| 138 | + if (sfs.f_type != 0x9fa0) { |
|---|
| 139 | + fprintf(stderr, "error: unexpected f_type %lx\n", (long)sfs.f_type); |
|---|
| 129 | 140 | return 2; |
|---|
| 141 | + } |
|---|
| 142 | + |
|---|
| 130 | 143 | f(d, 0); |
|---|
| 144 | + |
|---|
| 131 | 145 | return 0; |
|---|
| 132 | 146 | } |
|---|