mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
We want to have buffered images to speed up dump and, slightly, restore. Right now we use plan file descriptors to write and read images to/from. Making them buffered cannot be gracefully done on plain fds, so introduce a new class. This will also help if (when?) we will want to do more complex changes with images, e.g. store them all in one file or send them directly to the network. For now the cr_img just contains one int _fd variable. This patch chages the prototype of open_image() to return struct cr_img *, pb_(read|write)* to accept one and fixes the compilation of the rest of the code :) Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
37 lines
904 B
C
37 lines
904 B
C
#ifndef __CR_IMGSET_H__
|
|
#define __CR_IMGSET_H__
|
|
|
|
#include "image-desc.h"
|
|
#include "bug.h"
|
|
#include "image.h"
|
|
|
|
struct cr_imgset {
|
|
int fd_off;
|
|
int fd_nr;
|
|
struct cr_img **_imgs;
|
|
};
|
|
|
|
static inline struct cr_img *img_from_set(const struct cr_imgset *imgset, int type)
|
|
{
|
|
int idx;
|
|
|
|
idx = type - imgset->fd_off;
|
|
BUG_ON(idx > imgset->fd_nr);
|
|
|
|
return imgset->_imgs[idx];
|
|
}
|
|
|
|
extern struct cr_imgset *glob_imgset;
|
|
|
|
extern struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX];
|
|
|
|
extern struct cr_imgset *cr_task_imgset_open(int pid, int mode);
|
|
extern struct cr_imgset *cr_imgset_open_range(int pid, int from, int to,
|
|
unsigned long flags);
|
|
#define cr_imgset_open(pid, type, flags) cr_imgset_open_range(pid, \
|
|
_CR_FD_##type##_FROM, _CR_FD_##type##_TO, flags)
|
|
extern struct cr_imgset *cr_glob_imgset_open(int mode);
|
|
|
|
extern void close_cr_imgset(struct cr_imgset **cr_imgset);
|
|
|
|
#endif /* __CR_IMGSET_H__ */
|