mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 06:45:35 +00:00
files: Move do_dump_gen_file into files.c
It's a file dumping fn, it should be there. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
29
cr-dump.c
29
cr-dump.c
@@ -190,35 +190,6 @@ static int collect_fds(pid_t pid, struct parasite_drain_fd *dfds)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 make_gen_id(const struct fd_parms *p)
|
|
||||||
{
|
|
||||||
return ((u32)p->stat.st_dev) ^ ((u32)p->stat.st_ino) ^ ((u32)p->pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
int do_dump_gen_file(struct fd_parms *p, int lfd,
|
|
||||||
const struct fdtype_ops *ops, const int fdinfo)
|
|
||||||
{
|
|
||||||
FdinfoEntry e = FDINFO_ENTRY__INIT;
|
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
e.type = ops->type;
|
|
||||||
e.id = make_gen_id(p);
|
|
||||||
e.fd = p->fd;
|
|
||||||
e.flags = p->fd_flags;
|
|
||||||
|
|
||||||
ret = fd_id_generate(p->pid, &e);
|
|
||||||
if (ret == 1) /* new ID generated */
|
|
||||||
ret = ops->dump(lfd, e.id, p);
|
|
||||||
|
|
||||||
if (ret < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
pr_info("fdinfo: type: 0x%2x flags: %#o/%#o pos: 0x%8lx fd: %d\n",
|
|
||||||
ops->type, p->flags, (int)p->fd_flags, p->pos, p->fd);
|
|
||||||
|
|
||||||
return pb_write_one(fdinfo, &e, PB_FDINFO);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dump_task_exe_link(pid_t pid, MmEntry *mm)
|
static int dump_task_exe_link(pid_t pid, MmEntry *mm)
|
||||||
{
|
{
|
||||||
struct fd_parms params = FD_PARMS_INIT;
|
struct fd_parms params = FD_PARMS_INIT;
|
||||||
|
30
files.c
30
files.c
@@ -15,6 +15,7 @@
|
|||||||
#include "crtools.h"
|
#include "crtools.h"
|
||||||
|
|
||||||
#include "files.h"
|
#include "files.h"
|
||||||
|
#include "file-ids.h"
|
||||||
#include "files-reg.h"
|
#include "files-reg.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
@@ -95,6 +96,35 @@ void show_saved_files(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static u32 make_gen_id(const struct fd_parms *p)
|
||||||
|
{
|
||||||
|
return ((u32)p->stat.st_dev) ^ ((u32)p->stat.st_ino) ^ ((u32)p->pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
int do_dump_gen_file(struct fd_parms *p, int lfd,
|
||||||
|
const struct fdtype_ops *ops, const int fdinfo)
|
||||||
|
{
|
||||||
|
FdinfoEntry e = FDINFO_ENTRY__INIT;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
e.type = ops->type;
|
||||||
|
e.id = make_gen_id(p);
|
||||||
|
e.fd = p->fd;
|
||||||
|
e.flags = p->fd_flags;
|
||||||
|
|
||||||
|
ret = fd_id_generate(p->pid, &e);
|
||||||
|
if (ret == 1) /* new ID generated */
|
||||||
|
ret = ops->dump(lfd, e.id, p);
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
pr_info("fdinfo: type: 0x%2x flags: %#o/%#o pos: 0x%8lx fd: %d\n",
|
||||||
|
ops->type, p->flags, (int)p->fd_flags, p->pos, p->fd);
|
||||||
|
|
||||||
|
return pb_write_one(fdinfo, &e, PB_FDINFO);
|
||||||
|
}
|
||||||
|
|
||||||
int restore_fown(int fd, FownEntry *fown)
|
int restore_fown(int fd, FownEntry *fown)
|
||||||
{
|
{
|
||||||
struct f_owner_ex owner;
|
struct f_owner_ex owner;
|
||||||
|
Reference in New Issue
Block a user