blob: 878a750986dd799ad17d9acfc3818e93dcf288fa [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;
Amir Goldstein02bcd152017-06-21 15:28:36 +030017 bool index;
Miklos Szeredibbb1e542016-12-16 11:02:56 +010018};
19
20/* private information held for overlayfs's superblock */
21struct ovl_fs {
22 struct vfsmount *upper_mnt;
23 unsigned numlower;
24 struct vfsmount **lower_mnt;
Amir Goldstein2cac0c02017-06-21 15:28:33 +030025 /* workbasedir is the path at workdir= mount option */
26 struct dentry *workbasedir;
27 /* workdir is the 'work' directory under workbasedir */
Miklos Szeredibbb1e542016-12-16 11:02:56 +010028 struct dentry *workdir;
Amir Goldstein02bcd152017-06-21 15:28:36 +030029 /* index directory listing overlay inodes by origin file handle */
30 struct dentry *indexdir;
Miklos Szeredi6b2d5fe2016-12-16 11:02:56 +010031 long namelen;
Miklos Szeredibbb1e542016-12-16 11:02:56 +010032 /* pathnames of lower and upper dirs, for show_options */
33 struct ovl_config config;
34 /* creds of process who forced instantiation of super block */
35 const struct cred *creator_cred;
Amir Goldsteine7f52422017-01-17 06:34:53 +020036 bool tmpfile;
Amir Goldstein82b749b2017-05-17 00:12:40 +030037 bool noxattr;
Amir Goldstein7bcd74b2017-03-22 08:42:21 -040038 /* sb common to all layers */
39 struct super_block *same_sb;
Miklos Szeredibbb1e542016-12-16 11:02:56 +010040};
41
42/* private information held for every overlayfs dentry */
43struct ovl_entry {
Miklos Szeredibbb1e542016-12-16 11:02:56 +010044 union {
Miklos Szeredi55acc662017-07-04 22:03:18 +020045 struct {
46 unsigned long has_upper;
47 bool opaque;
48 };
Miklos Szeredibbb1e542016-12-16 11:02:56 +010049 struct rcu_head rcu;
50 };
51 unsigned numlower;
52 struct path lowerstack[];
53};
54
55struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
56
Amir Goldstein13cf1992017-06-12 09:54:40 +030057struct ovl_inode {
Miklos Szeredi04a01ac2017-07-04 22:03:16 +020058 struct ovl_dir_cache *cache;
Miklos Szeredicf31c462017-07-04 22:03:16 +020059 const char *redirect;
Miklos Szeredi04a01ac2017-07-04 22:03:16 +020060 u64 version;
Miklos Szeredi13c72072017-07-04 22:03:16 +020061 unsigned long flags;
Amir Goldstein13cf1992017-06-12 09:54:40 +030062 struct inode vfs_inode;
Miklos Szeredi09d8b582017-07-04 22:03:16 +020063 struct dentry *__upperdentry;
Miklos Szeredi25b77132017-07-04 22:03:16 +020064 struct inode *lower;
Amir Goldsteina015daf2017-06-21 15:28:51 +030065
66 /* synchronize copy up and more */
67 struct mutex lock;
Amir Goldstein13cf1992017-06-12 09:54:40 +030068};
69
70static inline struct ovl_inode *OVL_I(struct inode *inode)
71{
72 return container_of(inode, struct ovl_inode, vfs_inode);
73}
Miklos Szeredi09d8b582017-07-04 22:03:16 +020074
75static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi)
76{
77 return lockless_dereference(oi->__upperdentry);
78}