Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/sys_generic.c
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
#include <sys/fcntl.h> | #include <sys/fcntl.h> | ||||
#include <sys/file.h> | #include <sys/file.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/signalvar.h> | #include <sys/signalvar.h> | ||||
#include <sys/socketvar.h> | #include <sys/socketvar.h> | ||||
#include <sys/uio.h> | #include <sys/uio.h> | ||||
#include <sys/eventfd.h> | #include <sys/eventfd.h> | ||||
#include <sys/timerfd.h> | |||||
kib: The existing order is not alphabetical, but do not add more disordering | |||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/ktr.h> | #include <sys/ktr.h> | ||||
#include <sys/limits.h> | #include <sys/limits.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/poll.h> | #include <sys/poll.h> | ||||
#include <sys/resourcevar.h> | #include <sys/resourcevar.h> | ||||
#include <sys/selinfo.h> | #include <sys/selinfo.h> | ||||
#include <sys/sleepqueue.h> | #include <sys/sleepqueue.h> | ||||
▲ Show 20 Lines • Show All 864 Lines • ▼ Show 20 Lines | kern_fspacectl(struct thread *td, int fd, int cmd, | ||||
if (rmsrp != NULL) | if (rmsrp != NULL) | ||||
*rmsrp = rmsr; | *rmsrp = rmsr; | ||||
out: | out: | ||||
fdrop(fp, td); | fdrop(fp, td); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | int | ||||
kern_specialfd(struct thread *td, int type, void *arg) | kern_eventfd(struct thread *td, const void *args) | ||||
{ | { | ||||
struct file *fp; | struct specialfd_eventfd efd; | ||||
struct specialfd_eventfd *ae; | int error; | ||||
int error, fd, fflags; | |||||
fflags = 0; | error = copyin(args, &efd, sizeof(efd)); | ||||
error = falloc_noinstall(td, &fp); | |||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
switch (type) { | return (eventfd_create_file(td, efd.initval, efd.flags)); | ||||
case SPECIALFD_EVENTFD: | |||||
ae = arg; | |||||
if ((ae->flags & EFD_CLOEXEC) != 0) | |||||
fflags |= O_CLOEXEC; | |||||
error = eventfd_create_file(td, fp, ae->initval, ae->flags); | |||||
break; | |||||
default: | |||||
error = EINVAL; | |||||
break; | |||||
} | } | ||||
int | |||||
kern_timerfd_create(struct thread *td, const void *args) | |||||
{ | |||||
struct specialfd_timerfd_create tfd; | |||||
int error; | |||||
error = copyin(args, &tfd, sizeof(tfd)); | |||||
if (error != 0) | |||||
return (error); | |||||
return (timerfd_create_file(td, tfd.clockid, tfd.flags)); | |||||
} | |||||
int | |||||
kern_timerfd_gettime(struct thread *td, const void *args) | |||||
{ | |||||
struct specialfd_timerfd_gettime tfd; | |||||
struct itimerspec cts; | |||||
int error; | |||||
error = copyin(args, &tfd, sizeof(tfd)); | |||||
if (error != 0) | |||||
return (error); | |||||
error = timerfd_gettime_common(td, tfd.fd, &cts); | |||||
if (error == 0) | if (error == 0) | ||||
error = finstall(td, fp, &fd, fflags, NULL); | error = copyout(&cts, tfd.curr_value, sizeof(cts)); | ||||
fdrop(fp, td); | |||||
if (error == 0) | |||||
td->td_retval[0] = fd; | |||||
return (error); | return (error); | ||||
} | } | ||||
int | int | ||||
sys___specialfd(struct thread *td, struct __specialfd_args *args) | kern_timerfd_settime(struct thread *td, const void *args) | ||||
{ | { | ||||
struct specialfd_eventfd ae; | struct specialfd_timerfd_settime tfd; | ||||
struct itimerspec nts, ots, *pots; | |||||
int error; | int error; | ||||
error = copyin(args, &tfd, sizeof(tfd)); | |||||
if (error != 0) | |||||
return (error); | |||||
error = copyin(tfd.new_value, &nts, sizeof(nts)); | |||||
if (error != 0) | |||||
return (error); | |||||
pots = (tfd.old_value != NULL ? &ots : NULL); | |||||
error = timerfd_settime_common(td, tfd.fd, tfd.flags, &nts, pots); | |||||
if (error == 0 && tfd.old_value != NULL) | |||||
error = copyout(&ots, tfd.old_value, sizeof(ots)); | |||||
return (error); | |||||
} | |||||
int | |||||
sys___specialfd(struct thread *td, struct __specialfd_args *args) | |||||
{ | |||||
size_t arg_size; | |||||
int (*specialfd_func)(struct thread *, const void *); | |||||
switch (args->type) { | switch (args->type) { | ||||
case SPECIALFD_EVENTFD: | case SPECIALFD_EVENTFD: | ||||
if (args->len != sizeof(struct specialfd_eventfd)) { | arg_size = sizeof(struct specialfd_eventfd); | ||||
error = EINVAL; | specialfd_func = kern_eventfd; | ||||
break; | break; | ||||
} | case SPECIALFD_TIMERFD_CREATE: | ||||
error = copyin(args->req, &ae, sizeof(ae)); | arg_size = sizeof(struct specialfd_timerfd_create); | ||||
if (error != 0) | specialfd_func = kern_timerfd_create; | ||||
break; | break; | ||||
if ((ae.flags & ~(EFD_CLOEXEC | EFD_NONBLOCK | | case SPECIALFD_TIMERFD_SETTIME: | ||||
EFD_SEMAPHORE)) != 0) { | arg_size = sizeof(struct specialfd_timerfd_settime); | ||||
error = EINVAL; | specialfd_func = kern_timerfd_settime; | ||||
break; | break; | ||||
} | case SPECIALFD_TIMERFD_GETTIME: | ||||
error = kern_specialfd(td, args->type, &ae); | arg_size = sizeof(struct specialfd_timerfd_gettime); | ||||
specialfd_func = kern_timerfd_gettime; | |||||
break; | break; | ||||
default: | |||||
error = EINVAL; | |||||
break; | |||||
} | } | ||||
return (error); | |||||
if (args->len != arg_size) | |||||
return (EINVAL); | |||||
return (specialfd_func(td, args->req)); | |||||
} | } | ||||
int | int | ||||
poll_no_poll(int events) | poll_no_poll(int events) | ||||
{ | { | ||||
/* | /* | ||||
* Return true for read/write. If the user asked for something | * Return true for read/write. If the user asked for something | ||||
* special, return POLLNVAL, so that clients have a way of | * special, return POLLNVAL, so that clients have a way of | ||||
▲ Show 20 Lines • Show All 1,073 Lines • Show Last 20 Lines |
The existing order is not alphabetical, but do not add more disordering