diff --git a/src/kernel/emulation/linux/CMakeLists.txt b/src/kernel/emulation/linux/CMakeLists.txt index 2a6650f31..c41ab1e7d 100644 --- a/src/kernel/emulation/linux/CMakeLists.txt +++ b/src/kernel/emulation/linux/CMakeLists.txt @@ -265,6 +265,7 @@ set(emulation_sources ext/futex.c ext/mremap.c ext/file_handle.c + ext/fanotify.c bsdthread/bsdthread_register.c bsdthread/bsdthread_create.c bsdthread/bsdthread_terminate.c diff --git a/src/kernel/emulation/linux/ext/fanotify.c b/src/kernel/emulation/linux/ext/fanotify.c new file mode 100644 index 000000000..3da289deb --- /dev/null +++ b/src/kernel/emulation/linux/ext/fanotify.c @@ -0,0 +1,47 @@ +#include "fanotify.h" +#include "../errno.h" +#include "../vchroot_expand.h" +#include "../bsdthread/per_thread_wd.h" +#include "../../../../../platform-include/sys/errno.h" +#include + +extern long cerror(int __err); + +int fanotify_init(unsigned flags, unsigned event_f_flags) +{ + int rv = LINUX_SYSCALL(__NR_fanotify_init, flags, event_f_flags); + if (rv < 0) + { + cerror(errno_linux_to_bsd(-rv)); + return -1; + } + return rv; +} + +int fanotify_mark(int fanotify_fd, unsigned flags, unsigned long long mask, int dfd, const char *pathname) +{ + struct vchroot_expand_args vc; + + if (!pathname) + return -EFAULT; + + vc.flags = 0; + vc.dfd = dfd; + + strcpy(vc.path, pathname); + int rv = vchroot_expand(&vc); + + if (rv < 0) + { + cerror(errno_linux_to_bsd(-rv)); + return -1; + } + + rv = LINUX_SYSCALL(__NR_fanotify_mark, fanotify_fd, flags, mask, dfd, vc.path); + if (rv < 0) + { + cerror(errno_linux_to_bsd(-rv)); + return -1; + } + return rv; +} diff --git a/src/kernel/emulation/linux/ext/fanotify.h b/src/kernel/emulation/linux/ext/fanotify.h new file mode 100644 index 000000000..9d680dac1 --- /dev/null +++ b/src/kernel/emulation/linux/ext/fanotify.h @@ -0,0 +1,20 @@ +#ifndef _EXT_FANOTIFY_H +#define _EXT_FANOTIFY_H +#include "../base.h" + +#ifdef __cplusplus +extern "C" { +#endif + +VISIBLE +int fanotify_init(unsigned flags, unsigned event_f_flags); + +VISIBLE +int fanotify_mark(int fanotify_fd, unsigned flags, unsigned long long mask, int dfd, const char *pathname); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/kernel/emulation/linux/linux-syscalls/linux-x86.h b/src/kernel/emulation/linux/linux-syscalls/linux-x86.h index abeaf40d3..e8ebec1cd 100644 --- a/src/kernel/emulation/linux/linux-syscalls/linux-x86.h +++ b/src/kernel/emulation/linux/linux-syscalls/linux-x86.h @@ -377,5 +377,54 @@ #define __NR_copy_file_range 377 #define __NR_preadv2 378 #define __NR_pwritev2 379 +#define __NR_pkey_mprotect 380 +#define __NR_pkey_alloc 381 +#define __NR_pkey_free 382 +#define __NR_statx 383 +#define __NR_arch_prctl 384 +#define __NR_io_pgetevents 385 +#define __NR_rseq 386 +#define __NR_semget 393 +#define __NR_semctl 394 +#define __NR_shmget 395 +#define __NR_shmctl 396 +#define __NR_shmat 397 +#define __NR_shmdt 398 +#define __NR_msgget 399 +#define __NR_msgsnd 400 +#define __NR_msgrcv 401 +#define __NR_msgctl 402 +#define __NR_clock_gettime64 403 +#define __NR_clock_settime64 404 +#define __NR_clock_adjtime64 405 +#define __NR_clock_getres_time64 406 +#define __NR_clock_nanosleep_time64 407 +#define __NR_timer_gettime64 408 +#define __NR_timer_settime64 409 +#define __NR_timerfd_gettime64 410 +#define __NR_timerfd_settime64 411 +#define __NR_utimensat_time64 412 +#define __NR_pselect6_time64 413 +#define __NR_ppoll_time64 414 +#define __NR_io_pgetevents_time64 416 +#define __NR_recvmmsg_time64 417 +#define __NR_mq_timedsend_time64 418 +#define __NR_mq_timedreceive_time64 419 +#define __NR_semtimedop_time64 420 +#define __NR_rt_sigtimedwait_time64 421 +#define __NR_futex_time64 422 +#define __NR_sched_rr_get_interval_time64 423 +#define __NR_pidfd_send_signal 424 +#define __NR_io_uring_setup 425 +#define __NR_io_uring_enter 426 +#define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 #endif /* _ASM_X86_UNISTD_32_H */ diff --git a/src/kernel/emulation/linux/linux-syscalls/linux-x86_64.h b/src/kernel/emulation/linux/linux-syscalls/linux-x86_64.h index 73c3d1f66..a2f863d54 100644 --- a/src/kernel/emulation/linux/linux-syscalls/linux-x86_64.h +++ b/src/kernel/emulation/linux/linux-syscalls/linux-x86_64.h @@ -330,5 +330,23 @@ #define __NR_copy_file_range 326 #define __NR_preadv2 327 #define __NR_pwritev2 328 +#define __NR_pkey_mprotect 329 +#define __NR_pkey_alloc 330 +#define __NR_pkey_free 331 +#define __NR_statx 332 +#define __NR_io_pgetevents 333 +#define __NR_rseq 334 +#define __NR_pidfd_send_signal 424 +#define __NR_io_uring_setup 425 +#define __NR_io_uring_enter 426 +#define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 #endif /* _ASM_X86_UNISTD_64_H */