Commit 332e0e80 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Linus Torvalds

proc: more robust bulk read test

/proc may not be mounted and test will exit successfully.

Ensure proc is mounted at /proc.

Link: http://lkml.kernel.org/r/20190209105613.GA10384@avx2Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e483b020
...@@ -26,8 +26,10 @@ ...@@ -26,8 +26,10 @@
#include <dirent.h> #include <dirent.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/vfs.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
...@@ -123,10 +125,22 @@ static void f(DIR *d, unsigned int level) ...@@ -123,10 +125,22 @@ static void f(DIR *d, unsigned int level)
int main(void) int main(void)
{ {
DIR *d; DIR *d;
struct statfs sfs;
d = opendir("/proc"); d = opendir("/proc");
if (!d) if (!d)
return 4; return 4;
/* Ensure /proc is proc. */
if (fstatfs(dirfd(d), &sfs) == -1) {
return 1;
}
if (sfs.f_type != 0x9fa0) {
fprintf(stderr, "error: unexpected f_type %lx\n", (long)sfs.f_type);
return 2;
}
f(d, 0); f(d, 0);
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment