fs/ecryptfs/inode.c
Source file repositories/reference/linux-study-clean/fs/ecryptfs/inode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ecryptfs/inode.c- Extension
.c- Size
- 33266 bytes
- Lines
- 1184
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/file.hlinux/vmalloc.hlinux/pagemap.hlinux/dcache.hlinux/namei.hlinux/mount.hlinux/fs_stack.hlinux/slab.hlinux/xattr.hlinux/posix_acl.hlinux/posix_acl_xattr.hlinux/fileattr.hlinux/unaligned.hecryptfs_kernel.h
Detected Declarations
function Copyrightfunction ecryptfs_inode_testfunction ecryptfs_inode_setfunction ecryptfs_interposefunction ecryptfs_do_unlinkfunction ecryptfs_do_createfunction ecryptfs_initialize_filefunction ecryptfs_createfunction ecryptfs_i_size_readfunction ecryptfs_linkfunction ecryptfs_unlinkfunction ecryptfs_symlinkfunction ecryptfs_rmdirfunction ecryptfs_mknodfunction ecryptfs_renamefunction ecryptfs_iattr_to_lowerfunction upper_size_to_lower_sizefunction __ecryptfs_truncatefunction ecryptfs_truncatefunction ecryptfs_permissionfunction ecryptfs_setattrfunction ecryptfs_getattr_linkfunction ecryptfs_getattrfunction ecryptfs_setxattrfunction ecryptfs_getxattr_lowerfunction ecryptfs_getxattrfunction ecryptfs_listxattrfunction ecryptfs_removexattrfunction ecryptfs_fileattr_getfunction ecryptfs_fileattr_setfunction ecryptfs_set_aclfunction ecryptfs_xattr_getfunction ecryptfs_xattr_set
Annotated Snippet
if (rc) {
make_bad_inode(inode);
return ERR_PTR(rc);
}
}
if (inode_state_read_once(inode) & I_NEW)
unlock_new_inode(inode);
return d_splice_alias(inode, dentry);
}
/**
* ecryptfs_lookup
* @ecryptfs_dir_inode: The eCryptfs directory inode
* @ecryptfs_dentry: The eCryptfs dentry that we are looking up
* @flags: lookup flags
*
* Find a file on disk. If the file does not exist, then we'll add it to the
* dentry cache and continue on to read it from the disk.
*/
static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
struct dentry *ecryptfs_dentry,
unsigned int flags)
{
char *encrypted_and_encoded_name = NULL;
struct ecryptfs_mount_crypt_stat *mount_crypt_stat;
struct dentry *lower_dir_dentry, *lower_dentry;
struct qstr qname = QSTR_INIT(ecryptfs_dentry->d_name.name,
ecryptfs_dentry->d_name.len);
struct dentry *res;
int rc = 0;
lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent);
mount_crypt_stat = &ecryptfs_superblock_to_private(
ecryptfs_dentry->d_sb)->mount_crypt_stat;
if (mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES) {
size_t len = qname.len;
rc = ecryptfs_encrypt_and_encode_filename(
&encrypted_and_encoded_name, &len,
mount_crypt_stat, qname.name, len);
if (rc) {
printk(KERN_ERR "%s: Error attempting to encrypt and encode "
"filename; rc = [%d]\n", __func__, rc);
return ERR_PTR(rc);
}
qname.name = encrypted_and_encoded_name;
qname.len = len;
}
lower_dentry = lookup_noperm_unlocked(&qname, lower_dir_dentry);
if (IS_ERR(lower_dentry)) {
ecryptfs_printk(KERN_DEBUG, "%s: lookup_noperm() returned "
"[%ld] on lower_dentry = [%s]\n", __func__,
PTR_ERR(lower_dentry),
qname.name);
res = ERR_CAST(lower_dentry);
} else {
res = ecryptfs_lookup_interpose(ecryptfs_dentry, lower_dentry);
}
kfree(encrypted_and_encoded_name);
return res;
}
static int ecryptfs_link(struct dentry *old_dentry, struct inode *dir,
struct dentry *new_dentry)
{
struct dentry *lower_old_dentry;
struct dentry *lower_new_dentry;
struct inode *lower_dir;
u64 file_size_save;
int rc;
file_size_save = i_size_read(d_inode(old_dentry));
lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry);
lower_new_dentry = ecryptfs_start_creating_dentry(new_dentry);
if (IS_ERR(lower_new_dentry))
return PTR_ERR(lower_new_dentry);
lower_dir = lower_new_dentry->d_parent->d_inode;
rc = vfs_link(lower_old_dentry, &nop_mnt_idmap, lower_dir,
lower_new_dentry, NULL);
if (rc || d_really_is_negative(lower_new_dentry))
goto out_lock;
rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb);
if (rc)
goto out_lock;
fsstack_copy_attr_times(dir, lower_dir);
fsstack_copy_inode_size(dir, lower_dir);
set_nlink(d_inode(old_dentry),
ecryptfs_inode_to_lower(d_inode(old_dentry))->i_nlink);
Annotation
- Immediate include surface: `linux/file.h`, `linux/vmalloc.h`, `linux/pagemap.h`, `linux/dcache.h`, `linux/namei.h`, `linux/mount.h`, `linux/fs_stack.h`, `linux/slab.h`.
- Detected declarations: `function Copyright`, `function ecryptfs_inode_test`, `function ecryptfs_inode_set`, `function ecryptfs_interpose`, `function ecryptfs_do_unlink`, `function ecryptfs_do_create`, `function ecryptfs_initialize_file`, `function ecryptfs_create`, `function ecryptfs_i_size_read`, `function ecryptfs_link`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.