Home > database >  What's the purpose of function poll() in file_operations in Linux source code?
What's the purpose of function poll() in file_operations in Linux source code?

Time:01-30

I do not quite understand what will poll() do even after I tried to search for it on Google. Is there any documentation related to this function or all the interfaces in the file_operations?

CodePudding user response:

poll() method in VFS struct file_operations is (quoting kernel vfs documentation):

called by the VFS when a process wants to check if there is activity on this file and (optionally) go to sleep until there is activity. Called by the select(2) and poll(2) system calls

Note that struct contains a pointer to function of signature __poll_t (*poll) (struct file *, struct poll_table_struct *);. If I remember correctly, this (and most of other) file_operations methods are located (and pointers populated) partially by specific filesystem itself (usually in its file.c or similar) or - by filesystem calling out to VFS and VFS populating them by specific code for underlying block/character device.

  • Related