diff options
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r-- | include/linux/fs.h | 93 |
1 files changed, 90 insertions, 3 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index 0180102dace1..047bde30836a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -213,6 +213,7 @@ extern int dir_notify_enable; | |||
213 | #include <linux/radix-tree.h> | 213 | #include <linux/radix-tree.h> |
214 | #include <linux/prio_tree.h> | 214 | #include <linux/prio_tree.h> |
215 | #include <linux/init.h> | 215 | #include <linux/init.h> |
216 | #include <linux/sched.h> | ||
216 | 217 | ||
217 | #include <asm/atomic.h> | 218 | #include <asm/atomic.h> |
218 | #include <asm/semaphore.h> | 219 | #include <asm/semaphore.h> |
@@ -220,6 +221,7 @@ extern int dir_notify_enable; | |||
220 | 221 | ||
221 | struct iovec; | 222 | struct iovec; |
222 | struct nameidata; | 223 | struct nameidata; |
224 | struct kiocb; | ||
223 | struct pipe_inode_info; | 225 | struct pipe_inode_info; |
224 | struct poll_table_struct; | 226 | struct poll_table_struct; |
225 | struct kstatfs; | 227 | struct kstatfs; |
@@ -240,7 +242,7 @@ typedef int (get_block_t)(struct inode *inode, sector_t iblock, | |||
240 | typedef int (get_blocks_t)(struct inode *inode, sector_t iblock, | 242 | typedef int (get_blocks_t)(struct inode *inode, sector_t iblock, |
241 | unsigned long max_blocks, | 243 | unsigned long max_blocks, |
242 | struct buffer_head *bh_result, int create); | 244 | struct buffer_head *bh_result, int create); |
243 | typedef void (dio_iodone_t)(struct inode *inode, loff_t offset, | 245 | typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset, |
244 | ssize_t bytes, void *private); | 246 | ssize_t bytes, void *private); |
245 | 247 | ||
246 | /* | 248 | /* |
@@ -302,7 +304,6 @@ struct iattr { | |||
302 | struct page; | 304 | struct page; |
303 | struct address_space; | 305 | struct address_space; |
304 | struct writeback_control; | 306 | struct writeback_control; |
305 | struct kiocb; | ||
306 | 307 | ||
307 | struct address_space_operations { | 308 | struct address_space_operations { |
308 | int (*writepage)(struct page *page, struct writeback_control *wbc); | 309 | int (*writepage)(struct page *page, struct writeback_control *wbc); |
@@ -330,6 +331,8 @@ struct address_space_operations { | |||
330 | int (*releasepage) (struct page *, int); | 331 | int (*releasepage) (struct page *, int); |
331 | ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov, | 332 | ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov, |
332 | loff_t offset, unsigned long nr_segs); | 333 | loff_t offset, unsigned long nr_segs); |
334 | struct page* (*get_xip_page)(struct address_space *, sector_t, | ||
335 | int); | ||
333 | }; | 336 | }; |
334 | 337 | ||
335 | struct backing_dev_info; | 338 | struct backing_dev_info; |
@@ -581,7 +584,6 @@ struct file { | |||
581 | atomic_t f_count; | 584 | atomic_t f_count; |
582 | unsigned int f_flags; | 585 | unsigned int f_flags; |
583 | mode_t f_mode; | 586 | mode_t f_mode; |
584 | int f_error; | ||
585 | loff_t f_pos; | 587 | loff_t f_pos; |
586 | struct fown_struct f_owner; | 588 | struct fown_struct f_owner; |
587 | unsigned int f_uid, f_gid; | 589 | unsigned int f_uid, f_gid; |
@@ -674,6 +676,7 @@ struct file_lock { | |||
674 | struct lock_manager_operations *fl_lmops; /* Callbacks for lockmanagers */ | 676 | struct lock_manager_operations *fl_lmops; /* Callbacks for lockmanagers */ |
675 | union { | 677 | union { |
676 | struct nfs_lock_info nfs_fl; | 678 | struct nfs_lock_info nfs_fl; |
679 | struct nfs4_lock_info nfs4_fl; | ||
677 | } fl_u; | 680 | } fl_u; |
678 | }; | 681 | }; |
679 | 682 | ||
@@ -820,16 +823,34 @@ enum { | |||
820 | #define vfs_check_frozen(sb, level) \ | 823 | #define vfs_check_frozen(sb, level) \ |
821 | wait_event((sb)->s_wait_unfrozen, ((sb)->s_frozen < (level))) | 824 | wait_event((sb)->s_wait_unfrozen, ((sb)->s_frozen < (level))) |
822 | 825 | ||
826 | static inline void get_fs_excl(void) | ||
827 | { | ||
828 | atomic_inc(¤t->fs_excl); | ||
829 | } | ||
830 | |||
831 | static inline void put_fs_excl(void) | ||
832 | { | ||
833 | atomic_dec(¤t->fs_excl); | ||
834 | } | ||
835 | |||
836 | static inline int has_fs_excl(void) | ||
837 | { | ||
838 | return atomic_read(¤t->fs_excl); | ||
839 | } | ||
840 | |||
841 | |||
823 | /* | 842 | /* |
824 | * Superblock locking. | 843 | * Superblock locking. |
825 | */ | 844 | */ |
826 | static inline void lock_super(struct super_block * sb) | 845 | static inline void lock_super(struct super_block * sb) |
827 | { | 846 | { |
847 | get_fs_excl(); | ||
828 | down(&sb->s_lock); | 848 | down(&sb->s_lock); |
829 | } | 849 | } |
830 | 850 | ||
831 | static inline void unlock_super(struct super_block * sb) | 851 | static inline void unlock_super(struct super_block * sb) |
832 | { | 852 | { |
853 | put_fs_excl(); | ||
833 | up(&sb->s_lock); | 854 | up(&sb->s_lock); |
834 | } | 855 | } |
835 | 856 | ||
@@ -883,7 +904,9 @@ struct block_device_operations { | |||
883 | int (*open) (struct inode *, struct file *); | 904 | int (*open) (struct inode *, struct file *); |
884 | int (*release) (struct inode *, struct file *); | 905 | int (*release) (struct inode *, struct file *); |
885 | int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long); | 906 | int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long); |
907 | long (*unlocked_ioctl) (struct file *, unsigned, unsigned long); | ||
886 | long (*compat_ioctl) (struct file *, unsigned, unsigned long); | 908 | long (*compat_ioctl) (struct file *, unsigned, unsigned long); |
909 | int (*direct_access) (struct block_device *, sector_t, unsigned long *); | ||
887 | int (*media_changed) (struct gendisk *); | 910 | int (*media_changed) (struct gendisk *); |
888 | int (*revalidate_disk) (struct gendisk *); | 911 | int (*revalidate_disk) (struct gendisk *); |
889 | struct module *owner; | 912 | struct module *owner; |
@@ -1024,6 +1047,7 @@ struct super_operations { | |||
1024 | #define I_FREEING 16 | 1047 | #define I_FREEING 16 |
1025 | #define I_CLEAR 32 | 1048 | #define I_CLEAR 32 |
1026 | #define I_NEW 64 | 1049 | #define I_NEW 64 |
1050 | #define I_WILL_FREE 128 | ||
1027 | 1051 | ||
1028 | #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES) | 1052 | #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES) |
1029 | 1053 | ||
@@ -1494,6 +1518,23 @@ extern loff_t remote_llseek(struct file *file, loff_t offset, int origin); | |||
1494 | extern int generic_file_open(struct inode * inode, struct file * filp); | 1518 | extern int generic_file_open(struct inode * inode, struct file * filp); |
1495 | extern int nonseekable_open(struct inode * inode, struct file * filp); | 1519 | extern int nonseekable_open(struct inode * inode, struct file * filp); |
1496 | 1520 | ||
1521 | #ifdef CONFIG_FS_XIP | ||
1522 | extern ssize_t xip_file_read(struct file *filp, char __user *buf, size_t len, | ||
1523 | loff_t *ppos); | ||
1524 | extern ssize_t xip_file_sendfile(struct file *in_file, loff_t *ppos, | ||
1525 | size_t count, read_actor_t actor, | ||
1526 | void *target); | ||
1527 | extern int xip_file_mmap(struct file * file, struct vm_area_struct * vma); | ||
1528 | extern ssize_t xip_file_write(struct file *filp, const char __user *buf, | ||
1529 | size_t len, loff_t *ppos); | ||
1530 | extern int xip_truncate_page(struct address_space *mapping, loff_t from); | ||
1531 | #else | ||
1532 | static inline int xip_truncate_page(struct address_space *mapping, loff_t from) | ||
1533 | { | ||
1534 | return 0; | ||
1535 | } | ||
1536 | #endif | ||
1537 | |||
1497 | static inline void do_generic_file_read(struct file * filp, loff_t *ppos, | 1538 | static inline void do_generic_file_read(struct file * filp, loff_t *ppos, |
1498 | read_descriptor_t * desc, | 1539 | read_descriptor_t * desc, |
1499 | read_actor_t actor) | 1540 | read_actor_t actor) |
@@ -1657,6 +1698,52 @@ static inline void simple_transaction_set(struct file *file, size_t n) | |||
1657 | ar->size = n; | 1698 | ar->size = n; |
1658 | } | 1699 | } |
1659 | 1700 | ||
1701 | /* | ||
1702 | * simple attribute files | ||
1703 | * | ||
1704 | * These attributes behave similar to those in sysfs: | ||
1705 | * | ||
1706 | * Writing to an attribute immediately sets a value, an open file can be | ||
1707 | * written to multiple times. | ||
1708 | * | ||
1709 | * Reading from an attribute creates a buffer from the value that might get | ||
1710 | * read with multiple read calls. When the attribute has been read | ||
1711 | * completely, no further read calls are possible until the file is opened | ||
1712 | * again. | ||
1713 | * | ||
1714 | * All attributes contain a text representation of a numeric value | ||
1715 | * that are accessed with the get() and set() functions. | ||
1716 | */ | ||
1717 | #define DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt) \ | ||
1718 | static int __fops ## _open(struct inode *inode, struct file *file) \ | ||
1719 | { \ | ||
1720 | __simple_attr_check_format(__fmt, 0ull); \ | ||
1721 | return simple_attr_open(inode, file, __get, __set, __fmt); \ | ||
1722 | } \ | ||
1723 | static struct file_operations __fops = { \ | ||
1724 | .owner = THIS_MODULE, \ | ||
1725 | .open = __fops ## _open, \ | ||
1726 | .release = simple_attr_close, \ | ||
1727 | .read = simple_attr_read, \ | ||
1728 | .write = simple_attr_write, \ | ||
1729 | }; | ||
1730 | |||
1731 | static inline void __attribute__((format(printf, 1, 2))) | ||
1732 | __simple_attr_check_format(const char *fmt, ...) | ||
1733 | { | ||
1734 | /* don't do anything, just let the compiler check the arguments; */ | ||
1735 | } | ||
1736 | |||
1737 | int simple_attr_open(struct inode *inode, struct file *file, | ||
1738 | u64 (*get)(void *), void (*set)(void *, u64), | ||
1739 | const char *fmt); | ||
1740 | int simple_attr_close(struct inode *inode, struct file *file); | ||
1741 | ssize_t simple_attr_read(struct file *file, char __user *buf, | ||
1742 | size_t len, loff_t *ppos); | ||
1743 | ssize_t simple_attr_write(struct file *file, const char __user *buf, | ||
1744 | size_t len, loff_t *ppos); | ||
1745 | |||
1746 | |||
1660 | #ifdef CONFIG_SECURITY | 1747 | #ifdef CONFIG_SECURITY |
1661 | static inline char *alloc_secdata(void) | 1748 | static inline char *alloc_secdata(void) |
1662 | { | 1749 | { |