aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fs.h
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-10-28 11:26:12 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-28 11:26:12 -0400
commit7a9787e1eba95a166265e6a260cf30af04ef0a99 (patch)
treee730a4565e0318140d2fbd2f0415d18a339d7336 /include/linux/fs.h
parent41b9eb264c8407655db57b60b4457fe1b2ec9977 (diff)
parent0173a3265b228da319ceb9c1ec6a5682fd1b2d92 (diff)
Merge commit 'v2.6.28-rc2' into x86/pci-ioapic-boot-irq-quirks
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h277
1 files changed, 182 insertions, 95 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c6455dadb21b..5b248d61430c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -60,19 +60,26 @@ extern int dir_notify_enable;
60#define MAY_WRITE 2 60#define MAY_WRITE 2
61#define MAY_READ 4 61#define MAY_READ 4
62#define MAY_APPEND 8 62#define MAY_APPEND 8
63#define MAY_ACCESS 16
64#define MAY_OPEN 32
63 65
64#define FMODE_READ 1 66#define FMODE_READ ((__force fmode_t)1)
65#define FMODE_WRITE 2 67#define FMODE_WRITE ((__force fmode_t)2)
66 68
67/* Internal kernel extensions */ 69/* Internal kernel extensions */
68#define FMODE_LSEEK 4 70#define FMODE_LSEEK ((__force fmode_t)4)
69#define FMODE_PREAD 8 71#define FMODE_PREAD ((__force fmode_t)8)
70#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */ 72#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */
71 73
72/* File is being opened for execution. Primary users of this flag are 74/* File is being opened for execution. Primary users of this flag are
73 distributed filesystems that can use it to achieve correct ETXTBUSY 75 distributed filesystems that can use it to achieve correct ETXTBUSY
74 behavior for cross-node execution/opening_for_writing of files */ 76 behavior for cross-node execution/opening_for_writing of files */
75#define FMODE_EXEC 16 77#define FMODE_EXEC ((__force fmode_t)16)
78
79#define FMODE_NDELAY ((__force fmode_t)32)
80#define FMODE_EXCL ((__force fmode_t)64)
81#define FMODE_WRITE_IOCTL ((__force fmode_t)128)
82#define FMODE_NDELAY_NOW ((__force fmode_t)256)
76 83
77#define RW_MASK 1 84#define RW_MASK 1
78#define RWA_MASK 2 85#define RWA_MASK 2
@@ -84,7 +91,9 @@ extern int dir_notify_enable;
84#define READ_META (READ | (1 << BIO_RW_META)) 91#define READ_META (READ | (1 << BIO_RW_META))
85#define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC)) 92#define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC))
86#define SWRITE_SYNC (SWRITE | (1 << BIO_RW_SYNC)) 93#define SWRITE_SYNC (SWRITE | (1 << BIO_RW_SYNC))
87#define WRITE_BARRIER ((1 << BIO_RW) | (1 << BIO_RW_BARRIER)) 94#define WRITE_BARRIER (WRITE | (1 << BIO_RW_BARRIER))
95#define DISCARD_NOBARRIER (1 << BIO_RW_DISCARD)
96#define DISCARD_BARRIER ((1 << BIO_RW_DISCARD) | (1 << BIO_RW_BARRIER))
88 97
89#define SEL_IN 1 98#define SEL_IN 1
90#define SEL_OUT 2 99#define SEL_OUT 2
@@ -132,7 +141,7 @@ extern int dir_notify_enable;
132/* 141/*
133 * Superblock flags that can be altered by MS_REMOUNT 142 * Superblock flags that can be altered by MS_REMOUNT
134 */ 143 */
135#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK) 144#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION)
136 145
137/* 146/*
138 * Old magic mount flag and mask 147 * Old magic mount flag and mask
@@ -220,6 +229,7 @@ extern int dir_notify_enable;
220#define BLKTRACESTART _IO(0x12,116) 229#define BLKTRACESTART _IO(0x12,116)
221#define BLKTRACESTOP _IO(0x12,117) 230#define BLKTRACESTOP _IO(0x12,117)
222#define BLKTRACETEARDOWN _IO(0x12,118) 231#define BLKTRACETEARDOWN _IO(0x12,118)
232#define BLKDISCARD _IO(0x12,119)
223 233
224#define BMAP_IOCTL 1 /* obsolete - kept for compatibility */ 234#define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
225#define FIBMAP _IO(0x00,1) /* bmap access */ 235#define FIBMAP _IO(0x00,1) /* bmap access */
@@ -229,6 +239,7 @@ extern int dir_notify_enable;
229#define FS_IOC_SETFLAGS _IOW('f', 2, long) 239#define FS_IOC_SETFLAGS _IOW('f', 2, long)
230#define FS_IOC_GETVERSION _IOR('v', 1, long) 240#define FS_IOC_GETVERSION _IOR('v', 1, long)
231#define FS_IOC_SETVERSION _IOW('v', 2, long) 241#define FS_IOC_SETVERSION _IOW('v', 2, long)
242#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
232#define FS_IOC32_GETFLAGS _IOR('f', 1, int) 243#define FS_IOC32_GETFLAGS _IOR('f', 1, int)
233#define FS_IOC32_SETFLAGS _IOW('f', 2, int) 244#define FS_IOC32_SETFLAGS _IOW('f', 2, int)
234#define FS_IOC32_GETVERSION _IOR('v', 1, int) 245#define FS_IOC32_GETVERSION _IOR('v', 1, int)
@@ -277,7 +288,7 @@ extern int dir_notify_enable;
277#include <linux/types.h> 288#include <linux/types.h>
278#include <linux/kdev_t.h> 289#include <linux/kdev_t.h>
279#include <linux/dcache.h> 290#include <linux/dcache.h>
280#include <linux/namei.h> 291#include <linux/path.h>
281#include <linux/stat.h> 292#include <linux/stat.h>
282#include <linux/cache.h> 293#include <linux/cache.h>
283#include <linux/kobject.h> 294#include <linux/kobject.h>
@@ -289,6 +300,7 @@ extern int dir_notify_enable;
289#include <linux/mutex.h> 300#include <linux/mutex.h>
290#include <linux/capability.h> 301#include <linux/capability.h>
291#include <linux/semaphore.h> 302#include <linux/semaphore.h>
303#include <linux/fiemap.h>
292 304
293#include <asm/atomic.h> 305#include <asm/atomic.h>
294#include <asm/byteorder.h> 306#include <asm/byteorder.h>
@@ -318,22 +330,23 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
318 * Attribute flags. These should be or-ed together to figure out what 330 * Attribute flags. These should be or-ed together to figure out what
319 * has been changed! 331 * has been changed!
320 */ 332 */
321#define ATTR_MODE 1 333#define ATTR_MODE (1 << 0)
322#define ATTR_UID 2 334#define ATTR_UID (1 << 1)
323#define ATTR_GID 4 335#define ATTR_GID (1 << 2)
324#define ATTR_SIZE 8 336#define ATTR_SIZE (1 << 3)
325#define ATTR_ATIME 16 337#define ATTR_ATIME (1 << 4)
326#define ATTR_MTIME 32 338#define ATTR_MTIME (1 << 5)
327#define ATTR_CTIME 64 339#define ATTR_CTIME (1 << 6)
328#define ATTR_ATIME_SET 128 340#define ATTR_ATIME_SET (1 << 7)
329#define ATTR_MTIME_SET 256 341#define ATTR_MTIME_SET (1 << 8)
330#define ATTR_FORCE 512 /* Not a change, but a change it */ 342#define ATTR_FORCE (1 << 9) /* Not a change, but a change it */
331#define ATTR_ATTR_FLAG 1024 343#define ATTR_ATTR_FLAG (1 << 10)
332#define ATTR_KILL_SUID 2048 344#define ATTR_KILL_SUID (1 << 11)
333#define ATTR_KILL_SGID 4096 345#define ATTR_KILL_SGID (1 << 12)
334#define ATTR_FILE 8192 346#define ATTR_FILE (1 << 13)
335#define ATTR_KILL_PRIV 16384 347#define ATTR_KILL_PRIV (1 << 14)
336#define ATTR_OPEN 32768 /* Truncating from open(O_TRUNC) */ 348#define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
349#define ATTR_TIMES_SET (1 << 16)
337 350
338/* 351/*
339 * This is the Inode Attributes structure, used for notify_change(). It 352 * This is the Inode Attributes structure, used for notify_change(). It
@@ -440,6 +453,27 @@ static inline size_t iov_iter_count(struct iov_iter *i)
440 return i->count; 453 return i->count;
441} 454}
442 455
456/*
457 * "descriptor" for what we're up to with a read.
458 * This allows us to use the same read code yet
459 * have multiple different users of the data that
460 * we read from a file.
461 *
462 * The simplest case just copies the data to user
463 * mode.
464 */
465typedef struct {
466 size_t written;
467 size_t count;
468 union {
469 char __user *buf;
470 void *data;
471 } arg;
472 int error;
473} read_descriptor_t;
474
475typedef int (*read_actor_t)(read_descriptor_t *, struct page *,
476 unsigned long, unsigned long);
443 477
444struct address_space_operations { 478struct address_space_operations {
445 int (*writepage)(struct page *page, struct writeback_control *wbc); 479 int (*writepage)(struct page *page, struct writeback_control *wbc);
@@ -481,6 +515,8 @@ struct address_space_operations {
481 int (*migratepage) (struct address_space *, 515 int (*migratepage) (struct address_space *,
482 struct page *, struct page *); 516 struct page *, struct page *);
483 int (*launder_page) (struct page *); 517 int (*launder_page) (struct page *);
518 int (*is_partially_uptodate) (struct page *, read_descriptor_t *,
519 unsigned long);
484}; 520};
485 521
486/* 522/*
@@ -499,7 +535,7 @@ struct backing_dev_info;
499struct address_space { 535struct address_space {
500 struct inode *host; /* owner: inode, block_device */ 536 struct inode *host; /* owner: inode, block_device */
501 struct radix_tree_root page_tree; /* radix tree of all pages */ 537 struct radix_tree_root page_tree; /* radix tree of all pages */
502 rwlock_t tree_lock; /* and rwlock protecting it */ 538 spinlock_t tree_lock; /* and lock protecting it */
503 unsigned int i_mmap_writable;/* count VM_SHARED mappings */ 539 unsigned int i_mmap_writable;/* count VM_SHARED mappings */
504 struct prio_tree_root i_mmap; /* tree of private and shared mappings */ 540 struct prio_tree_root i_mmap; /* tree of private and shared mappings */
505 struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */ 541 struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */
@@ -792,9 +828,9 @@ struct file {
792#define f_dentry f_path.dentry 828#define f_dentry f_path.dentry
793#define f_vfsmnt f_path.mnt 829#define f_vfsmnt f_path.mnt
794 const struct file_operations *f_op; 830 const struct file_operations *f_op;
795 atomic_t f_count; 831 atomic_long_t f_count;
796 unsigned int f_flags; 832 unsigned int f_flags;
797 mode_t f_mode; 833 fmode_t f_mode;
798 loff_t f_pos; 834 loff_t f_pos;
799 struct fown_struct f_owner; 835 struct fown_struct f_owner;
800 unsigned int f_uid, f_gid; 836 unsigned int f_uid, f_gid;
@@ -821,8 +857,8 @@ extern spinlock_t files_lock;
821#define file_list_lock() spin_lock(&files_lock); 857#define file_list_lock() spin_lock(&files_lock);
822#define file_list_unlock() spin_unlock(&files_lock); 858#define file_list_unlock() spin_unlock(&files_lock);
823 859
824#define get_file(x) atomic_inc(&(x)->f_count) 860#define get_file(x) atomic_long_inc(&(x)->f_count)
825#define file_count(x) atomic_read(&(x)->f_count) 861#define file_count(x) atomic_long_read(&(x)->f_count)
826 862
827#ifdef CONFIG_DEBUG_WRITECOUNT 863#ifdef CONFIG_DEBUG_WRITECOUNT
828static inline void file_take_write(struct file *f) 864static inline void file_take_write(struct file *f)
@@ -886,6 +922,12 @@ static inline int file_check_writeable(struct file *filp)
886#define FL_SLEEP 128 /* A blocking lock */ 922#define FL_SLEEP 128 /* A blocking lock */
887 923
888/* 924/*
925 * Special return value from posix_lock_file() and vfs_lock_file() for
926 * asynchronous locking.
927 */
928#define FILE_LOCK_DEFERRED 1
929
930/*
889 * The POSIX file lock owner is determined by 931 * The POSIX file lock owner is determined by
890 * the "struct files_struct" in the thread group 932 * the "struct files_struct" in the thread group
891 * (or NULL for no owner - BSD locks). 933 * (or NULL for no owner - BSD locks).
@@ -910,6 +952,14 @@ struct lock_manager_operations {
910 int (*fl_change)(struct file_lock **, int); 952 int (*fl_change)(struct file_lock **, int);
911}; 953};
912 954
955struct lock_manager {
956 struct list_head list;
957};
958
959void locks_start_grace(struct lock_manager *);
960void locks_end_grace(struct lock_manager *);
961int locks_in_grace(void);
962
913/* that will die - we need it for nfs_lock_info */ 963/* that will die - we need it for nfs_lock_info */
914#include <linux/nfs_fs_i.h> 964#include <linux/nfs_fs_i.h>
915 965
@@ -918,12 +968,12 @@ struct file_lock {
918 struct list_head fl_link; /* doubly linked list of all locks */ 968 struct list_head fl_link; /* doubly linked list of all locks */
919 struct list_head fl_block; /* circular list of blocked processes */ 969 struct list_head fl_block; /* circular list of blocked processes */
920 fl_owner_t fl_owner; 970 fl_owner_t fl_owner;
971 unsigned char fl_flags;
972 unsigned char fl_type;
921 unsigned int fl_pid; 973 unsigned int fl_pid;
922 struct pid *fl_nspid; 974 struct pid *fl_nspid;
923 wait_queue_head_t fl_wait; 975 wait_queue_head_t fl_wait;
924 struct file *fl_file; 976 struct file *fl_file;
925 unsigned char fl_flags;
926 unsigned char fl_type;
927 loff_t fl_start; 977 loff_t fl_start;
928 loff_t fl_end; 978 loff_t fl_end;
929 979
@@ -951,6 +1001,13 @@ struct file_lock {
951 1001
952#include <linux/fcntl.h> 1002#include <linux/fcntl.h>
953 1003
1004extern void send_sigio(struct fown_struct *fown, int fd, int band);
1005
1006/* fs/sync.c */
1007extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
1008 loff_t endbyte, unsigned int flags);
1009
1010#ifdef CONFIG_FILE_LOCKING
954extern int fcntl_getlk(struct file *, struct flock __user *); 1011extern int fcntl_getlk(struct file *, struct flock __user *);
955extern int fcntl_setlk(unsigned int, struct file *, unsigned int, 1012extern int fcntl_setlk(unsigned int, struct file *, unsigned int,
956 struct flock __user *); 1013 struct flock __user *);
@@ -961,14 +1018,9 @@ extern int fcntl_setlk64(unsigned int, struct file *, unsigned int,
961 struct flock64 __user *); 1018 struct flock64 __user *);
962#endif 1019#endif
963 1020
964extern void send_sigio(struct fown_struct *fown, int fd, int band);
965extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); 1021extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
966extern int fcntl_getlease(struct file *filp); 1022extern int fcntl_getlease(struct file *filp);
967 1023
968/* fs/sync.c */
969extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
970 loff_t endbyte, unsigned int flags);
971
972/* fs/locks.c */ 1024/* fs/locks.c */
973extern void locks_init_lock(struct file_lock *); 1025extern void locks_init_lock(struct file_lock *);
974extern void locks_copy_lock(struct file_lock *, struct file_lock *); 1026extern void locks_copy_lock(struct file_lock *, struct file_lock *);
@@ -990,7 +1042,37 @@ extern int vfs_setlease(struct file *, long, struct file_lock **);
990extern int lease_modify(struct file_lock **, int); 1042extern int lease_modify(struct file_lock **, int);
991extern int lock_may_read(struct inode *, loff_t start, unsigned long count); 1043extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
992extern int lock_may_write(struct inode *, loff_t start, unsigned long count); 1044extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
993extern struct seq_operations locks_seq_operations; 1045#else /* !CONFIG_FILE_LOCKING */
1046#define fcntl_getlk(a, b) ({ -EINVAL; })
1047#define fcntl_setlk(a, b, c, d) ({ -EACCES; })
1048#if BITS_PER_LONG == 32
1049#define fcntl_getlk64(a, b) ({ -EINVAL; })
1050#define fcntl_setlk64(a, b, c, d) ({ -EACCES; })
1051#endif
1052#define fcntl_setlease(a, b, c) ({ 0; })
1053#define fcntl_getlease(a) ({ 0; })
1054#define locks_init_lock(a) ({ })
1055#define __locks_copy_lock(a, b) ({ })
1056#define locks_copy_lock(a, b) ({ })
1057#define locks_remove_posix(a, b) ({ })
1058#define locks_remove_flock(a) ({ })
1059#define posix_test_lock(a, b) ({ 0; })
1060#define posix_lock_file(a, b, c) ({ -ENOLCK; })
1061#define posix_lock_file_wait(a, b) ({ -ENOLCK; })
1062#define posix_unblock_lock(a, b) (-ENOENT)
1063#define vfs_test_lock(a, b) ({ 0; })
1064#define vfs_lock_file(a, b, c, d) (-ENOLCK)
1065#define vfs_cancel_lock(a, b) ({ 0; })
1066#define flock_lock_file_wait(a, b) ({ -ENOLCK; })
1067#define __break_lease(a, b) ({ 0; })
1068#define lease_get_mtime(a, b) ({ })
1069#define generic_setlease(a, b, c) ({ -EINVAL; })
1070#define vfs_setlease(a, b, c) ({ -EINVAL; })
1071#define lease_modify(a, b) ({ -EINVAL; })
1072#define lock_may_read(a, b, c) ({ 1; })
1073#define lock_may_write(a, b, c) ({ 1; })
1074#endif /* !CONFIG_FILE_LOCKING */
1075
994 1076
995struct fasync_struct { 1077struct fasync_struct {
996 int magic; 1078 int magic;
@@ -1025,6 +1107,7 @@ extern int send_sigurg(struct fown_struct *fown);
1025extern struct list_head super_blocks; 1107extern struct list_head super_blocks;
1026extern spinlock_t sb_lock; 1108extern spinlock_t sb_lock;
1027 1109
1110#define sb_entry(list) list_entry((list), struct super_block, s_list)
1028#define S_BIAS (1<<30) 1111#define S_BIAS (1<<30)
1029struct super_block { 1112struct super_block {
1030 struct list_head s_list; /* Keep this first */ 1113 struct list_head s_list; /* Keep this first */
@@ -1058,6 +1141,9 @@ struct super_block {
1058 struct list_head s_more_io; /* parked for more writeback */ 1141 struct list_head s_more_io; /* parked for more writeback */
1059 struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */ 1142 struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */
1060 struct list_head s_files; 1143 struct list_head s_files;
1144 /* s_dentry_lru and s_nr_dentry_unused are protected by dcache_lock */
1145 struct list_head s_dentry_lru; /* unused dentry lru */
1146 int s_nr_dentry_unused; /* # of dentry on lru */
1061 1147
1062 struct block_device *s_bdev; 1148 struct block_device *s_bdev;
1063 struct mtd_info *s_mtd; 1149 struct mtd_info *s_mtd;
@@ -1070,6 +1156,7 @@ struct super_block {
1070 char s_id[32]; /* Informational name */ 1156 char s_id[32]; /* Informational name */
1071 1157
1072 void *s_fs_info; /* Filesystem private info */ 1158 void *s_fs_info; /* Filesystem private info */
1159 fmode_t s_mode;
1073 1160
1074 /* 1161 /*
1075 * The next field is for VFS *only*. No filesystems have any business 1162 * The next field is for VFS *only*. No filesystems have any business
@@ -1126,7 +1213,7 @@ extern int vfs_permission(struct nameidata *, int);
1126extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *); 1213extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
1127extern int vfs_mkdir(struct inode *, struct dentry *, int); 1214extern int vfs_mkdir(struct inode *, struct dentry *, int);
1128extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t); 1215extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
1129extern int vfs_symlink(struct inode *, struct dentry *, const char *, int); 1216extern int vfs_symlink(struct inode *, struct dentry *, const char *);
1130extern int vfs_link(struct dentry *, struct inode *, struct dentry *); 1217extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1131extern int vfs_rmdir(struct inode *, struct dentry *); 1218extern int vfs_rmdir(struct inode *, struct dentry *);
1132extern int vfs_unlink(struct inode *, struct dentry *); 1219extern int vfs_unlink(struct inode *, struct dentry *);
@@ -1143,6 +1230,20 @@ extern void dentry_unhash(struct dentry *dentry);
1143extern int file_permission(struct file *, int); 1230extern int file_permission(struct file *, int);
1144 1231
1145/* 1232/*
1233 * VFS FS_IOC_FIEMAP helper definitions.
1234 */
1235struct fiemap_extent_info {
1236 unsigned int fi_flags; /* Flags as passed from user */
1237 unsigned int fi_extents_mapped; /* Number of mapped extents */
1238 unsigned int fi_extents_max; /* Size of fiemap_extent array */
1239 struct fiemap_extent *fi_extents_start; /* Start of fiemap_extent
1240 * array */
1241};
1242int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical,
1243 u64 phys, u64 len, u32 flags);
1244int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags);
1245
1246/*
1146 * File types 1247 * File types
1147 * 1248 *
1148 * NOTE! These match bits 12..15 of stat.st_mode 1249 * NOTE! These match bits 12..15 of stat.st_mode
@@ -1170,41 +1271,7 @@ int generic_osync_inode(struct inode *, struct address_space *, int);
1170 * to have different dirent layouts depending on the binary type. 1271 * to have different dirent layouts depending on the binary type.
1171 */ 1272 */
1172typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned); 1273typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned);
1173 1274struct block_device_operations;
1174struct block_device_operations {
1175 int (*open) (struct inode *, struct file *);
1176 int (*release) (struct inode *, struct file *);
1177 int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
1178 long (*unlocked_ioctl) (struct file *, unsigned, unsigned long);
1179 long (*compat_ioctl) (struct file *, unsigned, unsigned long);
1180 int (*direct_access) (struct block_device *, sector_t,
1181 void **, unsigned long *);
1182 int (*media_changed) (struct gendisk *);
1183 int (*revalidate_disk) (struct gendisk *);
1184 int (*getgeo)(struct block_device *, struct hd_geometry *);
1185 struct module *owner;
1186};
1187
1188/*
1189 * "descriptor" for what we're up to with a read.
1190 * This allows us to use the same read code yet
1191 * have multiple different users of the data that
1192 * we read from a file.
1193 *
1194 * The simplest case just copies the data to user
1195 * mode.
1196 */
1197typedef struct {
1198 size_t written;
1199 size_t count;
1200 union {
1201 char __user * buf;
1202 void *data;
1203 } arg;
1204 int error;
1205} read_descriptor_t;
1206
1207typedef int (*read_actor_t)(read_descriptor_t *, struct page *, unsigned long, unsigned long);
1208 1275
1209/* These macros are for out of kernel modules to test that 1276/* These macros are for out of kernel modules to test that
1210 * the kernel supports the unlocked_ioctl and compat_ioctl 1277 * the kernel supports the unlocked_ioctl and compat_ioctl
@@ -1262,7 +1329,7 @@ struct inode_operations {
1262 void * (*follow_link) (struct dentry *, struct nameidata *); 1329 void * (*follow_link) (struct dentry *, struct nameidata *);
1263 void (*put_link) (struct dentry *, struct nameidata *, void *); 1330 void (*put_link) (struct dentry *, struct nameidata *, void *);
1264 void (*truncate) (struct inode *); 1331 void (*truncate) (struct inode *);
1265 int (*permission) (struct inode *, int, struct nameidata *); 1332 int (*permission) (struct inode *, int);
1266 int (*setattr) (struct dentry *, struct iattr *); 1333 int (*setattr) (struct dentry *, struct iattr *);
1267 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); 1334 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
1268 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); 1335 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
@@ -1272,6 +1339,8 @@ struct inode_operations {
1272 void (*truncate_range)(struct inode *, loff_t, loff_t); 1339 void (*truncate_range)(struct inode *, loff_t, loff_t);
1273 long (*fallocate)(struct inode *inode, int mode, loff_t offset, 1340 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
1274 loff_t len); 1341 loff_t len);
1342 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
1343 u64 len);
1275}; 1344};
1276 1345
1277struct seq_file; 1346struct seq_file;
@@ -1516,7 +1585,6 @@ extern int get_sb_pseudo(struct file_system_type *, char *,
1516 struct vfsmount *mnt); 1585 struct vfsmount *mnt);
1517extern int simple_set_mnt(struct vfsmount *mnt, struct super_block *sb); 1586extern int simple_set_mnt(struct vfsmount *mnt, struct super_block *sb);
1518int __put_super_and_need_restart(struct super_block *sb); 1587int __put_super_and_need_restart(struct super_block *sb);
1519void unnamed_dev_init(void);
1520 1588
1521/* Alas, no aliases. Too much hassle with bringing module.h everywhere */ 1589/* Alas, no aliases. Too much hassle with bringing module.h everywhere */
1522#define fops_get(fops) \ 1590#define fops_get(fops) \
@@ -1539,9 +1607,12 @@ extern int vfs_statfs(struct dentry *, struct kstatfs *);
1539/* /sys/fs */ 1607/* /sys/fs */
1540extern struct kobject *fs_kobj; 1608extern struct kobject *fs_kobj;
1541 1609
1610extern int rw_verify_area(int, struct file *, loff_t *, size_t);
1611
1542#define FLOCK_VERIFY_READ 1 1612#define FLOCK_VERIFY_READ 1
1543#define FLOCK_VERIFY_WRITE 2 1613#define FLOCK_VERIFY_WRITE 2
1544 1614
1615#ifdef CONFIG_FILE_LOCKING
1545extern int locks_mandatory_locked(struct inode *); 1616extern int locks_mandatory_locked(struct inode *);
1546extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t); 1617extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
1547 1618
@@ -1572,8 +1643,6 @@ static inline int locks_verify_locked(struct inode *inode)
1572 return 0; 1643 return 0;
1573} 1644}
1574 1645
1575extern int rw_verify_area(int, struct file *, loff_t *, size_t);
1576
1577static inline int locks_verify_truncate(struct inode *inode, 1646static inline int locks_verify_truncate(struct inode *inode,
1578 struct file *filp, 1647 struct file *filp,
1579 loff_t size) 1648 loff_t size)
@@ -1594,6 +1663,15 @@ static inline int break_lease(struct inode *inode, unsigned int mode)
1594 return __break_lease(inode, mode); 1663 return __break_lease(inode, mode);
1595 return 0; 1664 return 0;
1596} 1665}
1666#else /* !CONFIG_FILE_LOCKING */
1667#define locks_mandatory_locked(a) ({ 0; })
1668#define locks_mandatory_area(a, b, c, d, e) ({ 0; })
1669#define __mandatory_lock(a) ({ 0; })
1670#define mandatory_lock(a) ({ 0; })
1671#define locks_verify_locked(a) ({ 0; })
1672#define locks_verify_truncate(a, b, c) ({ 0; })
1673#define break_lease(a, b) ({ 0; })
1674#endif /* CONFIG_FILE_LOCKING */
1597 1675
1598/* fs/open.c */ 1676/* fs/open.c */
1599 1677
@@ -1627,7 +1705,7 @@ extern struct block_device *bdget(dev_t);
1627extern void bd_set_size(struct block_device *, loff_t size); 1705extern void bd_set_size(struct block_device *, loff_t size);
1628extern void bd_forget(struct inode *inode); 1706extern void bd_forget(struct inode *inode);
1629extern void bdput(struct block_device *); 1707extern void bdput(struct block_device *);
1630extern struct block_device *open_by_devnum(dev_t, unsigned); 1708extern struct block_device *open_by_devnum(dev_t, fmode_t);
1631#else 1709#else
1632static inline void bd_forget(struct inode *inode) {} 1710static inline void bd_forget(struct inode *inode) {}
1633#endif 1711#endif
@@ -1637,13 +1715,10 @@ extern const struct file_operations bad_sock_fops;
1637extern const struct file_operations def_fifo_fops; 1715extern const struct file_operations def_fifo_fops;
1638#ifdef CONFIG_BLOCK 1716#ifdef CONFIG_BLOCK
1639extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long); 1717extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
1640extern int blkdev_ioctl(struct inode *, struct file *, unsigned, unsigned long); 1718extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long);
1641extern int blkdev_driver_ioctl(struct inode *inode, struct file *file,
1642 struct gendisk *disk, unsigned cmd,
1643 unsigned long arg);
1644extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long); 1719extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
1645extern int blkdev_get(struct block_device *, mode_t, unsigned); 1720extern int blkdev_get(struct block_device *, fmode_t);
1646extern int blkdev_put(struct block_device *); 1721extern int blkdev_put(struct block_device *, fmode_t);
1647extern int bd_claim(struct block_device *, void *); 1722extern int bd_claim(struct block_device *, void *);
1648extern void bd_release(struct block_device *); 1723extern void bd_release(struct block_device *);
1649#ifdef CONFIG_SYSFS 1724#ifdef CONFIG_SYSFS
@@ -1667,15 +1742,17 @@ extern void chrdev_show(struct seq_file *,off_t);
1667 1742
1668/* fs/block_dev.c */ 1743/* fs/block_dev.c */
1669#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */ 1744#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */
1745#define BDEVT_SIZE 10 /* Largest string for MAJ:MIN for blkdev */
1670 1746
1671#ifdef CONFIG_BLOCK 1747#ifdef CONFIG_BLOCK
1672#define BLKDEV_MAJOR_HASH_SIZE 255 1748#define BLKDEV_MAJOR_HASH_SIZE 255
1673extern const char *__bdevname(dev_t, char *buffer); 1749extern const char *__bdevname(dev_t, char *buffer);
1674extern const char *bdevname(struct block_device *bdev, char *buffer); 1750extern const char *bdevname(struct block_device *bdev, char *buffer);
1675extern struct block_device *lookup_bdev(const char *); 1751extern struct block_device *lookup_bdev(const char *);
1676extern struct block_device *open_bdev_excl(const char *, int, void *); 1752extern struct block_device *open_bdev_exclusive(const char *, fmode_t, void *);
1677extern void close_bdev_excl(struct block_device *); 1753extern void close_bdev_exclusive(struct block_device *, fmode_t);
1678extern void blkdev_show(struct seq_file *,off_t); 1754extern void blkdev_show(struct seq_file *,off_t);
1755
1679#else 1756#else
1680#define BLKDEV_MAJOR_HASH_SIZE 0 1757#define BLKDEV_MAJOR_HASH_SIZE 0
1681#endif 1758#endif
@@ -1686,9 +1763,9 @@ extern void init_special_inode(struct inode *, umode_t, dev_t);
1686extern void make_bad_inode(struct inode *); 1763extern void make_bad_inode(struct inode *);
1687extern int is_bad_inode(struct inode *); 1764extern int is_bad_inode(struct inode *);
1688 1765
1689extern const struct file_operations read_fifo_fops; 1766extern const struct file_operations read_pipefifo_fops;
1690extern const struct file_operations write_fifo_fops; 1767extern const struct file_operations write_pipefifo_fops;
1691extern const struct file_operations rdwr_fifo_fops; 1768extern const struct file_operations rdwr_pipefifo_fops;
1692 1769
1693extern int fs_may_remount_ro(struct super_block *); 1770extern int fs_may_remount_ro(struct super_block *);
1694 1771
@@ -1703,6 +1780,9 @@ extern int fs_may_remount_ro(struct super_block *);
1703 */ 1780 */
1704#define bio_data_dir(bio) ((bio)->bi_rw & 1) 1781#define bio_data_dir(bio) ((bio)->bi_rw & 1)
1705 1782
1783extern void check_disk_size_change(struct gendisk *disk,
1784 struct block_device *bdev);
1785extern int revalidate_disk(struct gendisk *);
1706extern int check_disk_change(struct block_device *); 1786extern int check_disk_change(struct block_device *);
1707extern int __invalidate_device(struct block_device *); 1787extern int __invalidate_device(struct block_device *);
1708extern int invalidate_partition(struct gendisk *, int); 1788extern int invalidate_partition(struct gendisk *, int);
@@ -1757,10 +1837,15 @@ extern int do_remount_sb(struct super_block *sb, int flags,
1757extern sector_t bmap(struct inode *, sector_t); 1837extern sector_t bmap(struct inode *, sector_t);
1758#endif 1838#endif
1759extern int notify_change(struct dentry *, struct iattr *); 1839extern int notify_change(struct dentry *, struct iattr *);
1760extern int permission(struct inode *, int, struct nameidata *); 1840extern int inode_permission(struct inode *, int);
1761extern int generic_permission(struct inode *, int, 1841extern int generic_permission(struct inode *, int,
1762 int (*check_acl)(struct inode *, int)); 1842 int (*check_acl)(struct inode *, int));
1763 1843
1844static inline bool execute_ok(struct inode *inode)
1845{
1846 return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode);
1847}
1848
1764extern int get_write_access(struct inode *); 1849extern int get_write_access(struct inode *);
1765extern int deny_write_access(struct file *); 1850extern int deny_write_access(struct file *);
1766static inline void put_write_access(struct inode * inode) 1851static inline void put_write_access(struct inode * inode)
@@ -1773,8 +1858,9 @@ static inline void allow_write_access(struct file *file)
1773 atomic_inc(&file->f_path.dentry->d_inode->i_writecount); 1858 atomic_inc(&file->f_path.dentry->d_inode->i_writecount);
1774} 1859}
1775extern int do_pipe(int *); 1860extern int do_pipe(int *);
1776extern struct file *create_read_pipe(struct file *f); 1861extern int do_pipe_flags(int *, int);
1777extern struct file *create_write_pipe(void); 1862extern struct file *create_read_pipe(struct file *f, int flags);
1863extern struct file *create_write_pipe(int flags);
1778extern void free_write_pipe(struct file *); 1864extern void free_write_pipe(struct file *);
1779 1865
1780extern struct file *do_filp_open(int dfd, const char *pathname, 1866extern struct file *do_filp_open(int dfd, const char *pathname,
@@ -1820,7 +1906,7 @@ extern void clear_inode(struct inode *);
1820extern void destroy_inode(struct inode *); 1906extern void destroy_inode(struct inode *);
1821extern struct inode *new_inode(struct super_block *); 1907extern struct inode *new_inode(struct super_block *);
1822extern int should_remove_suid(struct dentry *); 1908extern int should_remove_suid(struct dentry *);
1823extern int remove_suid(struct dentry *); 1909extern int file_remove_suid(struct file *);
1824 1910
1825extern void __insert_inode_hash(struct inode *, unsigned long hashval); 1911extern void __insert_inode_hash(struct inode *, unsigned long hashval);
1826extern void remove_inode_hash(struct inode *); 1912extern void remove_inode_hash(struct inode *);
@@ -1964,6 +2050,9 @@ extern int vfs_fstat(unsigned int, struct kstat *);
1964 2050
1965extern int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, 2051extern int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
1966 unsigned long arg); 2052 unsigned long arg);
2053extern int generic_block_fiemap(struct inode *inode,
2054 struct fiemap_extent_info *fieinfo, u64 start,
2055 u64 len, get_block_t *get_block);
1967 2056
1968extern void get_filesystem(struct file_system_type *fs); 2057extern void get_filesystem(struct file_system_type *fs);
1969extern void put_filesystem(struct file_system_type *fs); 2058extern void put_filesystem(struct file_system_type *fs);
@@ -2006,8 +2095,6 @@ extern void simple_release_fs(struct vfsmount **mount, int *count);
2006 2095
2007extern ssize_t simple_read_from_buffer(void __user *to, size_t count, 2096extern ssize_t simple_read_from_buffer(void __user *to, size_t count,
2008 loff_t *ppos, const void *from, size_t available); 2097 loff_t *ppos, const void *from, size_t available);
2009extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
2010 const void *from, size_t available);
2011 2098
2012#ifdef CONFIG_MIGRATION 2099#ifdef CONFIG_MIGRATION
2013extern int buffer_migrate_page(struct address_space *, 2100extern int buffer_migrate_page(struct address_space *,