Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:sys_flock: - flock() system call.*@fd: the file descriptor to lock.*@cmd: the type of lock to apply.* Apply a %FL_FLOCK style lock to an open file descriptor.* The @cmd can be one of:* - %LOCK_SH -- a shared lock.* - %LOCK_EX -- an exclusive lock.

Proto:SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd)

Type:

Parameter:Nothing

2190  f = fdget(fd)
2195  error = -EBADF
2196  If Not file Then Go to out
2199  can_sleep = Not (cmd & LOCK_NB)
2200  cmd &= ~LOCK_NB
2201  unlock = cmd == LOCK_UN
2203  If Not unlock && Not (cmd & LOCK_MAND) && Not (f_mode & (le is open for reading | le is open for writing )) Then Go to out_putf
2207  lock = Fill in a file_lock structure with an appropriate FLOCK lock.
2208  If IS_ERR(lock) Then
2209  error = PTR_ERR(lock)
2210  Go to out_putf
2213  If can_sleep Then fl_flags |= A blocking lock
2216  error = security_file_lock(file, fl_type)
2217  If error Then Go to out_free
2220  If flock Then error = flock(file, (can_sleep) ? F_SETLKW : F_SETLK, lock)
2224  Else error = locks_lock_file_wait(file, lock)
2227  out_free :
2228  Free a lock which is not in use.
2230  out_putf :
2231  fdput(f)
2232  out :
2233  Return error