diff options
Diffstat (limited to 'fs/ecryptfs/main.c')
-rw-r--r-- | fs/ecryptfs/main.c | 84 |
1 files changed, 5 insertions, 79 deletions
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index 89b93389af8e..9f1bb747d77d 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
@@ -135,12 +135,12 @@ static int ecryptfs_init_lower_file(struct dentry *dentry, | |||
135 | return rc; | 135 | return rc; |
136 | } | 136 | } |
137 | 137 | ||
138 | int ecryptfs_get_lower_file(struct dentry *dentry) | 138 | int ecryptfs_get_lower_file(struct dentry *dentry, struct inode *inode) |
139 | { | 139 | { |
140 | struct ecryptfs_inode_info *inode_info = | 140 | struct ecryptfs_inode_info *inode_info; |
141 | ecryptfs_inode_to_private(dentry->d_inode); | ||
142 | int count, rc = 0; | 141 | int count, rc = 0; |
143 | 142 | ||
143 | inode_info = ecryptfs_inode_to_private(inode); | ||
144 | mutex_lock(&inode_info->lower_file_mutex); | 144 | mutex_lock(&inode_info->lower_file_mutex); |
145 | count = atomic_inc_return(&inode_info->lower_file_count); | 145 | count = atomic_inc_return(&inode_info->lower_file_count); |
146 | if (WARN_ON_ONCE(count < 1)) | 146 | if (WARN_ON_ONCE(count < 1)) |
@@ -168,75 +168,6 @@ void ecryptfs_put_lower_file(struct inode *inode) | |||
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | static struct inode *ecryptfs_get_inode(struct inode *lower_inode, | ||
172 | struct super_block *sb) | ||
173 | { | ||
174 | struct inode *inode; | ||
175 | int rc = 0; | ||
176 | |||
177 | if (lower_inode->i_sb != ecryptfs_superblock_to_lower(sb)) { | ||
178 | rc = -EXDEV; | ||
179 | goto out; | ||
180 | } | ||
181 | if (!igrab(lower_inode)) { | ||
182 | rc = -ESTALE; | ||
183 | goto out; | ||
184 | } | ||
185 | inode = iget5_locked(sb, (unsigned long)lower_inode, | ||
186 | ecryptfs_inode_test, ecryptfs_inode_set, | ||
187 | lower_inode); | ||
188 | if (!inode) { | ||
189 | rc = -EACCES; | ||
190 | iput(lower_inode); | ||
191 | goto out; | ||
192 | } | ||
193 | if (inode->i_state & I_NEW) | ||
194 | unlock_new_inode(inode); | ||
195 | else | ||
196 | iput(lower_inode); | ||
197 | if (S_ISLNK(lower_inode->i_mode)) | ||
198 | inode->i_op = &ecryptfs_symlink_iops; | ||
199 | else if (S_ISDIR(lower_inode->i_mode)) | ||
200 | inode->i_op = &ecryptfs_dir_iops; | ||
201 | if (S_ISDIR(lower_inode->i_mode)) | ||
202 | inode->i_fop = &ecryptfs_dir_fops; | ||
203 | if (special_file(lower_inode->i_mode)) | ||
204 | init_special_inode(inode, lower_inode->i_mode, | ||
205 | lower_inode->i_rdev); | ||
206 | fsstack_copy_attr_all(inode, lower_inode); | ||
207 | /* This size will be overwritten for real files w/ headers and | ||
208 | * other metadata */ | ||
209 | fsstack_copy_inode_size(inode, lower_inode); | ||
210 | return inode; | ||
211 | out: | ||
212 | return ERR_PTR(rc); | ||
213 | } | ||
214 | |||
215 | /** | ||
216 | * ecryptfs_interpose | ||
217 | * @lower_dentry: Existing dentry in the lower filesystem | ||
218 | * @dentry: ecryptfs' dentry | ||
219 | * @sb: ecryptfs's super_block | ||
220 | * @flags: flags to govern behavior of interpose procedure | ||
221 | * | ||
222 | * Interposes upper and lower dentries. | ||
223 | * | ||
224 | * Returns zero on success; non-zero otherwise | ||
225 | */ | ||
226 | int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry, | ||
227 | struct super_block *sb, u32 flags) | ||
228 | { | ||
229 | struct inode *lower_inode = lower_dentry->d_inode; | ||
230 | struct inode *inode = ecryptfs_get_inode(lower_inode, sb); | ||
231 | if (IS_ERR(inode)) | ||
232 | return PTR_ERR(inode); | ||
233 | if (flags & ECRYPTFS_INTERPOSE_FLAG_D_ADD) | ||
234 | d_add(dentry, inode); | ||
235 | else | ||
236 | d_instantiate(dentry, inode); | ||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | enum { ecryptfs_opt_sig, ecryptfs_opt_ecryptfs_sig, | 171 | enum { ecryptfs_opt_sig, ecryptfs_opt_ecryptfs_sig, |
241 | ecryptfs_opt_cipher, ecryptfs_opt_ecryptfs_cipher, | 172 | ecryptfs_opt_cipher, ecryptfs_opt_ecryptfs_cipher, |
242 | ecryptfs_opt_ecryptfs_key_bytes, | 173 | ecryptfs_opt_ecryptfs_key_bytes, |
@@ -704,13 +635,8 @@ static struct ecryptfs_cache_info { | |||
704 | .size = sizeof(struct ecryptfs_sb_info), | 635 | .size = sizeof(struct ecryptfs_sb_info), |
705 | }, | 636 | }, |
706 | { | 637 | { |
707 | .cache = &ecryptfs_header_cache_1, | 638 | .cache = &ecryptfs_header_cache, |
708 | .name = "ecryptfs_headers_1", | 639 | .name = "ecryptfs_headers", |
709 | .size = PAGE_CACHE_SIZE, | ||
710 | }, | ||
711 | { | ||
712 | .cache = &ecryptfs_header_cache_2, | ||
713 | .name = "ecryptfs_headers_2", | ||
714 | .size = PAGE_CACHE_SIZE, | 640 | .size = PAGE_CACHE_SIZE, |
715 | }, | 641 | }, |
716 | { | 642 | { |