main.c (8f2368095e25018838e1bf145041f58270ccd32e) | main.c (72b55fffd631a89e5be6fe1b4f2565bc4cd90deb) |
---|---|
1/** 2 * eCryptfs: Linux filesystem encryption layer 3 * 4 * Copyright (C) 1997-2003 Erez Zadok 5 * Copyright (C) 2001-2003 Stony Brook University 6 * Copyright (C) 2004-2007 International Business Machines Corp. 7 * Author(s): Michael A. Halcrow <mahalcro@us.ibm.com> 8 * Michael C. Thompson <mcthomps@us.ibm.com> --- 103 unchanged lines hidden (view full) --- 112 * The persistent file will be opened with read/write permissions, if 113 * possible. Otherwise, it is opened read-only. 114 * 115 * This function does nothing if a lower persistent file is already 116 * associated with the eCryptfs inode. 117 * 118 * Returns zero on success; non-zero otherwise 119 */ | 1/** 2 * eCryptfs: Linux filesystem encryption layer 3 * 4 * Copyright (C) 1997-2003 Erez Zadok 5 * Copyright (C) 2001-2003 Stony Brook University 6 * Copyright (C) 2004-2007 International Business Machines Corp. 7 * Author(s): Michael A. Halcrow <mahalcro@us.ibm.com> 8 * Michael C. Thompson <mcthomps@us.ibm.com> --- 103 unchanged lines hidden (view full) --- 112 * The persistent file will be opened with read/write permissions, if 113 * possible. Otherwise, it is opened read-only. 114 * 115 * This function does nothing if a lower persistent file is already 116 * associated with the eCryptfs inode. 117 * 118 * Returns zero on success; non-zero otherwise 119 */ |
120static int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) | 120int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) |
121{ 122 struct ecryptfs_inode_info *inode_info = 123 ecryptfs_inode_to_private(ecryptfs_dentry->d_inode); 124 int rc = 0; 125 126 mutex_lock(&inode_info->lower_file_mutex); 127 if (!inode_info->lower_file) { 128 struct dentry *lower_dentry; --- 15 unchanged lines hidden (view full) --- 144 return rc; 145} 146 147/** 148 * ecryptfs_interpose 149 * @lower_dentry: Existing dentry in the lower filesystem 150 * @dentry: ecryptfs' dentry 151 * @sb: ecryptfs's super_block | 121{ 122 struct ecryptfs_inode_info *inode_info = 123 ecryptfs_inode_to_private(ecryptfs_dentry->d_inode); 124 int rc = 0; 125 126 mutex_lock(&inode_info->lower_file_mutex); 127 if (!inode_info->lower_file) { 128 struct dentry *lower_dentry; --- 15 unchanged lines hidden (view full) --- 144 return rc; 145} 146 147/** 148 * ecryptfs_interpose 149 * @lower_dentry: Existing dentry in the lower filesystem 150 * @dentry: ecryptfs' dentry 151 * @sb: ecryptfs's super_block |
152 * @flag: If set to true, then d_add is called, else d_instantiate is called | 152 * @flags: flags to govern behavior of interpose procedure |
153 * 154 * Interposes upper and lower dentries. 155 * 156 * Returns zero on success; non-zero otherwise 157 */ 158int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry, | 153 * 154 * Interposes upper and lower dentries. 155 * 156 * Returns zero on success; non-zero otherwise 157 */ 158int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry, |
159 struct super_block *sb, int flag) | 159 struct super_block *sb, u32 flags) |
160{ 161 struct inode *lower_inode; 162 struct inode *inode; 163 int rc = 0; 164 165 lower_inode = lower_dentry->d_inode; 166 if (lower_inode->i_sb != ecryptfs_superblock_to_lower(sb)) { 167 rc = -EXDEV; --- 20 unchanged lines hidden (view full) --- 188 else if (S_ISDIR(lower_inode->i_mode)) 189 inode->i_op = &ecryptfs_dir_iops; 190 if (S_ISDIR(lower_inode->i_mode)) 191 inode->i_fop = &ecryptfs_dir_fops; 192 if (special_file(lower_inode->i_mode)) 193 init_special_inode(inode, lower_inode->i_mode, 194 lower_inode->i_rdev); 195 dentry->d_op = &ecryptfs_dops; | 160{ 161 struct inode *lower_inode; 162 struct inode *inode; 163 int rc = 0; 164 165 lower_inode = lower_dentry->d_inode; 166 if (lower_inode->i_sb != ecryptfs_superblock_to_lower(sb)) { 167 rc = -EXDEV; --- 20 unchanged lines hidden (view full) --- 188 else if (S_ISDIR(lower_inode->i_mode)) 189 inode->i_op = &ecryptfs_dir_iops; 190 if (S_ISDIR(lower_inode->i_mode)) 191 inode->i_fop = &ecryptfs_dir_fops; 192 if (special_file(lower_inode->i_mode)) 193 init_special_inode(inode, lower_inode->i_mode, 194 lower_inode->i_rdev); 195 dentry->d_op = &ecryptfs_dops; |
196 if (flag) | 196 if (flags & ECRYPTFS_INTERPOSE_FLAG_D_ADD) |
197 d_add(dentry, inode); 198 else 199 d_instantiate(dentry, inode); 200 fsstack_copy_attr_all(inode, lower_inode, NULL); 201 /* This size will be overwritten for real files w/ headers and 202 * other metadata */ 203 fsstack_copy_inode_size(inode, lower_inode); | 197 d_add(dentry, inode); 198 else 199 d_instantiate(dentry, inode); 200 fsstack_copy_attr_all(inode, lower_inode, NULL); 201 /* This size will be overwritten for real files w/ headers and 202 * other metadata */ 203 fsstack_copy_inode_size(inode, lower_inode); |
204 rc = ecryptfs_init_persistent_file(dentry); 205 if (rc) { 206 printk(KERN_ERR "%s: Error attempting to initialize the " 207 "persistent file for the dentry with name [%s]; " 208 "rc = [%d]\n", __func__, dentry->d_name.name, rc); 209 goto out; | 204 if (!(flags & ECRYPTFS_INTERPOSE_FLAG_DELAY_PERSISTENT_FILE)) { 205 rc = ecryptfs_init_persistent_file(dentry); 206 if (rc) { 207 printk(KERN_ERR "%s: Error attempting to initialize " 208 "the persistent file for the dentry with name " 209 "[%s]; rc = [%d]\n", __func__, 210 dentry->d_name.name, rc); 211 goto out; 212 } 213 } else { 214 struct ecryptfs_inode_info *inode_info = 215 ecryptfs_inode_to_private(dentry->d_inode); 216 217 inode_info->lower_file = NULL; 218 inode_info->crypt_stat.flags |= ECRYPTFS_DELAY_PERSISTENT; |
210 } 211out: 212 return rc; 213} 214 215enum { ecryptfs_opt_sig, ecryptfs_opt_ecryptfs_sig, 216 ecryptfs_opt_cipher, ecryptfs_opt_ecryptfs_cipher, 217 ecryptfs_opt_ecryptfs_key_bytes, --- 624 unchanged lines hidden --- | 219 } 220out: 221 return rc; 222} 223 224enum { ecryptfs_opt_sig, ecryptfs_opt_ecryptfs_sig, 225 ecryptfs_opt_cipher, ecryptfs_opt_ecryptfs_cipher, 226 ecryptfs_opt_ecryptfs_key_bytes, --- 624 unchanged lines hidden --- |