cpt/rst: access and modification time of ghost files

Modification time changes after cpt/rst file_attr test in VZ7CT:
CT-102 criu# cat test/zdtm/live/static/file_attr.out
15:05:05.315:   146: FAIL: file_attr.c:101: modification time has
changed (errno = 11 (Resource temporarily unavailable))

https://jira.sw.ru/browse/PSBM-41401

v2: add timeval message, test seem to pass now - remove noauto
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Tikhomirov 2015-12-22 18:22:00 +03:00 committed by Pavel Emelyanov
parent e9fc593cde
commit 6aaa1a2efc
5 changed files with 28 additions and 1 deletions

View file

@ -99,6 +99,7 @@ static int create_ghost(struct ghost_file *gf, GhostFileEntry *gfe, struct cr_im
{
int gfd, ghost_flags, ret;
char path[PATH_MAX];
struct timeval tv[2];
ret = rst_get_mnt_root(gf->remap.rmnt_id, path, sizeof(path));
if (ret < 0) {
@ -156,6 +157,17 @@ static int create_ghost(struct ghost_file *gf, GhostFileEntry *gfe, struct cr_im
goto err_c;
}
if (gfe->atim) {
tv[0].tv_sec = gfe->atim->tv_sec;
tv[0].tv_usec = gfe->atim->tv_usec;
tv[1].tv_sec = gfe->mtim->tv_sec;
tv[1].tv_usec = gfe->mtim->tv_usec;
if (futimes(gfd, tv)) {
pr_perror("Can't set access and modufication times on ghost %s", path);
goto err_c;
}
}
ret = 0;
err_c:
close(gfd);
@ -518,6 +530,7 @@ static int dump_ghost_file(int _fd, u32 id, const struct stat *st, dev_t phys_de
{
struct cr_img *img;
GhostFileEntry gfe = GHOST_FILE_ENTRY__INIT;
Timeval atim = TIMEVAL__INIT, mtim = TIMEVAL__INIT;
pr_info("Dumping ghost file contents (id %#x)\n", id);
@ -529,6 +542,13 @@ static int dump_ghost_file(int _fd, u32 id, const struct stat *st, dev_t phys_de
gfe.gid = userns_gid(st->st_gid);
gfe.mode = st->st_mode;
gfe.atim = &atim;
gfe.mtim = &mtim;
gfe.atim->tv_sec = st->st_atim.tv_sec;
gfe.atim->tv_usec = st->st_atim.tv_nsec / 1000;
gfe.mtim->tv_sec = st->st_mtim.tv_sec;
gfe.mtim->tv_usec = st->st_mtim.tv_nsec / 1000;
gfe.has_dev = gfe.has_ino = true;
gfe.dev = phys_dev;
gfe.ino = st->st_ino;

View file

@ -57,6 +57,7 @@ proto-obj-y += google/protobuf/descriptor.o # To make protoc-c happy and compile
proto-obj-y += opts.o
proto-obj-y += seccomp.o
proto-obj-y += binfmt-misc.o
proto-obj-y += time.o
CFLAGS += -I$(obj)/

View file

@ -1,4 +1,5 @@
import "opts.proto";
import "time.proto";
message ghost_file_entry {
required uint32 uid = 1;
@ -8,4 +9,6 @@ message ghost_file_entry {
optional uint32 dev = 4 [(criu).dev = true];
optional uint64 ino = 5;
optional uint32 rdev = 6 [(criu).dev = true, (criu).odev = true];
optional timeval atim = 7;
optional timeval mtim = 8;
}

4
protobuf/time.proto Normal file
View file

@ -0,0 +1,4 @@
message timeval {
required uint64 tv_sec = 1;
required uint64 tv_usec = 2;
}

View file

@ -1 +0,0 @@
{'flags': 'noauto'}