diff options
Diffstat (limited to 'fs/ecryptfs/main.c')
-rw-r--r-- | fs/ecryptfs/main.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index 10475d93ff53..ee4f84b20410 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
@@ -117,7 +117,7 @@ void __ecryptfs_printk(const char *fmt, ...) | |||
117 | * | 117 | * |
118 | * Returns zero on success; non-zero otherwise | 118 | * Returns zero on success; non-zero otherwise |
119 | */ | 119 | */ |
120 | static int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) | 120 | int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) |
121 | { | 121 | { |
122 | struct ecryptfs_inode_info *inode_info = | 122 | struct ecryptfs_inode_info *inode_info = |
123 | ecryptfs_inode_to_private(ecryptfs_dentry->d_inode); | 123 | ecryptfs_inode_to_private(ecryptfs_dentry->d_inode); |
@@ -149,14 +149,14 @@ static int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) | |||
149 | * @lower_dentry: Existing dentry in the lower filesystem | 149 | * @lower_dentry: Existing dentry in the lower filesystem |
150 | * @dentry: ecryptfs' dentry | 150 | * @dentry: ecryptfs' dentry |
151 | * @sb: ecryptfs's super_block | 151 | * @sb: ecryptfs's super_block |
152 | * @flag: If set to true, then d_add is called, else d_instantiate is called | 152 | * @flags: flags to govern behavior of interpose procedure |
153 | * | 153 | * |
154 | * Interposes upper and lower dentries. | 154 | * Interposes upper and lower dentries. |
155 | * | 155 | * |
156 | * Returns zero on success; non-zero otherwise | 156 | * Returns zero on success; non-zero otherwise |
157 | */ | 157 | */ |
158 | int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry, | 158 | int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry, |
159 | struct super_block *sb, int flag) | 159 | struct super_block *sb, u32 flags) |
160 | { | 160 | { |
161 | struct inode *lower_inode; | 161 | struct inode *lower_inode; |
162 | struct inode *inode; | 162 | struct inode *inode; |
@@ -193,7 +193,7 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry, | |||
193 | init_special_inode(inode, lower_inode->i_mode, | 193 | init_special_inode(inode, lower_inode->i_mode, |
194 | lower_inode->i_rdev); | 194 | lower_inode->i_rdev); |
195 | dentry->d_op = &ecryptfs_dops; | 195 | dentry->d_op = &ecryptfs_dops; |
196 | if (flag) | 196 | if (flags & ECRYPTFS_INTERPOSE_FLAG_D_ADD) |
197 | d_add(dentry, inode); | 197 | d_add(dentry, inode); |
198 | else | 198 | else |
199 | d_instantiate(dentry, inode); | 199 | d_instantiate(dentry, inode); |
@@ -201,12 +201,21 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry, | |||
201 | /* This size will be overwritten for real files w/ headers and | 201 | /* This size will be overwritten for real files w/ headers and |
202 | * other metadata */ | 202 | * other metadata */ |
203 | fsstack_copy_inode_size(inode, lower_inode); | 203 | fsstack_copy_inode_size(inode, lower_inode); |
204 | rc = ecryptfs_init_persistent_file(dentry); | 204 | if (!(flags & ECRYPTFS_INTERPOSE_FLAG_DELAY_PERSISTENT_FILE)) { |
205 | if (rc) { | 205 | rc = ecryptfs_init_persistent_file(dentry); |
206 | printk(KERN_ERR "%s: Error attempting to initialize the " | 206 | if (rc) { |
207 | "persistent file for the dentry with name [%s]; " | 207 | printk(KERN_ERR "%s: Error attempting to initialize " |
208 | "rc = [%d]\n", __func__, dentry->d_name.name, rc); | 208 | "the persistent file for the dentry with name " |
209 | goto out; | 209 | "[%s]; rc = [%d]\n", __func__, |
210 | dentry->d_name.name, rc); | ||
211 | goto out; | ||
212 | } | ||
213 | } else { | ||
214 | struct ecryptfs_inode_info *inode_info = | ||
215 | ecryptfs_inode_to_private(dentry->d_inode); | ||
216 | |||
217 | inode_info->lower_file = NULL; | ||
218 | inode_info->crypt_stat.flags |= ECRYPTFS_DELAY_PERSISTENT; | ||
210 | } | 219 | } |
211 | out: | 220 | out: |
212 | return rc; | 221 | return rc; |