-
Notifications
You must be signed in to change notification settings - Fork 1
/
expfs.h
204 lines (170 loc) · 5.78 KB
/
expfs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#ifndef _LINUX_EXPFS_H
#define _LINUX_EXPFS_H
//struct inode *expfs_get_inode(struct super_block *sb, const struct inode *dir,
//umode_t mode, dev_t dev);
extern struct dentry *expfs_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data);
#ifndef CONFIG_MMU
extern int expfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize);
extern unsigned long expfs_nommu_get_unmapped_area(struct file *file,
unsigned long addr,
unsigned long len,
unsigned long pgoff,
unsigned long flags);
extern int expfs_nommu_mmap(struct file *file, struct vm_area_struct *vma);
#endif
extern const struct file_operations expfs_file_operations;
extern const struct file_operations expfs_dir_operations;
extern const struct vm_operations_struct generic_file_vm_ops;
extern int __init init_rootfs(void);
int expfs_fill_super(struct super_block *sb, void *data, int silent);
ssize_t expfs_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos);
ssize_t expfs_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos);
extern struct kmem_cache *expfs_dentry_info_cache;
extern struct kmem_cache *expfs_fs_info_cache;
extern struct kmem_cache *expfs_file_info_cache;
struct expfs_mount_opts {
umode_t mode;
};
struct expfs_inode_info {
struct inode vfs_inode;
struct inode *wii_inode;
struct mutex lower_file_mutex;
atomic_t lower_file_count;
struct file *lower_file;
//struct ecryptfs_crypt_stat crypt_stat;
};
struct expfs_file_info {
struct file *wfi_file;
//struct ecryptfs_crypt_stat *crypt_stat;
};
struct expfs_dentry_info {
struct path lower_path;
//struct ecryptfs_crypt_stat *crypt_stat;
};
struct expfs_fs_info {
struct expfs_mount_opts mount_opts;
struct super_block *lower_sb;
};
struct ecryptfs_getdents_callback {
void *dirent;
struct dentry *dentry;
filldir_t filldir;
int filldir_called;
int entries_written;
};
static inline struct expfs_inode_info *
expfs_inode_to_private(struct inode *inode)
{
return container_of(inode, struct expfs_inode_info, vfs_inode);
}
static inline struct inode *expfs_inode_to_lower(struct inode *inode)
{
return expfs_inode_to_private(inode)->wii_inode;
}
static inline void
expfs_set_inode_lower(struct inode *inode, struct inode *lower_inode)
{
expfs_inode_to_private(inode)->wii_inode = lower_inode;
}
static inline struct super_block *
expfs_superblock_to_lower(struct super_block *sb)
{
return ((struct expfs_fs_info *)sb->s_fs_info)->lower_sb;
}
static inline struct expfs_file_info *
expfs_file_to_private(struct file *file)
{
return file->private_data;
}
static inline void
expfs_set_file_private(struct file *file,
struct expfs_file_info *file_info)
{
file->private_data = file_info;
}
static inline struct file *expfs_file_to_lower(struct file *file)
{
return ((struct expfs_file_info *)file->private_data)->wfi_file;
}
static inline void
expfs_set_file_lower(struct file *file, struct file *lower_file)
{
((struct expfs_file_info *)file->private_data)->wfi_file =
lower_file;
}
static inline struct expfs_dentry_info *
expfs_dentry_to_private(struct dentry *dentry)
{
return (struct expfs_dentry_info *)dentry->d_fsdata;
}
static inline void
expfs_set_dentry_private(struct dentry *dentry,
struct expfs_dentry_info *dentry_info)
{
dentry->d_fsdata = dentry_info;
}
static inline struct dentry *
expfs_dentry_to_lower(struct dentry *dentry)
{
return ((struct expfs_dentry_info *)dentry->d_fsdata)->lower_path.dentry;
}
static inline struct vfsmount *
expfs_dentry_to_lower_mnt(struct dentry *dentry)
{
return ((struct expfs_dentry_info *)dentry->d_fsdata)->lower_path.mnt;
}
static inline void
expfs_set_dentry_lower(struct dentry *dentry, struct dentry *lower_dentry)
{
((struct expfs_dentry_info *)dentry->d_fsdata)->lower_path.dentry =
lower_dentry;
}
static inline void
expfs_set_dentry_lower_mnt(struct dentry *dentry, struct vfsmount *lower_mnt)
{
((struct expfs_dentry_info *)dentry->d_fsdata)->lower_path.mnt =
lower_mnt;
}
static int expfs_open(struct inode *inode, struct file *file);
static int expfs_read_dir(struct file *file, void *dirent, filldir_t filldir);
//struct kmem_cache *expfs_open_req_cache;
/**
* ecryptfs_privileged_open
* @lower_file: Result of dentry_open by root on lower dentry
* @lower_dentry: Lower dentry for file to open
* @lower_mnt: Lower vfsmount for file to open
*
* This function gets a r/w file opened againt the lower dentry.
*
* Returns zero on success; non-zero otherwise
*/
int expfs_privileged_open(struct file **lower_file,
struct dentry *lower_dentry,
struct vfsmount *lower_mnt,
const struct cred *cred);
/**
* ecryptfs_init_lower_file
* @ecryptfs_dentry: Fully initialized eCryptfs dentry object, with
* the lower dentry and the lower mount set
*
* eCryptfs only ever keeps a single open file for every lower
* inode. All I/O operations to the lower inode occur through that
* file. When the first eCryptfs dentry that interposes with the first
* lower dentry for that inode is created, this function creates the
* lower file struct and associates it with the eCryptfs
* inode. When all eCryptfs files associated with the inode are released, the
* file is closed.
*
* The lower file will be opened with read/write permissions, if
* possible. Otherwise, it is opened read-only.
*
* This function does nothing if a lower file is already
* associated with the eCryptfs inode.
* Returns zero on success; non-zero otherwise
*/
static int expfs_init_lower_file(struct dentry *dentry,
struct file **lower_file);
int expfs_get_lower_file(struct dentry *dentry, struct inode *inode);
void expfs_put_lower_file(struct inode *inode);
#endif