aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fs.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h93
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
221struct iovec; 222struct iovec;
222struct nameidata; 223struct nameidata;
224struct kiocb;
223struct pipe_inode_info; 225struct pipe_inode_info;
224struct poll_table_struct; 226struct poll_table_struct;
225struct kstatfs; 227struct kstatfs;
@@ -240,7 +242,7 @@ typedef int (get_block_t)(struct inode *inode, sector_t iblock,
240typedef int (get_blocks_t)(struct inode *inode, sector_t iblock, 242typedef 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);
243typedef void (dio_iodone_t)(struct inode *inode, loff_t offset, 245typedef 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 {
302struct page; 304struct page;
303struct address_space; 305struct address_space;
304struct writeback_control; 306struct writeback_control;
305struct kiocb;
306 307
307struct address_space_operations { 308struct 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
335struct backing_dev_info; 338struct 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
826static inline void get_fs_excl(void)
827{
828 atomic_inc(&current->fs_excl);
829}
830
831static inline void put_fs_excl(void)
832{
833 atomic_dec(&current->fs_excl);
834}
835
836static inline int has_fs_excl(void)
837{
838 return atomic_read(&current->fs_excl);
839}
840
841
823/* 842/*
824 * Superblock locking. 843 * Superblock locking.
825 */ 844 */
826static inline void lock_super(struct super_block * sb) 845static 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
831static inline void unlock_super(struct super_block * sb) 851static 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);
1494extern int generic_file_open(struct inode * inode, struct file * filp); 1518extern int generic_file_open(struct inode * inode, struct file * filp);
1495extern int nonseekable_open(struct inode * inode, struct file * filp); 1519extern int nonseekable_open(struct inode * inode, struct file * filp);
1496 1520
1521#ifdef CONFIG_FS_XIP
1522extern ssize_t xip_file_read(struct file *filp, char __user *buf, size_t len,
1523 loff_t *ppos);
1524extern ssize_t xip_file_sendfile(struct file *in_file, loff_t *ppos,
1525 size_t count, read_actor_t actor,
1526 void *target);
1527extern int xip_file_mmap(struct file * file, struct vm_area_struct * vma);
1528extern ssize_t xip_file_write(struct file *filp, const char __user *buf,
1529 size_t len, loff_t *ppos);
1530extern int xip_truncate_page(struct address_space *mapping, loff_t from);
1531#else
1532static inline int xip_truncate_page(struct address_space *mapping, loff_t from)
1533{
1534 return 0;
1535}
1536#endif
1537
1497static inline void do_generic_file_read(struct file * filp, loff_t *ppos, 1538static 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) \
1718static 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} \
1723static 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
1731static 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
1737int simple_attr_open(struct inode *inode, struct file *file,
1738 u64 (*get)(void *), void (*set)(void *, u64),
1739 const char *fmt);
1740int simple_attr_close(struct inode *inode, struct file *file);
1741ssize_t simple_attr_read(struct file *file, char __user *buf,
1742 size_t len, loff_t *ppos);
1743ssize_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
1661static inline char *alloc_secdata(void) 1748static inline char *alloc_secdata(void)
1662{ 1749{