aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2017-10-09 15:15:36 -0400
committerTheodore Ts'o <tytso@mit.edu>2017-10-18 19:52:36 -0400
commite0428a266d5a29a3c2eec287fcd49be9e8e2468e (patch)
tree0ecedc8aa9793db447da6abdb31506229f582a50
parent2ee6a576be56427209d370d8a511d49340c84139 (diff)
fscrypt: switch from ->is_encrypted() to IS_ENCRYPTED()
IS_ENCRYPTED() now gives the same information as i_sb->s_cop->is_encrypted() but is more efficient, since IS_ENCRYPTED() is just a simple flag check. Prepare to remove ->is_encrypted() by switching all callers to IS_ENCRYPTED(). Acked-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--fs/crypto/crypto.c2
-rw-r--r--fs/crypto/fname.c3
-rw-r--r--fs/crypto/keyinfo.c2
-rw-r--r--fs/crypto/policy.c6
-rw-r--r--include/linux/fscrypt_notsupp.h2
5 files changed, 7 insertions, 8 deletions
diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index c7835df7e7b8..608f6bbe0f31 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -340,7 +340,7 @@ static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags)
340 return -ECHILD; 340 return -ECHILD;
341 341
342 dir = dget_parent(dentry); 342 dir = dget_parent(dentry);
343 if (!d_inode(dir)->i_sb->s_cop->is_encrypted(d_inode(dir))) { 343 if (!IS_ENCRYPTED(d_inode(dir))) {
344 dput(dir); 344 dput(dir);
345 return 0; 345 return 0;
346 } 346 }
diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c
index ad9f814fdead..2878289b3ed2 100644
--- a/fs/crypto/fname.c
+++ b/fs/crypto/fname.c
@@ -382,8 +382,7 @@ int fscrypt_setup_filename(struct inode *dir, const struct qstr *iname,
382 memset(fname, 0, sizeof(struct fscrypt_name)); 382 memset(fname, 0, sizeof(struct fscrypt_name));
383 fname->usr_fname = iname; 383 fname->usr_fname = iname;
384 384
385 if (!dir->i_sb->s_cop->is_encrypted(dir) || 385 if (!IS_ENCRYPTED(dir) || fscrypt_is_dot_dotdot(iname)) {
386 fscrypt_is_dot_dotdot(iname)) {
387 fname->disk_name.name = (unsigned char *)iname->name; 386 fname->disk_name.name = (unsigned char *)iname->name;
388 fname->disk_name.len = iname->len; 387 fname->disk_name.len = iname->len;
389 return 0; 388 return 0;
diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
index 018c588c7ac3..236a68d4ea72 100644
--- a/fs/crypto/keyinfo.c
+++ b/fs/crypto/keyinfo.c
@@ -268,7 +268,7 @@ int fscrypt_get_encryption_info(struct inode *inode)
268 res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx)); 268 res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
269 if (res < 0) { 269 if (res < 0) {
270 if (!fscrypt_dummy_context_enabled(inode) || 270 if (!fscrypt_dummy_context_enabled(inode) ||
271 inode->i_sb->s_cop->is_encrypted(inode)) 271 IS_ENCRYPTED(inode))
272 return res; 272 return res;
273 /* Fake up a context for an unencrypted directory */ 273 /* Fake up a context for an unencrypted directory */
274 memset(&ctx, 0, sizeof(ctx)); 274 memset(&ctx, 0, sizeof(ctx));
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index ce07a86200f3..6a63b8a0d46c 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -109,7 +109,7 @@ int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
109 struct fscrypt_policy policy; 109 struct fscrypt_policy policy;
110 int res; 110 int res;
111 111
112 if (!inode->i_sb->s_cop->is_encrypted(inode)) 112 if (!IS_ENCRYPTED(inode))
113 return -ENODATA; 113 return -ENODATA;
114 114
115 res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx)); 115 res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
@@ -166,11 +166,11 @@ int fscrypt_has_permitted_context(struct inode *parent, struct inode *child)
166 return 1; 166 return 1;
167 167
168 /* No restrictions if the parent directory is unencrypted */ 168 /* No restrictions if the parent directory is unencrypted */
169 if (!cops->is_encrypted(parent)) 169 if (!IS_ENCRYPTED(parent))
170 return 1; 170 return 1;
171 171
172 /* Encrypted directories must not contain unencrypted files */ 172 /* Encrypted directories must not contain unencrypted files */
173 if (!cops->is_encrypted(child)) 173 if (!IS_ENCRYPTED(child))
174 return 0; 174 return 0;
175 175
176 /* 176 /*
diff --git a/include/linux/fscrypt_notsupp.h b/include/linux/fscrypt_notsupp.h
index 2d0b6960831e..7b390e356f7f 100644
--- a/include/linux/fscrypt_notsupp.h
+++ b/include/linux/fscrypt_notsupp.h
@@ -100,7 +100,7 @@ static inline int fscrypt_setup_filename(struct inode *dir,
100 const struct qstr *iname, 100 const struct qstr *iname,
101 int lookup, struct fscrypt_name *fname) 101 int lookup, struct fscrypt_name *fname)
102{ 102{
103 if (dir->i_sb->s_cop->is_encrypted(dir)) 103 if (IS_ENCRYPTED(dir))
104 return -EOPNOTSUPP; 104 return -EOPNOTSUPP;
105 105
106 memset(fname, 0, sizeof(struct fscrypt_name)); 106 memset(fname, 0, sizeof(struct fscrypt_name));