• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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;
16 	bool redirect_dir;
17 	bool index;
18 	bool override_creds;
19 };
20 
21 /* private information held for overlayfs's superblock */
22 struct ovl_fs {
23 	struct vfsmount *upper_mnt;
24 	unsigned numlower;
25 	struct vfsmount **lower_mnt;
26 	/* workbasedir is the path at workdir= mount option */
27 	struct dentry *workbasedir;
28 	/* workdir is the 'work' directory under workbasedir */
29 	struct dentry *workdir;
30 	/* index directory listing overlay inodes by origin file handle */
31 	struct dentry *indexdir;
32 	long namelen;
33 	/* pathnames of lower and upper dirs, for show_options */
34 	struct ovl_config config;
35 	/* creds of process who forced instantiation of super block */
36 	const struct cred *creator_cred;
37 	bool tmpfile;
38 	bool noxattr;
39 	/* sb common to all layers */
40 	struct super_block *same_sb;
41 	/* Did we take the inuse lock? */
42 	bool upperdir_locked;
43 	bool workdir_locked;
44 };
45 
46 /* private information held for every overlayfs dentry */
47 struct ovl_entry {
48 	union {
49 		struct {
50 			unsigned long has_upper;
51 			bool opaque;
52 		};
53 		struct rcu_head rcu;
54 	};
55 	unsigned numlower;
56 	struct path lowerstack[];
57 };
58 
59 struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
60 
61 struct ovl_inode {
62 	struct ovl_dir_cache *cache;
63 	const char *redirect;
64 	u64 version;
65 	unsigned long flags;
66 	struct inode vfs_inode;
67 	struct dentry *__upperdentry;
68 	struct inode *lower;
69 
70 	/* synchronize copy up and more */
71 	struct mutex lock;
72 };
73 
OVL_I(struct inode * inode)74 static inline struct ovl_inode *OVL_I(struct inode *inode)
75 {
76 	return container_of(inode, struct ovl_inode, vfs_inode);
77 }
78 
ovl_upperdentry_dereference(struct ovl_inode * oi)79 static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi)
80 {
81 	return READ_ONCE(oi->__upperdentry);
82 }
83