linux/fs/overlayfs/copy_up.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *
 * Copyright (C) 2011 Novell Inc.
 */

#include <linux/module.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/file.h>
#include <linux/fileattr.h>
#include <linux/splice.h>
#include <linux/xattr.h>
#include <linux/security.h>
#include <linux/uaccess.h>
#include <linux/sched/signal.h>
#include <linux/cred.h>
#include <linux/namei.h>
#include <linux/fdtable.h>
#include <linux/ratelimit.h>
#include <linux/exportfs.h>
#include "overlayfs.h"

#define OVL_COPY_UP_CHUNK_SIZE

static int ovl_ccup_set(const char *buf, const struct kernel_param *param)
{}

static int ovl_ccup_get(char *buf, const struct kernel_param *param)
{}

module_param_call();
MODULE_PARM_DESC();

static bool ovl_must_copy_xattr(const char *name)
{}

static int ovl_copy_acl(struct ovl_fs *ofs, const struct path *path,
			struct dentry *dentry, const char *acl_name)
{}

int ovl_copy_xattr(struct super_block *sb, const struct path *oldpath, struct dentry *new)
{}

static int ovl_copy_fileattr(struct inode *inode, const struct path *old,
			     const struct path *new)
{}

static int ovl_verify_area(loff_t pos, loff_t pos2, loff_t len, loff_t totlen)
{}

static int ovl_copy_up_file(struct ovl_fs *ofs, struct dentry *dentry,
			    struct file *new_file, loff_t len)
{}

static int ovl_set_size(struct ovl_fs *ofs,
			struct dentry *upperdentry, struct kstat *stat)
{}

static int ovl_set_timestamps(struct ovl_fs *ofs, struct dentry *upperdentry,
			      struct kstat *stat)
{}

int ovl_set_attr(struct ovl_fs *ofs, struct dentry *upperdentry,
		 struct kstat *stat)
{}

struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct dentry *real,
				  bool is_upper)
{}

struct ovl_fh *ovl_get_origin_fh(struct ovl_fs *ofs, struct dentry *origin)
{}

int ovl_set_origin_fh(struct ovl_fs *ofs, const struct ovl_fh *fh,
		      struct dentry *upper)
{}

/* Store file handle of @upper dir in @index dir entry */
static int ovl_set_upper_fh(struct ovl_fs *ofs, struct dentry *upper,
			    struct dentry *index)
{}

/*
 * Create and install index entry.
 *
 * Caller must hold i_mutex on indexdir.
 */
static int ovl_create_index(struct dentry *dentry, const struct ovl_fh *fh,
			    struct dentry *upper)
{}

struct ovl_copy_up_ctx {};

static int ovl_link_up(struct ovl_copy_up_ctx *c)
{}

static int ovl_copy_up_data(struct ovl_copy_up_ctx *c, const struct path *temp)
{}

static int ovl_copy_up_metadata(struct ovl_copy_up_ctx *c, struct dentry *temp)
{}

struct ovl_cu_creds {};

static int ovl_prep_cu_creds(struct dentry *dentry, struct ovl_cu_creds *cc)
{}

static void ovl_revert_cu_creds(struct ovl_cu_creds *cc)
{}

/*
 * Copyup using workdir to prepare temp file.  Used when copying up directories,
 * special files or when upper fs doesn't support O_TMPFILE.
 */
static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)
{}

/* Copyup using O_TMPFILE which does not require cross dir locking */
static int ovl_copy_up_tmpfile(struct ovl_copy_up_ctx *c)
{}

/*
 * Copy up a single dentry
 *
 * All renames start with copy up of source if necessary.  The actual
 * rename will only proceed once the copy up was successful.  Copy up uses
 * upper parent i_mutex for exclusion.  Since rename can change d_parent it
 * is possible that the copy up will lock the old parent.  At that point
 * the file will have already been copied up anyway.
 */
static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)
{}

static bool ovl_need_meta_copy_up(struct dentry *dentry, umode_t mode,
				  int flags)
{}

static ssize_t ovl_getxattr_value(const struct path *path, char *name, char **value)
{}

/* Copy up data of an inode which was copied up metadata only in the past. */
static int ovl_copy_up_meta_inode_data(struct ovl_copy_up_ctx *c)
{}

static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
			   int flags)
{}

static int ovl_copy_up_flags(struct dentry *dentry, int flags)
{}

static bool ovl_open_need_copy_up(struct dentry *dentry, int flags)
{}

int ovl_maybe_copy_up(struct dentry *dentry, int flags)
{}

int ovl_copy_up_with_data(struct dentry *dentry)
{}

int ovl_copy_up(struct dentry *dentry)
{}