diff options
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r-- | include/linux/fs.h | 22 |
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 **); | |||
883 | extern int lease_modify(struct file_lock **, int); | 883 | extern int lease_modify(struct file_lock **, int); |
884 | extern int lock_may_read(struct inode *, loff_t start, unsigned long count); | 884 | extern int lock_may_read(struct inode *, loff_t start, unsigned long count); |
885 | extern int lock_may_write(struct inode *, loff_t start, unsigned long count); | 885 | extern int lock_may_write(struct inode *, loff_t start, unsigned long count); |
886 | extern struct seq_operations locks_seq_operations; | ||
886 | 887 | ||
887 | struct fasync_struct { | 888 | struct 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) | 1380 | static 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 | |||
1390 | static inline int mandatory_lock(struct inode *ino) | ||
1391 | { | ||
1392 | return IS_MANDLOCK(ino) && __mandatory_lock(ino); | ||
1393 | } | ||
1380 | 1394 | ||
1381 | static inline int locks_verify_locked(struct inode *inode) | 1395 | static 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, |