2012-02-28 18:27:28 +04:00
|
|
|
#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"
|
2012-04-09 18:01:18 +04:00
|
|
|
#include "kcmp-ids.h"
|
2012-02-28 18:27:28 +04:00
|
|
|
#include "compiler.h"
|
|
|
|
#include "syscall.h"
|
|
|
|
#include "image.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
2012-04-09 18:01:18 +04:00
|
|
|
static DECLARE_KCMP_TREE(fd_tree, KCMP_FILE);
|
2012-03-23 20:23:00 +04:00
|
|
|
|
2012-04-09 17:56:36 +04:00
|
|
|
void fd_id_show_tree(void)
|
|
|
|
{
|
|
|
|
kid_show_tree(&fd_tree);
|
|
|
|
}
|
|
|
|
|
2012-04-09 12:57:38 +04:00
|
|
|
u32 fd_id_generate_special(void)
|
|
|
|
{
|
2012-04-09 17:54:35 +04:00
|
|
|
return fd_tree.subid++;
|
2012-04-09 12:57:38 +04:00
|
|
|
}
|
|
|
|
|
2012-03-24 22:02:10 +04:00
|
|
|
int fd_id_generate(pid_t pid, struct fdinfo_entry *fe)
|
2012-03-23 20:23:00 +04:00
|
|
|
{
|
2012-04-09 17:55:58 +04:00
|
|
|
u32 id;
|
2012-04-09 17:55:20 +04:00
|
|
|
struct kid_elem e;
|
2012-03-25 16:02:21 +04:00
|
|
|
int new_id = 0;
|
2012-03-24 22:02:10 +04:00
|
|
|
|
2012-04-09 17:55:20 +04:00
|
|
|
e.pid = pid;
|
|
|
|
e.genid = fe->id;
|
|
|
|
e.idx = fe->fd;
|
|
|
|
|
2012-04-09 17:55:58 +04:00
|
|
|
id = kid_generate_gen(&fd_tree, &e, &new_id);
|
|
|
|
if (!id)
|
2012-03-23 20:23:00 +04:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2012-04-09 17:55:58 +04:00
|
|
|
fe->id = id;
|
2012-03-25 16:02:21 +04:00
|
|
|
return new_id;
|
2012-02-28 18:27:28 +04:00
|
|
|
}
|