mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-27 09:02:06 +00:00
eCryptfs: do not try to open device files on mknod
When creating device nodes, eCryptfs needs to delay actually opening the lower persistent file until an application tries to open. Device handles may not be backed by anything when they first come into existence. [Valdis.Kletnieks@vt.edu: build fix] Signed-off-by: Michael Halcrow <mhalcrow@us.ibm.com> Cc: <Valdis.Kletnieks@vt.edu} Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
0a688ad713
commit
72b55fffd6
4 changed files with 42 additions and 13 deletions
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -193,7 +193,7 @@ 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);
|
||||
|
@ -201,12 +201,21 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry,
|
|||
/* 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue