Debian Codegraph @

tapset/linux/sysc_fallocate.stp

raw
1 # fallocate ____________________________________________________
2 #
3 # SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
4
5 @define _SYSCALL_FALLOCATE_NAME
6 %(
7 name = "fallocate"
8 %)
9
10 @define _SYSCALL_FALLOCATE_ARGSTR
11 %(
12 argstr = sprintf("%d, %s, %#x, %u", fd, mode_str, offset, len)
13 %)
14
15 probe syscall.fallocate = dw_syscall.fallocate !, nd_syscall.fallocate ? {}
16 probe syscall.fallocate.return = dw_syscall.fallocate.return !, nd_syscall.fallocate.return ? {}
17
18 # dw_fallocate _____________________________________________________
19
20 probe dw_syscall.fallocate = kernel.function("sys_fallocate").call ?
21 {
22 @__syscall_gate_compat_simple
23 @_SYSCALL_FALLOCATE_NAME
24 fd = __int32($fd)
25 mode = __uint32($mode)
26 mode_str = _stp_fallocate_mode_str(mode)
27 offset = $offset
28 len = $len
29 @_SYSCALL_FALLOCATE_ARGSTR
30 }
31 probe dw_syscall.fallocate.return = kernel.function("sys_fallocate").return ?
32 {
33 @__syscall_gate_compat_simple
34 @_SYSCALL_FALLOCATE_NAME
35 @SYSC_RETVALSTR($return)
36 }
37
38 # nd_fallocate _____________________________________________________
39
40 probe nd_syscall.fallocate = nd1_syscall.fallocate!, nd2_syscall.fallocate!, tp_syscall.fallocate
41 { }
42
43 probe nd1_syscall.fallocate = kprobe.function("sys_fallocate") ?
44 {
45 asmlinkage()
46 @__syscall_gate_compat_simple
47 @_SYSCALL_FALLOCATE_NAME
48 fd = int_arg(1)
49 mode = uint_arg(2)
50 mode_str = _stp_fallocate_mode_str(mode)
51 %( CONFIG_64BIT == "y" %?
52 offset = longlong_arg(3)
53 len = longlong_arg(4)
54 %:
55 # On a 32-bit kernel, 'long long' arguments take the space of
56 # 2 arguments, so we have to adjust the following argument
57 # numbers.
58 offset = longlong_arg(3)
59 len = longlong_arg(5)
60 %)
61 @_SYSCALL_FALLOCATE_ARGSTR
62 }
63
64 /* kernel 4.17+ */
65 probe nd2_syscall.fallocate = kprobe.function(@arch_syscall_prefix "sys_fallocate") ?
66 {
67 __set_syscall_pt_regs(pointer_arg(1))
68 @_SYSCALL_FALLOCATE_NAME
69 fd = int_arg(1)
70 mode = uint_arg(2)
71 mode_str = _stp_fallocate_mode_str(mode)
72 offset = longlong_arg(3)
73 len = longlong_arg(4)
74 @_SYSCALL_FALLOCATE_ARGSTR
75 },
76 {
77 %( @_IS_SREG_KERNEL %?
78 if (@probewrite(fd))
79 set_int_arg(1, fd)
80
81 if (@probewrite(mode))
82 set_uint_arg(2, mode)
83
84 if (@probewrite(offset))
85 set_longlong_arg(3, offset)
86
87 if (@probewrite(len))
88 set_longlong_arg(4, len)
89 %)
90 }
91
92 /* kernel 3.5+, but undesirable because it affects all syscalls */
93 probe tp_syscall.fallocate = kernel.trace("sys_enter")
94 {
95 __set_syscall_pt_regs($regs)
96 @__syscall_gate(@const("__NR_fallocate"))
97 @_SYSCALL_FALLOCATE_NAME
98 fd = int_arg(1)
99 mode = uint_arg(2)
100 mode_str = _stp_fallocate_mode_str(mode)
101 %( CONFIG_64BIT == "y" %?
102 offset = longlong_arg(3)
103 len = longlong_arg(4)
104 %:
105 # On a 32-bit kernel, 'long long' arguments take the space of
106 # 2 arguments, so we have to adjust the following argument
107 # numbers.
108 offset = longlong_arg(3)
109 len = longlong_arg(5)
110 %)
111 @_SYSCALL_FALLOCATE_ARGSTR
112 },
113 {
114 %( @_IS_SREG_KERNEL %?
115 if (@probewrite(fd))
116 set_int_arg(1, fd)
117
118 if (@probewrite(mode))
119 set_uint_arg(2, mode)
120
121 if (@probewrite(offset))
122 set_longlong_arg(3, offset)
123
124 %( CONFIG_64BIT == "y" %?
125 if (@probewrite(len))
126 set_longlong_arg(4, len)
127 %:
128 if (@probewrite(len))
129 set_longlong_arg(5, len)
130 %)
131 %)
132 }
133
134 probe nd_syscall.fallocate.return = nd1_syscall.fallocate.return!, nd2_syscall.fallocate.return!, tp_syscall.fallocate.return
135 { }
136
137 probe nd1_syscall.fallocate.return = kprobe.function("sys_fallocate").return ?
138 {
139 asmlinkage()
140 @__syscall_gate_compat_simple
141 @_SYSCALL_FALLOCATE_NAME
142 @SYSC_RETVALSTR(returnval())
143 }
144
145 /* kernel 4.17+ */
146 probe nd2_syscall.fallocate.return = kprobe.function(@arch_syscall_prefix "sys_fallocate").return ?
147 {
148 @_SYSCALL_FALLOCATE_NAME
149 @SYSC_RETVALSTR(returnval())
150 }
151
152 /* kernel 3.5+, but undesirable because it affects all syscalls */
153 probe tp_syscall.fallocate.return = kernel.trace("sys_exit")
154 {
155 __set_syscall_pt_regs($regs)
156 @__syscall_gate(@const("__NR_fallocate"))
157 @_SYSCALL_FALLOCATE_NAME
158 @SYSC_RETVALSTR($ret)
159 }