aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fs.h
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-10-01 17:41:11 -0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2007-10-09 18:32:46 -0400
commita16877ca9cec211708a161057a7cbfbf2cbc3a53 (patch)
treea114bfe588af58047b1eb2aa1f57ac4b890c01a6 /include/linux/fs.h
parent98257af5a2ad0c5b502ebd07094d9fd8ce87acef (diff)
Cleanup macros for distinguishing mandatory locks
The combination of S_ISGID bit set and S_IXGRP bit unset is used to mark the inode as "mandatory lockable" and there's a macro for this check called MANDATORY_LOCK(inode). However, fs/locks.c and some filesystems still perform the explicit i_mode checking. Besides, Andrew pointed out, that this macro is buggy itself, as it dereferences the inode arg twice. Convert this macro into static inline function and switch its users to it, making the code shorter and more readable. The __mandatory_lock() helper is to be used in places where the IS_MANDLOCK() for superblock is already known to be true. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Cc: Trond Myklebust <trond.myklebust@fys.uio.no> Cc: "J. Bruce Fields" <bfields@fieldses.org> Cc: David Howells <dhowells@redhat.com> Cc: Eric Van Hensbergen <ericvh@gmail.com> Cc: Ron Minnich <rminnich@sandia.gov> Cc: Latchesar Ionkov <lucho@ionkov.net> Cc: Steven Whitehouse <swhiteho@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 16421f662a7a..f5075e0e7301 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1369,12 +1369,25 @@ extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size
1369 * Candidates for mandatory locking have the setgid bit set 1369 * Candidates for mandatory locking have the setgid bit set
1370 * but no group execute bit - an otherwise meaningless combination. 1370 * but no group execute bit - an otherwise meaningless combination.
1371 */ 1371 */
1372#define MANDATORY_LOCK(inode) \ 1372
1373 (IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) 1373static inline int __mandatory_lock(struct inode *ino)
1374{
1375 return (ino->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID;
1376}
1377
1378/*
1379 * ... and these candidates should be on MS_MANDLOCK mounted fs,
1380 * otherwise these will be advisory locks
1381 */
1382
1383static inline int mandatory_lock(struct inode *ino)
1384{
1385 return IS_MANDLOCK(ino) && __mandatory_lock(ino);
1386}
1374 1387
1375static inline int locks_verify_locked(struct inode *inode) 1388static inline int locks_verify_locked(struct inode *inode)
1376{ 1389{
1377 if (MANDATORY_LOCK(inode)) 1390 if (mandatory_lock(inode))
1378 return locks_mandatory_locked(inode); 1391 return locks_mandatory_locked(inode);
1379 return 0; 1392 return 0;
1380} 1393}
@@ -1385,7 +1398,7 @@ static inline int locks_verify_truncate(struct inode *inode,
1385 struct file *filp, 1398 struct file *filp,
1386 loff_t size) 1399 loff_t size)
1387{ 1400{
1388 if (inode->i_flock && MANDATORY_LOCK(inode)) 1401 if (inode->i_flock && mandatory_lock(inode))
1389 return locks_mandatory_area( 1402 return locks_mandatory_area(
1390 FLOCK_VERIFY_WRITE, inode, filp, 1403 FLOCK_VERIFY_WRITE, inode, filp,
1391 size < inode->i_size ? size : inode->i_size, 1404 size < inode->i_size ? size : inode->i_size,