DF-2550 / probe_fifo.c
/* * DF-2550 probe: does VOP_GETATTR fail on a FIFO fd (fchown path)? * hammer2/ufs FIFO vnodes normally override getattr, so this likely * returns 0 (no failure) -- but verify empirically. */ #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <sys/stat.h> #include <errno.h> #include <string.h> int main(int argc, char **argv) { const char *path = argc > 1 ? argv[1] : "ftest"; unlink(path); if (mkfifo(path, 0644) != 0) { perror("mkfifo"); return 2; } /* FIFO needs a writer to open O_RDWR; open O_NONBLOCK|O_RDONLY then write-end */ int fd = open(path, O_RDWR); if (fd < 0) { perror("open"); return 2; } struct stat st; if (fstat(fd, &st) != 0) { printf("fstat errno=%d (%s)\n", errno, strerror(errno)); } printf("[probe] fifo fd=%d fstat rc=0 mode=0%o type=%d\n", fd, st.st_mode, (st.st_mode&S_IFMT)); int rc = fchown(fd, -1, -1); printf("[probe] fchown(fd) rc=%d errno=%d (%s)\n", rc, errno, rc? strerror(errno):"ok"); return 0; } |