aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/file.c
diff options
context:
space:
mode:
authorMichael Halcrow <mhalcrow@us.ibm.com>2007-02-12 03:53:49 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-12 12:48:37 -0500
commite2bd99ec5c0e20ed6aeb079fa8f975c2dcd78a2c (patch)
tree78892d49cf55fa4cf22ce9b8b226c63bac8b227c /fs/ecryptfs/file.c
parent9d8b8ce5561890464c54645cdea4d6b157159fec (diff)
[PATCH] eCryptfs: open-code flag checking and manipulation
Open-code flag checking and manipulation. Signed-off-by: Michael Halcrow <mhalcrow@us.ibm.com> Signed-off-by: Trevor Highland <tshighla@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ecryptfs/file.c')
-rw-r--r--fs/ecryptfs/file.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index 652ed772a9be..bd969adf70d7 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -273,11 +273,11 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
273 lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry); 273 lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry);
274 crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat; 274 crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat;
275 mutex_lock(&crypt_stat->cs_mutex); 275 mutex_lock(&crypt_stat->cs_mutex);
276 if (!ECRYPTFS_CHECK_FLAG(crypt_stat->flags, ECRYPTFS_POLICY_APPLIED)) { 276 if (!(crypt_stat->flags & ECRYPTFS_POLICY_APPLIED)) {
277 ecryptfs_printk(KERN_DEBUG, "Setting flags for stat...\n"); 277 ecryptfs_printk(KERN_DEBUG, "Setting flags for stat...\n");
278 /* Policy code enabled in future release */ 278 /* Policy code enabled in future release */
279 ECRYPTFS_SET_FLAG(crypt_stat->flags, ECRYPTFS_POLICY_APPLIED); 279 crypt_stat->flags |= ECRYPTFS_POLICY_APPLIED;
280 ECRYPTFS_SET_FLAG(crypt_stat->flags, ECRYPTFS_ENCRYPTED); 280 crypt_stat->flags |= ECRYPTFS_ENCRYPTED;
281 } 281 }
282 mutex_unlock(&crypt_stat->cs_mutex); 282 mutex_unlock(&crypt_stat->cs_mutex);
283 lower_flags = file->f_flags; 283 lower_flags = file->f_flags;
@@ -297,15 +297,13 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
297 lower_inode = lower_dentry->d_inode; 297 lower_inode = lower_dentry->d_inode;
298 if (S_ISDIR(ecryptfs_dentry->d_inode->i_mode)) { 298 if (S_ISDIR(ecryptfs_dentry->d_inode->i_mode)) {
299 ecryptfs_printk(KERN_DEBUG, "This is a directory\n"); 299 ecryptfs_printk(KERN_DEBUG, "This is a directory\n");
300 ECRYPTFS_CLEAR_FLAG(crypt_stat->flags, ECRYPTFS_ENCRYPTED); 300 crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
301 rc = 0; 301 rc = 0;
302 goto out; 302 goto out;
303 } 303 }
304 mutex_lock(&crypt_stat->cs_mutex); 304 mutex_lock(&crypt_stat->cs_mutex);
305 if (!ECRYPTFS_CHECK_FLAG(crypt_stat->flags, 305 if (!(crypt_stat->flags & ECRYPTFS_POLICY_APPLIED)
306 ECRYPTFS_POLICY_APPLIED) 306 || !(crypt_stat->flags & ECRYPTFS_KEY_VALID)) {
307 || !ECRYPTFS_CHECK_FLAG(crypt_stat->flags,
308 ECRYPTFS_KEY_VALID)) {
309 rc = ecryptfs_read_metadata(ecryptfs_dentry, lower_file); 307 rc = ecryptfs_read_metadata(ecryptfs_dentry, lower_file);
310 if (rc) { 308 if (rc) {
311 ecryptfs_printk(KERN_DEBUG, 309 ecryptfs_printk(KERN_DEBUG,
@@ -320,9 +318,8 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
320 mutex_unlock(&crypt_stat->cs_mutex); 318 mutex_unlock(&crypt_stat->cs_mutex);
321 goto out_puts; 319 goto out_puts;
322 } 320 }
323 ECRYPTFS_CLEAR_FLAG(crypt_stat->flags,
324 ECRYPTFS_ENCRYPTED);
325 rc = 0; 321 rc = 0;
322 crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
326 mutex_unlock(&crypt_stat->cs_mutex); 323 mutex_unlock(&crypt_stat->cs_mutex);
327 goto out; 324 goto out;
328 } 325 }