blob: ddd937490f0dcbf89274a57bc8d4cfd30ef38a7d [file] [log] [blame]
Miklos Szeredibbb1e542016-12-16 11:02:56 +01001/*
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
11struct ovl_config {
12 char *lowerdir;
13 char *upperdir;
14 char *workdir;
15 bool default_permissions;
Miklos Szeredia6c60652016-12-16 11:02:56 +010016 bool redirect_dir;
Miklos Szeredibbb1e542016-12-16 11:02:56 +010017};
18
19/* private information held for overlayfs's superblock */
20struct ovl_fs {
21 struct vfsmount *upper_mnt;
22 unsigned numlower;
23 struct vfsmount **lower_mnt;
24 struct dentry *workdir;
Miklos Szeredi6b2d5fe2016-12-16 11:02:56 +010025 long namelen;
Miklos Szeredibbb1e542016-12-16 11:02:56 +010026 /* pathnames of lower and upper dirs, for show_options */
27 struct ovl_config config;
28 /* creds of process who forced instantiation of super block */
29 const struct cred *creator_cred;
Amir Goldsteine7f52422017-01-17 06:34:53 +020030 bool tmpfile;
Amir Goldstein82b749b2017-05-17 00:12:40 +030031 bool noxattr;
Amir Goldstein39d3d602017-01-17 06:34:56 +020032 wait_queue_head_t copyup_wq;
Amir Goldstein7bcd74b2017-03-22 08:42:21 -040033 /* sb common to all layers */
34 struct super_block *same_sb;
Miklos Szeredibbb1e542016-12-16 11:02:56 +010035};
36
37/* private information held for every overlayfs dentry */
38struct ovl_entry {
Miklos Szeredibbb1e542016-12-16 11:02:56 +010039 struct ovl_dir_cache *cache;
40 union {
41 struct {
42 u64 version;
Miklos Szeredi02b69b22016-12-16 11:02:56 +010043 const char *redirect;
Miklos Szeredibbb1e542016-12-16 11:02:56 +010044 bool opaque;
Amir Goldsteinee1d6d372017-05-11 16:42:26 +030045 bool impure;
Amir Goldstein39d3d602017-01-17 06:34:56 +020046 bool copying;
Miklos Szeredibbb1e542016-12-16 11:02:56 +010047 };
48 struct rcu_head rcu;
49 };
50 unsigned numlower;
51 struct path lowerstack[];
52};
53
54struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
55
Amir Goldstein13cf1992017-06-12 09:54:40 +030056struct ovl_inode {
57 struct inode vfs_inode;
Miklos Szeredi09d8b582017-07-04 22:03:16 +020058 struct dentry *__upperdentry;
Miklos Szeredi25b77132017-07-04 22:03:16 +020059 struct inode *lower;
Amir Goldstein13cf1992017-06-12 09:54:40 +030060};
61
62static inline struct ovl_inode *OVL_I(struct inode *inode)
63{
64 return container_of(inode, struct ovl_inode, vfs_inode);
65}
Miklos Szeredi09d8b582017-07-04 22:03:16 +020066
67static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi)
68{
69 return lockless_dereference(oi->__upperdentry);
70}