}
}
+static int call_inspect_target_fd_method(int fd, void *data)
+{
+ struct file *f = data;
+
+ f->class->inspect_target_fd(f, fd);
+ return 0;
+}
+
+static void inspect_target_fd(struct file *f, struct proc *proc)
+{
+ if (proc->pidfd >= 0)
+ call_with_foreign_fd_via_pidfd(proc->pidfd, f->association,
+ call_inspect_target_fd_method, f);
+}
+
static struct file *collect_file_symlink(struct path_cxt *pc,
struct proc *proc,
const char *name,
read_fdinfo(f, fdinfo);
fclose(fdinfo);
}
+
+ if (f->class->needs_target_fd &&
+ f->class->needs_target_fd(f)) {
+ assert(f->class->inspect_target_fd);
+ inspect_target_fd(f, proc);
+ }
}
return f;
int column_id,
size_t column_index);
int (*handle_fdinfo)(struct file *file, const char *key, const char* value);
+
+ /* The lsfd core calls inspect_target_fd only if needs_target_fd()
+ * returns TRUE. */
+ bool (*needs_target_fd)(struct file *file);
+ void (*inspect_target_fd)(struct file *file, int fd);
+
void (*attach_xinfo)(struct file *file);
void (*initialize_content)(struct file *file);
void (*free_content)(struct file *file);
*/
int call_with_foreign_fd(pid_t target_pid, int target_fd,
int (*fn)(int, void*), void *data);
+int call_with_foreign_fd_via_pidfd(int pidfd, int target_fd,
+ int (*fn)(int, void*), void *data);
#endif /* UTIL_LINUX_LSFD_H */
#include "lsfd.h" /* prototype decl for call_with_foreign_fd */
#include "pidfd-utils.h"
-static int call_with_foreign_fd_via_pidfd(int pidfd, int target_fd,
- int (*fn)(int, void*), void *data)
+int call_with_foreign_fd_via_pidfd(int pidfd, int target_fd,
+ int (*fn)(int, void*), void *data)
{
int tfd, r;