Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\locks.c Create Date:2022-07-28 20:25:34
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_setlk64(unsigned int fd, struct file *filp, unsigned int cmd, struct flock64 *flock)

Type:int

Parameter:

TypeParameterName
unsigned intfd
struct file *filp
unsigned intcmd
struct flock64 *flock
2578  file_lock = Allocate an empty lock structure.
2579  inode = locks_inode(filp)
2583  If (file_lock == NULL) Then Return -ENOLCK
2589  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
2590  error = -EAGAIN
2591  Go to out
2594  error = flock64_to_posix_lock(filp, file_lock, flock)
2595  If error Then Go to out
2598  error = Ensure that fl->fl_file has compatible f_mode for F_SETLK calls
2599  If error Then Go to out
2607  Case cmd == F_OFD_SETLK
2608  error = -EINVAL
2609  If l_pid != 0 Then Go to out
2612  cmd = F_SETLK64
2613  fl_flags |= lock is "owned" by struct file
2614  fl_owner = filp
2615  Break
2616  Case cmd == F_OFD_SETLKW
2617  error = -EINVAL
2618  If l_pid != 0 Then Go to out
2621  cmd = F_SETLKW64
2622  fl_flags |= lock is "owned" by struct file
2623  fl_owner = filp
2625  Case cmd == F_SETLKW64
2626  fl_flags |= A blocking lock
2629  error = do_lock_file_wait(filp, cmd, file_lock)
2636  If Not error && fl_type != F_UNLCK && Not (fl_flags & lock is "owned" by struct file ) Then
2643  spin_lock( & file_lock)
2644  f = Check whether the specified fd has an open file.(fd)
2645  spin_unlock( & file_lock)
2646  If f != filp Then
2647  fl_type = F_UNLCK
2650  error = -EBADF
2653  out :
2654  Free a lock which is not in use.
2655  Return error