fs/overlayfs/copy_up.c
Source file repositories/reference/linux-study-clean/fs/overlayfs/copy_up.c
File Facts
- System
- Linux kernel
- Corpus path
fs/overlayfs/copy_up.c- Extension
.c- Size
- 31753 bytes
- Lines
- 1284
- 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/module.hlinux/fs.hlinux/slab.hlinux/file.hlinux/fileattr.hlinux/splice.hlinux/xattr.hlinux/security.hlinux/uaccess.hlinux/sched/signal.hlinux/cred.hlinux/namei.hlinux/ratelimit.hlinux/exportfs.hoverlayfs.h
Detected Declarations
struct ovl_copy_up_ctxfunction Copyrightfunction ovl_ccup_getfunction ovl_must_copy_xattrfunction ovl_copy_aclfunction ovl_copy_xattrfunction ovl_copy_fileattrfunction ovl_verify_areafunction ovl_sync_filefunction ovl_copy_up_filefunction ovl_set_sizefunction ovl_set_timestampsfunction ovl_set_attrfunction ovl_set_origin_fhfunction ovl_set_upper_fhfunction ovl_create_indexfunction ovl_link_upfunction ovl_copy_up_datafunction ovl_copy_up_metadatafunction ovl_revert_copy_up_credsfunction scoped_classfunction ovl_copy_up_tmpfilefunction scoped_classfunction ovl_do_copy_upfunction ovl_need_meta_copy_upfunction ovl_getxattr_valuefunction ovl_copy_up_meta_inode_datafunction ovl_copy_up_onefunction ovl_copy_up_flagsfunction ovl_open_need_copy_upfunction ovl_maybe_copy_upfunction ovl_copy_up_with_datafunction ovl_copy_up
Annotated Snippet
struct ovl_copy_up_ctx {
struct dentry *parent;
struct dentry *dentry;
struct path lowerpath;
struct kstat stat;
struct kstat pstat;
const char *link;
struct dentry *destdir;
struct qstr destname;
struct dentry *workdir;
const struct ovl_fh *origin_fh;
bool origin;
bool indexed;
bool metacopy;
bool metacopy_digest;
bool metadata_fsync;
};
static int ovl_link_up(struct ovl_copy_up_ctx *c)
{
int err;
struct dentry *upper;
struct dentry *upperdir = ovl_dentry_upper(c->parent);
struct ovl_fs *ofs = OVL_FS(c->dentry->d_sb);
struct inode *udir = d_inode(upperdir);
ovl_start_write(c->dentry);
/* Mark parent "impure" because it may now contain non-pure upper */
err = ovl_set_impure(c->parent, upperdir);
if (err)
goto out;
err = ovl_set_nlink_lower(c->dentry);
if (err)
goto out;
upper = ovl_start_creating_upper(ofs, upperdir,
&QSTR_LEN(c->dentry->d_name.name,
c->dentry->d_name.len));
err = PTR_ERR(upper);
if (!IS_ERR(upper)) {
err = ovl_do_link(ofs, ovl_dentry_upper(c->dentry), udir, upper);
if (!err) {
/* Restore timestamps on parent (best effort) */
ovl_set_timestamps(ofs, upperdir, &c->pstat);
ovl_dentry_set_upper_alias(c->dentry);
ovl_dentry_update_reval(c->dentry, upper);
}
end_creating(upper);
}
if (err)
goto out;
err = ovl_set_nlink_upper(c->dentry);
out:
ovl_end_write(c->dentry);
return err;
}
static int ovl_copy_up_data(struct ovl_copy_up_ctx *c, const struct path *temp)
{
struct ovl_fs *ofs = OVL_FS(c->dentry->d_sb);
struct file *new_file;
int err;
if (!S_ISREG(c->stat.mode) || c->metacopy || !c->stat.size)
return 0;
new_file = ovl_path_open(temp, O_LARGEFILE | O_WRONLY);
if (IS_ERR(new_file))
return PTR_ERR(new_file);
err = ovl_copy_up_file(ofs, c->dentry, new_file, c->stat.size,
!c->metadata_fsync);
fput(new_file);
return err;
}
static int ovl_copy_up_metadata(struct ovl_copy_up_ctx *c, struct dentry *temp)
{
struct ovl_fs *ofs = OVL_FS(c->dentry->d_sb);
struct inode *inode = d_inode(c->dentry);
struct path upperpath = { .mnt = ovl_upper_mnt(ofs), .dentry = temp };
int err;
err = ovl_copy_xattr(c->dentry->d_sb, &c->lowerpath, temp);
Annotation
- Immediate include surface: `linux/module.h`, `linux/fs.h`, `linux/slab.h`, `linux/file.h`, `linux/fileattr.h`, `linux/splice.h`, `linux/xattr.h`, `linux/security.h`.
- Detected declarations: `struct ovl_copy_up_ctx`, `function Copyright`, `function ovl_ccup_get`, `function ovl_must_copy_xattr`, `function ovl_copy_acl`, `function ovl_copy_xattr`, `function ovl_copy_fileattr`, `function ovl_verify_area`, `function ovl_sync_file`, `function ovl_copy_up_file`.
- 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.