函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\file.c Create Date:2022-07-29 10:38:43
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:Allocate a new files structure and copy contents from the* passed in files structure.* errorp will be valid only when the returned files_struct is NULL.

函数原型:struct files_struct *dup_fd(struct files_struct *oldf, int *errorp)

返回类型:struct files_struct

参数:

类型参数名称
struct files_struct *oldf
int *errorp
279  errorp等于负ENOMEM
280  newf等于分配高速缓存区
281  如果非newf则转到:out
284  atomic_set( & ad mostly part, 1)
286  spin_lock_init( & written part on a separate cache line in SMP)
287  resize_in_progress = false
288  init_waitqueue_head( & resize_wait)
289  next_fd等于0
290  new_fdt等于fdtab
291  max_fds等于The default fd array needs to be at least BITS_PER_LONG,* as this is the granularity returned by copy_fdset().
292  close_on_exec等于close_on_exec_init
293  open_fds等于open_fds_init
294  full_fds_bits等于full_fds_bits_init
295  current fd array 等于fd_array[0]
297  加自旋锁
298  old_fdt等于files_fdtable(oldf)
299  open_files等于count_open_files(old_fdt)
304 此条件成立可能性小(为编译器优化)(open_files > max_fds)循环
305  自旋锁解锁
307  如果new_fdt不等于fdtab__free_fdtable(new_fdt)
310  new_fdt等于alloc_fdtable(open_files - 1)
311  如果非new_fdt
312  errorp等于负ENOMEM
313  转到:out_release
319  errorp等于负EMFILE
320  转到:out_release
328  加自旋锁
329  old_fdt等于files_fdtable(oldf)
330  open_files等于count_open_files(old_fdt)
333  Copy 'count' fd bits from the old table to the new table and clear the extra* space if any. This does not copy the file pointers. Called with the files* spinlock held for write.
335  old_fds等于 current fd array
336  new_fds等于 current fd array
338 i不等于0循环
339  f等于old_fds自加
340  如果f
341  get_file(f)
342  否则
351  cu_assign_pointer() - assign to RCU-protected pointer*@p: pointer to assign to*@v: value to assign (publish)* Assigns the specified value to the specified RCU-protected* pointer, ensuring that any concurrent RCU readers will see* any prior initialization( * new_fds++, f)
353  自旋锁解锁
356  memset(new_fds, 0, (max_fds - open_files) * *的长度)
358  cu_assign_pointer() - assign to RCU-protected pointer*@p: pointer to assign to*@v: value to assign (publish)* Assigns the specified value to the specified RCU-protected* pointer, ensuring that any concurrent RCU readers will see* any prior initialization(fdt, new_fdt)
360  返回:newf
362  out_release :
363  kmem_cache_free(SLAB cache for files_struct structures (tsk->files) , newf)
364  out :
365  返回:NULL
调用者
名称描述
unshare_fdUnshare file descriptor table if it is being shared
copy_files复制打开文件信息