@@ -287,14 +287,16 @@ static inline void require_fanotify_access_permissions_supported_by_kernel(void)
SAFE_CLOSE(fd);
}
-static inline int fanotify_events_supported_by_kernel(uint64_t mask)
+static inline int fanotify_events_supported_by_kernel(uint64_t mask,
+ unsigned int init_flags,
+ unsigned int mark_flags)
{
int fd;
int rval = 0;
- fd = SAFE_FANOTIFY_INIT(FAN_CLASS_CONTENT, O_RDONLY);
+ fd = SAFE_FANOTIFY_INIT(init_flags, O_RDONLY);
- if (fanotify_mark(fd, FAN_MARK_ADD, mask, AT_FDCWD, ".") < 0) {
+ if (fanotify_mark(fd, FAN_MARK_ADD | mark_flags, mask, AT_FDCWD, ".") < 0) {
if (errno == EINVAL) {
rval = -1;
} else {
@@ -404,4 +406,13 @@ static inline int fanotify_mark_supported_by_kernel(uint64_t flag)
fanotify_mark_supported_by_kernel(mark_type)); \
} while (0)
+#define REQUIRE_FANOTIFY_EVENTS_SUPPORTED_ON_FS(init_flags, mark_type, mask, fname) do { \
+ if (mark_type) \
+ REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL(mark_type); \
+ if (init_flags) \
+ REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS(init_flags, fname); \
+ fanotify_init_flags_err_msg(#mask, __FILE__, __LINE__, tst_brk_, \
+ fanotify_events_supported_by_kernel(mask, init_flags, mark_type)); \
+} while (0)
+
#endif /* __FANOTIFY_H__ */
@@ -323,8 +323,8 @@ static void setup(void)
require_fanotify_access_permissions_supported_by_kernel();
filesystem_mark_unsupported = fanotify_mark_supported_by_kernel(FAN_MARK_FILESYSTEM);
- exec_events_unsupported = fanotify_events_supported_by_kernel(FAN_OPEN_EXEC_PERM);
-
+ exec_events_unsupported = fanotify_events_supported_by_kernel(FAN_OPEN_EXEC_PERM,
+ FAN_CLASS_CONTENT, 0);
sprintf(fname, MOUNT_PATH"/fname_%d", getpid());
SAFE_FILE_PRINTF(fname, "1");
@@ -509,7 +509,8 @@ cleanup:
static void setup(void)
{
- exec_events_unsupported = fanotify_events_supported_by_kernel(FAN_OPEN_EXEC);
+ exec_events_unsupported = fanotify_events_supported_by_kernel(FAN_OPEN_EXEC,
+ FAN_CLASS_CONTENT, 0);
filesystem_mark_unsupported = fanotify_mark_supported_by_kernel(FAN_MARK_FILESYSTEM);
fan_report_dfid_unsupported = fanotify_init_flags_supported_on_fs(FAN_REPORT_DFID_NAME,
MOUNT_PATH);
@@ -222,7 +222,8 @@ cleanup:
static void do_setup(void)
{
- exec_events_unsupported = fanotify_events_supported_by_kernel(FAN_OPEN_EXEC);
+ exec_events_unsupported = fanotify_events_supported_by_kernel(FAN_OPEN_EXEC,
+ FAN_CLASS_NOTIF, 0);
sprintf(fname, "fname_%d", getpid());
SAFE_FILE_PRINTF(fname, "1");