diff options
-rw-r--r-- | fs/Kconfig | 8 | ||||
-rw-r--r-- | fs/Makefile | 3 | ||||
-rw-r--r-- | fs/proc/proc_misc.c | 4 | ||||
-rw-r--r-- | include/linux/fs.h | 57 | ||||
-rw-r--r-- | kernel/sys_ni.c | 1 | ||||
-rw-r--r-- | kernel/sysctl.c | 6 |
6 files changed, 70 insertions, 9 deletions
diff --git a/fs/Kconfig b/fs/Kconfig index abccb5dab9a..c6ae4d4842e 100644 --- a/fs/Kconfig +++ b/fs/Kconfig | |||
@@ -419,6 +419,14 @@ config FS_POSIX_ACL | |||
419 | bool | 419 | bool |
420 | default n | 420 | default n |
421 | 421 | ||
422 | config FILE_LOCKING | ||
423 | bool "Enable POSIX file locking API" if EMBEDDED | ||
424 | default y | ||
425 | help | ||
426 | This option enables standard file locking support, required | ||
427 | for filesystems like NFS and for the flock() system | ||
428 | call. Disabling this option saves about 11k. | ||
429 | |||
422 | source "fs/xfs/Kconfig" | 430 | source "fs/xfs/Kconfig" |
423 | source "fs/gfs2/Kconfig" | 431 | source "fs/gfs2/Kconfig" |
424 | 432 | ||
diff --git a/fs/Makefile b/fs/Makefile index a1482a5eff1..4b86d433baa 100644 --- a/fs/Makefile +++ b/fs/Makefile | |||
@@ -7,7 +7,7 @@ | |||
7 | 7 | ||
8 | obj-y := open.o read_write.o file_table.o super.o \ | 8 | obj-y := open.o read_write.o file_table.o super.o \ |
9 | char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \ | 9 | char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \ |
10 | ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \ | 10 | ioctl.o readdir.o select.o fifo.o dcache.o inode.o \ |
11 | attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ | 11 | attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ |
12 | seq_file.o xattr.o libfs.o fs-writeback.o \ | 12 | seq_file.o xattr.o libfs.o fs-writeback.o \ |
13 | pnode.o drop_caches.o splice.o sync.o utimes.o \ | 13 | pnode.o drop_caches.o splice.o sync.o utimes.o \ |
@@ -27,6 +27,7 @@ obj-$(CONFIG_ANON_INODES) += anon_inodes.o | |||
27 | obj-$(CONFIG_SIGNALFD) += signalfd.o | 27 | obj-$(CONFIG_SIGNALFD) += signalfd.o |
28 | obj-$(CONFIG_TIMERFD) += timerfd.o | 28 | obj-$(CONFIG_TIMERFD) += timerfd.o |
29 | obj-$(CONFIG_EVENTFD) += eventfd.o | 29 | obj-$(CONFIG_EVENTFD) += eventfd.o |
30 | obj-$(CONFIG_FILE_LOCKING) += locks.o | ||
30 | obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o | 31 | obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o |
31 | 32 | ||
32 | nfsd-$(CONFIG_NFSD) := nfsctl.o | 33 | nfsd-$(CONFIG_NFSD) := nfsctl.o |
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 29e20c6b1f7..1aabbe2592e 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c | |||
@@ -684,6 +684,7 @@ static int cmdline_read_proc(char *page, char **start, off_t off, | |||
684 | return proc_calc_metrics(page, start, off, count, eof, len); | 684 | return proc_calc_metrics(page, start, off, count, eof, len); |
685 | } | 685 | } |
686 | 686 | ||
687 | #ifdef CONFIG_FILE_LOCKING | ||
687 | static int locks_open(struct inode *inode, struct file *filp) | 688 | static int locks_open(struct inode *inode, struct file *filp) |
688 | { | 689 | { |
689 | return seq_open(filp, &locks_seq_operations); | 690 | return seq_open(filp, &locks_seq_operations); |
@@ -695,6 +696,7 @@ static const struct file_operations proc_locks_operations = { | |||
695 | .llseek = seq_lseek, | 696 | .llseek = seq_lseek, |
696 | .release = seq_release, | 697 | .release = seq_release, |
697 | }; | 698 | }; |
699 | #endif /* CONFIG_FILE_LOCKING */ | ||
698 | 700 | ||
699 | static int execdomains_read_proc(char *page, char **start, off_t off, | 701 | static int execdomains_read_proc(char *page, char **start, off_t off, |
700 | int count, int *eof, void *data) | 702 | int count, int *eof, void *data) |
@@ -888,7 +890,9 @@ void __init proc_misc_init(void) | |||
888 | #ifdef CONFIG_PRINTK | 890 | #ifdef CONFIG_PRINTK |
889 | proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations); | 891 | proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations); |
890 | #endif | 892 | #endif |
893 | #ifdef CONFIG_FILE_LOCKING | ||
891 | proc_create("locks", 0, NULL, &proc_locks_operations); | 894 | proc_create("locks", 0, NULL, &proc_locks_operations); |
895 | #endif | ||
892 | proc_create("devices", 0, NULL, &proc_devinfo_operations); | 896 | proc_create("devices", 0, NULL, &proc_devinfo_operations); |
893 | proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations); | 897 | proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations); |
894 | #ifdef CONFIG_BLOCK | 898 | #ifdef CONFIG_BLOCK |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 580b513668f..9f540165a07 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -983,6 +983,13 @@ struct file_lock { | |||
983 | 983 | ||
984 | #include <linux/fcntl.h> | 984 | #include <linux/fcntl.h> |
985 | 985 | ||
986 | extern void send_sigio(struct fown_struct *fown, int fd, int band); | ||
987 | |||
988 | /* fs/sync.c */ | ||
989 | extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, | ||
990 | loff_t endbyte, unsigned int flags); | ||
991 | |||
992 | #ifdef CONFIG_FILE_LOCKING | ||
986 | extern int fcntl_getlk(struct file *, struct flock __user *); | 993 | extern int fcntl_getlk(struct file *, struct flock __user *); |
987 | extern int fcntl_setlk(unsigned int, struct file *, unsigned int, | 994 | extern int fcntl_setlk(unsigned int, struct file *, unsigned int, |
988 | struct flock __user *); | 995 | struct flock __user *); |
@@ -993,14 +1000,9 @@ extern int fcntl_setlk64(unsigned int, struct file *, unsigned int, | |||
993 | struct flock64 __user *); | 1000 | struct flock64 __user *); |
994 | #endif | 1001 | #endif |
995 | 1002 | ||
996 | extern void send_sigio(struct fown_struct *fown, int fd, int band); | ||
997 | extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); | 1003 | extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); |
998 | extern int fcntl_getlease(struct file *filp); | 1004 | extern int fcntl_getlease(struct file *filp); |
999 | 1005 | ||
1000 | /* fs/sync.c */ | ||
1001 | extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, | ||
1002 | loff_t endbyte, unsigned int flags); | ||
1003 | |||
1004 | /* fs/locks.c */ | 1006 | /* fs/locks.c */ |
1005 | extern void locks_init_lock(struct file_lock *); | 1007 | extern void locks_init_lock(struct file_lock *); |
1006 | extern void locks_copy_lock(struct file_lock *, struct file_lock *); | 1008 | extern void locks_copy_lock(struct file_lock *, struct file_lock *); |
@@ -1023,6 +1025,37 @@ extern int lease_modify(struct file_lock **, int); | |||
1023 | extern int lock_may_read(struct inode *, loff_t start, unsigned long count); | 1025 | extern int lock_may_read(struct inode *, loff_t start, unsigned long count); |
1024 | extern int lock_may_write(struct inode *, loff_t start, unsigned long count); | 1026 | extern int lock_may_write(struct inode *, loff_t start, unsigned long count); |
1025 | extern struct seq_operations locks_seq_operations; | 1027 | extern struct seq_operations locks_seq_operations; |
1028 | #else /* !CONFIG_FILE_LOCKING */ | ||
1029 | #define fcntl_getlk(a, b) ({ -EINVAL; }) | ||
1030 | #define fcntl_setlk(a, b, c, d) ({ -EACCES; }) | ||
1031 | #if BITS_PER_LONG == 32 | ||
1032 | #define fcntl_getlk64(a, b) ({ -EINVAL; }) | ||
1033 | #define fcntl_setlk64(a, b, c, d) ({ -EACCES; }) | ||
1034 | #endif | ||
1035 | #define fcntl_setlease(a, b, c) ({ 0; }) | ||
1036 | #define fcntl_getlease(a) ({ 0; }) | ||
1037 | #define locks_init_lock(a) ({ }) | ||
1038 | #define __locks_copy_lock(a, b) ({ }) | ||
1039 | #define locks_copy_lock(a, b) ({ }) | ||
1040 | #define locks_remove_posix(a, b) ({ }) | ||
1041 | #define locks_remove_flock(a) ({ }) | ||
1042 | #define posix_test_lock(a, b) ({ 0; }) | ||
1043 | #define posix_lock_file(a, b, c) ({ -ENOLCK; }) | ||
1044 | #define posix_lock_file_wait(a, b) ({ -ENOLCK; }) | ||
1045 | #define posix_unblock_lock(a, b) (-ENOENT) | ||
1046 | #define vfs_test_lock(a, b) ({ 0; }) | ||
1047 | #define vfs_lock_file(a, b, c, d) (-ENOLCK) | ||
1048 | #define vfs_cancel_lock(a, b) ({ 0; }) | ||
1049 | #define flock_lock_file_wait(a, b) ({ -ENOLCK; }) | ||
1050 | #define __break_lease(a, b) ({ 0; }) | ||
1051 | #define lease_get_mtime(a, b) ({ }) | ||
1052 | #define generic_setlease(a, b, c) ({ -EINVAL; }) | ||
1053 | #define vfs_setlease(a, b, c) ({ -EINVAL; }) | ||
1054 | #define lease_modify(a, b) ({ -EINVAL; }) | ||
1055 | #define lock_may_read(a, b, c) ({ 1; }) | ||
1056 | #define lock_may_write(a, b, c) ({ 1; }) | ||
1057 | #endif /* !CONFIG_FILE_LOCKING */ | ||
1058 | |||
1026 | 1059 | ||
1027 | struct fasync_struct { | 1060 | struct fasync_struct { |
1028 | int magic; | 1061 | int magic; |
@@ -1554,9 +1587,12 @@ extern int vfs_statfs(struct dentry *, struct kstatfs *); | |||
1554 | /* /sys/fs */ | 1587 | /* /sys/fs */ |
1555 | extern struct kobject *fs_kobj; | 1588 | extern struct kobject *fs_kobj; |
1556 | 1589 | ||
1590 | extern int rw_verify_area(int, struct file *, loff_t *, size_t); | ||
1591 | |||
1557 | #define FLOCK_VERIFY_READ 1 | 1592 | #define FLOCK_VERIFY_READ 1 |
1558 | #define FLOCK_VERIFY_WRITE 2 | 1593 | #define FLOCK_VERIFY_WRITE 2 |
1559 | 1594 | ||
1595 | #ifdef CONFIG_FILE_LOCKING | ||
1560 | extern int locks_mandatory_locked(struct inode *); | 1596 | extern int locks_mandatory_locked(struct inode *); |
1561 | extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t); | 1597 | extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t); |
1562 | 1598 | ||
@@ -1587,8 +1623,6 @@ static inline int locks_verify_locked(struct inode *inode) | |||
1587 | return 0; | 1623 | return 0; |
1588 | } | 1624 | } |
1589 | 1625 | ||
1590 | extern int rw_verify_area(int, struct file *, loff_t *, size_t); | ||
1591 | |||
1592 | static inline int locks_verify_truncate(struct inode *inode, | 1626 | static inline int locks_verify_truncate(struct inode *inode, |
1593 | struct file *filp, | 1627 | struct file *filp, |
1594 | loff_t size) | 1628 | loff_t size) |
@@ -1609,6 +1643,15 @@ static inline int break_lease(struct inode *inode, unsigned int mode) | |||
1609 | return __break_lease(inode, mode); | 1643 | return __break_lease(inode, mode); |
1610 | return 0; | 1644 | return 0; |
1611 | } | 1645 | } |
1646 | #else /* !CONFIG_FILE_LOCKING */ | ||
1647 | #define locks_mandatory_locked(a) ({ 0; }) | ||
1648 | #define locks_mandatory_area(a, b, c, d, e) ({ 0; }) | ||
1649 | #define __mandatory_lock(a) ({ 0; }) | ||
1650 | #define mandatory_lock(a) ({ 0; }) | ||
1651 | #define locks_verify_locked(a) ({ 0; }) | ||
1652 | #define locks_verify_truncate(a, b, c) ({ 0; }) | ||
1653 | #define break_lease(a, b) ({ 0; }) | ||
1654 | #endif /* CONFIG_FILE_LOCKING */ | ||
1612 | 1655 | ||
1613 | /* fs/open.c */ | 1656 | /* fs/open.c */ |
1614 | 1657 | ||
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index 08d6e1bb99a..503d8d4eb80 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c | |||
@@ -125,6 +125,7 @@ cond_syscall(sys_vm86old); | |||
125 | cond_syscall(sys_vm86); | 125 | cond_syscall(sys_vm86); |
126 | cond_syscall(compat_sys_ipc); | 126 | cond_syscall(compat_sys_ipc); |
127 | cond_syscall(compat_sys_sysctl); | 127 | cond_syscall(compat_sys_sysctl); |
128 | cond_syscall(sys_flock); | ||
128 | 129 | ||
129 | /* arch-specific weak syscall entries */ | 130 | /* arch-specific weak syscall entries */ |
130 | cond_syscall(sys_pciconfig_read); | 131 | cond_syscall(sys_pciconfig_read); |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 50ec0886fa3..4588b2cf2ec 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -97,7 +97,7 @@ static int sixty = 60; | |||
97 | static int neg_one = -1; | 97 | static int neg_one = -1; |
98 | #endif | 98 | #endif |
99 | 99 | ||
100 | #ifdef CONFIG_MMU | 100 | #if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING) |
101 | static int two = 2; | 101 | static int two = 2; |
102 | #endif | 102 | #endif |
103 | 103 | ||
@@ -1261,6 +1261,7 @@ static struct ctl_table fs_table[] = { | |||
1261 | .extra1 = &minolduid, | 1261 | .extra1 = &minolduid, |
1262 | .extra2 = &maxolduid, | 1262 | .extra2 = &maxolduid, |
1263 | }, | 1263 | }, |
1264 | #ifdef CONFIG_FILE_LOCKING | ||
1264 | { | 1265 | { |
1265 | .ctl_name = FS_LEASES, | 1266 | .ctl_name = FS_LEASES, |
1266 | .procname = "leases-enable", | 1267 | .procname = "leases-enable", |
@@ -1269,6 +1270,7 @@ static struct ctl_table fs_table[] = { | |||
1269 | .mode = 0644, | 1270 | .mode = 0644, |
1270 | .proc_handler = &proc_dointvec, | 1271 | .proc_handler = &proc_dointvec, |
1271 | }, | 1272 | }, |
1273 | #endif | ||
1272 | #ifdef CONFIG_DNOTIFY | 1274 | #ifdef CONFIG_DNOTIFY |
1273 | { | 1275 | { |
1274 | .ctl_name = FS_DIR_NOTIFY, | 1276 | .ctl_name = FS_DIR_NOTIFY, |
@@ -1280,6 +1282,7 @@ static struct ctl_table fs_table[] = { | |||
1280 | }, | 1282 | }, |
1281 | #endif | 1283 | #endif |
1282 | #ifdef CONFIG_MMU | 1284 | #ifdef CONFIG_MMU |
1285 | #ifdef CONFIG_FILE_LOCKING | ||
1283 | { | 1286 | { |
1284 | .ctl_name = FS_LEASE_TIME, | 1287 | .ctl_name = FS_LEASE_TIME, |
1285 | .procname = "lease-break-time", | 1288 | .procname = "lease-break-time", |
@@ -1291,6 +1294,7 @@ static struct ctl_table fs_table[] = { | |||
1291 | .extra1 = &zero, | 1294 | .extra1 = &zero, |
1292 | .extra2 = &two, | 1295 | .extra2 = &two, |
1293 | }, | 1296 | }, |
1297 | #endif | ||
1294 | { | 1298 | { |
1295 | .procname = "aio-nr", | 1299 | .procname = "aio-nr", |
1296 | .data = &aio_nr, | 1300 | .data = &aio_nr, |