Commit a9f76589 authored by Pavel Emelyanov's avatar Pavel Emelyanov

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: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 8e21401a
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment