struct proc *proc;
struct file *file;
struct filedesc *fildes[2];
+ struct cxmsg resp;
+ struct cxio_response *ioresp;
+
int fd[2];
int err;
int i;
- char buf[128];
- int len;
-
file = NULL;
- memset(&fd, 0, sizeof(fd));
- memset(&fildes, 0, sizeof(fildes));
+ fd[0] = -1;
+ fd[1] = -1;
- len = snprintf(buf, sizeof(buf), "%s(%d, %p)\n", __func__, pid, req);
- debug(buf, len);
+ ioresp = (struct cxio_response*)resp.cm_data;
+
+ memset(&resp, 0, sizeof(resp));
+ memset(&fildes, 0, sizeof(fildes));
err = proc_lookup(pid, &proc);
}
for(i = 0; i < 2; i++) {
+ char buf[128];
+ int len;
+
err = fd_new(&fildes[i]);
if(err < 0) {
}
fd_set_file(fildes[i], file);
- fd[i] = proc_add_fd(proc, fildes[i]);
+ err = proc_add_fd(proc, fildes[i]);
+
+ if(err < 0) {
+ goto cleanup;
+ }
+
+ fd[i] = err;
len = snprintf(buf, sizeof(buf), "%s: pipe[%d]=%d fd=%p file=%p\n", __func__, i, fd[i], fildes[i], file);
debug(buf, len);
fd_free(fildes[i]);
}
}
+
+ ioresp->retval = -1;
+ ioresp->error = -err;
+ } else {
+ ioresp->retval = 0;
+ ioresp->error = 0;
+
+ ioresp->extralen = sizeof(fd);
+ memcpy(ioresp->extradata, &fd, sizeof(fd));
}
+ ioresp->fd = -1;
+ resp.cm_type = CXIO_RESPONSE;
+ resp.cm_len = ioresp->extralen + sizeof(*ioresp);
+
+ cxsend(pid, &resp);
+
return;
}