1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2020 Facebook */ 3 #include "bpf_iter.h" 4 #include <bpf/bpf_helpers.h> 5 #include <bpf/bpf_tracing.h> 6 7 char _license[] SEC("license") = "GPL"; 8 9 SEC("iter/task_file") 10 int dump_task_file(struct bpf_iter__task_file *ctx) 11 { 12 struct seq_file *seq = ctx->meta->seq; 13 struct task_struct *task = ctx->task; 14 __u32 fd = ctx->fd; 15 struct file *file = ctx->file; 16 17 if (task == (void *)0 || file == (void *)0) 18 return 0; 19 20 if (ctx->meta->seq_num == 0) 21 BPF_SEQ_PRINTF(seq, " tgid gid fd file\n"); 22 23 BPF_SEQ_PRINTF(seq, "%8d %8d %8d %lx\n", task->tgid, task->pid, fd, 24 (long)file->f_op); 25 return 0; 26 } 27