ANDROID: vendor_hooks: Add hook for fsnotify

Add hook for fsnotify when file open with write mode.

- android_vh_fsnotify_open

Bug: 350651631

Change-Id: Ibeada7ce1d5a4a78c49b9a255b1e3a436029b631
Signed-off-by: huzhanyuan  <huzhanyuan@oppo.com>
This commit is contained in:
huzhanyuan 2024-07-02 17:19:21 +08:00 committed by Suren Baghdasaryan
parent 59717f94ca
commit ffb163667c
3 changed files with 28 additions and 0 deletions

View File

@ -74,6 +74,7 @@
#include <trace/hooks/psi.h> #include <trace/hooks/psi.h>
#include <trace/hooks/blk.h> #include <trace/hooks/blk.h>
#include <trace/hooks/suspend.h> #include <trace/hooks/suspend.h>
#include <trace/hooks/fsnotify.h>
/* /*
* Export tracepoints that act as a bare tracehook (ie: have no trace event * Export tracepoints that act as a bare tracehook (ie: have no trace event
@ -443,3 +444,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_contig_range_not_isolated);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_warn_alloc_tune_ratelimit); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_warn_alloc_tune_ratelimit);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_warn_alloc_show_mem_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_warn_alloc_show_mem_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_use_vm_swappiness); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_use_vm_swappiness);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_fsnotify_open);

View File

@ -17,6 +17,9 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/bug.h> #include <linux/bug.h>
#undef CREATE_TRACE_POINTS
#include <trace/hooks/fsnotify.h>
/* /*
* Notify this @dir inode about a change in a child directory entry. * Notify this @dir inode about a change in a child directory entry.
* The directory entry may have turned positive or negative or its inode may * The directory entry may have turned positive or negative or its inode may
@ -353,6 +356,7 @@ static inline void fsnotify_open(struct file *file)
if (file->f_flags & __FMODE_EXEC) if (file->f_flags & __FMODE_EXEC)
mask |= FS_OPEN_EXEC; mask |= FS_OPEN_EXEC;
trace_android_vh_fsnotify_open(file, &mask);
fsnotify_file(file, mask); fsnotify_file(file, mask);
} }

View File

@ -0,0 +1,22 @@
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM fsnotify
#ifdef CREATE_TRACE_POINTS
#define TRACE_INCLUDE_PATH trace/hooks
#define UNDEF_TRACE_INCLUDE_PATH
#endif
#if !defined(_TRACE_HOOK_FSNOTIFY_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_FSNOTIFY_H
#include <trace/hooks/vendor_hooks.h>
DECLARE_HOOK(android_vh_fsnotify_open,
TP_PROTO(struct file *file, __u32 *mask),
TP_ARGS(file, mask));
#endif /* _TRACE_HOOK_FSNOTIFY_H */
/* This part must be outside protection */
#include <trace/define_trace.h>