Commit 16b56920 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

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: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent f0592355
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment