Commit b9f13599 authored by Pavel Emelyanov's avatar Pavel Emelyanov

files: Simpler regfiles and sockets open

The list_head ptr passed into it can be converted into
the respective _info with container_of, rather than search.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent d1c9f0d7
......@@ -212,16 +212,12 @@ int prepare_fd_pid(int pid)
return ret;
}
static int open_fe_fd(struct fdinfo_entry *fe)
static int open_fe_fd(struct list_head *l)
{
struct reg_file_info *rfi;
int tmp;
rfi = find_reg_file(fe->id);
if (!rfi) {
pr_err("Can't find file id %x\n", fe->id);
return -1;
}
rfi = container_of(l, struct reg_file_info, fd_head);
tmp = open(rfi->path, rfi->rfe.flags);
if (tmp < 0) {
......@@ -233,12 +229,25 @@ static int open_fe_fd(struct fdinfo_entry *fe)
return tmp;
}
static int find_open_fe_fd(struct fdinfo_entry *fe)
{
struct reg_file_info *rfi;
int tmp;
rfi = find_reg_file(fe->id);
if (!rfi) {
pr_err("Can't find file id %x\n", fe->id);
return -1;
}
return open_fe_fd(&rfi->fd_head);
}
static int restore_cwd(struct fdinfo_entry *fe, int fd)
{
int cfd;
cfd = open_fe_fd(fe);
cfd = find_open_fe_fd(fe);
if (cfd < 0)
return cfd;
......@@ -267,7 +276,7 @@ static int restore_exe_early(struct fdinfo_entry *fe, int fd)
if (self_exe_fd < 0)
return self_exe_fd;
tmp = open_fe_fd(fe);
tmp = find_open_fe_fd(fe);
if (tmp < 0)
return tmp;
......@@ -360,10 +369,10 @@ static int open_fd(int pid, struct fdinfo_entry *fe,
switch (fe->type) {
case FDINFO_REG:
tmp = open_fe_fd(fe);
tmp = open_fe_fd(fd_list);
break;
case FDINFO_INETSK:
tmp = open_inet_sk(fe);
tmp = open_inet_sk(fd_list);
break;
default:
tmp = -1;
......@@ -444,7 +453,7 @@ static int open_fmap(int pid, struct fdinfo_entry *fe, int fd)
struct fmap_fd *new;
int tmp;
tmp = open_fe_fd(fe);
tmp = find_open_fe_fd(fe);
if (tmp < 0)
return -1;
......
......@@ -17,8 +17,7 @@ extern int collect_sockets(void);
extern int collect_inet_sockets(void);
extern int collect_unix_sockets(int pid);
extern int prepare_sockets(int pid);
struct fdinfo_entry;
extern int open_inet_sk(struct fdinfo_entry *fe);
extern int open_inet_sk(struct list_head *);
struct cr_options;
extern void show_unixsk(int fd, struct cr_options *);
extern void show_inetsk(int fd, struct cr_options *);
......
......@@ -1320,17 +1320,13 @@ int collect_inet_sockets(void)
return 0;
}
int open_inet_sk(struct fdinfo_entry *fe)
int open_inet_sk(struct list_head *l)
{
int sk;
struct sockaddr_in addr;
struct inet_sk_info *ii;
ii = find_inet_sk(fe->id);
if (ii == NULL) {
pr_err("Can't find inet sk %u\n", fe->id);
return -1;
}
ii = container_of(l, struct inet_sk_info, fd_head);
show_one_inet_img("Restore", &ii->ie);
......
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