Linux 文件缓存 (二)

close系统调用
1. 首先来到系统调用入口,主要使用__close_fd进行了具体的处理过程
(current->files表示进程当前打开文件表信息,fd为需要关闭的文件索引)
1048
/* 1049 * Careful here! We test whether the file pointer is NULL before 1050 * releasing the fd. This ensures that one clone task can‘t release 1051 * an fd while another clone is opening it. 1052 */ 1053 SYSCALL_DEFINE1(close, unsigned int, fd) 1054 { 1055 int retval = __close_fd(current->files, fd); 1056 1057 /* can‘t restart close syscall because file table entry was cleared */ 1058 if (unlikely(retval == -ERESTARTSYS || 1059 retval == -ERESTARTNOINTR || 1060 retval == -ERESTARTNOHAND || 1061 retval == -ERESTART_RESTARTBLOCK)) 1062 retval = -EINTR; 1063 1064 return retval; 1065 } 1066 EXPORT_SYMBOL(sys_close);

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。