1

My question is regarding usage of file descriptors in linux. My general understanding from answers here and here us the for each process/thread the opened files are maintained correspondingly.

However, if a file descriptor is returned from within the kernel code like what I have tried here what happens to the regular scheme of things? To which process would this descriptor belong? Is it even possible to do so?

  • 2
    The kernel code deals with `struct file` objects internally. This is a reference-counted representation of a user-space *open file description* and is usually referenced by one or more process's file descriptors (although it can also be created purely for use within kernel code, for example via the `filp_open` function). – Ian Abbott Mar 27 '19 at 18:27
  • @IanAbbott I am using the function perf_event_open() which returns a file descriptor for event monitoring. Where would this descriptor be stored? – Nikhilesh Singh Mar 28 '19 at 04:37

0 Answers0