0001
0002
0003
0004
0005
0006
0007
0008 struct ovl_config {
0009 char *lowerdir;
0010 char *upperdir;
0011 char *workdir;
0012 bool default_permissions;
0013 bool redirect_dir;
0014 bool redirect_follow;
0015 const char *redirect_mode;
0016 bool index;
0017 bool uuid;
0018 bool nfs_export;
0019 int xino;
0020 bool metacopy;
0021 bool userxattr;
0022 bool ovl_volatile;
0023 };
0024
0025 struct ovl_sb {
0026 struct super_block *sb;
0027 dev_t pseudo_dev;
0028
0029 bool bad_uuid;
0030
0031 bool is_lower;
0032 };
0033
0034 struct ovl_layer {
0035 struct vfsmount *mnt;
0036
0037 struct inode *trap;
0038 struct ovl_sb *fs;
0039
0040 int idx;
0041
0042 int fsid;
0043 };
0044
0045 struct ovl_path {
0046 const struct ovl_layer *layer;
0047 struct dentry *dentry;
0048 };
0049
0050
0051 struct ovl_fs {
0052 unsigned int numlayer;
0053
0054 unsigned int numfs;
0055 const struct ovl_layer *layers;
0056 struct ovl_sb *fs;
0057
0058 struct dentry *workbasedir;
0059
0060 struct dentry *workdir;
0061
0062 struct dentry *indexdir;
0063 long namelen;
0064
0065 struct ovl_config config;
0066
0067 const struct cred *creator_cred;
0068 bool tmpfile;
0069 bool noxattr;
0070
0071 bool upperdir_locked;
0072 bool workdir_locked;
0073 bool share_whiteout;
0074
0075 struct inode *workbasedir_trap;
0076 struct inode *workdir_trap;
0077 struct inode *indexdir_trap;
0078
0079 int xino_mode;
0080
0081 atomic_long_t last_ino;
0082
0083 struct dentry *whiteout;
0084
0085 errseq_t errseq;
0086 };
0087
0088 static inline struct vfsmount *ovl_upper_mnt(struct ovl_fs *ofs)
0089 {
0090 return ofs->layers[0].mnt;
0091 }
0092
0093 static inline struct user_namespace *ovl_upper_mnt_userns(struct ovl_fs *ofs)
0094 {
0095 return mnt_user_ns(ovl_upper_mnt(ofs));
0096 }
0097
0098 static inline struct ovl_fs *OVL_FS(struct super_block *sb)
0099 {
0100 return (struct ovl_fs *)sb->s_fs_info;
0101 }
0102
0103 static inline bool ovl_should_sync(struct ovl_fs *ofs)
0104 {
0105 return !ofs->config.ovl_volatile;
0106 }
0107
0108
0109 struct ovl_entry {
0110 union {
0111 struct {
0112 unsigned long flags;
0113 };
0114 struct rcu_head rcu;
0115 };
0116 unsigned numlower;
0117 struct ovl_path lowerstack[];
0118 };
0119
0120 struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
0121
0122 static inline struct ovl_entry *OVL_E(struct dentry *dentry)
0123 {
0124 return (struct ovl_entry *) dentry->d_fsdata;
0125 }
0126
0127 struct ovl_inode {
0128 union {
0129 struct ovl_dir_cache *cache;
0130 struct inode *lowerdata;
0131 };
0132 const char *redirect;
0133 u64 version;
0134 unsigned long flags;
0135 struct inode vfs_inode;
0136 struct dentry *__upperdentry;
0137 struct ovl_path lowerpath;
0138
0139
0140 struct mutex lock;
0141 };
0142
0143 static inline struct ovl_inode *OVL_I(struct inode *inode)
0144 {
0145 return container_of(inode, struct ovl_inode, vfs_inode);
0146 }
0147
0148 static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi)
0149 {
0150 return READ_ONCE(oi->__upperdentry);
0151 }