Skip to content

Commit 50d9fad

Browse files
committed
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/[email protected] Acked-by: Richard Weinberger <[email protected]> Signed-off-by: Eric Biggers <[email protected]>
1 parent 2d8f7f1 commit 50d9fad

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

fs/ubifs/dir.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
8181
struct ubifs_inode *ui;
8282
bool encrypted = false;
8383

84-
if (ubifs_crypt_is_encrypted(dir)) {
84+
if (IS_ENCRYPTED(dir)) {
8585
err = fscrypt_get_encryption_info(dir);
8686
if (err) {
8787
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,
261261
goto done;
262262
}
263263

264-
if (ubifs_crypt_is_encrypted(dir) &&
264+
if (IS_ENCRYPTED(dir) &&
265265
(S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
266266
!fscrypt_has_permitted_context(dir, inode)) {
267267
ubifs_warn(c, "Inconsistent encryption contexts: %lu/%lu",
@@ -499,7 +499,7 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx)
499499
struct ubifs_dent_node *dent;
500500
struct inode *dir = file_inode(file);
501501
struct ubifs_info *c = dir->i_sb->s_fs_info;
502-
bool encrypted = ubifs_crypt_is_encrypted(dir);
502+
bool encrypted = IS_ENCRYPTED(dir);
503503

504504
dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, ctx->pos);
505505

@@ -1618,7 +1618,7 @@ int ubifs_getattr(const struct path *path, struct kstat *stat,
16181618

16191619
static int ubifs_dir_open(struct inode *dir, struct file *file)
16201620
{
1621-
if (ubifs_crypt_is_encrypted(dir))
1621+
if (IS_ENCRYPTED(dir))
16221622
return fscrypt_get_encryption_info(dir) ? -EACCES : 0;
16231623

16241624
return 0;

fs/ubifs/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static int read_block(struct inode *inode, void *addr, unsigned int block,
6767

6868
dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
6969

70-
if (ubifs_crypt_is_encrypted(inode)) {
70+
if (IS_ENCRYPTED(inode)) {
7171
err = ubifs_decrypt(inode, dn, &dlen, block);
7272
if (err)
7373
goto dump;
@@ -647,7 +647,7 @@ static int populate_page(struct ubifs_info *c, struct page *page,
647647
dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
648648
out_len = UBIFS_BLOCK_SIZE;
649649

650-
if (ubifs_crypt_is_encrypted(inode)) {
650+
if (IS_ENCRYPTED(inode)) {
651651
err = ubifs_decrypt(inode, dn, &dlen, page_block);
652652
if (err)
653653
goto out_err;

fs/ubifs/journal.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode,
727727
int dlen = COMPRESSED_DATA_NODE_BUF_SZ, allocated = 1;
728728
int write_len;
729729
struct ubifs_inode *ui = ubifs_inode(inode);
730-
bool encrypted = ubifs_crypt_is_encrypted(inode);
730+
bool encrypted = IS_ENCRYPTED(inode);
731731
u8 hash[UBIFS_HASH_ARR_SZ];
732732

733733
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
14491449
dlen = old_dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
14501450
compr_type = le16_to_cpu(dn->compr_type);
14511451

1452-
if (ubifs_crypt_is_encrypted(inode)) {
1452+
if (IS_ENCRYPTED(inode)) {
14531453
err = ubifs_decrypt(inode, dn, &dlen, block);
14541454
if (err)
14551455
goto out;
@@ -1465,7 +1465,7 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in
14651465
ubifs_compress(c, buf, *new_len, &dn->data, &out_len, &compr_type);
14661466
}
14671467

1468-
if (ubifs_crypt_is_encrypted(inode)) {
1468+
if (IS_ENCRYPTED(inode)) {
14691469
err = ubifs_encrypt(inode, dn, out_len, &old_dlen, block);
14701470
if (err)
14711471
goto out;

fs/ubifs/ubifs.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,13 +2095,6 @@ int ubifs_decrypt(const struct inode *inode, struct ubifs_data_node *dn,
20952095

20962096
extern const struct fscrypt_operations ubifs_crypt_operations;
20972097

2098-
static inline bool ubifs_crypt_is_encrypted(const struct inode *inode)
2099-
{
2100-
const struct ubifs_inode *ui = ubifs_inode(inode);
2101-
2102-
return ui->flags & UBIFS_CRYPT_FL;
2103-
}
2104-
21052098
/* Normal UBIFS messages */
21062099
__printf(2, 3)
21072100
void ubifs_msg(const struct ubifs_info *c, const char *fmt, ...);

0 commit comments

Comments
 (0)