Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105453
b: refs/heads/master
c: 72b55ff
h: refs/heads/master
i:
  105451: 9a6111b
v: v3
  • Loading branch information
Michael Halcrow authored and Linus Torvalds committed Jul 24, 2008
1 parent c4db352 commit a8cc788
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0a688ad713949643e201431d3f4a4ceddfeb70ca
refs/heads/master: 72b55fffd631a89e5be6fe1b4f2565bc4cd90deb
6 changes: 5 additions & 1 deletion trunk/fs/ecryptfs/ecryptfs_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ struct ecryptfs_crypt_stat {
#define ECRYPTFS_METADATA_IN_XATTR 0x00000100
#define ECRYPTFS_VIEW_AS_ENCRYPTED 0x00000200
#define ECRYPTFS_KEY_SET 0x00000400
#define ECRYPTFS_DELAY_PERSISTENT 0x00000800
u32 flags;
unsigned int file_version;
size_t iv_bytes;
Expand Down Expand Up @@ -574,9 +575,11 @@ struct ecryptfs_open_req {
struct list_head kthread_ctl_list;
};

#define ECRYPTFS_INTERPOSE_FLAG_D_ADD 0x00000001
#define ECRYPTFS_INTERPOSE_FLAG_DELAY_PERSISTENT_FILE 0x00000002
int ecryptfs_interpose(struct dentry *hidden_dentry,
struct dentry *this_dentry, struct super_block *sb,
int flag);
u32 flags);
int ecryptfs_fill_zeros(struct file *file, loff_t new_length);
int ecryptfs_decode_filename(struct ecryptfs_crypt_stat *crypt_stat,
const char *name, int length,
Expand Down Expand Up @@ -709,5 +712,6 @@ void ecryptfs_destroy_kthread(void);
int ecryptfs_privileged_open(struct file **lower_file,
struct dentry *lower_dentry,
struct vfsmount *lower_mnt);
int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry);

#endif /* #ifndef ECRYPTFS_KERNEL_H */
14 changes: 14 additions & 0 deletions trunk/fs/ecryptfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,20 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
"file must hence be opened RO\n", __func__);
goto out;
}
if (!ecryptfs_inode_to_private(inode)->lower_file) {
BUG_ON(!(crypt_stat->flags & ECRYPTFS_DELAY_PERSISTENT));
mutex_lock(&crypt_stat->cs_mutex);
crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
mutex_unlock(&crypt_stat->cs_mutex);
rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
if (rc) {
printk(KERN_ERR "%s: Error attempting to initialize "
"the persistent file for the dentry with name "
"[%s]; rc = [%d]\n", __func__,
ecryptfs_dentry->d_name.name, rc);
goto out;
}
}
ecryptfs_set_file_lower(
file, ecryptfs_inode_to_private(inode)->lower_file);
if (S_ISDIR(ecryptfs_dentry->d_inode->i_mode)) {
Expand Down
6 changes: 4 additions & 2 deletions trunk/fs/ecryptfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
d_add(dentry, NULL);
goto out;
}
rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 1);
rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb,
ECRYPTFS_INTERPOSE_FLAG_D_ADD);
if (rc) {
ecryptfs_printk(KERN_ERR, "Error interposing\n");
goto out_dput;
Expand Down Expand Up @@ -537,7 +538,8 @@ ecryptfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
rc = vfs_mknod(lower_dir_dentry->d_inode, lower_dentry, mode, dev);
if (rc || !lower_dentry->d_inode)
goto out;
rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb,
ECRYPTFS_INTERPOSE_FLAG_DELAY_PERSISTENT_FILE);
if (rc)
goto out;
fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
Expand Down
29 changes: 19 additions & 10 deletions trunk/fs/ecryptfs/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void __ecryptfs_printk(const char *fmt, ...)
*
* Returns zero on success; non-zero otherwise
*/
static int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry)
int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry)
{
struct ecryptfs_inode_info *inode_info =
ecryptfs_inode_to_private(ecryptfs_dentry->d_inode);
Expand Down Expand Up @@ -149,14 +149,14 @@ static int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry)
* @lower_dentry: Existing dentry in the lower filesystem
* @dentry: ecryptfs' dentry
* @sb: ecryptfs's super_block
* @flag: If set to true, then d_add is called, else d_instantiate is called
* @flags: flags to govern behavior of interpose procedure
*
* Interposes upper and lower dentries.
*
* Returns zero on success; non-zero otherwise
*/
int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry,
struct super_block *sb, int flag)
struct super_block *sb, u32 flags)
{
struct inode *lower_inode;
struct inode *inode;
Expand Down Expand Up @@ -193,20 +193,29 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry,
init_special_inode(inode, lower_inode->i_mode,
lower_inode->i_rdev);
dentry->d_op = &ecryptfs_dops;
if (flag)
if (flags & ECRYPTFS_INTERPOSE_FLAG_D_ADD)
d_add(dentry, inode);
else
d_instantiate(dentry, inode);
fsstack_copy_attr_all(inode, lower_inode, NULL);
/* This size will be overwritten for real files w/ headers and
* other metadata */
fsstack_copy_inode_size(inode, lower_inode);
rc = ecryptfs_init_persistent_file(dentry);
if (rc) {
printk(KERN_ERR "%s: Error attempting to initialize the "
"persistent file for the dentry with name [%s]; "
"rc = [%d]\n", __func__, dentry->d_name.name, rc);
goto out;
if (!(flags & ECRYPTFS_INTERPOSE_FLAG_DELAY_PERSISTENT_FILE)) {
rc = ecryptfs_init_persistent_file(dentry);
if (rc) {
printk(KERN_ERR "%s: Error attempting to initialize "
"the persistent file for the dentry with name "
"[%s]; rc = [%d]\n", __func__,
dentry->d_name.name, rc);
goto out;
}
} else {
struct ecryptfs_inode_info *inode_info =
ecryptfs_inode_to_private(dentry->d_inode);

inode_info->lower_file = NULL;
inode_info->crypt_stat.flags |= ECRYPTFS_DELAY_PERSISTENT;
}
out:
return rc;
Expand Down

0 comments on commit a8cc788

Please sign in to comment.