fs/overlayfs/dir.c
Source file repositories/reference/linux-study-clean/fs/overlayfs/dir.c
File Facts
- System
- Linux kernel
- Corpus path
fs/overlayfs/dir.c- Extension
.c- Size
- 36365 bytes
- Lines
- 1497
- 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/fs.hlinux/namei.hlinux/xattr.hlinux/security.hlinux/cred.hlinux/module.hlinux/posix_acl.hlinux/posix_acl_xattr.hlinux/atomic.hlinux/ratelimit.hlinux/backing-file.hoverlayfs.h
Detected Declarations
struct ovl_renamedatastruct renamedatafunction ovl_cleanup_lockedfunction ovl_cleanupfunction ovl_tempnamefunction ovl_cleanup_and_whiteoutfunction ovl_set_opaque_xerrfunction ovl_set_opaquefunction ovl_instantiatefunction ovl_type_mergefunction ovl_type_originfunction ovl_create_upperfunction ovl_set_upper_aclfunction ovl_create_over_whiteoutfunction umaskfunction ovl_revert_creator_credsfunction ovl_create_or_linkfunction scoped_classfunction scoped_classfunction ovl_create_objectfunction ovl_createfunction ovl_mknodfunction ovl_symlinkfunction ovl_set_link_redirectfunction ovl_linkfunction ovl_matches_upperfunction ovl_remove_and_whiteoutfunction ovl_remove_upperfunction ovl_pure_upperfunction ovl_drop_nlinkfunction ovl_do_removefunction with_ovl_credsfunction ovl_unlinkfunction ovl_rmdirfunction ovl_type_merge_or_lowerfunction ovl_can_movefunction ovl_need_absolute_redirectfunction ovl_set_redirectfunction ovl_rename_startfunction ovl_rename_upperfunction ovl_rename_endfunction ovl_renamefunction ovl_create_tmpfilefunction scoped_classfunction ovl_dummy_openfunction ovl_tmpfile
Annotated Snippet
struct ovl_renamedata {
struct renamedata;
struct dentry *opaquedir;
bool cleanup_whiteout;
bool update_nlink;
bool overwrite;
};
static int ovl_rename_start(struct ovl_renamedata *ovlrd, struct list_head *list)
{
struct dentry *old = ovlrd->old_dentry;
struct dentry *new = ovlrd->new_dentry;
bool is_dir = d_is_dir(old);
bool new_is_dir = d_is_dir(new);
int err;
if (ovlrd->flags & ~(RENAME_EXCHANGE | RENAME_NOREPLACE))
return -EINVAL;
ovlrd->flags &= ~RENAME_NOREPLACE;
/* Don't copy up directory trees */
err = -EXDEV;
if (!ovl_can_move(old))
return err;
if (!ovlrd->overwrite && !ovl_can_move(new))
return err;
if (ovlrd->overwrite && new_is_dir && !ovl_pure_upper(new)) {
err = ovl_check_empty_dir(new, list);
if (err)
return err;
}
if (ovlrd->overwrite) {
if (ovl_lower_positive(old)) {
if (!ovl_dentry_is_whiteout(new)) {
/* Whiteout source */
ovlrd->flags |= RENAME_WHITEOUT;
} else {
/* Switch whiteouts */
ovlrd->flags |= RENAME_EXCHANGE;
}
} else if (is_dir && ovl_dentry_is_whiteout(new)) {
ovlrd->flags |= RENAME_EXCHANGE;
ovlrd->cleanup_whiteout = true;
}
}
err = ovl_copy_up(old);
if (err)
return err;
err = ovl_copy_up(new->d_parent);
if (err)
return err;
if (!ovlrd->overwrite) {
err = ovl_copy_up(new);
if (err)
return err;
} else if (d_inode(new)) {
err = ovl_nlink_start(new);
if (err)
return err;
ovlrd->update_nlink = true;
}
if (!ovlrd->update_nlink) {
/* ovl_nlink_start() took ovl_want_write() */
err = ovl_want_write(old);
if (err)
return err;
}
return 0;
}
static int ovl_rename_upper(struct ovl_renamedata *ovlrd, struct list_head *list)
{
struct dentry *old = ovlrd->old_dentry;
struct dentry *new = ovlrd->new_dentry;
struct ovl_fs *ofs = OVL_FS(old->d_sb);
struct dentry *old_upperdir = ovl_dentry_upper(old->d_parent);
struct dentry *new_upperdir = ovl_dentry_upper(new->d_parent);
bool is_dir = d_is_dir(old);
bool new_is_dir = d_is_dir(new);
bool samedir = old->d_parent == new->d_parent;
struct renamedata rd = {};
Annotation
- Immediate include surface: `linux/fs.h`, `linux/namei.h`, `linux/xattr.h`, `linux/security.h`, `linux/cred.h`, `linux/module.h`, `linux/posix_acl.h`, `linux/posix_acl_xattr.h`.
- Detected declarations: `struct ovl_renamedata`, `struct renamedata`, `function ovl_cleanup_locked`, `function ovl_cleanup`, `function ovl_tempname`, `function ovl_cleanup_and_whiteout`, `function ovl_set_opaque_xerr`, `function ovl_set_opaque`, `function ovl_instantiate`, `function ovl_type_merge`.
- 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.