aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2008-08-06 09:12:22 -0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2008-09-29 17:56:57 -0400
commitbfcd17a6c5529bc37234cfa720a047cf9397bcfc (patch)
treef4e087479a8c559f1a5ca3be96c64afd172e12c1 /include/linux
parent04716e6621ff4abb422d64ba7b48718f52716a3e (diff)
Configure out file locking features
This patch adds the CONFIG_FILE_LOCKING option which allows to remove support for advisory locks. With this patch enabled, the flock() system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() and NFS support are disabled. These features are not necessarly needed on embedded systems. It allows to save ~11 Kb of kernel code and data: text data bss dec hex filename 1125436 118764 212992 1457192 163c28 vmlinux.old 1114299 118564 212992 1445855 160fdf vmlinux -11137 -200 0 -11337 -2C49 +/- This patch has originally been written by Matt Mackall <mpm@selenic.com>, and is part of the Linux Tiny project. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Matt Mackall <mpm@selenic.com> Cc: matthew@wil.cx Cc: linux-fsdevel@vger.kernel.org Cc: mpm@selenic.com Cc: akpm@linux-foundation.org Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/fs.h57
1 files changed, 50 insertions, 7 deletions
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