criu/include/fdset.h
Andrey Vagin 1300cf4915 crtools: move all stuff about fdset in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 15:24:48 +04:00

36 lines
786 B
C

#ifndef __CR_FDSET_H__
#define __CR_FDSET_H__
#include "image-desc.h"
#include "bug.h"
struct cr_fdset {
int fd_off;
int fd_nr;
int *_fds;
};
static inline int fdset_fd(const struct cr_fdset *fdset, int type)
{
int idx;
idx = type - fdset->fd_off;
BUG_ON(idx > fdset->fd_nr);
return fdset->_fds[idx];
}
extern struct cr_fdset *glob_fdset;
extern struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX];
struct cr_fdset *cr_task_fdset_open(int pid, int mode);
struct cr_fdset *cr_fdset_open_range(int pid, int from, int to,
unsigned long flags);
#define cr_fdset_open(pid, type, flags) cr_fdset_open_range(pid, \
_CR_FD_##type##_FROM, _CR_FD_##type##_TO, flags)
struct cr_fdset *cr_glob_fdset_open(int mode);
void close_cr_fdset(struct cr_fdset **cr_fdset);
#endif