aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-15 19:07:40 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-15 19:07:40 -0400
commit541010e4b8921cd781ff02ae68028501457045b6 (patch)
tree58bd529d4c6e69899a0aa20afa2d7f1c23326417 /include
parente457f790d8b05977853aa238bbc667b3bb375671 (diff)
parent5e7fc436426b1f9e106f511a049de91c82ec2c53 (diff)
Merge branch 'locks' of git://linux-nfs.org/~bfields/linux
* 'locks' of git://linux-nfs.org/~bfields/linux: nfsd: remove IS_ISMNDLCK macro Rework /proc/locks via seq_files and seq_list helpers fs/locks.c: use list_for_each_entry() instead of list_for_each() NFS: clean up explicit check for mandatory locks AFS: clean up explicit check for mandatory locks 9PFS: clean up explicit check for mandatory locks GFS2: clean up explicit check for mandatory locks Cleanup macros for distinguishing mandatory locks Documentation: move locks.txt in filesystems/ locks: add warning about mandatory locking races Documentation: move mandatory locking documentation to filesystems/ locks: Fix potential OOPS in generic_setlease() Use list_first_entry in locks_wake_up_blocks locks: fix flock_lock_file() comment Memory shortage can result in inconsistent flocks state locks: kill redundant local variable locks: reverse order of posix_locks_conflict() arguments
Diffstat (limited to 'include')
-rw-r--r--include/linux/fs.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 6d760f1ad875..4a6a21077bae 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -883,6 +883,7 @@ extern int vfs_setlease(struct file *, long, struct file_lock **);
883extern int lease_modify(struct file_lock **, int); 883extern int lease_modify(struct file_lock **, int);
884extern int lock_may_read(struct inode *, loff_t start, unsigned long count); 884extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
885extern int lock_may_write(struct inode *, loff_t start, unsigned long count); 885extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
886extern struct seq_operations locks_seq_operations;
886 887
887struct fasync_struct { 888struct fasync_struct {
888 int magic; 889 int magic;
@@ -1375,12 +1376,25 @@ extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size
1375 * Candidates for mandatory locking have the setgid bit set 1376 * Candidates for mandatory locking have the setgid bit set
1376 * but no group execute bit - an otherwise meaningless combination. 1377 * but no group execute bit - an otherwise meaningless combination.
1377 */ 1378 */
1378#define MANDATORY_LOCK(inode) \ 1379
1379 (IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) 1380static inline int __mandatory_lock(struct inode *ino)
1381{
1382 return (ino->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID;
1383}
1384
1385/*
1386 * ... and these candidates should be on MS_MANDLOCK mounted fs,
1387 * otherwise these will be advisory locks
1388 */
1389
1390static inline int mandatory_lock(struct inode *ino)
1391{
1392 return IS_MANDLOCK(ino) && __mandatory_lock(ino);
1393}
1380 1394
1381static inline int locks_verify_locked(struct inode *inode) 1395static inline int locks_verify_locked(struct inode *inode)
1382{ 1396{
1383 if (MANDATORY_LOCK(inode)) 1397 if (mandatory_lock(inode))
1384 return locks_mandatory_locked(inode); 1398 return locks_mandatory_locked(inode);
1385 return 0; 1399 return 0;
1386} 1400}
@@ -1391,7 +1405,7 @@ static inline int locks_verify_truncate(struct inode *inode,
1391 struct file *filp, 1405 struct file *filp,
1392 loff_t size) 1406 loff_t size)
1393{ 1407{
1394 if (inode->i_flock && MANDATORY_LOCK(inode)) 1408 if (inode->i_flock && mandatory_lock(inode))
1395 return locks_mandatory_area( 1409 return locks_mandatory_area(
1396 FLOCK_VERIFY_WRITE, inode, filp, 1410 FLOCK_VERIFY_WRITE, inode, filp,
1397 size < inode->i_size ? size : inode->i_size, 1411 size < inode->i_size ? size : inode->i_size,