kern_return_t _S_set_fd (mach_port_t msgport, mach_port_t auth, int which, mach_port_t port) { AUTHCHECK; /* We consume the reference if successful. */ return HURD_FD_USE (which, (_hurd_port2fd (descriptor, port, 0), 0)); }
/* Allocate a new file descriptor and install PORT in it. FLAGS are as for `open'; only O_IGNORE_CTTY and O_CLOEXEC are meaningful. If the descriptor table is full, set errno, and return -1. If DEALLOC is nonzero, deallocate PORT first. */ int _hurd_intern_fd (io_t port, int flags, int dealloc) { int fd; struct hurd_fd *d; HURD_CRITICAL_BEGIN; d = _hurd_alloc_fd (&fd, 0); if (d != NULL) { _hurd_port2fd (d, port, flags); __spin_unlock (&d->port.lock); } HURD_CRITICAL_END; if (d == NULL) { if (dealloc) __mach_port_deallocate (__mach_task_self (), port); return -1; } return fd; }