Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72d457d3 authored by Chandan Rajendra's avatar Chandan Rajendra Committed by Jaegeuk Kim
Browse files

ext4: use IS_ENCRYPTED() to check encryption status



This commit removes the ext4 specific ext4_encrypted_inode() and makes
use of the generic IS_ENCRYPTED() macro to check for the encryption
status of an inode.

Reviewed-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarChandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
parent 94e1068e
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
	int dir_has_error = 0;
	struct fscrypt_str fstr = FSTR_INIT(NULL, 0);

	if (ext4_encrypted_inode(inode)) {
	if (IS_ENCRYPTED(inode)) {
		err = fscrypt_get_encryption_info(inode);
		if (err && err != -ENOKEY)
			return err;
@@ -138,7 +138,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
			return err;
	}

	if (ext4_encrypted_inode(inode)) {
	if (IS_ENCRYPTED(inode)) {
		err = fscrypt_fname_alloc_buffer(inode, EXT4_NAME_LEN, &fstr);
		if (err < 0)
			return err;
@@ -245,7 +245,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
			offset += ext4_rec_len_from_disk(de->rec_len,
					sb->s_blocksize);
			if (le32_to_cpu(de->inode)) {
				if (!ext4_encrypted_inode(inode)) {
				if (!IS_ENCRYPTED(inode)) {
					if (!dir_emit(ctx, de->name,
					    de->name_len,
					    le32_to_cpu(de->inode),
@@ -613,7 +613,7 @@ static int ext4_dx_readdir(struct file *file, struct dir_context *ctx)

static int ext4_dir_open(struct inode * inode, struct file * filp)
{
	if (ext4_encrypted_inode(inode))
	if (IS_ENCRYPTED(inode))
		return fscrypt_get_encryption_info(inode) ? -EACCES : 0;
	return 0;
}
+0 −5
Original line number Diff line number Diff line
@@ -2283,11 +2283,6 @@ extern unsigned ext4_free_clusters_after_init(struct super_block *sb,
					      struct ext4_group_desc *gdp);
ext4_fsblk_t ext4_inode_to_goal_block(struct inode *);

static inline bool ext4_encrypted_inode(struct inode *inode)
{
	return ext4_test_inode_flag(inode, EXT4_INODE_ENCRYPT);
}

#ifdef CONFIG_EXT4_FS_ENCRYPTION
static inline int ext4_fname_setup_filename(struct inode *dir,
			const struct qstr *iname,
+1 −1
Original line number Diff line number Diff line
@@ -411,7 +411,7 @@ static inline int ext4_inode_journal_mode(struct inode *inode)
	    (ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA) &&
	    !test_opt(inode->i_sb, DELALLOC))) {
		/* We do not support data journalling for encrypted data */
		if (S_ISREG(inode->i_mode) && ext4_encrypted_inode(inode))
		if (S_ISREG(inode->i_mode) && IS_ENCRYPTED(inode))
			return EXT4_INODE_ORDERED_DATA_MODE;  /* ordered */
		return EXT4_INODE_JOURNAL_DATA_MODE;	/* journal data */
	}
+2 −2
Original line number Diff line number Diff line
@@ -3569,7 +3569,7 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
		max_zeroout = sbi->s_extent_max_zeroout_kb >>
			(inode->i_sb->s_blocksize_bits - 10);

	if (ext4_encrypted_inode(inode))
	if (IS_ENCRYPTED(inode))
		max_zeroout = 0;

	/*
@@ -4919,7 +4919,7 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
	 * leave it disabled for encrypted inodes for now.  This is a
	 * bug we should fix....
	 */
	if (ext4_encrypted_inode(inode) &&
	if (IS_ENCRYPTED(inode) &&
	    (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE |
		     FALLOC_FL_ZERO_RANGE)))
		return -EOPNOTSUPP;
+1 −1
Original line number Diff line number Diff line
@@ -771,7 +771,7 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
	if (unlikely(ext4_forced_shutdown(sbi)))
		return ERR_PTR(-EIO);

	if ((ext4_encrypted_inode(dir) || DUMMY_ENCRYPTION_ENABLED(sbi)) &&
	if ((IS_ENCRYPTED(dir) || DUMMY_ENCRYPTION_ENABLED(sbi)) &&
	    (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) &&
	    !(i_flags & EXT4_EA_INODE_FL)) {
		err = fscrypt_get_encryption_info(dir);
Loading