mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
image: open_image_at -- Add O_OPT flag
This allows us to distinguish the situation where image to be opened is missing but optional, thus no error message should be printed. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
f059235523
commit
16b5692061
5
image.c
5
image.c
@@ -184,16 +184,21 @@ struct cr_fdset *cr_glob_fdset_open(int mode)
|
||||
|
||||
int open_image_at(int dfd, int type, unsigned long flags, ...)
|
||||
{
|
||||
bool optional = !!(flags & O_OPT);
|
||||
char path[PATH_MAX];
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
flags &= ~O_OPT;
|
||||
|
||||
va_start(args, flags);
|
||||
vsnprintf(path, PATH_MAX, fdset_template[type].fmt, args);
|
||||
va_end(args);
|
||||
|
||||
ret = openat(dfd, path, flags, CR_FD_PERM);
|
||||
if (ret < 0) {
|
||||
if (optional && errno == ENOENT)
|
||||
return -ENOENT;
|
||||
pr_perror("Unable to open %s", path);
|
||||
goto err;
|
||||
}
|
||||
|
@@ -68,6 +68,7 @@ extern bool ns_per_id;
|
||||
#define O_DUMP (O_RDWR | O_CREAT | O_TRUNC)
|
||||
#define O_SHOW (O_RDONLY)
|
||||
#define O_RSTR (O_RDONLY)
|
||||
#define O_OPT (O_PATH)
|
||||
|
||||
extern int open_image_dir(char *dir);
|
||||
extern void close_image_dir(void);
|
||||
|
Reference in New Issue
Block a user