summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-12-23 21:53:20 +0000
committerphk <phk@FreeBSD.org>2002-12-23 21:53:20 +0000
commitb9e78196906ce4e1ddcc9226147152ae434299af (patch)
tree1029129c1c43d78a4359b6cc2e981fd42f7d59e4 /sys
parentce7c11d2b715e7ecc8863611787ef8a3dfc6df0d (diff)
downloadFreeBSD-src-b9e78196906ce4e1ddcc9226147152ae434299af.zip
FreeBSD-src-b9e78196906ce4e1ddcc9226147152ae434299af.tar.gz
Detediousficate declaration of fileops array members by introducing
typedefs for them.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_descrip.c17
-rw-r--r--sys/kern/kern_event.c20
-rw-r--r--sys/kern/sys_pipe.c19
-rw-r--r--sys/kern/vfs_vnops.c19
-rw-r--r--sys/sys/file.h65
5 files changed, 64 insertions, 76 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 27e0bcc..61f2dfd 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -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,
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index 9fa9de7..7bf8c74 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -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,
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index d09f31f..bdf6cc3 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -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,
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 0281a29..74f4c23 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -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,
diff --git a/sys/sys/file.h b/sys/sys/file.h
index 990bd2b..77344d0 100644
--- a/sys/sys/file.h
+++ b/sys/sys/file.h
@@ -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));
OpenPOWER on IntegriCloud