mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-18 00:58:31 +00:00
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: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
337c73114f
commit
ba68d61f54
1 changed files with 24 additions and 1 deletions
25
files.c
25
files.c
|
|
@ -271,6 +271,29 @@ static const struct fdtype_ops *get_misc_dev_ops(int minor)
|
|||
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 = ®file_dump_ops;
|
||||
break;
|
||||
};
|
||||
|
||||
return ops;
|
||||
}
|
||||
|
||||
static int dump_chrdev(struct fd_parms *p, int lfd, struct cr_img *img)
|
||||
{
|
||||
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)
|
|||
|
||||
switch (maj) {
|
||||
case MEM_MAJOR:
|
||||
ops = ®file_dump_ops;
|
||||
ops = get_mem_dev_ops(p, minor(p->stat.st_rdev));
|
||||
break;
|
||||
case MISC_MAJOR:
|
||||
ops = get_misc_dev_ops(minor(p->stat.st_rdev));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue