Merge tag 'xtensa-20180225' of git://github.com/jcmvbkbc/linux-xtensa
[cris-mirror.git] / fs / overlayfs / ovl_entry.h
blobbfef6edcc1112853e750a3a5468334aa39991465
1 /*
3 * Copyright (C) 2011 Novell Inc.
4 * Copyright (C) 2016 Red Hat, Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.
9 */
11 struct ovl_config {
12 char *lowerdir;
13 char *upperdir;
14 char *workdir;
15 bool default_permissions;
16 bool redirect_dir;
17 bool redirect_follow;
18 const char *redirect_mode;
19 bool index;
20 bool nfs_export;
23 struct ovl_layer {
24 struct vfsmount *mnt;
25 dev_t pseudo_dev;
26 /* Index of this layer in fs root (upper == 0) */
27 int idx;
30 struct ovl_path {
31 struct ovl_layer *layer;
32 struct dentry *dentry;
35 /* private information held for overlayfs's superblock */
36 struct ovl_fs {
37 struct vfsmount *upper_mnt;
38 unsigned numlower;
39 struct ovl_layer *lower_layers;
40 /* workbasedir is the path at workdir= mount option */
41 struct dentry *workbasedir;
42 /* workdir is the 'work' directory under workbasedir */
43 struct dentry *workdir;
44 /* index directory listing overlay inodes by origin file handle */
45 struct dentry *indexdir;
46 long namelen;
47 /* pathnames of lower and upper dirs, for show_options */
48 struct ovl_config config;
49 /* creds of process who forced instantiation of super block */
50 const struct cred *creator_cred;
51 bool tmpfile;
52 bool noxattr;
53 /* sb common to all layers */
54 struct super_block *same_sb;
55 /* Did we take the inuse lock? */
56 bool upperdir_locked;
57 bool workdir_locked;
60 /* private information held for every overlayfs dentry */
61 struct ovl_entry {
62 union {
63 struct {
64 unsigned long flags;
66 struct rcu_head rcu;
68 unsigned numlower;
69 struct ovl_path lowerstack[];
72 struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
74 static inline struct ovl_entry *OVL_E(struct dentry *dentry)
76 return (struct ovl_entry *) dentry->d_fsdata;
79 struct ovl_inode {
80 struct ovl_dir_cache *cache;
81 const char *redirect;
82 u64 version;
83 unsigned long flags;
84 struct inode vfs_inode;
85 struct dentry *__upperdentry;
86 struct inode *lower;
88 /* synchronize copy up and more */
89 struct mutex lock;
92 static inline struct ovl_inode *OVL_I(struct inode *inode)
94 return container_of(inode, struct ovl_inode, vfs_inode);
97 static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi)
99 return READ_ONCE(oi->__upperdentry);