DF-3184 / tchain.c
/* * DF-3184 chain test: as an unpriv user, stat /procN/<pid>/* while the * scratch mount is live, print stat results, sleep, exit; the instrumented * kernel then reports the walk's "marked=" count. */ #include <sys/stat.h> #include <stdio.h> #include <unistd.h> #include <string.h> #include <errno.h> int main(int argc, char **argv) { char p[128]; struct stat st; int i, ok = 0, fail = 0; int sleep_s = argc > 1 ? atoi(argv[1]) : 3; static const char *t[] = { "status", "cmdline", "map", "type", "rlimit", "regs", "fpregs", "dbregs", "ctl", "note", "notepg", "file", NULL }; snprintf(p, sizeof(p), "/procN/%d", (int)getpid()); if (stat(p, &st) < 0) printf("dir stat FAIL: %s\n", strerror(errno)); else { printf("dir stat OK\n"); ok++; } for (i = 0; t[i]; i++) { snprintf(p, sizeof(p), "/procN/%d/%s", (int)getpid(), t[i]); if (stat(p, &st) < 0) { printf("%s FAIL: %s\n", t[i], strerror(errno)); fail++; } else { printf("%s OK\n", t[i]); ok++; } } printf("CHAIN pid=%d ok=%d fail=%d sleeping %ds\n", (int)getpid(), ok, fail, sleep_s); fflush(stdout); sleep(sleep_s); _exit(0); } |