OLD | NEW |
1 /** | 1 /** |
2 * eCryptfs: Linux filesystem encryption layer | 2 * eCryptfs: Linux filesystem encryption layer |
3 * | 3 * |
4 * Copyright (C) 1997-2003 Erez Zadok | 4 * Copyright (C) 1997-2003 Erez Zadok |
5 * Copyright (C) 2001-2003 Stony Brook University | 5 * Copyright (C) 2001-2003 Stony Brook University |
6 * Copyright (C) 2004-2007 International Business Machines Corp. | 6 * Copyright (C) 2004-2007 International Business Machines Corp. |
7 * Author(s): Michael A. Halcrow <mahalcro@us.ibm.com> | 7 * Author(s): Michael A. Halcrow <mahalcro@us.ibm.com> |
8 * Michael C. Thompson <mcthomps@us.ibm.com> | 8 * Michael C. Thompson <mcthomps@us.ibm.com> |
9 * Tyler Hicks <tyhicks@ou.edu> | 9 * Tyler Hicks <tyhicks@ou.edu> |
10 * | 10 * |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 * Returns zero on success; non-zero otherwise | 115 * Returns zero on success; non-zero otherwise |
116 */ | 116 */ |
117 int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) | 117 int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) |
118 { | 118 { |
119 const struct cred *cred = current_cred(); | 119 const struct cred *cred = current_cred(); |
120 struct ecryptfs_inode_info *inode_info = | 120 struct ecryptfs_inode_info *inode_info = |
121 ecryptfs_inode_to_private(ecryptfs_dentry->d_inode); | 121 ecryptfs_inode_to_private(ecryptfs_dentry->d_inode); |
122 int opened_lower_file = 0; | 122 int opened_lower_file = 0; |
123 int rc = 0; | 123 int rc = 0; |
124 | 124 |
| 125 mutex_lock(&inode_info->lower_file_mutex); |
125 if (!inode_info->lower_file) { | 126 if (!inode_info->lower_file) { |
126 struct dentry *lower_dentry; | 127 struct dentry *lower_dentry; |
127 struct vfsmount *lower_mnt = | 128 struct vfsmount *lower_mnt = |
128 ecryptfs_dentry_to_lower_mnt(ecryptfs_dentry); | 129 ecryptfs_dentry_to_lower_mnt(ecryptfs_dentry); |
129 | 130 |
130 lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry); | 131 lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry); |
131 rc = ecryptfs_privileged_open(&inode_info->lower_file, | 132 rc = ecryptfs_privileged_open(&inode_info->lower_file, |
132 lower_dentry, lower_mnt, cred); | 133 lower_dentry, lower_mnt, cred); |
133 if (rc) { | 134 if (rc) { |
134 printk(KERN_ERR "Error opening lower persistent file " | 135 printk(KERN_ERR "Error opening lower persistent file " |
135 "for lower_dentry [0x%p] and lower_mnt [0x%p]; " | 136 "for lower_dentry [0x%p] and lower_mnt [0x%p]; " |
136 "rc = [%d]\n", lower_dentry, lower_mnt, rc); | 137 "rc = [%d]\n", lower_dentry, lower_mnt, rc); |
137 inode_info->lower_file = NULL; | 138 inode_info->lower_file = NULL; |
138 } else | 139 } else |
139 opened_lower_file = 1; | 140 opened_lower_file = 1; |
140 } | 141 } |
| 142 mutex_unlock(&inode_info->lower_file_mutex); |
141 if (opened_lower_file) | 143 if (opened_lower_file) |
142 ima_counts_get(inode_info->lower_file); | 144 ima_counts_get(inode_info->lower_file); |
143 return rc; | 145 return rc; |
144 } | 146 } |
145 | 147 |
146 /** | 148 /** |
147 * ecryptfs_interpose | 149 * ecryptfs_interpose |
148 * @lower_dentry: Existing dentry in the lower filesystem | 150 * @lower_dentry: Existing dentry in the lower filesystem |
149 * @dentry: ecryptfs' dentry | 151 * @dentry: ecryptfs' dentry |
150 * @sb: ecryptfs's super_block | 152 * @sb: ecryptfs's super_block |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 ecryptfs_free_kmem_caches(); | 898 ecryptfs_free_kmem_caches(); |
897 } | 899 } |
898 | 900 |
899 MODULE_AUTHOR("Michael A. Halcrow <mhalcrow@us.ibm.com>"); | 901 MODULE_AUTHOR("Michael A. Halcrow <mhalcrow@us.ibm.com>"); |
900 MODULE_DESCRIPTION("eCryptfs"); | 902 MODULE_DESCRIPTION("eCryptfs"); |
901 | 903 |
902 MODULE_LICENSE("GPL"); | 904 MODULE_LICENSE("GPL"); |
903 | 905 |
904 module_init(ecryptfs_init) | 906 module_init(ecryptfs_init) |
905 module_exit(ecryptfs_exit) | 907 module_exit(ecryptfs_exit) |
OLD | NEW |