mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 01:51:51 +00:00
ghost-files: Save device and inode in image
Because we need to lookup for ghost files from inotify system where we only have device/inode as a key, we save dev/ino in ghost image entry. Note we use in-kernel format for device to be consistent with inotify and mount related code base. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
7bd34c699e
commit
7eb33a76a8
23
files-reg.c
23
files-reg.c
@ -28,14 +28,11 @@
|
||||
struct ghost_file {
|
||||
struct list_head list;
|
||||
u32 id;
|
||||
union {
|
||||
struct /* for dumping */ {
|
||||
u32 dev;
|
||||
u32 ino;
|
||||
};
|
||||
|
||||
struct file_remap remap; /* for restoring */
|
||||
};
|
||||
u32 dev;
|
||||
u32 ino;
|
||||
|
||||
struct file_remap remap;
|
||||
};
|
||||
|
||||
static u32 ghost_file_ids = 1;
|
||||
@ -83,6 +80,14 @@ static int open_remap_ghost(struct reg_file_info *rfi,
|
||||
if (pb_read_one(ifd, &gfe, PB_GHOST_FILE) < 0)
|
||||
goto close_ifd;
|
||||
|
||||
/*
|
||||
* For old formats where optional has_[dev|ino] is
|
||||
* not present we will have zeros here which is quite
|
||||
* a sign for "absent" fields.
|
||||
*/
|
||||
gf->dev = gfe->dev;
|
||||
gf->ino = gfe->ino;
|
||||
|
||||
snprintf(gf->remap.path, PATH_MAX, "%s.cr.%x.ghost", rfi->path, rfe->remap_id);
|
||||
|
||||
if (S_ISFIFO(gfe->mode)) {
|
||||
@ -218,6 +223,10 @@ static int dump_ghost_file(int _fd, u32 id, const struct stat *st)
|
||||
gfe.gid = st->st_gid;
|
||||
gfe.mode = st->st_mode;
|
||||
|
||||
gfe.has_dev = gfe.has_ino = true;
|
||||
gfe.dev = MKKDEV(MAJOR(st->st_dev), MINOR(st->st_dev));
|
||||
gfe.ino = st->st_ino;
|
||||
|
||||
if (pb_write_one(img, &gfe, PB_GHOST_FILE))
|
||||
return -1;
|
||||
|
||||
|
@ -79,6 +79,7 @@ typedef unsigned char u8;
|
||||
typedef signed char s8;
|
||||
|
||||
#define MAJOR(dev) ((dev)>>8)
|
||||
#define MINOR(dev) ((dev) & 0xff)
|
||||
|
||||
#define _LINUX_CAPABILITY_VERSION_3 0x20080522
|
||||
#define _LINUX_CAPABILITY_U32S_3 2
|
||||
|
@ -2,4 +2,7 @@ message ghost_file_entry {
|
||||
required uint32 uid = 1;
|
||||
required uint32 gid = 2;
|
||||
required uint32 mode = 3;
|
||||
|
||||
optional uint32 dev = 4;
|
||||
optional uint64 ino = 5;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user