Commit 5cae819d authored by Pavel Emelyanov's avatar Pavel Emelyanov

img: Get rid of open_image_ro helper

O_RSTR flag should be used instead for regular open_image
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ba0ed603
......@@ -276,9 +276,9 @@ static int restore_priv_vma_content(pid_t pid)
vma = list_first_entry(&rst_vmas.h, struct vma_area, list);
fd = open_image_ro(CR_FD_PAGEMAP, (long)pid);
fd = open_image(CR_FD_PAGEMAP, O_RSTR, (long)pid);
if (fd < 0) {
fd_pg = open_image_ro(CR_FD_PAGES_OLD, pid);
fd_pg = open_image(CR_FD_PAGES_OLD, O_RSTR, pid);
if (fd_pg < 0)
return -1;
} else {
......@@ -428,7 +428,7 @@ static int read_vmas(int pid)
list_replace_init(&rst_vmas.h, &old);
/* Skip errors, because a zombie doesn't have an image of vmas */
fd = open_image_ro(CR_FD_VMAS, pid);
fd = open_image(CR_FD_VMAS, O_RSTR, pid);
if (fd < 0) {
if (errno != ENOENT)
ret = fd;
......@@ -571,7 +571,7 @@ static int prepare_sigactions(int pid)
int sig;
int ret = -1;
fd_sigact = open_image_ro(CR_FD_SIGACT, pid);
fd_sigact = open_image(CR_FD_SIGACT, O_RSTR, pid);
if (fd_sigact < 0)
return -1;
......@@ -859,7 +859,7 @@ static inline int fork_with_pid(struct pstree_item *item)
pid_t pid = item->pid.virt;
if (item->state != TASK_HELPER) {
fd = open_image_ro(CR_FD_CORE, pid);
fd = open_image(CR_FD_CORE, O_RSTR, pid);
if (fd < 0)
return -1;
......@@ -1434,7 +1434,7 @@ static int prepare_itimers(int pid, struct task_restore_core_args *args)
int fd, ret = -1;
ItimerEntry *ie;
fd = open_image_ro(CR_FD_ITIMERS, pid);
fd = open_image(CR_FD_ITIMERS, O_RSTR, pid);
if (fd < 0)
return fd;
......@@ -1477,7 +1477,7 @@ static int prepare_creds(int pid, struct task_restore_core_args *args)
int fd, ret;
CredsEntry *ce;
fd = open_image_ro(CR_FD_CREDS, pid);
fd = open_image(CR_FD_CREDS, O_RSTR, pid);
if (fd < 0)
return fd;
......@@ -1550,7 +1550,7 @@ static int prepare_mm(pid_t pid, struct task_restore_core_args *args)
int fd, exe_fd, i, ret = -1;
MmEntry *mm;
fd = open_image_ro(CR_FD_MM, pid);
fd = open_image(CR_FD_MM, O_RSTR, pid);
if (fd < 0)
return -1;
......@@ -1673,7 +1673,7 @@ static int prepare_rlimits(int pid, struct task_restore_core_args *ta)
ta->nr_rlim = 0;
fd = open_image_ro(CR_FD_RLIMIT, pid);
fd = open_image(CR_FD_RLIMIT, O_RSTR, pid);
if (fd < 0) {
if (errno == ENOENT) {
pr_info("Skip rlimits for %d\n", pid);
......@@ -1719,7 +1719,7 @@ static int open_signal_image(int type, pid_t pid, siginfo_t **ptr,
{
int fd, ret, n;
fd = open_image_ro(type, pid);
fd = open_image(type, O_RSTR, pid);
if (fd < 0)
return -1;
......@@ -1993,7 +1993,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
task_args->t = thread_args + i;
tcore = core;
} else {
fd_core = open_image_ro(CR_FD_CORE, thread_args[i].pid);
fd_core = open_image(CR_FD_CORE, O_RSTR, thread_args[i].pid);
if (fd_core < 0) {
pr_err("Can't open core data for thread %d\n",
thread_args[i].pid);
......
......@@ -460,7 +460,7 @@ static int cr_show_pstree_item(struct cr_options *opts, struct pstree_item *item
if (item->threads[i].virt == item->pid.virt)
continue;
fd_th = open_image_ro(CR_FD_CORE, item->threads[i].virt);
fd_th = open_image(CR_FD_CORE, O_SHOW, item->threads[i].virt);
if (fd_th < 0)
goto outc;
......@@ -484,7 +484,7 @@ static int cr_show_pstree_item(struct cr_options *opts, struct pstree_item *item
}
if (pb_read_one(fdset_fd(cr_fdset, CR_FD_IDS), &ids, PB_IDS) > 0) {
i = open_image_ro(CR_FD_FDINFO, ids->files_id);
i = open_image(CR_FD_FDINFO, O_SHOW, ids->files_id);
if (i >= 0) {
pr_msg("* ");
pr_msg(fdset_template[CR_FD_FDINFO].fmt, ids->files_id);
......@@ -511,7 +511,7 @@ static int cr_show_pid(struct cr_options *opts, int pid)
int fd, ret;
struct pstree_item item;
fd = open_image_ro(CR_FD_PSTREE);
fd = open_image(CR_FD_PSTREE, O_SHOW);
if (fd < 0)
return -1;
......@@ -541,13 +541,13 @@ static int cr_show_all(struct cr_options *opts)
struct pstree_item *item = NULL, *tmp;
int ret = -1, fd, pid;
fd = open_image_ro(CR_FD_PSTREE);
fd = open_image(CR_FD_PSTREE, O_SHOW);
if (fd < 0)
goto out;
show_collect_pstree(fd, 1);
close(fd);
fd = open_image_ro(CR_FD_SK_QUEUES);
fd = open_image(CR_FD_SK_QUEUES, O_SHOW);
if (fd < 0)
goto out;
......
......@@ -222,7 +222,7 @@ static int restore_file_locks(int pid)
int fd, ret = -1;
FileLockEntry *fle;
fd = open_image_ro(CR_FD_FILE_LOCKS, pid);
fd = open_image(CR_FD_FILE_LOCKS, O_RSTR, pid);
if (fd < 0) {
if (errno == ENOENT)
return 0;
......
......@@ -73,7 +73,7 @@ static int open_remap_ghost(struct reg_file_info *rfi,
if (!gf->remap.path)
goto err;
ifd = open_image_ro(CR_FD_GHOST_FILE, rfe->remap_id);
ifd = open_image(CR_FD_GHOST_FILE, O_RSTR, rfe->remap_id);
if (ifd < 0)
goto err;
......@@ -169,7 +169,7 @@ static int collect_remaps(void)
{
int fd, ret = 0;
fd = open_image_ro(CR_FD_REMAP_FPATH);
fd = open_image(CR_FD_REMAP_FPATH, O_RSTR);
if (fd < 0)
return -1;
......
......@@ -435,7 +435,7 @@ int prepare_fd_pid(struct pstree_item *item)
INIT_LIST_HEAD(&rst_info->tty_slaves);
if (!fdinfo_per_id) {
fdinfo_fd = open_image_ro(CR_FD_FDINFO, pid);
fdinfo_fd = open_image(CR_FD_FDINFO, O_RSTR, pid);
if (fdinfo_fd < 0) {
if (errno == ENOENT)
return 0;
......@@ -448,7 +448,7 @@ int prepare_fd_pid(struct pstree_item *item)
if (item->rst->fdt && item->rst->fdt->pid != item->pid.virt)
return 0;
fdinfo_fd = open_image_ro(CR_FD_FDINFO, item->ids->files_id);
fdinfo_fd = open_image(CR_FD_FDINFO, O_RSTR, item->ids->files_id);
if (fdinfo_fd < 0)
return -1;
}
......@@ -817,7 +817,7 @@ int prepare_fs(int pid)
int ifd, cwd, ret = -1;
FsEntry *fe;
ifd = open_image_ro(CR_FD_FS, pid);
ifd = open_image(CR_FD_FS, O_RSTR, pid);
if (ifd < 0)
return -1;
......
......@@ -25,7 +25,7 @@ int check_img_inventory(void)
int fd, ret = -1;
InventoryEntry *he;
fd = open_image_ro(CR_FD_INVENTORY);
fd = open_image(CR_FD_INVENTORY, O_RSTR);
if (fd < 0)
return -1;
......
......@@ -189,7 +189,6 @@ extern int open_image_dir(void);
extern void close_image_dir(void);
int open_image(int type, unsigned long flags, ...);
#define open_image_ro(type, ...) open_image(type, O_RDONLY, ##__VA_ARGS__)
int open_pages_image(unsigned long flags, int pm_fd);
void up_page_ids_base(void);
......
......@@ -600,7 +600,7 @@ static int prepare_ipc_sem(int pid)
int fd, ret;
pr_info("Restoring IPC semaphores sets\n");
fd = open_image_ro(CR_FD_IPCNS_SEM, pid);
fd = open_image(CR_FD_IPCNS_SEM, O_RSTR, pid);
if (fd < 0)
return -1;
......@@ -733,7 +733,7 @@ static int prepare_ipc_msg(int pid)
int fd, ret;
pr_info("Restoring IPC message queues\n");
fd = open_image_ro(CR_FD_IPCNS_MSG, pid);
fd = open_image(CR_FD_IPCNS_MSG, O_RSTR, pid);
if (fd < 0)
return -1;
......@@ -843,7 +843,7 @@ static int prepare_ipc_shm(int pid)
int fd, ret;
pr_info("Restoring IPC shared memory\n");
fd = open_image_ro(CR_FD_IPCNS_SHM, pid);
fd = open_image(CR_FD_IPCNS_SHM, O_RSTR, pid);
if (fd < 0)
return -1;
......@@ -881,7 +881,7 @@ static int prepare_ipc_var(int pid)
IpcVarEntry *var;
pr_info("Restoring IPC variables\n");
fd = open_image_ro(CR_FD_IPCNS_VAR, pid);
fd = open_image(CR_FD_IPCNS_VAR, O_RSTR, pid);
if (fd < 0)
return -1;
......
......@@ -296,7 +296,7 @@ static int tmpfs_restore(struct mount_info *pm)
int ret;
int fd_img;
fd_img = open_image_ro(CR_FD_TMPFS, pm->mnt_id);
fd_img = open_image(CR_FD_TMPFS, O_RSTR, pm->mnt_id);
if (fd_img < 0)
return -1;
......@@ -641,7 +641,7 @@ static int populate_mnt_ns(int ns_pid)
pr_info("Populating mount namespace\n");
img = open_image_ro(CR_FD_MOUNTPOINTS, ns_pid);
img = open_image(CR_FD_MOUNTPOINTS, O_RSTR, ns_pid);
if (img < 0)
return -1;
......
......@@ -256,7 +256,7 @@ static int restore_links(int pid)
int fd, nlsk, ret;
NetDeviceEntry *nde;
fd = open_image_ro(CR_FD_NETDEV, pid);
fd = open_image(CR_FD_NETDEV, O_RSTR, pid);
if (fd < 0)
return -1;
......@@ -318,7 +318,7 @@ static int restore_ip_dump(int type, int pid, char *cmd)
{
int fd, ret;
ret = fd = open_image_ro(type, pid);
ret = fd = open_image(type, O_RSTR, pid);
if (fd >= 0) {
ret = run_ip_tool(cmd, "restore", fd, -1);
close(fd);
......
......@@ -74,7 +74,7 @@ int collect_pipe_data(int img_type, struct pipe_data_rst **hash)
int fd, ret;
struct pipe_data_rst *r = NULL;
fd = open_image_ro(img_type);
fd = open_image(img_type, O_RSTR);
if (fd < 0)
return -1;
......
......@@ -684,7 +684,7 @@ static int __collect_image(int fd_t, int obj_t, unsigned size,
{
int fd, ret;
fd = open_image_ro(fd_t);
fd = open_image(fd_t, O_RSTR);
if (fd < 0)
return -1;
......
......@@ -190,7 +190,7 @@ static int read_pstree_image(void)
pr_info("Reading image tree\n");
ps_fd = open_image_ro(CR_FD_PSTREE);
ps_fd = open_image(CR_FD_PSTREE, O_RSTR);
if (ps_fd < 0)
return ps_fd;
......@@ -268,7 +268,7 @@ static int read_pstree_image(void)
pstree_entry__free_unpacked(e, NULL);
fd = open_image_ro(CR_FD_IDS, pi->pid.virt);
fd = open_image(CR_FD_IDS, O_RSTR, pi->pid.virt);
if (fd < 0) {
if (errno == ENOENT)
continue;
......
......@@ -83,7 +83,7 @@ int prepare_shmem_pid(int pid)
int fd, ret = -1;
VmaEntry *vi;
fd = open_image_ro(CR_FD_VMAS, pid);
fd = open_image(CR_FD_VMAS, O_RSTR, pid);
if (fd < 0) {
if (errno == ENOENT)
return 0;
......@@ -138,9 +138,9 @@ static int restore_shmem_content(void *addr, struct shmem_info *si)
{
int fd, fd_pg, ret = 0;
fd = open_image_ro(CR_FD_SHMEM_PAGEMAP, si->shmid);
fd = open_image(CR_FD_SHMEM_PAGEMAP, O_RSTR, si->shmid);
if (fd < 0) {
fd_pg = open_image_ro(CR_FD_SHM_PAGES_OLD, si->shmid);
fd_pg = open_image(CR_FD_SHM_PAGES_OLD, O_RSTR, si->shmid);
if (fd_pg < 0)
goto err_unmap;
} else {
......
......@@ -38,7 +38,7 @@ int read_sk_queues(void)
pr_info("Trying to read socket queues image\n");
fd = open_image_ro(CR_FD_SK_QUEUES);
fd = open_image(CR_FD_SK_QUEUES, O_RSTR);
if (fd < 0)
return -1;
......@@ -192,7 +192,7 @@ int restore_sk_queue(int fd, unsigned int peer_id)
if (restore_prepare_socket(fd))
return -1;
img_fd = open_image_ro(CR_FD_SK_QUEUES);
img_fd = open_image(CR_FD_SK_QUEUES, O_RSTR);
if (img_fd < 0)
return -1;
......
......@@ -512,7 +512,7 @@ static int restore_tcp_conn_state(int sk, struct inet_sk_info *ii)
pr_info("Restoring TCP connection id %x ino %x\n", ii->ie->id, ii->ie->ino);
ifd = open_image_ro(CR_FD_TCP_STREAM, ii->ie->ino);
ifd = open_image(CR_FD_TCP_STREAM, O_RSTR, ii->ie->ino);
if (ifd < 0)
goto err;
......
......@@ -45,7 +45,7 @@ int prepare_utsns(int pid)
{ },
};
fd = open_image_ro(CR_FD_UTSNS, pid);
fd = open_image(CR_FD_UTSNS, O_RSTR, pid);
if (fd < 0)
return -1;
......
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