Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Apply the lock described by l to an open file descriptor.* This implements both the F_SETLK and F_SETLKW commands of fcntl().

Proto:int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd, struct flock *flock)

Type:int

Parameter:

TypeParameterName
unsigned intfd
struct file *filp
unsigned intcmd
struct flock *flock
2447  file_lock = Allocate an empty lock structure.
2448  inode = locks_inode(filp)
2452  If (file_lock == NULL) Then Return -ENOLCK
2458  If mandatory_lock(inode) && Might pages of this file have been modified in userspace?* Note that i_mmap_writable counts all VM_SHARED vmas: do_mmap_pgoff* marks vma as VM_SHARED if it is shared, and the file was opened for* writing i Then
2459  error = -EAGAIN
2460  Go to out
2463  error = Verify a "struct flock" and copy it to a "struct file_lock" as a POSIX* style lock.
2464  If error Then Go to out
2467  error = Ensure that fl->fl_file has compatible f_mode for F_SETLK calls
2468  If error Then Go to out
2476  Case cmd == F_OFD_SETLK
2477  error = -EINVAL
2478  If l_pid != 0 Then Go to out
2481  cmd = F_SETLK
2482  fl_flags |= lock is "owned" by struct file
2483  fl_owner = filp
2484  Break
2485  Case cmd == F_OFD_SETLKW
2486  error = -EINVAL
2487  If l_pid != 0 Then Go to out
2490  cmd = F_SETLKW
2491  fl_flags |= lock is "owned" by struct file
2492  fl_owner = filp
2494  Case cmd == F_SETLKW
2495  fl_flags |= A blocking lock
2498  error = do_lock_file_wait(filp, cmd, file_lock)
2505  If Not error && fl_type != F_UNLCK && Not (fl_flags & lock is "owned" by struct file ) Then
2512  spin_lock( & file_lock)
2513  f = Check whether the specified fd has an open file.(fd)
2514  spin_unlock( & file_lock)
2515  If f != filp Then
2516  fl_type = F_UNLCK
2519  error = -EBADF
2522  out :
2523  trace_fcntl_setlk(inode, file_lock, error)
2524  Free a lock which is not in use.
2525  Return error
Caller
NameDescribe
do_compat_fcntl64