Commit e29c9dae authored by Pavel Emelyanov's avatar Pavel Emelyanov

img: Remove O_OPT and COLLECT_OPTIONAL

Current code doesn't make any difference between OPT and no-OPT
except for the message is printed or not in the open_image().
So this particular change changes nothing but the availability of
this message.

In the next patches I wil introduce "empty images" to deal with
the ENOENT situation in a more graceful manner.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 8218e014
......@@ -428,7 +428,7 @@ int cpu_validate_cpuinfo(void)
struct cr_img *img;
int ret = -1;
img = open_image(CR_FD_CPUINFO, O_RSTR | O_OPT);
img = open_image(CR_FD_CPUINFO, O_RSTR);
if (!img)
return -1;
......
......@@ -1291,7 +1291,7 @@ int prepare_cgroup(void)
struct cr_img *img;
CgroupEntry *ce;
img = open_image(CR_FD_CGROUP, O_RSTR | O_OPT);
img = open_image(CR_FD_CGROUP, O_RSTR);
if (!img) {
if (errno == ENOENT) /* backward compatibility */
return 0;
......
......@@ -2419,7 +2419,7 @@ static int prepare_rlimits_from_fd(int pid)
/*
* Old image -- read from the file.
*/
img = open_image(CR_FD_RLIMIT, O_RSTR | O_OPT, pid);
img = open_image(CR_FD_RLIMIT, O_RSTR, pid);
if (!img) {
if (errno == ENOENT) {
pr_info("Skip rlimits for %d\n", pid);
......@@ -2511,7 +2511,7 @@ static int open_signal_image(int type, pid_t pid, unsigned int *nr)
int ret;
struct cr_img *img;
img = open_image(type, O_RSTR | O_OPT, pid);
img = open_image(type, O_RSTR, pid);
if (!img) {
if (errno == ENOENT) /* backward compatibility */
return 0;
......
......@@ -454,7 +454,7 @@ static int cr_show_pstree_item(struct pstree_item *item)
cr_parse_fd(img_from_set(cr_imgset, i), imgset_template[i].magic);
}
img = open_image(CR_FD_RLIMIT, O_SHOW | O_OPT, item->pid.virt);
img = open_image(CR_FD_RLIMIT, O_SHOW, item->pid.virt);
if (img) {
pr_msg("* ");
pr_msg(imgset_template[CR_FD_RLIMIT].fmt, item->pid.virt);
......
......@@ -210,7 +210,6 @@ struct collect_image_info epoll_tfd_cinfo = {
.pb_type = PB_EVENTPOLL_TFD,
.priv_size = sizeof(struct eventpoll_tfd_file_info),
.collect = collect_one_epoll_tfd,
.flags = COLLECT_OPTIONAL,
};
static int collect_one_epoll(void *o, ProtobufCMessage *msg)
......
......@@ -40,7 +40,6 @@ struct collect_image_info file_locks_cinfo = {
.pb_type = PB_FILE_LOCK,
.priv_size = sizeof(struct file_lock_rst),
.collect = collect_one_file_lock,
.flags = COLLECT_OPTIONAL,
};
struct file_lock *alloc_file_lock(void)
......@@ -342,7 +341,7 @@ static int restore_file_locks_legacy(int pid)
struct cr_img *img;
FileLockEntry *fle;
img = open_image(CR_FD_FILE_LOCKS_PID, O_RSTR | O_OPT, pid);
img = open_image(CR_FD_FILE_LOCKS_PID, O_RSTR, pid);
if (!img) {
if (errno == ENOENT)
return 0;
......
......@@ -609,7 +609,7 @@ int prepare_fd_pid(struct pstree_item *item)
INIT_LIST_HEAD(&rst_info->tty_slaves);
if (!fdinfo_per_id) {
img = open_image(CR_FD_FDINFO, O_RSTR | O_OPT, pid);
img = open_image(CR_FD_FDINFO, O_RSTR, pid);
if (!img) {
if (errno == ENOENT)
return 0;
......@@ -1116,7 +1116,7 @@ int prepare_fs_pid(struct pstree_item *item)
struct cr_img *img;
FsEntry *fe;
img = open_image(CR_FD_FS, O_RSTR | O_OPT, pid);
img = open_image(CR_FD_FS, O_RSTR, pid);
if (!img) {
if (errno == ENOENT)
goto ok;
......
......@@ -756,7 +756,6 @@ struct collect_image_info inotify_cinfo = {
.pb_type = PB_INOTIFY_FILE,
.priv_size = sizeof(struct fsnotify_file_info),
.collect = collect_one_inotify,
.flags = COLLECT_OPTIONAL,
};
static int collect_one_fanotify(void *o, ProtobufCMessage *msg)
......@@ -792,7 +791,6 @@ struct collect_image_info fanotify_cinfo = {
.pb_type = PB_FANOTIFY_FILE,
.priv_size = sizeof(struct fsnotify_file_info),
.collect = collect_one_fanotify,
.flags = COLLECT_OPTIONAL,
};
static int collect_one_inotify_mark(void *o, ProtobufCMessage *msg)
......@@ -811,7 +809,6 @@ struct collect_image_info inotify_mark_cinfo = {
.pb_type = PB_INOTIFY_WD,
.priv_size = sizeof(struct fsnotify_mark_info),
.collect = collect_one_inotify_mark,
.flags = COLLECT_OPTIONAL,
};
static int collect_one_fanotify_mark(void *o, ProtobufCMessage *msg)
......@@ -830,5 +827,4 @@ struct collect_image_info fanotify_mark_cinfo = {
.pb_type = PB_FANOTIFY_MARK,
.priv_size = sizeof(struct fsnotify_mark_info),
.collect = collect_one_fanotify_mark,
.flags = COLLECT_OPTIONAL,
};
......@@ -218,7 +218,7 @@ struct cr_img *open_image_at(int dfd, int type, unsigned long flags, ...)
goto errn;
oflags |= imgset_template[type].oflags;
flags &= ~(O_OPT | O_NOBUF);
flags &= ~(O_NOBUF);
va_start(args, flags);
vsnprintf(path, PATH_MAX, imgset_template[type].fmt, args);
......@@ -226,12 +226,10 @@ struct cr_img *open_image_at(int dfd, int type, unsigned long flags, ...)
ret = openat(dfd, path, flags, CR_FD_PERM);
if (ret < 0) {
if ((oflags & O_OPT) && errno == ENOENT) {
xfree(img);
return NULL;
}
pr_perror("Unable to open %s", path);
if (errno == ENOENT)
pr_info("No %s image\n", path);
else
pr_perror("Unable to open %s", path);
goto err;
}
......
......@@ -117,7 +117,6 @@
extern bool fdinfo_per_id;
extern bool ns_per_id;
#define O_OPT (O_PATH)
#define O_NOBUF (O_DIRECT)
#define O_DUMP (O_WRONLY | O_CREAT | O_TRUNC)
......
......@@ -50,7 +50,6 @@ struct collect_image_info {
};
#define COLLECT_SHARED 0x1 /* use shared memory for obj-s */
#define COLLECT_OPTIONAL 0x2 /* image file may be missing */
#define COLLECT_HAPPENED 0x4 /* image was opened and collected */
extern int collect_image(struct collect_image_info *);
......
......@@ -399,7 +399,7 @@ static int open_irmap_cache(struct cr_img **img)
pr_info("Searching irmap cache in work dir\n");
in:
*img = open_image_at(dir, CR_FD_IRMAP_CACHE, O_RSTR | O_OPT);
*img = open_image_at(dir, CR_FD_IRMAP_CACHE, O_RSTR);
if (dir != AT_FDCWD)
close(dir);
......
......@@ -395,7 +395,7 @@ int prepare_mm_pid(struct pstree_item *i)
struct cr_img *img;
struct rst_info *ri = rsti(i);
img = open_image(CR_FD_MM, O_RSTR | O_OPT, pid);
img = open_image(CR_FD_MM, O_RSTR, pid);
if (!img) {
if (errno == ENOENT)
return 0;
......
......@@ -408,7 +408,6 @@ struct collect_image_info nsfile_cinfo = {
.pb_type = PB_NS_FILE,
.priv_size = sizeof(struct ns_file_info),
.collect = collect_one_nsfile,
.flags = COLLECT_OPTIONAL,
};
/*
......
......@@ -633,7 +633,6 @@ err:
int collect_image(struct collect_image_info *cinfo)
{
bool optional = !!(cinfo->flags & COLLECT_OPTIONAL);
int ret;
struct cr_img *img;
void *(*o_alloc)(size_t size) = malloc;
......@@ -642,9 +641,9 @@ int collect_image(struct collect_image_info *cinfo)
pr_info("Collecting %d/%d (flags %x)\n",
cinfo->fd_type, cinfo->pb_type, cinfo->flags);
img = open_image(cinfo->fd_type, O_RSTR | (optional ? O_OPT : 0));
img = open_image(cinfo->fd_type, O_RSTR);
if (!img) {
if (optional && errno == ENOENT)
if (errno == ENOENT)
return 0;
else
return -1;
......
......@@ -120,5 +120,4 @@ struct collect_image_info signalfd_cinfo = {
.pb_type = PB_SIGNALFD,
.priv_size = sizeof(struct signalfd_info),
.collect = collect_one_sigfd,
.flags = COLLECT_OPTIONAL,
};
......@@ -230,5 +230,4 @@ struct collect_image_info netlink_sk_cinfo = {
.pb_type = PB_NETLINK_SK,
.priv_size = sizeof(struct netlink_sock_info),
.collect = collect_one_netlink_sk,
.flags = COLLECT_OPTIONAL,
};
......@@ -500,5 +500,4 @@ struct collect_image_info packet_sk_cinfo = {
.pb_type = PB_PACKET_SOCK,
.priv_size = sizeof(struct packet_sock_info),
.collect = collect_one_packet_sk,
.flags = COLLECT_OPTIONAL,
};
......@@ -194,5 +194,4 @@ struct collect_image_info timerfd_cinfo = {
.pb_type = PB_TIMERFD,
.priv_size = sizeof(struct timerfd_info),
.collect = collect_one_timerfd,
.flags = COLLECT_OPTIONAL,
};
......@@ -1274,7 +1274,6 @@ struct collect_image_info tty_info_cinfo = {
.pb_type = PB_TTY_INFO,
.priv_size = sizeof(struct tty_info_entry),
.collect = collect_one_tty_info_entry,
.flags = COLLECT_OPTIONAL,
};
static int collect_one_tty(void *obj, ProtobufCMessage *msg)
......@@ -1339,7 +1338,6 @@ struct collect_image_info tty_cinfo = {
.pb_type = PB_TTY_FILE,
.priv_size = sizeof(struct tty_info),
.collect = collect_one_tty,
.flags = COLLECT_OPTIONAL,
};
/* Make sure the ttys we're dumping do belong our process tree */
......
......@@ -400,7 +400,6 @@ struct collect_image_info tunfile_cinfo = {
.pb_type = PB_TUNFILE,
.priv_size = sizeof(struct tunfile_info),
.collect = collect_one_tunfile,
.flags = COLLECT_OPTIONAL,
};
int dump_tun_link(NetDeviceEntry *nde, struct cr_imgset *fds)
......
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