diff options
author | Tyler Hicks <tyhicks@linux.vnet.ibm.com> | 2011-05-23 22:18:20 -0400 |
---|---|---|
committer | Tyler Hicks <tyhicks@linux.vnet.ibm.com> | 2011-05-29 13:49:53 -0400 |
commit | c4f790736ca8d7d86883c5aee2ba1caa15cd8da3 (patch) | |
tree | 827e371fb2aff1e9290fbd90ca436d069aaa356d /fs/ecryptfs/main.c | |
parent | 139f37f5e14cd883eee2a8a36289f544b5390a44 (diff) |
eCryptfs: Consolidate inode functions into inode.c
These functions should live in inode.c since their focus is on inodes
and they're primarily used by functions in inode.c.
Also does a simple cleanup of ecryptfs_inode_test() and rolls
ecryptfs_init_inode() into ecryptfs_inode_set().
Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
Tested-by: David <david@unsolicited.net>
Diffstat (limited to 'fs/ecryptfs/main.c')
-rw-r--r-- | fs/ecryptfs/main.c | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index 89b93389af8e..7c697abab396 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
@@ -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, |