Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\file.c Create Date:2022-07-28 20:08:31
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:allocate a file descriptor, mark it busy.

Proto:int __alloc_fd(struct files_struct *files, unsigned start, unsigned end, unsigned flags)

Type:int

Parameter:

TypeParameterName
struct files_struct *files
unsignedstart
unsignedend
unsignedflags
487  spin_lock( & written part on a separate cache line in SMP)
488  repeat :
489  fdt = files_fdtable(files)
490  fd = start
491  If fd < next_fd Then fd = next_fd
494  If fd < max_fds Then fd = find_next_fd(fdt, fd)
501  error = -EMFILE
502  If fd >= end Then Go to out
505  error = Expand files.* This function will expand the file structures, if the requested size exceeds* the current capacity and there is room for expansion.* Return <0 error code on error; 0 when nothing done; 1 when files were
506  If error < 0 Then Go to out
513  If error Then Go to repeat
516  If start <= next_fd Then next_fd = fd + 1
519  __set_open_fd(fd, fdt)
520  If flags & O_CLOEXEC Then __set_close_on_exec(fd, fdt)
522  Else __clear_close_on_exec(fd, fdt)
524  error = fd
527  If (cu_access_pointer() - fetch RCU pointer with no dereferencing*@p: The pointer to read* Return the value of the specified RCU-protected pointer, but omit the* lockdep checks for being in an RCU read-side critical section( current fd array [fd]) != NULL) Then
528  printk - print a kernel message*@fmt: format string* This is printk(). It can be called from any context. We want it to work.* We try to grab the console_lock. If we succeed, it's easy - we log the* output and call the console drivers
529  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( current fd array [fd], NULL)
533  out :
534  spin_unlock( & written part on a separate cache line in SMP)
535  Return error
Caller
NameDescribe
alloc_fd
get_unused_fd_flags