Why is the close function is called release in `struct file_operations` in the Linux kernel?

后端 未结 3 1380
礼貌的吻别
礼貌的吻别 2021-02-13 12:48

I\'m trying to make a linux kernel module, which supports open, close, read and write operations. So I want to register these functions via struct file_operations, however I can

3条回答
  •  天涯浪人
    2021-02-13 13:22

    Note that release isn’t invoked every time a process calls close. Whenever a file structure is shared (for example, after a fork or a dup),release won’t be invoked until all copies are closed. If you need to flush pending data when any copy is closed, you should implement the flush method.

    taken from LDD3 (chapter 3).

提交回复
热议问题