diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2021-10-02 05:23:03 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2021-10-12 07:43:07 +0000 |
commit | 7259ca31048e5ced8e7f90657a3d7084aeafdf51 (patch) | |
tree | 1c335c5d775d82bdadbf68cf2fc882011a30a951 /tests/sys | |
parent | fc22fe5c74055802ac41090f345c8a45eab396b6 (diff) | |
download | src-7259ca31048e5ced8e7f90657a3d7084aeafdf51.tar.gz src-7259ca31048e5ced8e7f90657a3d7084aeafdf51.zip |
fifos: delegate unhandled kqueue filters to underlying filesystem
This gives the vfs layer a chance to provide handling for EVFILT_VNODE,
for instance. Change pipe_specops to use the default vop_kqfilter to
accommodate fifoops that don't specify the method (i.e. all in-tree).
Based on a patch by Jan Kokemüller.
PR: 225934
Reviewed by: kib, markj (both pre-KASSERT)
Differential Revision: https://reviews.freebsd.org/D32271
Diffstat (limited to 'tests/sys')
-rw-r--r-- | tests/sys/kqueue/libkqueue/common.h | 2 | ||||
-rw-r--r-- | tests/sys/kqueue/libkqueue/vnode.c | 59 |
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/sys/kqueue/libkqueue/common.h b/tests/sys/kqueue/libkqueue/common.h index d621a8bf1e00..a92e544910ba 100644 --- a/tests/sys/kqueue/libkqueue/common.h +++ b/tests/sys/kqueue/libkqueue/common.h @@ -36,6 +36,8 @@ #include <stdint.h> #include <sys/socket.h> #include <sys/types.h> +#include <sys/stat.h> +#include <sys/wait.h> #include <unistd.h> #include <sys/event.h> diff --git a/tests/sys/kqueue/libkqueue/vnode.c b/tests/sys/kqueue/libkqueue/vnode.c index 8f4311e90745..b6c0915b2654 100644 --- a/tests/sys/kqueue/libkqueue/vnode.c +++ b/tests/sys/kqueue/libkqueue/vnode.c @@ -65,6 +65,64 @@ test_kevent_vnode_note_delete(void) } static void +test_kevent_vnode_note_delete_fifo(void) +{ + const char *test_id = "kevent(EVFILT_VNODE, NOTE_DELETE, FIFO)"; + const char *fifo_path = "./kqueue-fifo.tmp"; + struct kevent kev; + int fd; + pid_t pid; + + test_begin(test_id); + + if (mkfifo(fifo_path, 0600) != 0) + err(1, "mkfifo"); + + pid = fork(); + if (pid == -1) + err(1, "fork"); + + if (pid == 0) { + char buf[4]; + + fd = open(fifo_path, O_RDONLY); + if (fd == -1) + _exit(1); + + while (read(fd, buf, sizeof(buf)) != 0) { + } + + _exit(0); + } + + sleep(1); + if (waitpid(pid, NULL, WNOHANG) == pid) { + unlink(fifo_path); + err(1, "open"); + } + + fd = open(fifo_path, O_WRONLY); + if (fd < 0) { + unlink(fifo_path); + err(1, "open"); + } + + EV_SET(&kev, fd, EVFILT_VNODE, EV_ADD | EV_ONESHOT, NOTE_DELETE, 0, NULL); + if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0) { + unlink(fifo_path); + err(1, "%s", test_id); + } + + if (unlink(fifo_path) < 0) + err(1, "unlink"); + + kevent_cmp(&kev, kevent_get(kqfd)); + close(fd); + + success(); +} + +static void test_kevent_vnode_note_write(void) { const char *test_id = "kevent(EVFILT_VNODE, NOTE_WRITE)"; @@ -261,5 +319,6 @@ test_evfilt_vnode(void) test_kevent_vnode_note_attrib(); test_kevent_vnode_note_rename(); test_kevent_vnode_note_delete(); + test_kevent_vnode_note_delete_fifo(); close(kqfd); } |