mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-23 10:28:05 +00:00
files: Support ghost devices
When we have opened and unlinked chr or blk device, we shouls also take care of their rdev value. Thus -- new field in image and some new steps on dump and restore. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
8e21401aa2
commit
a9f765894e
16
files-reg.c
16
files-reg.c
@ -79,6 +79,17 @@ static int create_ghost(struct ghost_file *gf, GhostFileEntry *gfe, char *root,
|
||||
goto err;
|
||||
}
|
||||
ghost_flags = O_RDWR; /* To not block */
|
||||
} else if (S_ISCHR(gfe->mode) || S_ISBLK(gfe->mode)) {
|
||||
if (!gfe->has_rdev) {
|
||||
pr_err("No rdev for ghost device\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (mknod(gf->remap.path, gfe->mode, gfe->rdev)) {
|
||||
pr_perror("Can't create node for ghost dev");
|
||||
goto err;
|
||||
}
|
||||
ghost_flags = O_WRONLY;
|
||||
} else
|
||||
ghost_flags = O_WRONLY | O_CREAT | O_EXCL;
|
||||
|
||||
@ -258,6 +269,11 @@ static int dump_ghost_file(int _fd, u32 id, const struct stat *st, dev_t phys_de
|
||||
gfe.dev = phys_dev;
|
||||
gfe.ino = st->st_ino;
|
||||
|
||||
if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode)) {
|
||||
gfe.has_rdev = true;
|
||||
gfe.rdev = st->st_rdev;
|
||||
}
|
||||
|
||||
if (pb_write_one(img, &gfe, PB_GHOST_FILE))
|
||||
return -1;
|
||||
|
||||
|
@ -5,4 +5,5 @@ message ghost_file_entry {
|
||||
|
||||
optional uint32 dev = 4;
|
||||
optional uint64 ino = 5;
|
||||
optional uint32 rdev = 6;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user