From c45eb121e5ce3ecbb032e52bff8eba9605416caa Mon Sep 17 00:00:00 2001 From: Rodrigo Bruno Date: Sat, 11 Feb 2017 04:34:39 +0100 Subject: [PATCH] img: Introduce O_FORCE_LOCAL flag for images criu/image-desc.c | 4 ++-- criu/image.c | 4 ++-- criu/include/image.h | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) In order to prepare for remote snapshots (possible with Image Proxy and Image Cache) the O_FORCE_LOCAL flag is added to force some images not to be remote and stay as local files in the file system. Signed-off-by: Rodrigo Bruno Signed-off-by: Pavel Emelyanov Signed-off-by: Andrei Vagin --- criu/image-desc.c | 4 ++-- criu/image.c | 4 ++-- criu/include/image.h | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/criu/image-desc.c b/criu/image-desc.c index b96eb3e5f..053e7af21 100644 --- a/criu/image-desc.c +++ b/criu/image-desc.c @@ -104,13 +104,13 @@ struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX] = { [CR_FD_STATS] = { .fmt = "stats-%s", .magic = STATS_MAGIC, - .oflags = O_SERVICE, + .oflags = O_SERVICE | O_FORCE_LOCAL, }, [CR_FD_IRMAP_CACHE] = { .fmt = "irmap-cache", .magic = IRMAP_CACHE_MAGIC, - .oflags = O_SERVICE, + .oflags = O_SERVICE | O_FORCE_LOCAL, }, [CR_FD_FILE_LOCKS_PID] = { diff --git a/criu/image.c b/criu/image.c index 84e6c8af5..b2e82347a 100644 --- a/criu/image.c +++ b/criu/image.c @@ -317,11 +317,11 @@ static int do_open_image(struct cr_img *img, int dfd, int type, unsigned long of { int ret, flags; - flags = oflags & ~(O_NOBUF | O_SERVICE); + flags = oflags & ~(O_NOBUF | O_SERVICE | O_FORCE_LOCAL); ret = openat(dfd, path, flags, CR_FD_PERM); if (ret < 0) { - if (!(flags & O_CREAT) && (errno == ENOENT)) { + if (!(flags & O_CREAT) && (errno == ENOENT || ret == -ENOENT)) { pr_info("No %s image\n", path); img->_x.fd = EMPTY_IMG_FD; goto skip_magic; diff --git a/criu/include/image.h b/criu/include/image.h index d60cbadd2..d9c4bdbc8 100644 --- a/criu/include/image.h +++ b/criu/include/image.h @@ -108,6 +108,7 @@ extern bool img_common_magic; #define O_DUMP (O_WRONLY | O_CREAT | O_TRUNC) #define O_SHOW (O_RDONLY | O_NOBUF) #define O_RSTR (O_RDONLY) +#define O_FORCE_LOCAL (O_SYNC) struct cr_img { union {