Modify tools/ext4dist.py for 4.10+
based on kernel version, different kernel functions are kprobed.
@@ -174,6 +174,15 @@ if debug or args.ebpf:
b = BPF(text=bpf_text)
# Common file functions. See earlier comment about generic_file_read_iter().
+# Comment by Joe Yin
+# From Linux 4.10, the function .read_iter at the ext4_file_operations has
+# changed to ext4_file_read_iter.
+# So, I add get_kprobe_functions('ext4_file_read_iter'),it will first to attach ext4_file_read_iter,
+# if fails and will attach the generic_file_read_iter which used to pre-4.10.
+
+if BPF.get_kprobe_functions('ext4_file_read_iter'):
+ b.attach_kprobe(event="ext4_file_read_iter", fn_name="trace_entry")
+else:
b.attach_kprobe(event="generic_file_read_iter", fn_name="trace_read_entry")
b.attach_kprobe(event="ext4_file_write_iter", fn_name="trace_entry")
b.attach_kprobe(event="ext4_file_open", fn_name="trace_entry")
