Detediousficate declaration of fileops array members by introducing
typedefs for them.
This commit is contained in:
parent
828463d085
commit
f3a682116c
@ -103,16 +103,6 @@ enum dup_type { DUP_VARIABLE, DUP_FIXED };
|
||||
|
||||
static int do_dup(struct thread *td, enum dup_type type, int old, int new,
|
||||
register_t *retval);
|
||||
static int badfo_readwrite(struct file *fp, struct uio *uio,
|
||||
struct ucred *active_cred, int flags, struct thread *td);
|
||||
static int badfo_ioctl(struct file *fp, u_long com, void *data,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
static int badfo_poll(struct file *fp, int events,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
static int badfo_kqfilter(struct file *fp, struct knote *kn);
|
||||
static int badfo_stat(struct file *fp, struct stat *sb,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
static int badfo_close(struct file *fp, struct thread *td);
|
||||
|
||||
/*
|
||||
* Descriptor management.
|
||||
@ -2174,6 +2164,13 @@ fildesc_drvinit(void *unused)
|
||||
}
|
||||
}
|
||||
|
||||
static fo_rdwr_t badfo_readwrite;
|
||||
static fo_ioctl_t badfo_ioctl;
|
||||
static fo_poll_t badfo_poll;
|
||||
static fo_kqfilter_t badfo_kqfilter;
|
||||
static fo_stat_t badfo_stat;
|
||||
static fo_close_t badfo_close;
|
||||
|
||||
struct fileops badfileops = {
|
||||
badfo_readwrite,
|
||||
badfo_readwrite,
|
||||
|
@ -56,20 +56,16 @@ MALLOC_DEFINE(M_KQUEUE, "kqueue", "memory for kqueue system");
|
||||
static int kqueue_scan(struct file *fp, int maxevents,
|
||||
struct kevent *ulistp, const struct timespec *timeout,
|
||||
struct thread *td);
|
||||
static int kqueue_read(struct file *fp, struct uio *uio,
|
||||
struct ucred *active_cred, int flags, struct thread *td);
|
||||
static int kqueue_write(struct file *fp, struct uio *uio,
|
||||
struct ucred *active_cred, int flags, struct thread *td);
|
||||
static int kqueue_ioctl(struct file *fp, u_long com, void *data,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
static int kqueue_poll(struct file *fp, int events,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
static int kqueue_kqfilter(struct file *fp, struct knote *kn);
|
||||
static int kqueue_stat(struct file *fp, struct stat *st,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
static int kqueue_close(struct file *fp, struct thread *td);
|
||||
static void kqueue_wakeup(struct kqueue *kq);
|
||||
|
||||
static fo_rdwr_t kqueue_read;
|
||||
static fo_rdwr_t kqueue_write;
|
||||
static fo_ioctl_t kqueue_ioctl;
|
||||
static fo_poll_t kqueue_poll;
|
||||
static fo_kqfilter_t kqueue_kqfilter;
|
||||
static fo_stat_t kqueue_stat;
|
||||
static fo_close_t kqueue_close;
|
||||
|
||||
static struct fileops kqueueops = {
|
||||
kqueue_read,
|
||||
kqueue_write,
|
||||
|
@ -94,18 +94,13 @@
|
||||
/*
|
||||
* interfaces to the outside world
|
||||
*/
|
||||
static int pipe_read(struct file *fp, struct uio *uio,
|
||||
struct ucred *active_cred, int flags, struct thread *td);
|
||||
static int pipe_write(struct file *fp, struct uio *uio,
|
||||
struct ucred *active_cred, int flags, struct thread *td);
|
||||
static int pipe_close(struct file *fp, struct thread *td);
|
||||
static int pipe_poll(struct file *fp, int events, struct ucred *active_cred,
|
||||
struct thread *td);
|
||||
static int pipe_kqfilter(struct file *fp, struct knote *kn);
|
||||
static int pipe_stat(struct file *fp, struct stat *sb,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
static int pipe_ioctl(struct file *fp, u_long cmd, void *data,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
static fo_rdwr_t pipe_read;
|
||||
static fo_rdwr_t pipe_write;
|
||||
static fo_ioctl_t pipe_ioctl;
|
||||
static fo_poll_t pipe_poll;
|
||||
static fo_kqfilter_t pipe_kqfilter;
|
||||
static fo_stat_t pipe_stat;
|
||||
static fo_close_t pipe_close;
|
||||
|
||||
static struct fileops pipeops = {
|
||||
pipe_read, pipe_write, pipe_ioctl, pipe_poll, pipe_kqfilter,
|
||||
|
@ -63,18 +63,13 @@
|
||||
|
||||
#include <machine/limits.h>
|
||||
|
||||
static int vn_closefile(struct file *fp, struct thread *td);
|
||||
static int vn_ioctl(struct file *fp, u_long com, void *data,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
static int vn_read(struct file *fp, struct uio *uio,
|
||||
struct ucred *active_cred, int flags, struct thread *td);
|
||||
static int vn_poll(struct file *fp, int events, struct ucred *active_cred,
|
||||
struct thread *td);
|
||||
static int vn_kqfilter(struct file *fp, struct knote *kn);
|
||||
static int vn_statfile(struct file *fp, struct stat *sb,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
static int vn_write(struct file *fp, struct uio *uio,
|
||||
struct ucred *active_cred, int flags, struct thread *td);
|
||||
static fo_rdwr_t vn_read;
|
||||
static fo_rdwr_t vn_write;
|
||||
static fo_ioctl_t vn_ioctl;
|
||||
static fo_poll_t vn_poll;
|
||||
static fo_kqfilter_t vn_kqfilter;
|
||||
static fo_stat_t vn_statfile;
|
||||
static fo_close_t vn_closefile;
|
||||
|
||||
struct fileops vnops = {
|
||||
vn_read, vn_write, vn_ioctl, vn_poll, vn_kqfilter,
|
||||
|
@ -64,6 +64,32 @@ struct socket;
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
struct file;
|
||||
struct ucred;
|
||||
|
||||
typedef int fo_rdwr_t(struct file *fp, struct uio *uio,
|
||||
struct ucred *active_cred, int flags,
|
||||
struct thread *td);
|
||||
#define FOF_OFFSET 1 /* Use the offset in uio argument */
|
||||
typedef int fo_ioctl_t(struct file *fp, u_long com, void *data,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
typedef int fo_poll_t(struct file *fp, int events,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
typedef int fo_kqfilter_t(struct file *fp, struct knote *kn);
|
||||
typedef int fo_stat_t(struct file *fp, struct stat *sb,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
typedef int fo_close_t(struct file *fp, struct thread *td);
|
||||
|
||||
struct fileops {
|
||||
fo_rdwr_t *fo_read;
|
||||
fo_rdwr_t *fo_write;
|
||||
fo_ioctl_t *fo_ioctl;
|
||||
fo_poll_t *fo_poll;
|
||||
fo_kqfilter_t *fo_kqfilter;
|
||||
fo_stat_t *fo_stat;
|
||||
fo_close_t *fo_close;
|
||||
};
|
||||
|
||||
/*
|
||||
* Kernel descriptor table.
|
||||
* One entry for each open kernel vnode and socket.
|
||||
@ -81,23 +107,7 @@ struct file {
|
||||
int f_count; /* (f) reference count */
|
||||
int f_msgcount; /* (f) references from message queue */
|
||||
struct ucred *f_cred; /* credentials associated with descriptor */
|
||||
struct fileops {
|
||||
int (*fo_read)(struct file *fp, struct uio *uio,
|
||||
struct ucred *active_cred, int flags,
|
||||
struct thread *td);
|
||||
int (*fo_write)(struct file *fp, struct uio *uio,
|
||||
struct ucred *active_cred, int flags,
|
||||
struct thread *td);
|
||||
#define FOF_OFFSET 1
|
||||
int (*fo_ioctl)(struct file *fp, u_long com, void *data,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
int (*fo_poll)(struct file *fp, int events,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
int (*fo_kqfilter)(struct file *fp, struct knote *kn);
|
||||
int (*fo_stat)(struct file *fp, struct stat *sb,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
int (*fo_close)(struct file *fp, struct thread *td);
|
||||
} *f_ops;
|
||||
struct fileops *f_ops; /* File operations */
|
||||
int f_seqcount; /*
|
||||
* count of sequential accesses -- cleared
|
||||
* by most seek operations.
|
||||
@ -177,18 +187,13 @@ void fputsock(struct socket *sp);
|
||||
FILE_UNLOCK(fp); \
|
||||
} while (0)
|
||||
|
||||
static __inline int fo_read(struct file *fp, struct uio *uio,
|
||||
struct ucred *active_cred, int flags, struct thread *td);
|
||||
static __inline int fo_write(struct file *fp, struct uio *uio,
|
||||
struct ucred *active_cred, int flags, struct thread *td);
|
||||
static __inline int fo_ioctl(struct file *fp, u_long com, void *data,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
static __inline int fo_poll(struct file *fp, int events,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
static __inline int fo_stat(struct file *fp, struct stat *sb,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
static __inline int fo_close(struct file *fp, struct thread *td);
|
||||
static __inline int fo_kqfilter(struct file *fp, struct knote *kn);
|
||||
static __inline fo_rdwr_t fo_read;
|
||||
static __inline fo_rdwr_t fo_write;
|
||||
static __inline fo_ioctl_t fo_ioctl;
|
||||
static __inline fo_poll_t fo_poll;
|
||||
static __inline fo_kqfilter_t fo_kqfilter;
|
||||
static __inline fo_stat_t fo_stat;
|
||||
static __inline fo_close_t fo_close;
|
||||
struct proc;
|
||||
|
||||
static __inline int
|
||||
@ -208,8 +213,8 @@ fo_write(fp, uio, active_cred, flags, td)
|
||||
struct file *fp;
|
||||
struct uio *uio;
|
||||
struct ucred *active_cred;
|
||||
struct thread *td;
|
||||
int flags;
|
||||
struct thread *td;
|
||||
{
|
||||
|
||||
return ((*fp->f_ops->fo_write)(fp, uio, active_cred, flags, td));
|
||||
|
Loading…
x
Reference in New Issue
Block a user