struct cr_fdset *cr_fdset_open_range(int pid, int from, int to, unsigned long flags) { struct cr_fdset *fdset; unsigned int i; int ret = -1; fdset = alloc_cr_fdset(to - from); if (!fdset) goto err; from++; fdset->fd_off = from; for (i = from; i < to; i++) { ret = open_image(i, flags, pid); if (ret < 0) { if (!(flags & O_CREAT)) /* caller should check himself */ continue; goto err; } fdset->_fds[i - from] = ret; } return fdset; err: close_cr_fdset(&fdset); return NULL; }
int dump_ipc_ns(int ns_pid, int ns_id) { int ret; struct cr_fdset *fdset; fdset = cr_fdset_open(ns_id, IPCNS, O_DUMP); if (fdset == NULL) return -1; ret = switch_ns(ns_pid, &ipc_ns_desc, NULL); if (ret < 0) goto err; ret = dump_ipc_data(fdset); if (ret < 0) { pr_err("Failed to write IPC namespace data\n"); goto err; } err: close_cr_fdset(&fdset); return ret < 0 ? -1 : 0; }