Commit 0327d551 authored by Pavel Emelyanov's avatar Pavel Emelyanov

fdset: Beautify fdset opening

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 02227d87
...@@ -147,7 +147,7 @@ void close_cr_fdset(struct cr_fdset **cr_fdset) ...@@ -147,7 +147,7 @@ void close_cr_fdset(struct cr_fdset **cr_fdset)
*cr_fdset = NULL; *cr_fdset = NULL;
} }
struct cr_fdset *cr_fdset_open(int pid, int from, int to, struct cr_fdset *cr_fdset_open_range(int pid, int from, int to,
unsigned long flags) unsigned long flags)
{ {
struct cr_fdset *fdset; struct cr_fdset *fdset;
...@@ -181,12 +181,12 @@ err: ...@@ -181,12 +181,12 @@ err:
struct cr_fdset *cr_task_fdset_open(int pid, int mode) struct cr_fdset *cr_task_fdset_open(int pid, int mode)
{ {
return cr_fdset_open(pid, _CR_FD_TASK_FROM, _CR_FD_TASK_TO, mode); return cr_fdset_open(pid, TASK, mode);
} }
struct cr_fdset *cr_glob_fdset_open(int mode) struct cr_fdset *cr_glob_fdset_open(int mode)
{ {
return cr_fdset_open(-1 /* ignored */, _CR_FD_GLOB_FROM, _CR_FD_GLOB_TO, mode); return cr_fdset_open(-1 /* ignored */, GLOB, mode);
} }
int open_image_at(int dfd, int type, unsigned long flags, ...) int open_image_at(int dfd, int type, unsigned long flags, ...)
......
...@@ -124,8 +124,10 @@ int cr_exec(int pid, char **opts); ...@@ -124,8 +124,10 @@ int cr_exec(int pid, char **opts);
#define O_RSTR (O_RDONLY) #define O_RSTR (O_RDONLY)
struct cr_fdset *cr_task_fdset_open(int pid, int mode); struct cr_fdset *cr_task_fdset_open(int pid, int mode);
struct cr_fdset *cr_fdset_open(int pid, int from, int to, struct cr_fdset *cr_fdset_open_range(int pid, int from, int to,
unsigned long flags); unsigned long flags);
#define cr_fdset_open(pid, type, flags) cr_fdset_open_range(pid, \
_CR_FD_##type##_FROM, _CR_FD_##type##_TO, flags)
struct cr_fdset *cr_glob_fdset_open(int mode); struct cr_fdset *cr_glob_fdset_open(int mode);
void close_cr_fdset(struct cr_fdset **cr_fdset); void close_cr_fdset(struct cr_fdset **cr_fdset);
......
...@@ -460,7 +460,7 @@ int dump_ipc_ns(int ns_pid, int ns_id) ...@@ -460,7 +460,7 @@ int dump_ipc_ns(int ns_pid, int ns_id)
int ret; int ret;
struct cr_fdset *fdset; struct cr_fdset *fdset;
fdset = cr_fdset_open(ns_id, _CR_FD_IPCNS_FROM, _CR_FD_IPCNS_TO, O_DUMP); fdset = cr_fdset_open(ns_id, IPCNS, O_DUMP);
if (fdset == NULL) if (fdset == NULL)
return -1; return -1;
......
...@@ -495,8 +495,7 @@ int try_show_namespaces(int ns_pid) ...@@ -495,8 +495,7 @@ int try_show_namespaces(int ns_pid)
if (ret < 0) if (ret < 0)
return -1; return -1;
fdset = cr_fdset_open(ids->net_ns_id, fdset = cr_fdset_open(ids->net_ns_id, NETNS, O_SHOW);
_CR_FD_NETNS_FROM, _CR_FD_NETNS_TO, O_SHOW);
if (fdset) { if (fdset) {
pr_msg("-------------------NETNS---------------------\n"); pr_msg("-------------------NETNS---------------------\n");
for (i = _CR_FD_NETNS_FROM + 1; i < _CR_FD_NETNS_TO; i++) { for (i = _CR_FD_NETNS_FROM + 1; i < _CR_FD_NETNS_TO; i++) {
...@@ -511,8 +510,7 @@ int try_show_namespaces(int ns_pid) ...@@ -511,8 +510,7 @@ int try_show_namespaces(int ns_pid)
close_cr_fdset(&fdset); close_cr_fdset(&fdset);
} }
fdset = cr_fdset_open(ids->ipc_ns_id, fdset = cr_fdset_open(ids->ipc_ns_id, IPCNS, O_SHOW);
_CR_FD_IPCNS_FROM, _CR_FD_IPCNS_TO, O_SHOW);
if (fdset) { if (fdset) {
pr_msg("-------------------IPCNS---------------------\n"); pr_msg("-------------------IPCNS---------------------\n");
for (i = _CR_FD_IPCNS_FROM + 1; i < _CR_FD_IPCNS_TO; i++) { for (i = _CR_FD_IPCNS_FROM + 1; i < _CR_FD_IPCNS_TO; i++) {
......
...@@ -468,7 +468,7 @@ int dump_net_ns(int pid, int ns_id) ...@@ -468,7 +468,7 @@ int dump_net_ns(int pid, int ns_id)
struct cr_fdset *fds; struct cr_fdset *fds;
int ret; int ret;
fds = cr_fdset_open(ns_id, _CR_FD_NETNS_FROM, _CR_FD_NETNS_TO, O_DUMP); fds = cr_fdset_open(ns_id, NETNS, O_DUMP);
if (fds == NULL) if (fds == NULL)
return -1; 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