fs/ext2/namei.c
Source file repositories/reference/linux-study-clean/fs/ext2/namei.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ext2/namei.c- Extension
.c- Size
- 9866 bytes
- Lines
- 435
- 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.
- 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/pagemap.hlinux/quotaops.hext2.hxattr.hacl.h
Detected Declarations
function Copyrightfunction d_instantiatefunction ext2_tmpfilefunction ext2_mknodfunction ext2_symlinkfunction ext2_linkfunction ext2_unlinkfunction ext2_rmdirfunction ext2_rename
Annotated Snippet
if (inode == ERR_PTR(-ESTALE)) {
ext2_error(dir->i_sb, __func__,
"deleted inode referenced: %lu",
(unsigned long) ino);
return ERR_PTR(-EIO);
}
}
return d_splice_alias(inode, dentry);
}
struct dentry *ext2_get_parent(struct dentry *child)
{
ino_t ino;
int res;
res = ext2_inode_by_name(d_inode(child), &dotdot_name, &ino);
if (res)
return ERR_PTR(res);
return d_obtain_alias(ext2_iget(child->d_sb, ino));
}
/*
* By the time this is called, we already have created
* the directory cache entry for the new file, but it
* is so far negative - it has no inode.
*
* If the create succeeds, we fill in the inode information
* with d_instantiate().
*/
static int ext2_create (struct mnt_idmap * idmap,
struct inode * dir, struct dentry * dentry,
umode_t mode, bool excl)
{
struct inode *inode;
int err;
err = dquot_initialize(dir);
if (err)
return err;
inode = ext2_new_inode(dir, mode, &dentry->d_name);
if (IS_ERR(inode))
return PTR_ERR(inode);
ext2_set_file_ops(inode);
mark_inode_dirty(inode);
return ext2_add_nondir(dentry, inode);
}
static int ext2_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
struct inode *inode = ext2_new_inode(dir, mode, NULL);
if (IS_ERR(inode))
return PTR_ERR(inode);
ext2_set_file_ops(inode);
mark_inode_dirty(inode);
d_tmpfile(file, inode);
unlock_new_inode(inode);
return finish_open_simple(file, 0);
}
static int ext2_mknod (struct mnt_idmap * idmap, struct inode * dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct inode * inode;
int err;
err = dquot_initialize(dir);
if (err)
return err;
inode = ext2_new_inode (dir, mode, &dentry->d_name);
err = PTR_ERR(inode);
if (!IS_ERR(inode)) {
init_special_inode(inode, inode->i_mode, rdev);
inode->i_op = &ext2_special_inode_operations;
mark_inode_dirty(inode);
err = ext2_add_nondir(dentry, inode);
}
return err;
}
static int ext2_symlink (struct mnt_idmap * idmap, struct inode * dir,
struct dentry * dentry, const char * symname)
{
struct super_block * sb = dir->i_sb;
int err = -ENAMETOOLONG;
Annotation
- Immediate include surface: `linux/pagemap.h`, `linux/quotaops.h`, `ext2.h`, `xattr.h`, `acl.h`.
- Detected declarations: `function Copyright`, `function d_instantiate`, `function ext2_tmpfile`, `function ext2_mknod`, `function ext2_symlink`, `function ext2_link`, `function ext2_unlink`, `function ext2_rmdir`, `function ext2_rename`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
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.