forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/tools/testing/selftests/proc/read.c
....@@ -26,8 +26,10 @@
2626 #include <dirent.h>
2727 #include <stdbool.h>
2828 #include <stdlib.h>
29
+#include <stdio.h>
2930 #include <string.h>
3031 #include <sys/stat.h>
32
+#include <sys/vfs.h>
3133 #include <fcntl.h>
3234 #include <unistd.h>
3335
....@@ -123,10 +125,22 @@
123125 int main(void)
124126 {
125127 DIR *d;
128
+ struct statfs sfs;
126129
127130 d = opendir("/proc");
128131 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);
129140 return 2;
141
+ }
142
+
130143 f(d, 0);
144
+
131145 return 0;
132146 }