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