Lines Matching defs:cpipe
241 static void pipeclose(struct pipe *cpipe);
242 static void pipe_free_kmem(struct pipe *cpipe);
244 static void pipeselwakeup(struct pipe *cpipe, struct pipe *spipe);
245 static __inline int pipelock(struct pipe *cpipe, int catch);
246 static __inline void pipeunlock(struct pipe *cpipe);
256 extern void evpipefree(struct pipe *cpipe);
259 static int pipespace(struct pipe *cpipe, int size);
422 pipe_stat(struct pipe *cpipe, void *ub, int isstat64)
432 if (cpipe == NULL)
434 PIPE_LOCK(cpipe);
437 error = mac_pipe_check_stat(kauth_cred_get(), cpipe);
439 PIPE_UNLOCK(cpipe);
443 if (cpipe->pipe_buffer.buffer == 0) {
447 if (cpipe->pipe_peer) {
451 pipe_size = cpipe->pipe_peer->pipe_buffer.size;
452 pipe_count = cpipe->pipe_peer->pipe_buffer.cnt;
457 pipe_size = cpipe->pipe_buffer.size;
458 pipe_count = cpipe->pipe_buffer.cnt;
479 sb64->st_atimespec.tv_sec = cpipe->st_atimespec.tv_sec;
480 sb64->st_atimespec.tv_nsec = cpipe->st_atimespec.tv_nsec;
482 sb64->st_mtimespec.tv_sec = cpipe->st_mtimespec.tv_sec;
483 sb64->st_mtimespec.tv_nsec = cpipe->st_mtimespec.tv_nsec;
485 sb64->st_ctimespec.tv_sec = cpipe->st_ctimespec.tv_sec;
486 sb64->st_ctimespec.tv_nsec = cpipe->st_ctimespec.tv_nsec;
493 sb64->st_ino = (ino64_t)((uint32_t)cpipe);
506 sb->st_atimespec.tv_sec = cpipe->st_atimespec.tv_sec;
507 sb->st_atimespec.tv_nsec = cpipe->st_atimespec.tv_nsec;
509 sb->st_mtimespec.tv_sec = cpipe->st_mtimespec.tv_sec;
510 sb->st_mtimespec.tv_nsec = cpipe->st_mtimespec.tv_nsec;
512 sb->st_ctimespec.tv_sec = cpipe->st_ctimespec.tv_sec;
513 sb->st_ctimespec.tv_nsec = cpipe->st_ctimespec.tv_nsec;
520 sb->st_ino = (ino_t)cpipe;
522 PIPE_UNLOCK(cpipe);
543 pipespace(struct pipe *cpipe, int size)
553 pipe_free_kmem(cpipe);
554 cpipe->pipe_buffer.buffer = (caddr_t)buffer;
555 cpipe->pipe_buffer.size = size;
556 cpipe->pipe_buffer.in = 0;
557 cpipe->pipe_buffer.out = 0;
558 cpipe->pipe_buffer.cnt = 0;
561 OSAddAtomic(cpipe->pipe_buffer.size, (SInt32 *)&amountpipekva);
572 struct pipe *cpipe;
574 cpipe = (struct pipe *)zalloc(pipe_zone);
576 if ((*cpipep = cpipe) == NULL)
583 bzero(cpipe, sizeof *cpipe);
586 pipe_touch(cpipe, PIPE_ATIME | PIPE_MTIME | PIPE_CTIME);
596 pipelock(struct pipe *cpipe, int catch)
600 while (cpipe->pipe_state & PIPE_LOCKFL) {
601 cpipe->pipe_state |= PIPE_LWANT;
603 error = msleep(cpipe, PIPE_MTX(cpipe), catch ? (PRIBIO | PCATCH) : PRIBIO,
608 cpipe->pipe_state |= PIPE_LOCKFL;
617 pipeunlock(struct pipe *cpipe)
619 cpipe->pipe_state &= ~PIPE_LOCKFL;
621 if (cpipe->pipe_state & PIPE_LWANT) {
622 cpipe->pipe_state &= ~PIPE_LWANT;
623 wakeup(cpipe);
628 pipeselwakeup(struct pipe *cpipe, struct pipe *spipe)
630 if (cpipe->pipe_state & PIPE_SEL) {
631 cpipe->pipe_state &= ~PIPE_SEL;
632 selwakeup(&cpipe->pipe_sel);
634 if (cpipe->pipe_state & PIPE_KNOTE)
635 KNOTE(&cpipe->pipe_sel.si_note, 1);
637 postpipeevent(cpipe, EV_RWBYTES);
1510 struct pipe *cpipe;
1513 cpipe = (struct pipe *)fg->fg_data;
1517 if (cpipe)
1518 pipeclose(cpipe);
1524 pipe_free_kmem(struct pipe *cpipe)
1527 if (cpipe->pipe_buffer.buffer != NULL) {
1528 if (cpipe->pipe_buffer.size > PIPE_SIZE)
1530 OSAddAtomic(-(cpipe->pipe_buffer.size), (SInt32 *)&amountpipekva);
1533 kmem_free(kernel_map, (vm_offset_t)cpipe->pipe_buffer.buffer,
1534 cpipe->pipe_buffer.size);
1535 cpipe->pipe_buffer.buffer = NULL;
1538 if (cpipe->pipe_map.kva != 0) {
1540 cpipe->pipe_buffer.size + PAGE_SIZE);
1542 cpipe->pipe_map.kva,
1543 cpipe->pipe_buffer.size + PAGE_SIZE);
1544 cpipe->pipe_map.cnt = 0;
1545 cpipe->pipe_map.kva = 0;
1546 cpipe->pipe_map.pos = 0;
1547 cpipe->pipe_map.npages = 0;
1556 pipeclose(struct pipe *cpipe)
1560 if (cpipe == NULL)
1564 if (PIPE_MTX(cpipe) != NULL)
1565 PIPE_LOCK(cpipe);
1572 cpipe->pipe_state |= PIPE_EOF;
1573 pipeselwakeup(cpipe, cpipe);
1575 while (cpipe->pipe_busy) {
1576 cpipe->pipe_state |= PIPE_WANT;
1578 wakeup(cpipe);
1579 msleep(cpipe, PIPE_MTX(cpipe), PRIBIO, "pipecl", 0);
1586 if (cpipe->pipe_label != NULL && cpipe->pipe_peer == NULL)
1587 mac_pipe_label_destroy(cpipe);
1593 if ((ppipe = cpipe->pipe_peer) != NULL) {
1600 if (cpipe->pipe_state & PIPE_KNOTE)
1607 evpipefree(cpipe);
1612 if (PIPE_MTX(cpipe) != NULL) {
1618 PIPE_UNLOCK(cpipe);
1624 lck_mtx_free(PIPE_MTX(cpipe), pipe_mtx_grp);
1627 pipe_free_kmem(cpipe);
1629 zfree(pipe_zone, cpipe);
1636 struct pipe *cpipe;
1638 cpipe = (struct pipe *)kn->kn_fp->f_data;
1640 PIPE_LOCK(cpipe);
1647 if (mac_pipe_check_kqfilter(vfs_context_ucred(ctx), kn, cpipe) != 0) {
1648 PIPE_UNLOCK(cpipe);
1661 if (cpipe->pipe_peer == NULL) {
1665 PIPE_UNLOCK(cpipe);
1668 if (cpipe->pipe_peer)
1669 cpipe = cpipe->pipe_peer;
1672 PIPE_UNLOCK(cpipe);
1676 if (KNOTE_ATTACH(&cpipe->pipe_sel.si_note, kn))
1677 cpipe->pipe_state |= PIPE_KNOTE;
1679 PIPE_UNLOCK(cpipe);
1686 struct pipe *cpipe = (struct pipe *)kn->kn_fp->f_data;
1688 PIPE_LOCK(cpipe);
1691 if (cpipe->pipe_peer == NULL) {
1692 PIPE_UNLOCK(cpipe);
1695 cpipe = cpipe->pipe_peer;
1697 if (cpipe->pipe_state & PIPE_KNOTE) {
1698 if (KNOTE_DETACH(&cpipe->pipe_sel.si_note, kn))
1699 cpipe->pipe_state &= ~PIPE_KNOTE;
1701 PIPE_UNLOCK(cpipe);
1785 fill_pipeinfo(struct pipe * cpipe, struct pipe_info * pinfo)
1795 if (cpipe == NULL)
1797 PIPE_LOCK(cpipe);
1800 error = mac_pipe_check_stat(kauth_cred_get(), cpipe);
1802 PIPE_UNLOCK(cpipe);
1806 if (cpipe->pipe_buffer.buffer == 0) {
1810 if (cpipe->pipe_peer) {
1814 pipe_size = cpipe->pipe_peer->pipe_buffer.size;
1815 pipe_count = cpipe->pipe_peer->pipe_buffer.cnt;
1820 pipe_size = cpipe->pipe_buffer.size;
1821 pipe_count = cpipe->pipe_buffer.cnt;
1858 pinfo->pipe_handle = (uint64_t)((uintptr_t)cpipe);
1859 pinfo->pipe_peerhandle = (uint64_t)((uintptr_t)(cpipe->pipe_peer));
1860 pinfo->pipe_status = cpipe->pipe_state;
1862 PIPE_UNLOCK(cpipe);