2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 09:58:09 +00:00
criu/file-ids.c
Pavel Emelyanov 3386535491 kcmp: Introduce generic object ID generator
Just move the patched code from file-ids.c to kcmp-ids.c and
make the former one be client for the latter.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 18:01:18 +04:00

50 lines
778 B
C

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <signal.h>
#include <limits.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include "types.h"
#include "file-ids.h"
#include "rbtree.h"
#include "kcmp-ids.h"
#include "compiler.h"
#include "syscall.h"
#include "image.h"
#include "util.h"
static DECLARE_KCMP_TREE(fd_tree, KCMP_FILE);
void fd_id_show_tree(void)
{
kid_show_tree(&fd_tree);
}
u32 fd_id_generate_special(void)
{
return fd_tree.subid++;
}
int fd_id_generate(pid_t pid, struct fdinfo_entry *fe)
{
u32 id;
struct kid_elem e;
int new_id = 0;
e.pid = pid;
e.genid = fe->id;
e.idx = fe->fd;
id = kid_generate_gen(&fd_tree, &e, &new_id);
if (!id)
return -ENOMEM;
fe->id = id;
return new_id;
}