fs/overlayfs/util.c
Source file repositories/reference/linux-study-clean/fs/overlayfs/util.c
File Facts
- System
- Linux kernel
- Corpus path
fs/overlayfs/util.c- Extension
.c- Size
- 38587 bytes
- Lines
- 1519
- 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/mount.hlinux/slab.hlinux/cred.hlinux/xattr.hlinux/exportfs.hlinux/file.hlinux/fileattr.hlinux/uuid.hlinux/namei.hlinux/ratelimit.hlinux/overflow.hoverlayfs.h
Detected Declarations
function Copyrightfunction ovl_start_writefunction ovl_want_writefunction ovl_put_write_accessfunction ovl_end_writefunction ovl_drop_writefunction ovl_can_decode_fhfunction ovl_index_allfunction ovl_verify_lowerfunction ovl_stack_cpyfunction ovl_stack_putfunction ovl_stack_freefunction ovl_free_entryfunction ovl_dentry_remotefunction ovl_dentry_update_revalfunction ovl_dentry_init_revalfunction ovl_dentry_init_flagsfunction ovl_dentry_weirdfunction ovl_path_typefunction ovl_path_upperfunction ovl_path_lowerfunction ovl_path_lowerdatafunction ovl_path_realfunction ovl_path_realdatafunction ovl_dentry_lowerfunction ovl_dentry_set_lowerdatafunction ovl_set_dir_cachefunction ovl_dentry_set_flagfunction ovl_dentry_clear_flagfunction ovl_dentry_test_flagfunction ovl_dentry_is_opaquefunction ovl_dentry_is_whiteoutfunction ovl_dentry_set_opaquefunction ovl_dentry_has_xwhiteoutsfunction ovl_dentry_set_xwhiteoutsfunction ovl_layer_set_xwhiteoutsfunction ovl_dentry_has_upper_aliasfunction ovl_dentry_set_upper_aliasfunction ovl_should_check_upperdatafunction ovl_has_upperdatafunction ovl_set_upperdatafunction ovl_dentry_needs_data_copy_up_lockedfunction ovl_dentry_needs_data_copy_upfunction ovl_dentry_set_redirectfunction ovl_inode_updatefunction ovl_dir_version_incfunction ovl_dir_modifiedfunction ovl_inode_version_get
Annotated Snippet
if (ovl_numlower(oe)) {
if (ovl_test_flag(OVL_CONST_INO, d_inode(dentry)))
type |= __OVL_PATH_ORIGIN;
if (d_is_dir(dentry) ||
!ovl_has_upperdata(d_inode(dentry)))
type |= __OVL_PATH_MERGE;
}
} else {
if (ovl_numlower(oe) > 1)
type |= __OVL_PATH_MERGE;
}
return type;
}
void ovl_path_upper(struct dentry *dentry, struct path *path)
{
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
path->mnt = ovl_upper_mnt(ofs);
path->dentry = ovl_dentry_upper(dentry);
}
void ovl_path_lower(struct dentry *dentry, struct path *path)
{
struct ovl_entry *oe = OVL_E(dentry);
struct ovl_path *lowerpath = ovl_lowerstack(oe);
if (ovl_numlower(oe)) {
path->mnt = lowerpath->layer->mnt;
path->dentry = lowerpath->dentry;
} else {
*path = (struct path) { };
}
}
void ovl_path_lowerdata(struct dentry *dentry, struct path *path)
{
struct ovl_entry *oe = OVL_E(dentry);
struct ovl_path *lowerdata = ovl_lowerdata(oe);
struct dentry *lowerdata_dentry = ovl_lowerdata_dentry(oe);
if (lowerdata_dentry) {
path->dentry = lowerdata_dentry;
/*
* Pairs with smp_wmb() in ovl_dentry_set_lowerdata().
* Make sure that if lowerdata->dentry is visible, then
* datapath->layer is visible as well.
*/
smp_rmb();
path->mnt = READ_ONCE(lowerdata->layer)->mnt;
} else {
*path = (struct path) { };
}
}
enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path)
{
enum ovl_path_type type = ovl_path_type(dentry);
if (!OVL_TYPE_UPPER(type))
ovl_path_lower(dentry, path);
else
ovl_path_upper(dentry, path);
return type;
}
enum ovl_path_type ovl_path_realdata(struct dentry *dentry, struct path *path)
{
enum ovl_path_type type = ovl_path_type(dentry);
WARN_ON_ONCE(d_is_dir(dentry));
if (!OVL_TYPE_UPPER(type) || OVL_TYPE_MERGE(type))
ovl_path_lowerdata(dentry, path);
else
ovl_path_upper(dentry, path);
return type;
}
struct dentry *ovl_dentry_upper(struct dentry *dentry)
{
struct inode *inode = d_inode(dentry);
return inode ? ovl_upperdentry_dereference(OVL_I(inode)) : NULL;
}
struct dentry *ovl_dentry_lower(struct dentry *dentry)
{
Annotation
- Immediate include surface: `linux/fs.h`, `linux/mount.h`, `linux/slab.h`, `linux/cred.h`, `linux/xattr.h`, `linux/exportfs.h`, `linux/file.h`, `linux/fileattr.h`.
- Detected declarations: `function Copyright`, `function ovl_start_write`, `function ovl_want_write`, `function ovl_put_write_access`, `function ovl_end_write`, `function ovl_drop_write`, `function ovl_can_decode_fh`, `function ovl_index_all`, `function ovl_verify_lower`, `function ovl_stack_cpy`.
- 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.