forked from checkpoint-restore/criu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file-ids.c
49 lines (40 loc) · 774 Bytes
/
file-ids.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#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 "asm/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, FdinfoEntry *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;
}