* Audit pipe ioctl() routine. Handle file descriptor and audit pipe layer * commands. */
| 689 | * commands. |
| 690 | */ |
| 691 | static int |
| 692 | audit_pipe_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, |
| 693 | struct thread *td) |
| 694 | { |
| 695 | struct auditpipe_ioctl_preselect *aip; |
| 696 | struct audit_pipe *ap; |
| 697 | au_mask_t *maskp; |
| 698 | int error, mode; |
| 699 | au_id_t auid; |
| 700 | |
| 701 | error = devfs_get_cdevpriv((void **)&ap); |
| 702 | if (error != 0) |
| 703 | return (error); |
| 704 | |
| 705 | /* |
| 706 | * Audit pipe ioctls: first come standard device node ioctls, then |
| 707 | * manipulation of pipe settings, and finally, statistics query |
| 708 | * ioctls. |
| 709 | */ |
| 710 | switch (cmd) { |
| 711 | case FIONBIO: |
| 712 | AUDIT_PIPE_LOCK(ap); |
| 713 | if (*(int *)data) |
| 714 | ap->ap_flags |= AUDIT_PIPE_NBIO; |
| 715 | else |
| 716 | ap->ap_flags &= ~AUDIT_PIPE_NBIO; |
| 717 | AUDIT_PIPE_UNLOCK(ap); |
| 718 | error = 0; |
| 719 | break; |
| 720 | |
| 721 | case FIONREAD: |
| 722 | AUDIT_PIPE_LOCK(ap); |
| 723 | *(int *)data = ap->ap_qbyteslen - ap->ap_qoffset; |
| 724 | AUDIT_PIPE_UNLOCK(ap); |
| 725 | error = 0; |
| 726 | break; |
| 727 | |
| 728 | case FIOASYNC: |
| 729 | AUDIT_PIPE_LOCK(ap); |
| 730 | if (*(int *)data) |
| 731 | ap->ap_flags |= AUDIT_PIPE_ASYNC; |
| 732 | else |
| 733 | ap->ap_flags &= ~AUDIT_PIPE_ASYNC; |
| 734 | AUDIT_PIPE_UNLOCK(ap); |
| 735 | error = 0; |
| 736 | break; |
| 737 | |
| 738 | case FIOSETOWN: |
| 739 | error = fsetown(*(int *)data, &ap->ap_sigio); |
| 740 | break; |
| 741 | |
| 742 | case FIOGETOWN: |
| 743 | *(int *)data = fgetown(&ap->ap_sigio); |
| 744 | error = 0; |
| 745 | break; |
| 746 | |
| 747 | case AUDITPIPE_GET_QLEN: |
| 748 | *(u_int *)data = ap->ap_qlen; |
nothing calls this directly
no test coverage detected