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.h88
1 files changed, 61 insertions, 27 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 8de675523e46..51978ed43e97 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -173,6 +173,15 @@ struct inodes_stat_t {
173#define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA) 173#define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA)
174#define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA) 174#define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA)
175 175
176
177/*
178 * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector
179 * that indicates that they should check the contents of the iovec are
180 * valid, but not check the memory that the iovec elements
181 * points too.
182 */
183#define CHECK_IOVEC_ONLY -1
184
176#define SEL_IN 1 185#define SEL_IN 1
177#define SEL_OUT 2 186#define SEL_OUT 2
178#define SEL_EX 4 187#define SEL_EX 4
@@ -402,6 +411,7 @@ struct inodes_stat_t {
402#include <linux/atomic.h> 411#include <linux/atomic.h>
403#include <linux/shrinker.h> 412#include <linux/shrinker.h>
404#include <linux/migrate_mode.h> 413#include <linux/migrate_mode.h>
414#include <linux/uidgid.h>
405 415
406#include <asm/byteorder.h> 416#include <asm/byteorder.h>
407 417
@@ -469,8 +479,8 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
469struct iattr { 479struct iattr {
470 unsigned int ia_valid; 480 unsigned int ia_valid;
471 umode_t ia_mode; 481 umode_t ia_mode;
472 uid_t ia_uid; 482 kuid_t ia_uid;
473 gid_t ia_gid; 483 kgid_t ia_gid;
474 loff_t ia_size; 484 loff_t ia_size;
475 struct timespec ia_atime; 485 struct timespec ia_atime;
476 struct timespec ia_mtime; 486 struct timespec ia_mtime;
@@ -761,8 +771,8 @@ struct posix_acl;
761struct inode { 771struct inode {
762 umode_t i_mode; 772 umode_t i_mode;
763 unsigned short i_opflags; 773 unsigned short i_opflags;
764 uid_t i_uid; 774 kuid_t i_uid;
765 gid_t i_gid; 775 kgid_t i_gid;
766 unsigned int i_flags; 776 unsigned int i_flags;
767 777
768#ifdef CONFIG_FS_POSIX_ACL 778#ifdef CONFIG_FS_POSIX_ACL
@@ -927,6 +937,31 @@ static inline void i_size_write(struct inode *inode, loff_t i_size)
927#endif 937#endif
928} 938}
929 939
940/* Helper functions so that in most cases filesystems will
941 * not need to deal directly with kuid_t and kgid_t and can
942 * instead deal with the raw numeric values that are stored
943 * in the filesystem.
944 */
945static inline uid_t i_uid_read(const struct inode *inode)
946{
947 return from_kuid(&init_user_ns, inode->i_uid);
948}
949
950static inline gid_t i_gid_read(const struct inode *inode)
951{
952 return from_kgid(&init_user_ns, inode->i_gid);
953}
954
955static inline void i_uid_write(struct inode *inode, uid_t uid)
956{
957 inode->i_uid = make_kuid(&init_user_ns, uid);
958}
959
960static inline void i_gid_write(struct inode *inode, gid_t gid)
961{
962 inode->i_gid = make_kgid(&init_user_ns, gid);
963}
964
930static inline unsigned iminor(const struct inode *inode) 965static inline unsigned iminor(const struct inode *inode)
931{ 966{
932 return MINOR(inode->i_rdev); 967 return MINOR(inode->i_rdev);
@@ -943,7 +978,7 @@ struct fown_struct {
943 rwlock_t lock; /* protects pid, uid, euid fields */ 978 rwlock_t lock; /* protects pid, uid, euid fields */
944 struct pid *pid; /* pid or -pgrp where SIGIO should be sent */ 979 struct pid *pid; /* pid or -pgrp where SIGIO should be sent */
945 enum pid_type pid_type; /* Kind of process group SIGIO should be sent to */ 980 enum pid_type pid_type; /* Kind of process group SIGIO should be sent to */
946 uid_t uid, euid; /* uid/euid of process setting the owner */ 981 kuid_t uid, euid; /* uid/euid of process setting the owner */
947 int signum; /* posix.1b rt signal to be delivered on IO */ 982 int signum; /* posix.1b rt signal to be delivered on IO */
948}; 983};
949 984
@@ -1527,12 +1562,6 @@ enum {
1527#define vfs_check_frozen(sb, level) \ 1562#define vfs_check_frozen(sb, level) \
1528 wait_event((sb)->s_wait_unfrozen, ((sb)->s_frozen < (level))) 1563 wait_event((sb)->s_wait_unfrozen, ((sb)->s_frozen < (level)))
1529 1564
1530/*
1531 * until VFS tracks user namespaces for inodes, just make all files
1532 * belong to init_user_ns
1533 */
1534extern struct user_namespace init_user_ns;
1535#define inode_userns(inode) (&init_user_ns)
1536extern bool inode_owner_or_capable(const struct inode *inode); 1565extern bool inode_owner_or_capable(const struct inode *inode);
1537 1566
1538/* not quite ready to be deprecated, but... */ 1567/* not quite ready to be deprecated, but... */
@@ -1661,9 +1690,9 @@ struct inode_operations {
1661 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t); 1690 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1662 ssize_t (*listxattr) (struct dentry *, char *, size_t); 1691 ssize_t (*listxattr) (struct dentry *, char *, size_t);
1663 int (*removexattr) (struct dentry *, const char *); 1692 int (*removexattr) (struct dentry *, const char *);
1664 void (*truncate_range)(struct inode *, loff_t, loff_t);
1665 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, 1693 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
1666 u64 len); 1694 u64 len);
1695 int (*update_time)(struct inode *, struct timespec *, int);
1667} ____cacheline_aligned; 1696} ____cacheline_aligned;
1668 1697
1669struct seq_file; 1698struct seq_file;
@@ -1671,8 +1700,7 @@ struct seq_file;
1671ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, 1700ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
1672 unsigned long nr_segs, unsigned long fast_segs, 1701 unsigned long nr_segs, unsigned long fast_segs,
1673 struct iovec *fast_pointer, 1702 struct iovec *fast_pointer,
1674 struct iovec **ret_pointer, 1703 struct iovec **ret_pointer);
1675 int check_access);
1676 1704
1677extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *); 1705extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
1678extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *); 1706extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *);
@@ -1744,8 +1772,8 @@ struct super_operations {
1744 * I_FREEING Set when inode is about to be freed but still has dirty 1772 * I_FREEING Set when inode is about to be freed but still has dirty
1745 * pages or buffers attached or the inode itself is still 1773 * pages or buffers attached or the inode itself is still
1746 * dirty. 1774 * dirty.
1747 * I_CLEAR Added by end_writeback(). In this state the inode is clean 1775 * I_CLEAR Added by clear_inode(). In this state the inode is
1748 * and can be destroyed. Inode keeps I_FREEING. 1776 * clean and can be destroyed. Inode keeps I_FREEING.
1749 * 1777 *
1750 * Inodes that are I_WILL_FREE, I_FREEING or I_CLEAR are 1778 * Inodes that are I_WILL_FREE, I_FREEING or I_CLEAR are
1751 * prohibited for many purposes. iget() must wait for 1779 * prohibited for many purposes. iget() must wait for
@@ -1753,9 +1781,10 @@ struct super_operations {
1753 * anew. Other functions will just ignore such inodes, 1781 * anew. Other functions will just ignore such inodes,
1754 * if appropriate. I_NEW is used for waiting. 1782 * if appropriate. I_NEW is used for waiting.
1755 * 1783 *
1756 * I_SYNC Synchonized write of dirty inode data. The bits is 1784 * I_SYNC Writeback of inode is running. The bit is set during
1757 * set during data writeback, and cleared with a wakeup 1785 * data writeback, and cleared with a wakeup on the bit
1758 * on the bit address once it is done. 1786 * address once it is done. The bit is also used to pin
1787 * the inode in memory for flusher thread.
1759 * 1788 *
1760 * I_REFERENCED Marks the inode as recently references on the LRU list. 1789 * I_REFERENCED Marks the inode as recently references on the LRU list.
1761 * 1790 *
@@ -1822,6 +1851,13 @@ static inline void inode_inc_iversion(struct inode *inode)
1822 spin_unlock(&inode->i_lock); 1851 spin_unlock(&inode->i_lock);
1823} 1852}
1824 1853
1854enum file_time_flags {
1855 S_ATIME = 1,
1856 S_MTIME = 2,
1857 S_CTIME = 4,
1858 S_VERSION = 8,
1859};
1860
1825extern void touch_atime(struct path *); 1861extern void touch_atime(struct path *);
1826static inline void file_accessed(struct file *file) 1862static inline void file_accessed(struct file *file)
1827{ 1863{
@@ -2051,6 +2087,7 @@ extern void unregister_blkdev(unsigned int, const char *);
2051extern struct block_device *bdget(dev_t); 2087extern struct block_device *bdget(dev_t);
2052extern struct block_device *bdgrab(struct block_device *bdev); 2088extern struct block_device *bdgrab(struct block_device *bdev);
2053extern void bd_set_size(struct block_device *, loff_t size); 2089extern void bd_set_size(struct block_device *, loff_t size);
2090extern sector_t blkdev_max_block(struct block_device *bdev);
2054extern void bd_forget(struct inode *inode); 2091extern void bd_forget(struct inode *inode);
2055extern void bdput(struct block_device *); 2092extern void bdput(struct block_device *);
2056extern void invalidate_bdev(struct block_device *); 2093extern void invalidate_bdev(struct block_device *);
@@ -2328,7 +2365,7 @@ extern unsigned int get_next_ino(void);
2328 2365
2329extern void __iget(struct inode * inode); 2366extern void __iget(struct inode * inode);
2330extern void iget_failed(struct inode *); 2367extern void iget_failed(struct inode *);
2331extern void end_writeback(struct inode *); 2368extern void clear_inode(struct inode *);
2332extern void __destroy_inode(struct inode *); 2369extern void __destroy_inode(struct inode *);
2333extern struct inode *new_inode_pseudo(struct super_block *sb); 2370extern struct inode *new_inode_pseudo(struct super_block *sb);
2334extern struct inode *new_inode(struct super_block *sb); 2371extern struct inode *new_inode(struct super_block *sb);
@@ -2432,8 +2469,6 @@ enum {
2432}; 2469};
2433 2470
2434void dio_end_io(struct bio *bio, int error); 2471void dio_end_io(struct bio *bio, int error);
2435void inode_dio_wait(struct inode *inode);
2436void inode_dio_done(struct inode *inode);
2437 2472
2438ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, 2473ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
2439 struct block_device *bdev, const struct iovec *iov, loff_t offset, 2474 struct block_device *bdev, const struct iovec *iov, loff_t offset,
@@ -2448,12 +2483,11 @@ static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb,
2448 offset, nr_segs, get_block, NULL, NULL, 2483 offset, nr_segs, get_block, NULL, NULL,
2449 DIO_LOCKING | DIO_SKIP_HOLES); 2484 DIO_LOCKING | DIO_SKIP_HOLES);
2450} 2485}
2451#else
2452static inline void inode_dio_wait(struct inode *inode)
2453{
2454}
2455#endif 2486#endif
2456 2487
2488void inode_dio_wait(struct inode *inode);
2489void inode_dio_done(struct inode *inode);
2490
2457extern const struct file_operations generic_ro_fops; 2491extern const struct file_operations generic_ro_fops;
2458 2492
2459#define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m)) 2493#define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
@@ -2557,7 +2591,7 @@ extern int inode_change_ok(const struct inode *, struct iattr *);
2557extern int inode_newsize_ok(const struct inode *, loff_t offset); 2591extern int inode_newsize_ok(const struct inode *, loff_t offset);
2558extern void setattr_copy(struct inode *inode, const struct iattr *attr); 2592extern void setattr_copy(struct inode *inode, const struct iattr *attr);
2559 2593
2560extern void file_update_time(struct file *file); 2594extern int file_update_time(struct file *file);
2561 2595
2562extern int generic_show_options(struct seq_file *m, struct dentry *root); 2596extern int generic_show_options(struct seq_file *m, struct dentry *root);
2563extern void save_mount_options(struct super_block *sb, char *options); 2597extern void save_mount_options(struct super_block *sb, char *options);