Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/kqueue]: src/sys/miscfs/genfs implement genfs_kqfilter() - this is based...



details:   https://anonhg.NetBSD.org/src/rev/feb7e137ca18
branches:  kqueue
changeset: 512523:feb7e137ca18
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Wed Sep 25 21:36:58 2002 +0000

description:
implement genfs_kqfilter() - this is based upon ufs_kqfilter(), but uses
vp->v_size for EVFILT_READ

diffstat:

 sys/miscfs/genfs/genfs.h       |   3 +-
 sys/miscfs/genfs/genfs_vnops.c |  84 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 84 insertions(+), 3 deletions(-)

diffs (123 lines):

diff -r 5e7b7ef7f87e -r feb7e137ca18 sys/miscfs/genfs/genfs.h
--- a/sys/miscfs/genfs/genfs.h  Wed Sep 25 16:10:20 2002 +0000
+++ b/sys/miscfs/genfs/genfs.h  Wed Sep 25 21:36:58 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: genfs.h,v 1.12.2.2 2002/01/10 20:01:34 thorpej Exp $   */
+/*     $NetBSD: genfs.h,v 1.12.2.3 2002/09/25 21:36:58 jdolecek Exp $  */
 
 int    genfs_badop             __P((void *));
 int    genfs_nullop            __P((void *));
@@ -28,3 +28,4 @@
 int    genfs_putpages          __P((void *));
 int    genfs_null_putpages     __P((void *));
 int    genfs_compat_getpages   __P((void *));
+int    genfs_kqfilter          __P((void *));
diff -r 5e7b7ef7f87e -r feb7e137ca18 sys/miscfs/genfs/genfs_vnops.c
--- a/sys/miscfs/genfs/genfs_vnops.c    Wed Sep 25 16:10:20 2002 +0000
+++ b/sys/miscfs/genfs/genfs_vnops.c    Wed Sep 25 21:36:58 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: genfs_vnops.c,v 1.35.2.5 2002/06/23 17:50:09 jdolecek Exp $    */
+/*     $NetBSD: genfs_vnops.c,v 1.35.2.6 2002/09/25 21:36:58 jdolecek Exp $    */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.35.2.5 2002/06/23 17:50:09 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.35.2.6 2002/09/25 21:36:58 jdolecek Exp $");
 
 #include "opt_nfsserver.h"
 
@@ -50,6 +50,7 @@
 #include <sys/malloc.h>
 #include <sys/poll.h>
 #include <sys/mman.h>
+#include <sys/file.h>
 
 #include <miscfs/genfs/genfs.h>
 #include <miscfs/genfs/genfs_node.h>
@@ -1647,3 +1648,82 @@
        uvm_aio_aiodone(bp);
        return (error);
 }
+
+static void
+filt_genfsdetach(struct knote *kn)
+{
+       struct vnode *vp = (struct vnode *)kn->kn_hook;
+
+       /* XXXLUKEM lock the struct? */
+       SLIST_REMOVE(&vp->v_klist, kn, knote, kn_selnext);
+}
+
+static int
+filt_genfsread(struct knote *kn, long hint)
+{
+       struct vnode *vp = (struct vnode *)kn->kn_hook;
+
+       /*
+        * filesystem is gone, so set the EOF flag and schedule
+        * the knote for deletion.
+        */
+       if (hint == NOTE_REVOKE) {
+               kn->kn_flags |= (EV_EOF | EV_ONESHOT);
+               return (1);
+       }
+
+       /* XXXLUKEM lock the struct? */
+       /* XXXLUKEM (jdolecek): clipping to 32bit value */
+       kn->kn_data = vp->v_size - kn->kn_fp->f_offset;
+        return (kn->kn_data != 0);
+}
+
+static int
+filt_genfsvnode(struct knote *kn, long hint)
+{
+
+       if (kn->kn_sfflags & hint)
+               kn->kn_fflags |= hint;
+       if (hint == NOTE_REVOKE) {
+               kn->kn_flags |= EV_EOF;
+               return (1);
+       }
+       return (kn->kn_fflags != 0);
+}
+
+static const struct filterops genfsread_filtops = 
+       { 1, NULL, filt_genfsdetach, filt_genfsread };
+static const struct filterops genfsvnode_filtops = 
+       { 1, NULL, filt_genfsdetach, filt_genfsvnode };
+
+int
+genfs_kqfilter(void *v)
+{
+       struct vop_kqfilter_args /* {
+               struct vnode    *a_vp;
+               struct knote    *a_kn;
+       } */ *ap = v;
+       struct vnode *vp;
+       struct knote *kn;
+
+       vp = ap->a_vp;
+       kn = ap->a_kn;
+       switch (kn->kn_filter) {
+       case EVFILT_READ:
+               kn->kn_fop = &genfsread_filtops;
+               break;
+       case EVFILT_VNODE:
+               kn->kn_fop = &genfsvnode_filtops;
+               break;
+       default:
+               return (1);
+       }
+
+       kn->kn_hook = (caddr_t)vp;
+
+       /* XXXLUKEM lock the struct? */
+       SLIST_INSERT_HEAD(&vp->v_klist, kn, kn_selnext);
+
+       return (0);
+}
+



Home | Main Index | Thread Index | Old Index