| 862 | } |
| 863 | |
| 864 | int |
| 865 | kern_specialfd(struct thread *td, int type, void *arg) |
| 866 | { |
| 867 | struct file *fp; |
| 868 | struct specialfd_eventfd *ae; |
| 869 | int error, fd, fflags; |
| 870 | |
| 871 | fflags = 0; |
| 872 | error = falloc_noinstall(td, &fp); |
| 873 | if (error != 0) |
| 874 | return (error); |
| 875 | |
| 876 | switch (type) { |
| 877 | case SPECIALFD_EVENTFD: |
| 878 | ae = arg; |
| 879 | if ((ae->flags & EFD_CLOEXEC) != 0) |
| 880 | fflags |= O_CLOEXEC; |
| 881 | error = eventfd_create_file(td, fp, ae->initval, ae->flags); |
| 882 | break; |
| 883 | default: |
| 884 | error = EINVAL; |
| 885 | break; |
| 886 | } |
| 887 | |
| 888 | if (error == 0) |
| 889 | error = finstall(td, fp, &fd, fflags, NULL); |
| 890 | fdrop(fp, td); |
| 891 | if (error == 0) |
| 892 | td->td_retval[0] = fd; |
| 893 | return (error); |
| 894 | } |
| 895 | |
| 896 | int |
| 897 | sys___specialfd(struct thread *td, struct __specialfd_args *args) |
no test coverage detected