#ifndef _SYS_FILE_H_
#define _SYS_FILE_H_
#ifndef _SYS_TYPES_H_
#include <sys/types.h>
#endif
#ifndef _SYS_FCNTL_H_
#include <sys/fcntl.h>
#endif
#ifndef _SYS_UNISTD_H_
#include <sys/unistd.h>
#endif
#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
#ifndef _SYS_EVENT_H_
#include <sys/event.h>
#endif
#ifndef _SYS_QUEUE_H_
#include <sys/queue.h>
#endif
#ifndef _SYS_SPINLOCK_H_
#include <sys/spinlock.h>
#endif
#ifndef _SYS_NAMECACHE_H_
#include <sys/namecache.h>
#endif
#ifndef _SYS__UIO_H_
#include <sys/_uio.h>
#endif
struct stat;
struct proc;
struct thread;
struct uio;
struct knote;
struct file;
struct ucred;
struct vnode;
struct lwkt_port;
struct namecache;
struct sysmsg;
struct fileops {
int (*fo_read) (struct file *fp, struct uio *uio,
struct ucred *cred, int flags);
int (*fo_write) (struct file *fp, struct uio *uio,
struct ucred *cred, int flags);
int (*fo_ioctl) (struct file *fp, u_long com, caddr_t data,
struct ucred *cred, struct sysmsg *msg);
int (*fo_kqfilter)(struct file *fp, struct knote *kn);
int (*fo_stat) (struct file *fp, struct stat *sb,
struct ucred *cred);
int (*fo_close) (struct file *fp);
int (*fo_shutdown)(struct file *fp, int how);
int (*fo_seek) (struct file *fp, off_t offset, int whence, off_t *res);
};
struct file {
LIST_ENTRY(file) f_list;
short f_FILLER3;
short f_type;
u_int f_flag;
struct ucred *f_cred;
struct fileops *f_ops;
int f_seqcount;
off_t f_nextoff;
off_t f_offset;
void *f_data;
void *f_data1;
int f_count;
int f_msgcount;
struct nchandle f_nchandle;
struct spinlock f_spin;
struct klist f_klist;
void *private_data;
};
#define DTYPE_VNODE 1
#define DTYPE_SOCKET 2
#define DTYPE_PIPE 3
#define DTYPE_FIFO 4
#define DTYPE_KQUEUE 5
#define DTYPE_CRYPTO 6
#define DTYPE_MQUEUE 7
#define DTYPE_DMABUF 8
LIST_HEAD(filelist, file);
#endif
#ifdef _KERNEL
void fhold(struct file *);
int fdrop(struct file *);
int checkfdclosed(thread_t, struct filedesc *, int, struct file *, int);
int fp_open(const char *, int, int, struct file **);
int fp_vpopen(struct vnode *, int, struct file **);
int fp_pread(struct file *, void *, size_t, off_t, ssize_t *, enum uio_seg);
int fp_pwrite(struct file *, void *, size_t, off_t, ssize_t *, enum uio_seg);
int fp_read(struct file *, void *, size_t, ssize_t *, int, enum uio_seg);
int fp_write(struct file *, void *, size_t, ssize_t *, enum uio_seg);
int fp_stat(struct file *, struct stat *);
int fp_mmap(void *, size_t, int, int, struct file *, off_t, void **);
int nofo_shutdown(struct file *, int);
int fp_close(struct file *);
int fp_shutdown(struct file *, int);
extern struct fileops vnode_fileops;
extern struct fileops specvnode_fileops;
extern struct fileops badfileops;
extern int maxfiles;
extern int maxfilesrootres;
extern int minfilesperproc;
extern int maxfilesperproc;
extern int maxfilesperuser;
int badfo_readwrite(struct file *fp, struct uio *uio,
struct ucred *cred, int flags);
int badfo_ioctl(struct file *fp, u_long com, caddr_t data,
struct ucred *cred, struct sysmsg *msg);
int badfo_kqfilter(struct file *fp, struct knote *kn);
int badfo_stat(struct file *fp, struct stat *sb, struct ucred *cred);
int badfo_close(struct file *fp);
int badfo_shutdown(struct file *fp, int how);
int badfo_seek(struct file *fp, off_t offset, int whence, off_t *res);
#endif
#endif