Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/sys_generic.c
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
#include <sys/filio.h> | #include <sys/filio.h> | ||||
#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/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> | ||||
#include <sys/specialfd.h> | |||||
#include <sys/syscallsubr.h> | #include <sys/syscallsubr.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/sysent.h> | #include <sys/sysent.h> | ||||
#include <sys/vnode.h> | #include <sys/vnode.h> | ||||
#include <sys/bio.h> | #include <sys/bio.h> | ||||
#include <sys/buf.h> | #include <sys/buf.h> | ||||
#include <sys/condvar.h> | #include <sys/condvar.h> | ||||
#ifdef KTRACE | #ifdef KTRACE | ||||
▲ Show 20 Lines • Show All 777 Lines • ▼ Show 20 Lines | kern_posix_fallocate(struct thread *td, int fd, off_t offset, off_t len) | ||||
if ((fp->f_flag & FWRITE) == 0) { | if ((fp->f_flag & FWRITE) == 0) { | ||||
error = EBADF; | error = EBADF; | ||||
goto out; | goto out; | ||||
} | } | ||||
error = fo_fallocate(fp, offset, len, td); | error = fo_fallocate(fp, offset, len, td); | ||||
out: | out: | ||||
fdrop(fp, td); | fdrop(fp, td); | ||||
return (error); | |||||
} | |||||
int | |||||
kern_specialfd(struct thread *td, int type, void *arg) | |||||
{ | |||||
struct file *fp; | |||||
struct specialfd_eventfd *ae; | |||||
int error, fd, fflags; | |||||
fflags = 0; | |||||
error = falloc_noinstall(td, &fp); | |||||
if (error != 0) | |||||
return (error); | |||||
switch (type) { | |||||
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; | |||||
} | |||||
if (error == 0) | |||||
error = finstall(td, fp, &fd, fflags, NULL); | |||||
fdrop(fp, td); | |||||
if (error == 0) | |||||
td->td_retval[0] = fd; | |||||
return (error); | |||||
} | |||||
int | |||||
sys___specialfd(struct thread *td, struct __specialfd_args *args) | |||||
{ | |||||
struct specialfd_eventfd ae; | |||||
int error; | |||||
switch (args->type) { | |||||
case SPECIALFD_EVENTFD: | |||||
if (args->len != sizeof(struct specialfd_eventfd)) { | |||||
error = EINVAL; | |||||
break; | |||||
} | |||||
error = copyin(args->req, &ae, sizeof(ae)); | |||||
if (error != 0) | |||||
break; | |||||
if ((ae.flags & ~(EFD_CLOEXEC | EFD_NONBLOCK | | |||||
EFD_SEMAPHORE)) != 0) { | |||||
error = EINVAL; | |||||
break; | |||||
} | |||||
error = kern_specialfd(td, args->type, &ae); | |||||
break; | |||||
default: | |||||
error = EINVAL; | |||||
break; | |||||
} | |||||
return (error); | return (error); | ||||
} | } | ||||
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 | ||||
▲ Show 20 Lines • Show All 1,083 Lines • Show Last 20 Lines |