[CRIU] [PATCH 2/4] files: Support ghost devices
Pavel Emelyanov
xemul at parallels.com
Wed Jul 2 02:32:47 PDT 2014
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 at parallels.com>
---
files-reg.c | 16 ++++++++++++++++
protobuf/ghost-file.proto | 1 +
2 files changed, 17 insertions(+)
diff --git a/files-reg.c b/files-reg.c
index eb3c010..4045f93 100644
--- a/files-reg.c
+++ b/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;
diff --git a/protobuf/ghost-file.proto b/protobuf/ghost-file.proto
index d1946d8..3bfbbad 100644
--- a/protobuf/ghost-file.proto
+++ b/protobuf/ghost-file.proto
@@ -5,4 +5,5 @@ message ghost_file_entry {
optional uint32 dev = 4;
optional uint64 ino = 5;
+ optional uint32 rdev = 6;
}
--
1.8.4.2
More information about the CRIU
mailing list