问题描述
我正在尝试制作一个Linux内核模块,该模块支持打开,关闭,读取和写入操作.所以我想通过struct file_operations注册这些函数,但是在struct中找不到'close'条目.我想我应该使用发布"而不是关闭",但是我想知道为什么名称是发布"而不是关闭"吗?
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't find 'close' entry in the struct.I think I should use 'release' instead of 'close', but I wonder why the name is 'release' and not 'close'?
推荐答案
因为文件可能会多次打开,所以当您关闭描述符时,仅在最后一次关闭调用时才对文件的最后引用调用release.因此,关闭和释放之间是有区别的.
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.
这篇关于为什么关闭功能在Linux内核的`struct file_operations`中被称为release?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!