Commit ba68d61f authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

files: Adjust file position for /dev/kmsg

The kernel doesnt allow to call lseek on /dev/kmsg
if it has been opened with O_WRONLY mode so our
restore procedure fails.

Thus if we meet a file which fits the condition
above -- set it's position to predefined value
which tells criu to not call lseek on restore.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 337c7311
...@@ -271,6 +271,29 @@ static const struct fdtype_ops *get_misc_dev_ops(int minor) ...@@ -271,6 +271,29 @@ static const struct fdtype_ops *get_misc_dev_ops(int minor)
return NULL; return NULL;
} }
static const struct fdtype_ops *get_mem_dev_ops(struct fd_parms *p, int minor)
{
const struct fdtype_ops *ops = NULL;
switch (minor) {
case 11:
/*
* If /dev/kmsg is opened in write-only mode the file position
* should not be set up upon restore, kernel doesn't allow that.
*/
if ((p->flags & O_ACCMODE) == O_WRONLY && p->pos == 0)
p->pos = -1ULL;
/*
* Fallthrough.
*/
default:
ops = &regfile_dump_ops;
break;
};
return ops;
}
static int dump_chrdev(struct fd_parms *p, int lfd, struct cr_img *img) static int dump_chrdev(struct fd_parms *p, int lfd, struct cr_img *img)
{ {
int maj = major(p->stat.st_rdev); int maj = major(p->stat.st_rdev);
...@@ -278,7 +301,7 @@ static int dump_chrdev(struct fd_parms *p, int lfd, struct cr_img *img) ...@@ -278,7 +301,7 @@ static int dump_chrdev(struct fd_parms *p, int lfd, struct cr_img *img)
switch (maj) { switch (maj) {
case MEM_MAJOR: case MEM_MAJOR:
ops = &regfile_dump_ops; ops = get_mem_dev_ops(p, minor(p->stat.st_rdev));
break; break;
case MISC_MAJOR: case MISC_MAJOR:
ops = get_misc_dev_ops(minor(p->stat.st_rdev)); ops = get_misc_dev_ops(minor(p->stat.st_rdev));
......
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