1 /* SPDX-License-Identifier: GPL-2.0-only */
4 * Copyright (C) 2011 Novell Inc.
5 * Copyright (C) 2016 Red Hat, Inc.
12 bool default_permissions;
15 const char *redirect_mode;
23 struct super_block *sb;
25 /* Unusable (conflicting) uuid */
27 /* Used as a lower layer (but maybe also as upper) */
33 /* Trap in ovl inode cache */
36 /* Index of this layer in fs root (upper idx == 0) */
38 /* One fsid per unique underlying sb (upper fsid == 0) */
43 const struct ovl_layer *layer;
44 struct dentry *dentry;
47 /* private information held for overlayfs's superblock */
49 unsigned int numlayer;
50 /* Number of unique fs among layers including upper fs */
52 const struct ovl_layer *layers;
54 /* workbasedir is the path at workdir= mount option */
55 struct dentry *workbasedir;
56 /* workdir is the 'work' directory under workbasedir */
57 struct dentry *workdir;
58 /* index directory listing overlay inodes by origin file handle */
59 struct dentry *indexdir;
61 /* pathnames of lower and upper dirs, for show_options */
62 struct ovl_config config;
63 /* creds of process who forced instantiation of super block */
64 const struct cred *creator_cred;
67 /* Did we take the inuse lock? */
71 /* Traps in ovl inode cache */
72 struct inode *workbasedir_trap;
73 struct inode *workdir_trap;
74 struct inode *indexdir_trap;
75 /* -1: disabled, 0: same fs, 1..32: number of unused ino bits */
77 /* For allocation of non-persistent inode numbers */
78 atomic_long_t last_ino;
79 /* Whiteout dentry cache */
80 struct dentry *whiteout;
83 static inline struct vfsmount *ovl_upper_mnt(struct ovl_fs *ofs)
85 return ofs->layers[0].mnt;
88 static inline struct ovl_fs *OVL_FS(struct super_block *sb)
90 return (struct ovl_fs *)sb->s_fs_info;
93 /* private information held for every overlayfs dentry */
102 struct ovl_path lowerstack[];
105 struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
107 static inline struct ovl_entry *OVL_E(struct dentry *dentry)
109 return (struct ovl_entry *) dentry->d_fsdata;
114 struct ovl_dir_cache *cache; /* directory */
115 struct inode *lowerdata; /* regular file */
117 const char *redirect;
120 struct inode vfs_inode;
121 struct dentry *__upperdentry;
124 /* synchronize copy up and more */
128 static inline struct ovl_inode *OVL_I(struct inode *inode)
130 return container_of(inode, struct ovl_inode, vfs_inode);
133 static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi)
135 return READ_ONCE(oi->__upperdentry);