Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/uipc_shm.c
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
#include "opt_ktrace.h" | #include "opt_ktrace.h" | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/capsicum.h> | #include <sys/capsicum.h> | ||||
#include <sys/conf.h> | #include <sys/conf.h> | ||||
#include <sys/fcntl.h> | #include <sys/fcntl.h> | ||||
#include <sys/file.h> | #include <sys/file.h> | ||||
#include <sys/filedesc.h> | #include <sys/filedesc.h> | ||||
#include <sys/filio.h> | |||||
#include <sys/fnv_hash.h> | #include <sys/fnv_hash.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/uio.h> | #include <sys/uio.h> | ||||
#include <sys/signal.h> | #include <sys/signal.h> | ||||
#include <sys/jail.h> | #include <sys/jail.h> | ||||
#include <sys/ktrace.h> | #include <sys/ktrace.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
static void shm_init(void *arg); | static void shm_init(void *arg); | ||||
static void shm_insert(char *path, Fnv32_t fnv, struct shmfd *shmfd); | static void shm_insert(char *path, Fnv32_t fnv, struct shmfd *shmfd); | ||||
static struct shmfd *shm_lookup(char *path, Fnv32_t fnv); | static struct shmfd *shm_lookup(char *path, Fnv32_t fnv); | ||||
static int shm_remove(char *path, Fnv32_t fnv, struct ucred *ucred); | static int shm_remove(char *path, Fnv32_t fnv, struct ucred *ucred); | ||||
static fo_rdwr_t shm_read; | static fo_rdwr_t shm_read; | ||||
static fo_rdwr_t shm_write; | static fo_rdwr_t shm_write; | ||||
static fo_truncate_t shm_truncate; | static fo_truncate_t shm_truncate; | ||||
static fo_ioctl_t shm_ioctl; | |||||
static fo_stat_t shm_stat; | static fo_stat_t shm_stat; | ||||
static fo_close_t shm_close; | static fo_close_t shm_close; | ||||
static fo_chmod_t shm_chmod; | static fo_chmod_t shm_chmod; | ||||
static fo_chown_t shm_chown; | static fo_chown_t shm_chown; | ||||
static fo_seek_t shm_seek; | static fo_seek_t shm_seek; | ||||
static fo_fill_kinfo_t shm_fill_kinfo; | static fo_fill_kinfo_t shm_fill_kinfo; | ||||
static fo_mmap_t shm_mmap; | static fo_mmap_t shm_mmap; | ||||
/* File descriptor operations. */ | /* File descriptor operations. */ | ||||
struct fileops shm_ops = { | struct fileops shm_ops = { | ||||
.fo_read = shm_read, | .fo_read = shm_read, | ||||
.fo_write = shm_write, | .fo_write = shm_write, | ||||
.fo_truncate = shm_truncate, | .fo_truncate = shm_truncate, | ||||
.fo_ioctl = invfo_ioctl, | .fo_ioctl = shm_ioctl, | ||||
.fo_poll = invfo_poll, | .fo_poll = invfo_poll, | ||||
.fo_kqfilter = invfo_kqfilter, | .fo_kqfilter = invfo_kqfilter, | ||||
.fo_stat = shm_stat, | .fo_stat = shm_stat, | ||||
.fo_close = shm_close, | .fo_close = shm_close, | ||||
.fo_chmod = shm_chmod, | .fo_chmod = shm_chmod, | ||||
.fo_chown = shm_chown, | .fo_chown = shm_chown, | ||||
.fo_sendfile = vn_sendfile, | .fo_sendfile = vn_sendfile, | ||||
.fo_seek = shm_seek, | .fo_seek = shm_seek, | ||||
▲ Show 20 Lines • Show All 205 Lines • ▼ Show 20 Lines | #endif | ||||
shmfd = fp->f_data; | shmfd = fp->f_data; | ||||
#ifdef MAC | #ifdef MAC | ||||
error = mac_posixshm_check_truncate(active_cred, fp->f_cred, shmfd); | error = mac_posixshm_check_truncate(active_cred, fp->f_cred, shmfd); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
#endif | #endif | ||||
return (shm_dotruncate(shmfd, length)); | return (shm_dotruncate(shmfd, length)); | ||||
} | |||||
int | |||||
shm_ioctl(struct file *fp, u_long com, void *data, struct ucred *active_cred, | |||||
struct thread *td) | |||||
{ | |||||
switch (com) { | |||||
case FIONBIO: | |||||
case FIOASYNC: | |||||
/* | |||||
* Allow fcntl(fd, F_SETFL, O_NONBLOCK) to work, | |||||
* just like it would on an unlinked regular file | |||||
*/ | |||||
return (0); | |||||
default: | |||||
return (ENOTTY); | |||||
} | |||||
} | } | ||||
static int | static int | ||||
shm_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, | shm_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, | ||||
struct thread *td) | struct thread *td) | ||||
{ | { | ||||
struct shmfd *shmfd; | struct shmfd *shmfd; | ||||
#ifdef MAC | #ifdef MAC | ||||
▲ Show 20 Lines • Show All 742 Lines • Show Last 20 Lines |