为什么Linux内核函数filp_close中的posix线程id可以为NULL?
以下摘自linux内核:为什么Linux内核函数filp_close中的posix线程id可以为NULL?,linux,file,linux-kernel,posix,rationale,Linux,File,Linux Kernel,Posix,Rationale,以下摘自linux内核: /* * "id" is the POSIX thread ID. We use the * files pointer for this.. */ int filp_close(struct file *filp, fl_owner_t id) 文档中说,id是posix线程id,应该是current->files 然而,我在Linux内核中发现了许多用法,例如,将其用作filp\u close(filp,NULL) 我的问题是: 为什么调用filp\u cl
/*
* "id" is the POSIX thread ID. We use the
* files pointer for this..
*/
int filp_close(struct file *filp, fl_owner_t id)
文档中说,id
是posix线程id,应该是current->files
然而,我在Linux内核中发现了许多用法,例如,将其用作filp\u close(filp,NULL)
我的问题是:
为什么调用filp\u close
时可以接受NULL
参数id
的意图是什么?根据这一点,对fl\u所有者的正式描述将是
A generic "file lock owner" value. This is set differently for different
types of locks.
The POSIX file lock owner is determined by the "struct files_struct" in the
thread group.
Flock (BSD) locks, OFD locks and leases set the fl_owner to the
file description pointer.
但实际上这是一个不透明的指针
legacy typedef, should eventually go away
它引用进程文件描述符表(struct files\u struct
)
对于filp_close
函数,只有fs/file.c
source使用非空id
参数。所有其他用户手动创建filp
(使用filp\u open
或file\u open\u name
)并将id
传递为空