aboutsummaryrefslogtreecommitdiffstats
path: root/fs/locks.c
diff options
context:
space:
mode:
authorMarc Eshel <eshel@almaden.ibm.com>2007-02-21 00:55:18 -0500
committerJ. Bruce Fields <bfields@citi.umich.edu>2007-05-06 17:39:00 -0400
commit9d6a8c5c213e34c475e72b245a8eb709258e968c (patch)
tree96110535c2bd9485129c0753a9e0f012083b220f /fs/locks.c
parent70cc6487a4e08b8698c0e2ec935fb48d10490162 (diff)
locks: give posix_test_lock same interface as ->lock
posix_test_lock() and ->lock() do the same job but have gratuitously different interfaces. Modify posix_test_lock() so the two agree, simplifying some code in the process. Signed-off-by: Marc Eshel <eshel@almaden.ibm.com> Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
Diffstat (limited to 'fs/locks.c')
-rw-r--r--fs/locks.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/fs/locks.c b/fs/locks.c
index b07e6e6f819b..749a0dc7cd4b 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -666,11 +666,11 @@ static int locks_block_on_timeout(struct file_lock *blocker, struct file_lock *w
666} 666}
667 667
668int 668int
669posix_test_lock(struct file *filp, struct file_lock *fl, 669posix_test_lock(struct file *filp, struct file_lock *fl)
670 struct file_lock *conflock)
671{ 670{
672 struct file_lock *cfl; 671 struct file_lock *cfl;
673 672
673 fl->fl_type = F_UNLCK;
674 lock_kernel(); 674 lock_kernel();
675 for (cfl = filp->f_path.dentry->d_inode->i_flock; cfl; cfl = cfl->fl_next) { 675 for (cfl = filp->f_path.dentry->d_inode->i_flock; cfl; cfl = cfl->fl_next) {
676 if (!IS_POSIX(cfl)) 676 if (!IS_POSIX(cfl))
@@ -679,7 +679,7 @@ posix_test_lock(struct file *filp, struct file_lock *fl,
679 break; 679 break;
680 } 680 }
681 if (cfl) { 681 if (cfl) {
682 __locks_copy_lock(conflock, cfl); 682 __locks_copy_lock(fl, cfl);
683 unlock_kernel(); 683 unlock_kernel();
684 return 1; 684 return 1;
685 } 685 }
@@ -1648,7 +1648,7 @@ static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl)
1648 */ 1648 */
1649int fcntl_getlk(struct file *filp, struct flock __user *l) 1649int fcntl_getlk(struct file *filp, struct flock __user *l)
1650{ 1650{
1651 struct file_lock *fl, cfl, file_lock; 1651 struct file_lock file_lock;
1652 struct flock flock; 1652 struct flock flock;
1653 int error; 1653 int error;
1654 1654
@@ -1667,15 +1667,12 @@ int fcntl_getlk(struct file *filp, struct flock __user *l)
1667 error = filp->f_op->lock(filp, F_GETLK, &file_lock); 1667 error = filp->f_op->lock(filp, F_GETLK, &file_lock);
1668 if (error < 0) 1668 if (error < 0)
1669 goto out; 1669 goto out;
1670 else 1670 } else
1671 fl = (file_lock.fl_type == F_UNLCK ? NULL : &file_lock); 1671 posix_test_lock(filp, &file_lock);
1672 } else {
1673 fl = (posix_test_lock(filp, &file_lock, &cfl) ? &cfl : NULL);
1674 }
1675 1672
1676 flock.l_type = F_UNLCK; 1673 flock.l_type = file_lock.fl_type;
1677 if (fl != NULL) { 1674 if (file_lock.fl_type != F_UNLCK) {
1678 error = posix_lock_to_flock(&flock, fl); 1675 error = posix_lock_to_flock(&flock, &file_lock);
1679 if (error) 1676 if (error)
1680 goto out; 1677 goto out;
1681 } 1678 }
@@ -1785,7 +1782,7 @@ out:
1785 */ 1782 */
1786int fcntl_getlk64(struct file *filp, struct flock64 __user *l) 1783int fcntl_getlk64(struct file *filp, struct flock64 __user *l)
1787{ 1784{
1788 struct file_lock *fl, cfl, file_lock; 1785 struct file_lock file_lock;
1789 struct flock64 flock; 1786 struct flock64 flock;
1790 int error; 1787 int error;
1791 1788
@@ -1804,15 +1801,13 @@ int fcntl_getlk64(struct file *filp, struct flock64 __user *l)
1804 error = filp->f_op->lock(filp, F_GETLK, &file_lock); 1801 error = filp->f_op->lock(filp, F_GETLK, &file_lock);
1805 if (error < 0) 1802 if (error < 0)
1806 goto out; 1803 goto out;
1807 else 1804 } else
1808 fl = (file_lock.fl_type == F_UNLCK ? NULL : &file_lock); 1805 posix_test_lock(filp, &file_lock);
1809 } else {
1810 fl = (posix_test_lock(filp, &file_lock, &cfl) ? &cfl : NULL);
1811 }
1812 1806
1813 flock.l_type = F_UNLCK; 1807 flock.l_type = file_lock.fl_type;
1814 if (fl != NULL) 1808 if (file_lock.fl_type != F_UNLCK)
1815 posix_lock_to_flock64(&flock, fl); 1809 posix_lock_to_flock64(&flock, &file_lock);
1810
1816 error = -EFAULT; 1811 error = -EFAULT;
1817 if (!copy_to_user(l, &flock, sizeof(flock))) 1812 if (!copy_to_user(l, &flock, sizeof(flock)))
1818 error = 0; 1813 error = 0;