aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/Kconfig8
-rw-r--r--fs/Makefile3
-rw-r--r--fs/proc/proc_misc.c4
-rw-r--r--include/linux/fs.h57
-rw-r--r--kernel/sys_ni.c1
-rw-r--r--kernel/sysctl.c6
6 files changed, 70 insertions, 9 deletions
diff --git a/fs/Kconfig b/fs/Kconfig
index abccb5dab9a8..c6ae4d4842eb 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
422config 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
422source "fs/xfs/Kconfig" 430source "fs/xfs/Kconfig"
423source "fs/gfs2/Kconfig" 431source "fs/gfs2/Kconfig"
424 432
diff --git a/fs/Makefile b/fs/Makefile
index a1482a5eff15..4b86d433baaf 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -7,7 +7,7 @@
7 7
8obj-y := open.o read_write.o file_table.o super.o \ 8obj-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
27obj-$(CONFIG_SIGNALFD) += signalfd.o 27obj-$(CONFIG_SIGNALFD) += signalfd.o
28obj-$(CONFIG_TIMERFD) += timerfd.o 28obj-$(CONFIG_TIMERFD) += timerfd.o
29obj-$(CONFIG_EVENTFD) += eventfd.o 29obj-$(CONFIG_EVENTFD) += eventfd.o
30obj-$(CONFIG_FILE_LOCKING) += locks.o
30obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o 31obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o
31 32
32nfsd-$(CONFIG_NFSD) := nfsctl.o 33nfsd-$(CONFIG_NFSD) := nfsctl.o
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 29e20c6b1f7f..1aabbe2592e1 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
687static int locks_open(struct inode *inode, struct file *filp) 688static 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
699static int execdomains_read_proc(char *page, char **start, off_t off, 701static 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 580b513668fe..9f540165a078 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
986extern void send_sigio(struct fown_struct *fown, int fd, int band);
987
988/* fs/sync.c */
989extern 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
986extern int fcntl_getlk(struct file *, struct flock __user *); 993extern int fcntl_getlk(struct file *, struct flock __user *);
987extern int fcntl_setlk(unsigned int, struct file *, unsigned int, 994extern 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
996extern void send_sigio(struct fown_struct *fown, int fd, int band);
997extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); 1003extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
998extern int fcntl_getlease(struct file *filp); 1004extern int fcntl_getlease(struct file *filp);
999 1005
1000/* fs/sync.c */
1001extern 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 */
1005extern void locks_init_lock(struct file_lock *); 1007extern void locks_init_lock(struct file_lock *);
1006extern void locks_copy_lock(struct file_lock *, struct file_lock *); 1008extern void locks_copy_lock(struct file_lock *, struct file_lock *);
@@ -1023,6 +1025,37 @@ extern int lease_modify(struct file_lock **, int);
1023extern int lock_may_read(struct inode *, loff_t start, unsigned long count); 1025extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
1024extern int lock_may_write(struct inode *, loff_t start, unsigned long count); 1026extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
1025extern struct seq_operations locks_seq_operations; 1027extern 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
1027struct fasync_struct { 1060struct 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 */
1555extern struct kobject *fs_kobj; 1588extern struct kobject *fs_kobj;
1556 1589
1590extern 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
1560extern int locks_mandatory_locked(struct inode *); 1596extern int locks_mandatory_locked(struct inode *);
1561extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t); 1597extern 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
1590extern int rw_verify_area(int, struct file *, loff_t *, size_t);
1591
1592static inline int locks_verify_truncate(struct inode *inode, 1626static 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 08d6e1bb99ac..503d8d4eb80a 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -125,6 +125,7 @@ cond_syscall(sys_vm86old);
125cond_syscall(sys_vm86); 125cond_syscall(sys_vm86);
126cond_syscall(compat_sys_ipc); 126cond_syscall(compat_sys_ipc);
127cond_syscall(compat_sys_sysctl); 127cond_syscall(compat_sys_sysctl);
128cond_syscall(sys_flock);
128 129
129/* arch-specific weak syscall entries */ 130/* arch-specific weak syscall entries */
130cond_syscall(sys_pciconfig_read); 131cond_syscall(sys_pciconfig_read);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 50ec0886fa3d..4588b2cf2ecb 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -97,7 +97,7 @@ static int sixty = 60;
97static int neg_one = -1; 97static int neg_one = -1;
98#endif 98#endif
99 99
100#ifdef CONFIG_MMU 100#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING)
101static int two = 2; 101static 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,