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

后端 未结 3 1385
礼貌的吻别
礼貌的吻别 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:34

    Because the file may be opened multiple times, when you close a descriptor, only on the last close call for the last reference to the file invokes release. So there is a difference between close and release.

    release: called at the last close(2) of this file, i.e. when file->f_count reaches 0. Although defined as returning int, the return value is ignored by VFS (see fs/file_table.c:__fput()). more

提交回复
热议问题