mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 13:58:34 +00:00
files-reg: split create_ghost_dentry out of create_ghost
Will use it to make create_ghost work with mount-v2. Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com> Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com> Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com> Cherry-picked from Virtuozzo criu: https://src.openvz.org/projects/OVZ/repos/criu/commits/156fa4877 Cherry-picked from Virtuozzo criu: https://src.openvz.org/projects/OVZ/repos/criu/commits/069bba0ad Changes: merge fixup. Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
parent
9fb3984a7e
commit
169f95c394
@ -355,32 +355,11 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int create_ghost(struct ghost_file *gf, GhostFileEntry *gfe, struct cr_img *img)
|
||||
static int create_ghost_dentry(char *path, GhostFileEntry *gfe, struct cr_img *img)
|
||||
{
|
||||
struct mount_info *mi;
|
||||
char path[PATH_MAX];
|
||||
int ret, root_len;
|
||||
int ret = -1;
|
||||
char *msg;
|
||||
|
||||
root_len = ret = rst_get_mnt_root(gf->remap.rmnt_id, path, sizeof(path));
|
||||
if (ret < 0) {
|
||||
pr_err("The %d mount is not found for ghost\n", gf->remap.rmnt_id);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Add a '/' only if we have no at the end */
|
||||
if (path[root_len - 1] != '/') {
|
||||
path[root_len++] = '/';
|
||||
path[root_len] = '\0';
|
||||
}
|
||||
|
||||
snprintf(path + root_len, sizeof(path) - root_len, "%s", gf->remap.rpath);
|
||||
ret = -1;
|
||||
|
||||
mi = lookup_mnt_id(gf->remap.rmnt_id);
|
||||
/* We get here while in service mntns */
|
||||
if (mi && try_remount_writable(mi, false))
|
||||
goto err;
|
||||
again:
|
||||
if (S_ISFIFO(gfe->mode)) {
|
||||
if ((ret = mknod(path, gfe->mode, 0)) < 0)
|
||||
@ -417,18 +396,49 @@ again:
|
||||
goto err;
|
||||
}
|
||||
|
||||
strcpy(gf->remap.rpath, path + root_len);
|
||||
pr_debug("Remap rpath is %s\n", gf->remap.rpath);
|
||||
|
||||
ret = -1;
|
||||
if (ghost_apply_metadata(path, gfe))
|
||||
goto err;
|
||||
|
||||
ret = 0;
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int create_ghost(struct ghost_file *gf, GhostFileEntry *gfe, struct cr_img *img)
|
||||
{
|
||||
struct mount_info *mi;
|
||||
char path[PATH_MAX];
|
||||
int ret, root_len;
|
||||
|
||||
root_len = ret = rst_get_mnt_root(gf->remap.rmnt_id, path, sizeof(path));
|
||||
if (ret < 0) {
|
||||
pr_err("The %d mount is not found for ghost\n", gf->remap.rmnt_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Add a '/' only if we have no at the end */
|
||||
if (path[root_len - 1] != '/') {
|
||||
path[root_len++] = '/';
|
||||
path[root_len] = '\0';
|
||||
}
|
||||
|
||||
snprintf(path + root_len, sizeof(path) - root_len, "%s", gf->remap.rpath);
|
||||
ret = -1;
|
||||
|
||||
mi = lookup_mnt_id(gf->remap.rmnt_id);
|
||||
/* We get here while in service mntns */
|
||||
if (mi && try_remount_writable(mi, false))
|
||||
return -1;
|
||||
|
||||
ret = create_ghost_dentry(path, gfe, img);
|
||||
if (ret)
|
||||
return -1;
|
||||
|
||||
if (ghost_apply_metadata(path, gfe))
|
||||
return -1;
|
||||
|
||||
strcpy(gf->remap.rpath, path + root_len);
|
||||
pr_debug("Remap rpath is %s\n", gf->remap.rpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void ghost_path(char *path, int plen, struct reg_file_info *rfi, RemapFilePathEntry *rpe)
|
||||
{
|
||||
snprintf(path, plen, "%s.cr.%x.ghost", rfi->path, rpe->remap_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user