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.h49
1 files changed, 46 insertions, 3 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a957d4366c24..9ab779e8a63c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -223,6 +223,13 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
223#define ATTR_TIMES_SET (1 << 16) 223#define ATTR_TIMES_SET (1 << 16)
224 224
225/* 225/*
226 * Whiteout is represented by a char device. The following constants define the
227 * mode and device number to use.
228 */
229#define WHITEOUT_MODE 0
230#define WHITEOUT_DEV 0
231
232/*
226 * This is the Inode Attributes structure, used for notify_change(). It 233 * This is the Inode Attributes structure, used for notify_change(). It
227 * uses the above definitions as flags, to know which values have changed. 234 * uses the above definitions as flags, to know which values have changed.
228 * Also, in this manner, a Filesystem can look at only the values it cares 235 * Also, in this manner, a Filesystem can look at only the values it cares
@@ -254,6 +261,12 @@ struct iattr {
254 */ 261 */
255#include <linux/quota.h> 262#include <linux/quota.h>
256 263
264/*
265 * Maximum number of layers of fs stack. Needs to be limited to
266 * prevent kernel stack overflow
267 */
268#define FILESYSTEM_MAX_STACK_DEPTH 2
269
257/** 270/**
258 * enum positive_aop_returns - aop return codes with specific semantics 271 * enum positive_aop_returns - aop return codes with specific semantics
259 * 272 *
@@ -626,11 +639,13 @@ static inline int inode_unhashed(struct inode *inode)
626 * 2: child/target 639 * 2: child/target
627 * 3: xattr 640 * 3: xattr
628 * 4: second non-directory 641 * 4: second non-directory
629 * The last is for certain operations (such as rename) which lock two 642 * 5: second parent (when locking independent directories in rename)
643 *
644 * I_MUTEX_NONDIR2 is for certain operations (such as rename) which lock two
630 * non-directories at once. 645 * non-directories at once.
631 * 646 *
632 * The locking order between these classes is 647 * The locking order between these classes is
633 * parent -> child -> normal -> xattr -> second non-directory 648 * parent[2] -> child -> grandchild -> normal -> xattr -> second non-directory
634 */ 649 */
635enum inode_i_mutex_lock_class 650enum inode_i_mutex_lock_class
636{ 651{
@@ -638,7 +653,8 @@ enum inode_i_mutex_lock_class
638 I_MUTEX_PARENT, 653 I_MUTEX_PARENT,
639 I_MUTEX_CHILD, 654 I_MUTEX_CHILD,
640 I_MUTEX_XATTR, 655 I_MUTEX_XATTR,
641 I_MUTEX_NONDIR2 656 I_MUTEX_NONDIR2,
657 I_MUTEX_PARENT2,
642}; 658};
643 659
644void lock_two_nondirectories(struct inode *, struct inode*); 660void lock_two_nondirectories(struct inode *, struct inode*);
@@ -1266,6 +1282,11 @@ struct super_block {
1266 struct list_lru s_dentry_lru ____cacheline_aligned_in_smp; 1282 struct list_lru s_dentry_lru ____cacheline_aligned_in_smp;
1267 struct list_lru s_inode_lru ____cacheline_aligned_in_smp; 1283 struct list_lru s_inode_lru ____cacheline_aligned_in_smp;
1268 struct rcu_head rcu; 1284 struct rcu_head rcu;
1285
1286 /*
1287 * Indicates how deep in a filesystem stack this SB is
1288 */
1289 int s_stack_depth;
1269}; 1290};
1270 1291
1271extern struct timespec current_fs_time(struct super_block *sb); 1292extern struct timespec current_fs_time(struct super_block *sb);
@@ -1398,6 +1419,7 @@ extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct ino
1398extern int vfs_rmdir(struct inode *, struct dentry *); 1419extern int vfs_rmdir(struct inode *, struct dentry *);
1399extern int vfs_unlink(struct inode *, struct dentry *, struct inode **); 1420extern int vfs_unlink(struct inode *, struct dentry *, struct inode **);
1400extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **, unsigned int); 1421extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **, unsigned int);
1422extern int vfs_whiteout(struct inode *, struct dentry *);
1401 1423
1402/* 1424/*
1403 * VFS dentry helper functions. 1425 * VFS dentry helper functions.
@@ -1528,6 +1550,9 @@ struct inode_operations {
1528 umode_t create_mode, int *opened); 1550 umode_t create_mode, int *opened);
1529 int (*tmpfile) (struct inode *, struct dentry *, umode_t); 1551 int (*tmpfile) (struct inode *, struct dentry *, umode_t);
1530 int (*set_acl)(struct inode *, struct posix_acl *, int); 1552 int (*set_acl)(struct inode *, struct posix_acl *, int);
1553
1554 /* WARNING: probably going away soon, do not use! */
1555 int (*dentry_open)(struct dentry *, struct file *, const struct cred *);
1531} ____cacheline_aligned; 1556} ____cacheline_aligned;
1532 1557
1533ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, 1558ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
@@ -1625,6 +1650,9 @@ struct super_operations {
1625#define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT) 1650#define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
1626#define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC) 1651#define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
1627 1652
1653#define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \
1654 (inode)->i_rdev == WHITEOUT_DEV)
1655
1628/* 1656/*
1629 * Inode state bits. Protected by inode->i_lock 1657 * Inode state bits. Protected by inode->i_lock
1630 * 1658 *
@@ -2040,6 +2068,7 @@ extern struct file *file_open_name(struct filename *, int, umode_t);
2040extern struct file *filp_open(const char *, int, umode_t); 2068extern struct file *filp_open(const char *, int, umode_t);
2041extern struct file *file_open_root(struct dentry *, struct vfsmount *, 2069extern struct file *file_open_root(struct dentry *, struct vfsmount *,
2042 const char *, int); 2070 const char *, int);
2071extern int vfs_open(const struct path *, struct file *, const struct cred *);
2043extern struct file * dentry_open(const struct path *, int, const struct cred *); 2072extern struct file * dentry_open(const struct path *, int, const struct cred *);
2044extern int filp_close(struct file *, fl_owner_t id); 2073extern int filp_close(struct file *, fl_owner_t id);
2045 2074
@@ -2253,7 +2282,9 @@ extern sector_t bmap(struct inode *, sector_t);
2253#endif 2282#endif
2254extern int notify_change(struct dentry *, struct iattr *, struct inode **); 2283extern int notify_change(struct dentry *, struct iattr *, struct inode **);
2255extern int inode_permission(struct inode *, int); 2284extern int inode_permission(struct inode *, int);
2285extern int __inode_permission(struct inode *, int);
2256extern int generic_permission(struct inode *, int); 2286extern int generic_permission(struct inode *, int);
2287extern int __check_sticky(struct inode *dir, struct inode *inode);
2257 2288
2258static inline bool execute_ok(struct inode *inode) 2289static inline bool execute_ok(struct inode *inode)
2259{ 2290{
@@ -2438,6 +2469,7 @@ extern ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, lo
2438extern ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos); 2469extern ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos);
2439 2470
2440/* fs/block_dev.c */ 2471/* fs/block_dev.c */
2472extern ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to);
2441extern ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from); 2473extern ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from);
2442extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end, 2474extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end,
2443 int datasync); 2475 int datasync);
@@ -2452,6 +2484,9 @@ extern ssize_t iter_file_splice_write(struct pipe_inode_info *,
2452 struct file *, loff_t *, size_t, unsigned int); 2484 struct file *, loff_t *, size_t, unsigned int);
2453extern ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe, 2485extern ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
2454 struct file *out, loff_t *, size_t len, unsigned int flags); 2486 struct file *out, loff_t *, size_t len, unsigned int flags);
2487extern long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
2488 loff_t *opos, size_t len, unsigned int flags);
2489
2455 2490
2456extern void 2491extern void
2457file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping); 2492file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
@@ -2737,6 +2772,14 @@ static inline int is_sxid(umode_t mode)
2737 return (mode & S_ISUID) || ((mode & S_ISGID) && (mode & S_IXGRP)); 2772 return (mode & S_ISUID) || ((mode & S_ISGID) && (mode & S_IXGRP));
2738} 2773}
2739 2774
2775static inline int check_sticky(struct inode *dir, struct inode *inode)
2776{
2777 if (!(dir->i_mode & S_ISVTX))
2778 return 0;
2779
2780 return __check_sticky(dir, inode);
2781}
2782
2740static inline void inode_has_no_xattr(struct inode *inode) 2783static inline void inode_has_no_xattr(struct inode *inode)
2741{ 2784{
2742 if (!is_sxid(inode->i_mode) && (inode->i_sb->s_flags & MS_NOSEC)) 2785 if (!is_sxid(inode->i_mode) && (inode->i_sb->s_flags & MS_NOSEC))