diff options
-rw-r--r-- | fs/locks.c | 80 | ||||
-rw-r--r-- | include/linux/fs.h | 14 |
2 files changed, 0 insertions, 94 deletions
diff --git a/fs/locks.c b/fs/locks.c index c3991dc80137..5200ffd2ba9b 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -2597,86 +2597,6 @@ static int __init proc_locks_init(void) | |||
2597 | module_init(proc_locks_init); | 2597 | module_init(proc_locks_init); |
2598 | #endif | 2598 | #endif |
2599 | 2599 | ||
2600 | /** | ||
2601 | * lock_may_read - checks that the region is free of locks | ||
2602 | * @inode: the inode that is being read | ||
2603 | * @start: the first byte to read | ||
2604 | * @len: the number of bytes to read | ||
2605 | * | ||
2606 | * Emulates Windows locking requirements. Whole-file | ||
2607 | * mandatory locks (share modes) can prohibit a read and | ||
2608 | * byte-range POSIX locks can prohibit a read if they overlap. | ||
2609 | * | ||
2610 | * N.B. this function is only ever called | ||
2611 | * from knfsd and ownership of locks is never checked. | ||
2612 | */ | ||
2613 | int lock_may_read(struct inode *inode, loff_t start, unsigned long len) | ||
2614 | { | ||
2615 | struct file_lock *fl; | ||
2616 | int result = 1; | ||
2617 | |||
2618 | spin_lock(&inode->i_lock); | ||
2619 | for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { | ||
2620 | if (IS_POSIX(fl)) { | ||
2621 | if (fl->fl_type == F_RDLCK) | ||
2622 | continue; | ||
2623 | if ((fl->fl_end < start) || (fl->fl_start > (start + len))) | ||
2624 | continue; | ||
2625 | } else if (IS_FLOCK(fl)) { | ||
2626 | if (!(fl->fl_type & LOCK_MAND)) | ||
2627 | continue; | ||
2628 | if (fl->fl_type & LOCK_READ) | ||
2629 | continue; | ||
2630 | } else | ||
2631 | continue; | ||
2632 | result = 0; | ||
2633 | break; | ||
2634 | } | ||
2635 | spin_unlock(&inode->i_lock); | ||
2636 | return result; | ||
2637 | } | ||
2638 | |||
2639 | EXPORT_SYMBOL(lock_may_read); | ||
2640 | |||
2641 | /** | ||
2642 | * lock_may_write - checks that the region is free of locks | ||
2643 | * @inode: the inode that is being written | ||
2644 | * @start: the first byte to write | ||
2645 | * @len: the number of bytes to write | ||
2646 | * | ||
2647 | * Emulates Windows locking requirements. Whole-file | ||
2648 | * mandatory locks (share modes) can prohibit a write and | ||
2649 | * byte-range POSIX locks can prohibit a write if they overlap. | ||
2650 | * | ||
2651 | * N.B. this function is only ever called | ||
2652 | * from knfsd and ownership of locks is never checked. | ||
2653 | */ | ||
2654 | int lock_may_write(struct inode *inode, loff_t start, unsigned long len) | ||
2655 | { | ||
2656 | struct file_lock *fl; | ||
2657 | int result = 1; | ||
2658 | |||
2659 | spin_lock(&inode->i_lock); | ||
2660 | for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { | ||
2661 | if (IS_POSIX(fl)) { | ||
2662 | if ((fl->fl_end < start) || (fl->fl_start > (start + len))) | ||
2663 | continue; | ||
2664 | } else if (IS_FLOCK(fl)) { | ||
2665 | if (!(fl->fl_type & LOCK_MAND)) | ||
2666 | continue; | ||
2667 | if (fl->fl_type & LOCK_WRITE) | ||
2668 | continue; | ||
2669 | } else | ||
2670 | continue; | ||
2671 | result = 0; | ||
2672 | break; | ||
2673 | } | ||
2674 | spin_unlock(&inode->i_lock); | ||
2675 | return result; | ||
2676 | } | ||
2677 | |||
2678 | EXPORT_SYMBOL(lock_may_write); | ||
2679 | |||
2680 | static int __init filelock_init(void) | 2600 | static int __init filelock_init(void) |
2681 | { | 2601 | { |
2682 | int i; | 2602 | int i; |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 3b07ce2698de..458f733c96bd 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -985,8 +985,6 @@ extern void lease_get_mtime(struct inode *, struct timespec *time); | |||
985 | extern int generic_setlease(struct file *, long, struct file_lock **); | 985 | extern int generic_setlease(struct file *, long, struct file_lock **); |
986 | extern int vfs_setlease(struct file *, long, struct file_lock **); | 986 | extern int vfs_setlease(struct file *, long, struct file_lock **); |
987 | extern int lease_modify(struct file_lock **, int); | 987 | extern int lease_modify(struct file_lock **, int); |
988 | extern int lock_may_read(struct inode *, loff_t start, unsigned long count); | ||
989 | extern int lock_may_write(struct inode *, loff_t start, unsigned long count); | ||
990 | #else /* !CONFIG_FILE_LOCKING */ | 988 | #else /* !CONFIG_FILE_LOCKING */ |
991 | static inline int fcntl_getlk(struct file *file, unsigned int cmd, | 989 | static inline int fcntl_getlk(struct file *file, unsigned int cmd, |
992 | struct flock __user *user) | 990 | struct flock __user *user) |
@@ -1117,18 +1115,6 @@ static inline int lease_modify(struct file_lock **before, int arg) | |||
1117 | { | 1115 | { |
1118 | return -EINVAL; | 1116 | return -EINVAL; |
1119 | } | 1117 | } |
1120 | |||
1121 | static inline int lock_may_read(struct inode *inode, loff_t start, | ||
1122 | unsigned long len) | ||
1123 | { | ||
1124 | return 1; | ||
1125 | } | ||
1126 | |||
1127 | static inline int lock_may_write(struct inode *inode, loff_t start, | ||
1128 | unsigned long len) | ||
1129 | { | ||
1130 | return 1; | ||
1131 | } | ||
1132 | #endif /* !CONFIG_FILE_LOCKING */ | 1118 | #endif /* !CONFIG_FILE_LOCKING */ |
1133 | 1119 | ||
1134 | 1120 | ||