[CRIU] [PATCH CRIU] cpt/rst: access and modification time of ghost files
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Tue Dec 22 00:54:16 PST 2015
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
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
files-reg.c | 18 ++++++++++++++++++
protobuf/ghost-file.proto | 4 ++++
2 files changed, 22 insertions(+)
diff --git a/files-reg.c b/files-reg.c
index 9aa2481..1e602ca 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->has_atim_sec) {
+ tv[0].tv_sec = gfe->atim_sec;
+ tv[0].tv_usec = gfe->atim_usec;
+ tv[1].tv_sec = gfe->mtim_sec;
+ tv[1].tv_usec = gfe->mtim_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);
@@ -529,6 +541,12 @@ 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.has_atim_sec = gfe.has_atim_usec = gfe.has_mtim_sec = gfe.has_mtim_usec = true;
+ gfe.atim_sec = st->st_atim.tv_sec;
+ gfe.atim_usec = st->st_atim.tv_nsec / 1000;
+ gfe.mtim_sec = st->st_mtim.tv_sec;
+ gfe.mtim_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/ghost-file.proto b/protobuf/ghost-file.proto
index a600a43..3f0df4e 100644
--- a/protobuf/ghost-file.proto
+++ b/protobuf/ghost-file.proto
@@ -8,4 +8,8 @@ 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 uint64 atim_sec = 7;
+ optional uint64 atim_usec = 8;
+ optional uint64 mtim_sec = 9;
+ optional uint64 mtim_usec = 10;
}
--
1.9.3
More information about the CRIU
mailing list