Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54487
b: refs/heads/master
c: 3ee17ab
h: refs/heads/master
i:
  54485: 52019fa
  54483: ca2aa17
  54479: 245c41a
v: v3
  • Loading branch information
J. Bruce Fields committed May 6, 2007
1 parent d167950 commit 37870a2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9d6a8c5c213e34c475e72b245a8eb709258e968c
refs/heads/master: 3ee17abd14c728d4e0ca7a991c58f2250cb091af
38 changes: 25 additions & 13 deletions trunk/fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,24 @@ asmlinkage long sys_flock(unsigned int fd, unsigned int cmd)
return error;
}

/**
* vfs_test_lock - test file byte range lock
* @filp: The file to test lock for
* @fl: The lock to test
* @conf: Place to return a copy of the conflicting lock, if found
*
* Returns -ERRNO on failure. Indicates presence of conflicting lock by
* setting conf->fl_type to something other than F_UNLCK.
*/
int vfs_test_lock(struct file *filp, struct file_lock *fl)
{
if (filp->f_op && filp->f_op->lock)
return filp->f_op->lock(filp, F_GETLK, fl);
posix_test_lock(filp, fl);
return 0;
}
EXPORT_SYMBOL_GPL(vfs_test_lock);

static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl)
{
flock->l_pid = fl->fl_pid;
Expand Down Expand Up @@ -1663,12 +1681,9 @@ int fcntl_getlk(struct file *filp, struct flock __user *l)
if (error)
goto out;

if (filp->f_op && filp->f_op->lock) {
error = filp->f_op->lock(filp, F_GETLK, &file_lock);
if (error < 0)
goto out;
} else
posix_test_lock(filp, &file_lock);
error = vfs_test_lock(filp, &file_lock);
if (error)
goto out;

flock.l_type = file_lock.fl_type;
if (file_lock.fl_type != F_UNLCK) {
Expand Down Expand Up @@ -1797,13 +1812,10 @@ int fcntl_getlk64(struct file *filp, struct flock64 __user *l)
if (error)
goto out;

if (filp->f_op && filp->f_op->lock) {
error = filp->f_op->lock(filp, F_GETLK, &file_lock);
if (error < 0)
goto out;
} else
posix_test_lock(filp, &file_lock);

error = vfs_test_lock(filp, &file_lock);
if (error)
goto out;

flock.l_type = file_lock.fl_type;
if (file_lock.fl_type != F_UNLCK)
posix_lock_to_flock64(&flock, &file_lock);
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,7 @@ extern int posix_lock_file_conf(struct file *, struct file_lock *, struct file_l
extern int posix_lock_file(struct file *, struct file_lock *);
extern int posix_lock_file_wait(struct file *, struct file_lock *);
extern int posix_unblock_lock(struct file *, struct file_lock *);
extern int vfs_test_lock(struct file *, struct file_lock *);
extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl);
extern int __break_lease(struct inode *inode, unsigned int flags);
extern void lease_get_mtime(struct inode *, struct timespec *time);
Expand Down

0 comments on commit 37870a2

Please sign in to comment.