Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么Linux内核函数filp_close中的posix线程id可以为NULL?_Linux_File_Linux Kernel_Posix_Rationale - Fatal编程技术网

为什么Linux内核函数filp_close中的posix线程id可以为NULL?

为什么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

以下摘自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 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
传递为空