Commit | Line | Data |
---|---|---|
bbb1e54d MS |
1 | /* |
2 | * | |
3 | * Copyright (C) 2011 Novell Inc. | |
4 | * Copyright (C) 2016 Red Hat, Inc. | |
5 | * | |
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 | */ | |
10 | ||
11 | struct ovl_config { | |
12 | char *lowerdir; | |
13 | char *upperdir; | |
14 | char *workdir; | |
15 | bool default_permissions; | |
a6c60655 | 16 | bool redirect_dir; |
438c84c2 MS |
17 | bool redirect_follow; |
18 | const char *redirect_mode; | |
02bcd157 | 19 | bool index; |
f168f109 | 20 | bool nfs_export; |
795939a9 | 21 | int xino; |
d5791044 | 22 | bool metacopy; |
bbb1e54d MS |
23 | }; |
24 | ||
5148626b AG |
25 | struct ovl_sb { |
26 | struct super_block *sb; | |
27 | dev_t pseudo_dev; | |
28 | }; | |
29 | ||
b9343632 CR |
30 | struct ovl_layer { |
31 | struct vfsmount *mnt; | |
5148626b AG |
32 | struct ovl_sb *fs; |
33 | /* Index of this layer in fs root (upper idx == 0) */ | |
d583ed7d | 34 | int idx; |
5148626b AG |
35 | /* One fsid per unique underlying sb (upper fsid == 0) */ |
36 | int fsid; | |
b9343632 CR |
37 | }; |
38 | ||
39 | struct ovl_path { | |
40 | struct ovl_layer *layer; | |
41 | struct dentry *dentry; | |
42 | }; | |
43 | ||
bbb1e54d MS |
44 | /* private information held for overlayfs's superblock */ |
45 | struct ovl_fs { | |
46 | struct vfsmount *upper_mnt; | |
5148626b AG |
47 | unsigned int numlower; |
48 | /* Number of unique lower sb that differ from upper sb */ | |
49 | unsigned int numlowerfs; | |
b9343632 | 50 | struct ovl_layer *lower_layers; |
5148626b | 51 | struct ovl_sb *lower_fs; |
2cac0c00 AG |
52 | /* workbasedir is the path at workdir= mount option */ |
53 | struct dentry *workbasedir; | |
54 | /* workdir is the 'work' directory under workbasedir */ | |
bbb1e54d | 55 | struct dentry *workdir; |
02bcd157 AG |
56 | /* index directory listing overlay inodes by origin file handle */ |
57 | struct dentry *indexdir; | |
6b2d5fe4 | 58 | long namelen; |
bbb1e54d MS |
59 | /* pathnames of lower and upper dirs, for show_options */ |
60 | struct ovl_config config; | |
61 | /* creds of process who forced instantiation of super block */ | |
62 | const struct cred *creator_cred; | |
e7f52429 | 63 | bool tmpfile; |
82b749b2 | 64 | bool noxattr; |
85fdee1e AG |
65 | /* Did we take the inuse lock? */ |
66 | bool upperdir_locked; | |
67 | bool workdir_locked; | |
e487d889 AG |
68 | /* Inode numbers in all layers do not use the high xino_bits */ |
69 | unsigned int xino_bits; | |
bbb1e54d MS |
70 | }; |
71 | ||
72 | /* private information held for every overlayfs dentry */ | |
73 | struct ovl_entry { | |
bbb1e54d | 74 | union { |
55acc661 | 75 | struct { |
c62520a8 | 76 | unsigned long flags; |
55acc661 | 77 | }; |
bbb1e54d MS |
78 | struct rcu_head rcu; |
79 | }; | |
80 | unsigned numlower; | |
b9343632 | 81 | struct ovl_path lowerstack[]; |
bbb1e54d MS |
82 | }; |
83 | ||
84 | struct ovl_entry *ovl_alloc_entry(unsigned int numlower); | |
85 | ||
c62520a8 AG |
86 | static inline struct ovl_entry *OVL_E(struct dentry *dentry) |
87 | { | |
88 | return (struct ovl_entry *) dentry->d_fsdata; | |
89 | } | |
90 | ||
13cf199d | 91 | struct ovl_inode { |
2664bd08 VG |
92 | union { |
93 | struct ovl_dir_cache *cache; /* directory */ | |
94 | struct inode *lowerdata; /* regular file */ | |
95 | }; | |
cf31c463 | 96 | const char *redirect; |
04a01ac7 | 97 | u64 version; |
13c72075 | 98 | unsigned long flags; |
13cf199d | 99 | struct inode vfs_inode; |
09d8b586 | 100 | struct dentry *__upperdentry; |
25b7713a | 101 | struct inode *lower; |
a015dafc AG |
102 | |
103 | /* synchronize copy up and more */ | |
104 | struct mutex lock; | |
13cf199d AG |
105 | }; |
106 | ||
107 | static inline struct ovl_inode *OVL_I(struct inode *inode) | |
108 | { | |
109 | return container_of(inode, struct ovl_inode, vfs_inode); | |
110 | } | |
09d8b586 MS |
111 | |
112 | static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi) | |
113 | { | |
506458ef | 114 | return READ_ONCE(oi->__upperdentry); |
09d8b586 | 115 | } |