diff --git a/files-reg.c b/files-reg.c index 9aa248111..0f89be5a7 100644 --- a/files-reg.c +++ b/files-reg.c @@ -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; diff --git a/protobuf/Makefile b/protobuf/Makefile index 4b43eca9d..12089a219 100644 --- a/protobuf/Makefile +++ b/protobuf/Makefile @@ -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)/ diff --git a/protobuf/ghost-file.proto b/protobuf/ghost-file.proto index a600a4374..db056dbcf 100644 --- a/protobuf/ghost-file.proto +++ b/protobuf/ghost-file.proto @@ -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; } diff --git a/protobuf/time.proto b/protobuf/time.proto new file mode 100644 index 000000000..09cdf42a6 --- /dev/null +++ b/protobuf/time.proto @@ -0,0 +1,4 @@ +message timeval { + required uint64 tv_sec = 1; + required uint64 tv_usec = 2; +} diff --git a/test/zdtm/live/static/file_attr.desc b/test/zdtm/live/static/file_attr.desc deleted file mode 100644 index 95c58b401..000000000 --- a/test/zdtm/live/static/file_attr.desc +++ /dev/null @@ -1 +0,0 @@ -{'flags': 'noauto'}