Ejemplo n.º 1
0
/**
 * ecryptfs_interpose
 * @lower_dentry: Existing dentry in the lower filesystem
 * @dentry: ecryptfs' dentry
 * @sb: ecryptfs's super_block
 *
 * Interposes upper and lower dentries.
 *
 * Returns zero on success; non-zero otherwise
 */
static int ecryptfs_interpose(struct dentry *lower_dentry,
			      struct dentry *dentry, struct super_block *sb)
{
	struct inode *inode = ecryptfs_get_inode(lower_dentry->d_inode, sb);

	if (IS_ERR(inode))
		return PTR_ERR(inode);
	d_instantiate(dentry, inode);

	return 0;
}
Ejemplo n.º 2
0
/**
 * ecryptfs_interpose
 * @lower_dentry: Existing dentry in the lower filesystem
 * @dentry: ecryptfs' dentry
 * @sb: ecryptfs's super_block
 *
 * Interposes upper and lower dentries.
 *
 * Returns zero on success; non-zero otherwise
 */
static int ecryptfs_interpose(struct dentry *lower_dentry,
			      struct dentry *dentry, struct super_block *sb)
{
	struct inode *inode = ecryptfs_get_inode(lower_dentry->d_inode, sb);

	if (IS_ERR(inode))
		return PTR_ERR(inode);

	d_instantiate(dentry, inode);
	if(d_unhashed(dentry))
		d_rehash(dentry);

#ifdef CONFIG_SDP
	if(S_ISDIR(inode->i_mode) && dentry) {
		if(IS_UNDER_ROOT(dentry)) {
			struct ecryptfs_mount_crypt_stat *mount_crypt_stat  =
					&ecryptfs_superblock_to_private(inode->i_sb)->mount_crypt_stat;
			int engineid;
			printk("Creating a directoy under root directory of current partition.\n");

			if(is_chamber_directory(mount_crypt_stat, dentry->d_name.name, &engineid)) {
				printk("This is a chamber directory engine[%d]\n", engineid);
				set_chamber_flag(engineid, inode);
			}
		} else if(IS_SENSITIVE_DENTRY(dentry->d_parent)) {
			/*
			 * When parent directory is sensitive
			 */
			struct ecryptfs_crypt_stat *crypt_stat =
					&ecryptfs_inode_to_private(inode)->crypt_stat;
			struct ecryptfs_crypt_stat *parent_crypt_stat =
					&ecryptfs_inode_to_private(dentry->d_parent->d_inode)->crypt_stat;

			//TODO : remove this log
			DEK_LOGE("Parent %s[id:%d] is sensitive. so this directory is sensitive too\n",
					dentry->d_parent->d_name.name, parent_crypt_stat->engine_id);
			crypt_stat->flags |= ECRYPTFS_DEK_IS_SENSITIVE;
			crypt_stat->engine_id = parent_crypt_stat->engine_id;
		}
	}
#endif

	return 0;
}
Ejemplo n.º 3
0
/**
 * ecryptfs_interpose
 * @lower_dentry: Existing dentry in the lower filesystem
 * @dentry: ecryptfs' dentry
 * @sb: ecryptfs's super_block
 *
 * Interposes upper and lower dentries.
 *
 * Returns zero on success; non-zero otherwise
 */
static int ecryptfs_interpose(struct dentry *lower_dentry,
			      struct dentry *dentry, struct super_block *sb)
{
	struct inode *inode = ecryptfs_get_inode(lower_dentry->d_inode, sb);

	if (IS_ERR(inode))
		return PTR_ERR(inode);
	d_instantiate(dentry, inode);

#ifdef CONFIG_SDP
	if(S_ISDIR(inode->i_mode) && dentry) {
	    if(IS_UNDER_ROOT(dentry)) {
	        struct ecryptfs_mount_crypt_stat *mount_crypt_stat  =
	                &ecryptfs_superblock_to_private(inode->i_sb)->mount_crypt_stat;
	        printk("Creating a directoy under root directory of current partition.\n");

	        if(is_chamber_directory(mount_crypt_stat, (char *)dentry->d_name.name)) {
	            printk("This is a chamber directory\n");
	            set_chamber_flag(inode);
	        }
	    } else if(IS_SENSITIVE_DENTRY(dentry->d_parent)) {
	        /*
	         * When parent directory is sensitive
	         */
	        struct ecryptfs_crypt_stat *crypt_stat =
	                &ecryptfs_inode_to_private(inode)->crypt_stat;

	        printk("Parent %s is sensitive. so this directory is sensitive too\n",
	                dentry->d_parent->d_name.name);
	        crypt_stat->flags |= ECRYPTFS_DEK_IS_SENSITIVE;
	    }
	}
#endif

	return 0;
}