Lines Matching defs:rpipe

390  *  FREAD  | fd0 | -->[struct rpipe] --> |~~buffer~~| \  
400 struct pipe *rpipe, *wpipe;
407 rpipe = wpipe = NULL;
408 if (pipe_create(&rpipe) || pipe_create(&wpipe)) {
417 error = pipespace(rpipe, choose_pipespace(rpipe->pipe_buffer.size, 0));
421 TAILQ_INIT(&rpipe->pipe_evlist);
436 rf->f_data = (caddr_t)rpipe;
449 rpipe->pipe_peer = wpipe;
450 wpipe->pipe_peer = rpipe;
452 rpipe->pipe_mtxp = wpipe->pipe_mtxp = pmtx;
464 mac_pipe_label_init(rpipe);
465 mac_pipe_label_associate(kauth_cred_get(), rpipe);
466 wpipe->pipe_label = rpipe->pipe_label;
479 pipeclose(rpipe);
715 struct pipe *rpipe = (struct pipe *)fp->f_data;
720 PIPE_LOCK(rpipe);
721 ++rpipe->pipe_busy;
723 error = pipeio_lock(rpipe, 1);
728 error = mac_pipe_check_read(kauth_cred_get(), rpipe);
738 if (rpipe->pipe_buffer.cnt > 0) {
744 size = rpipe->pipe_buffer.size - rpipe->pipe_buffer.out;
745 if (size > rpipe->pipe_buffer.cnt)
746 size = rpipe->pipe_buffer.cnt;
751 PIPE_UNLOCK(rpipe); /* we still hold io lock.*/
753 &rpipe->pipe_buffer.buffer[rpipe->pipe_buffer.out],
755 PIPE_LOCK(rpipe);
759 rpipe->pipe_buffer.out += size;
760 if (rpipe->pipe_buffer.out >= rpipe->pipe_buffer.size)
761 rpipe->pipe_buffer.out = 0;
763 rpipe->pipe_buffer.cnt -= size;
770 if (rpipe->pipe_buffer.cnt == 0) {
771 rpipe->pipe_buffer.in = 0;
772 rpipe->pipe_buffer.out = 0;
780 if (rpipe->pipe_state & (PIPE_DRAIN | PIPE_EOF)) {
787 if (rpipe->pipe_state & PIPE_WANTW) {
788 rpipe->pipe_state &= ~PIPE_WANTW;
789 wakeup(rpipe);
803 pipeio_unlock(rpipe);
812 rpipe->pipe_state |= PIPE_WANTR;
813 error = msleep(rpipe, PIPE_MTX(rpipe), PRIBIO | PCATCH, "piperd", 0);
815 error = pipeio_lock(rpipe, 1);
824 pipeio_unlock(rpipe);
827 --rpipe->pipe_busy;
832 if ((rpipe->pipe_busy == 0) && (rpipe->pipe_state & PIPE_WANT)) {
833 rpipe->pipe_state &= ~(PIPE_WANT|PIPE_WANTW);
834 wakeup(rpipe);
835 } else if (rpipe->pipe_buffer.cnt < rpipe->pipe_buffer.size) {
839 if (rpipe->pipe_state & PIPE_WANTW) {
840 rpipe->pipe_state &= ~PIPE_WANTW;
841 wakeup(rpipe);
845 if ((rpipe->pipe_buffer.size - rpipe->pipe_buffer.cnt) > 0)
846 pipeselwakeup(rpipe, rpipe->pipe_peer);
849 pipe_touch(rpipe, PIPE_ATIME);
851 PIPE_UNLOCK(rpipe);
867 struct pipe *wpipe, *rpipe;
872 rpipe = (struct pipe *)fp->f_data;
874 PIPE_LOCK(rpipe);
875 wpipe = rpipe->pipe_peer;
881 PIPE_UNLOCK(rpipe);
887 PIPE_UNLOCK(rpipe);
936 PIPE_UNLOCK(rpipe);
995 PIPE_UNLOCK(rpipe);
998 PIPE_LOCK(rpipe);
1011 PIPE_UNLOCK(rpipe);
1015 PIPE_LOCK(rpipe);
1106 pipe_touch(rpipe, PIPE_MTIME | PIPE_CTIME);
1108 PIPE_UNLOCK(rpipe);
1178 struct pipe *rpipe = (struct pipe *)fp->f_data;
1182 if (rpipe == NULL || rpipe == (struct pipe *)-1)
1185 PIPE_LOCK(rpipe);
1187 wpipe = rpipe->pipe_peer;
1196 if (mac_pipe_check_select(vfs_context_ucred(ctx), rpipe, which)) {
1197 PIPE_UNLOCK(rpipe);
1204 if ((rpipe->pipe_state & PIPE_DIRECTW) ||
1205 (rpipe->pipe_buffer.cnt > 0) ||
1206 (rpipe->pipe_state & (PIPE_DRAIN | PIPE_EOF))) {
1210 rpipe->pipe_state |= PIPE_SEL;
1211 selrecord(vfs_context_proc(ctx), &rpipe->pipe_sel, wql);
1229 rpipe->pipe_state |= PIPE_SEL;
1230 selrecord(vfs_context_proc(ctx), &rpipe->pipe_sel, wql);
1233 PIPE_UNLOCK(rpipe);
1430 struct pipe *rpipe = (struct pipe *)kn->kn_fp->f_data;
1441 PIPE_LOCK(rpipe);
1443 wpipe = rpipe->pipe_peer;
1444 kn->kn_data = rpipe->pipe_buffer.cnt;
1445 if ((rpipe->pipe_state & (PIPE_DRAIN | PIPE_EOF)) ||
1452 if (rpipe->pipe_buffer.size && kn->kn_sdata > MAX_PIPESIZE(rpipe))
1453 lowwat = MAX_PIPESIZE(rpipe);
1461 PIPE_UNLOCK(rpipe);
1470 struct pipe *rpipe = (struct pipe *)kn->kn_fp->f_data;
1480 PIPE_LOCK(rpipe);
1482 wpipe = rpipe->pipe_peer;
1489 PIPE_UNLOCK(rpipe);
1503 PIPE_UNLOCK(rpipe);