mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
ovl: extract helper to get temp file in copy up
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
parent
15932c415b
commit
7d90b853f9
1 changed files with 41 additions and 18 deletions
|
@ -345,16 +345,13 @@ static int ovl_install_temp(struct dentry *workdir, struct dentry *upperdir,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
|
static int ovl_get_tmpfile(struct dentry *workdir, struct dentry *upperdir,
|
||||||
struct dentry *dentry, struct path *lowerpath,
|
struct dentry *dentry,
|
||||||
struct kstat *stat, const char *link,
|
struct kstat *stat, const char *link, bool tmpfile,
|
||||||
struct kstat *pstat, bool tmpfile)
|
struct dentry **tempp)
|
||||||
{
|
{
|
||||||
struct inode *wdir = workdir->d_inode;
|
|
||||||
struct inode *udir = upperdir->d_inode;
|
|
||||||
struct dentry *newdentry = NULL;
|
|
||||||
struct dentry *temp = NULL;
|
|
||||||
int err;
|
int err;
|
||||||
|
struct dentry *temp;
|
||||||
const struct cred *old_creds = NULL;
|
const struct cred *old_creds = NULL;
|
||||||
struct cred *new_creds = NULL;
|
struct cred *new_creds = NULL;
|
||||||
struct cattr cattr = {
|
struct cattr cattr = {
|
||||||
|
@ -371,24 +368,50 @@ static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
|
||||||
if (new_creds)
|
if (new_creds)
|
||||||
old_creds = override_creds(new_creds);
|
old_creds = override_creds(new_creds);
|
||||||
|
|
||||||
if (tmpfile)
|
if (tmpfile) {
|
||||||
temp = ovl_do_tmpfile(upperdir, stat->mode);
|
temp = ovl_do_tmpfile(upperdir, stat->mode);
|
||||||
else
|
if (IS_ERR(temp))
|
||||||
|
goto temp_err;
|
||||||
|
} else {
|
||||||
temp = ovl_lookup_temp(workdir);
|
temp = ovl_lookup_temp(workdir);
|
||||||
err = 0;
|
if (IS_ERR(temp))
|
||||||
if (IS_ERR(temp)) {
|
goto temp_err;
|
||||||
err = PTR_ERR(temp);
|
|
||||||
temp = NULL;
|
err = ovl_create_real(d_inode(workdir), temp, &cattr,
|
||||||
|
NULL, true);
|
||||||
|
if (err) {
|
||||||
|
dput(temp);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
err = 0;
|
||||||
if (!err && !tmpfile)
|
*tempp = temp;
|
||||||
err = ovl_create_real(wdir, temp, &cattr, NULL, true);
|
out:
|
||||||
|
|
||||||
if (new_creds) {
|
if (new_creds) {
|
||||||
revert_creds(old_creds);
|
revert_creds(old_creds);
|
||||||
put_cred(new_creds);
|
put_cred(new_creds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
|
||||||
|
temp_err:
|
||||||
|
err = PTR_ERR(temp);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
|
||||||
|
struct dentry *dentry, struct path *lowerpath,
|
||||||
|
struct kstat *stat, const char *link,
|
||||||
|
struct kstat *pstat, bool tmpfile)
|
||||||
|
{
|
||||||
|
struct inode *wdir = workdir->d_inode;
|
||||||
|
struct inode *udir = upperdir->d_inode;
|
||||||
|
struct dentry *newdentry = NULL;
|
||||||
|
struct dentry *temp = NULL;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = ovl_get_tmpfile(workdir, upperdir, dentry, stat, link, tmpfile,
|
||||||
|
&temp);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue