Commit 50d9fad7 authored by Eric Biggers's avatar Eric Biggers

ubifs: use IS_ENCRYPTED() instead of ubifs_crypt_is_encrypted()

There's no need for the ubifs_crypt_is_encrypted() function anymore.
Just use IS_ENCRYPTED() instead, like ext4 and f2fs do.  IS_ENCRYPTED()
checks the VFS-level flag instead of the UBIFS-specific flag, but it
shouldn't change any behavior since the flags are kept in sync.

Link: https://lore.kernel.org/r/20191209212721.244396-1-ebiggers@kernel.orgAcked-by: default avatarRichard Weinberger <richard@nod.at>
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
parent 2d8f7f11
...@@ -81,7 +81,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir, ...@@ -81,7 +81,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
struct ubifs_inode *ui; struct ubifs_inode *ui;
bool encrypted = false; bool encrypted = false;
if (ubifs_crypt_is_encrypted(dir)) { if (IS_ENCRYPTED(dir)) {
err = fscrypt_get_encryption_info(dir); err = fscrypt_get_encryption_info(dir);
if (err) { if (err) {
ubifs_err(c, "fscrypt_get_encryption_info failed: %i", err); ubifs_err(c, "fscrypt_get_encryption_info failed: %i", err);
...@@ -261,7 +261,7 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -261,7 +261,7 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry,
goto done; goto done;
} }
if (ubifs_crypt_is_encrypted(dir) && if (IS_ENCRYPTED(dir) &&
(S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) && (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
!fscrypt_has_permitted_context(dir, inode)) { !fscrypt_has_permitted_context(dir, inode)) {
ubifs_warn(c, "Inconsistent encryption contexts: %lu/%lu", ubifs_warn(c, "Inconsistent encryption contexts: %lu/%lu",
...@@ -499,7 +499,7 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx) ...@@ -499,7 +499,7 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx)
struct ubifs_dent_node *dent; struct ubifs_dent_node *dent;
struct inode *dir = file_inode(file); struct inode *dir = file_inode(file);
struct ubifs_info *c = dir->i_sb->s_fs_info; struct ubifs_info *c = dir->i_sb->s_fs_info;
bool encrypted = ubifs_crypt_is_encrypted(dir); bool encrypted = IS_ENCRYPTED(dir);
dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, ctx->pos); dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, ctx->pos);
...@@ -1618,7 +1618,7 @@ int ubifs_getattr(const struct path *path, struct kstat *stat, ...@@ -1618,7 +1618,7 @@ int ubifs_getattr(const struct path *path, struct kstat *stat,
static int ubifs_dir_open(struct inode *dir, struct file *file) static int ubifs_dir_open(struct inode *dir, struct file *file)
{ {
if (ubifs_crypt_is_encrypted(dir)) if (IS_ENCRYPTED(dir))
return fscrypt_get_encryption_info(dir) ? -EACCES : 0; return fscrypt_get_encryption_info(dir) ? -EACCES : 0;
return 0; return 0;
......
...@@ -67,7 +67,7 @@ static int read_block(struct inode *inode, void *addr, unsigned int block, ...@@ -67,7 +67,7 @@ static int read_block(struct inode *inode, void *addr, unsigned int block,
dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ; dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
if (ubifs_crypt_is_encrypted(inode)) { if (IS_ENCRYPTED(inode)) {
err = ubifs_decrypt(inode, dn, &dlen, block); err = ubifs_decrypt(inode, dn, &dlen, block);
if (err) if (err)
goto dump; goto dump;
...@@ -647,7 +647,7 @@ static int populate_page(struct ubifs_info *c, struct page *page, ...@@ -647,7 +647,7 @@ static int populate_page(struct ubifs_info *c, struct page *page,
dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ; dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
out_len = UBIFS_BLOCK_SIZE; out_len = UBIFS_BLOCK_SIZE;
if (ubifs_crypt_is_encrypted(inode)) { if (IS_ENCRYPTED(inode)) {
err = ubifs_decrypt(inode, dn, &dlen, page_block); err = ubifs_decrypt(inode, dn, &dlen, page_block);
if (err) if (err)
goto out_err; goto out_err;
......
...@@ -727,7 +727,7 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode, ...@@ -727,7 +727,7 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode,
int dlen = COMPRESSED_DATA_NODE_BUF_SZ, allocated = 1; int dlen = COMPRESSED_DATA_NODE_BUF_SZ, allocated = 1;
int write_len; int write_len;
struct ubifs_inode *ui = ubifs_inode(inode); struct ubifs_inode *ui = ubifs_inode(inode);
bool encrypted = ubifs_crypt_is_encrypted(inode); bool encrypted = IS_ENCRYPTED(inode);
u8 hash[UBIFS_HASH_ARR_SZ]; u8 hash[UBIFS_HASH_ARR_SZ];
dbg_jnlk(key, "ino %lu, blk %u, len %d, key ", dbg_jnlk(key, "ino %lu, blk %u, len %d, key ",
...@@ -1449,7 +1449,7 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in ...@@ -1449,7 +1449,7 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in
dlen = old_dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ; dlen = old_dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
compr_type = le16_to_cpu(dn->compr_type); compr_type = le16_to_cpu(dn->compr_type);
if (ubifs_crypt_is_encrypted(inode)) { if (IS_ENCRYPTED(inode)) {
err = ubifs_decrypt(inode, dn, &dlen, block); err = ubifs_decrypt(inode, dn, &dlen, block);
if (err) if (err)
goto out; goto out;
...@@ -1465,7 +1465,7 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in ...@@ -1465,7 +1465,7 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in
ubifs_compress(c, buf, *new_len, &dn->data, &out_len, &compr_type); ubifs_compress(c, buf, *new_len, &dn->data, &out_len, &compr_type);
} }
if (ubifs_crypt_is_encrypted(inode)) { if (IS_ENCRYPTED(inode)) {
err = ubifs_encrypt(inode, dn, out_len, &old_dlen, block); err = ubifs_encrypt(inode, dn, out_len, &old_dlen, block);
if (err) if (err)
goto out; goto out;
......
...@@ -2095,13 +2095,6 @@ int ubifs_decrypt(const struct inode *inode, struct ubifs_data_node *dn, ...@@ -2095,13 +2095,6 @@ int ubifs_decrypt(const struct inode *inode, struct ubifs_data_node *dn,
extern const struct fscrypt_operations ubifs_crypt_operations; extern const struct fscrypt_operations ubifs_crypt_operations;
static inline bool ubifs_crypt_is_encrypted(const struct inode *inode)
{
const struct ubifs_inode *ui = ubifs_inode(inode);
return ui->flags & UBIFS_CRYPT_FL;
}
/* Normal UBIFS messages */ /* Normal UBIFS messages */
__printf(2, 3) __printf(2, 3)
void ubifs_msg(const struct ubifs_info *c, const char *fmt, ...); void ubifs_msg(const struct ubifs_info *c, const char *fmt, ...);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment