kernel - Fix kqfilter error return codes
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 9 Jul 2010 05:19:06 +0000 (22:19 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 9 Jul 2010 05:19:06 +0000 (22:19 -0700)
* Some kqfilters returned an Exxx error, others return 1 on error,
  and the device kq code returned -1 on error.

* All kqfilters now return a proper Exxx error.

* When an EVFILT is not implemented, EOPNOTSUPP is now returned.
  EPERM is no longer returned.

46 files changed:
sys/bus/firewire/fwdev.c
sys/bus/usb/usb.c
sys/dev/drm/drm_fops.c
sys/dev/misc/cmx/cmx.c
sys/dev/misc/hotplug/hotplug.c
sys/dev/misc/kbd/kbd.c
sys/dev/misc/mse/mse.c
sys/dev/misc/psm/psm.c
sys/dev/misc/snp/snp.c
sys/dev/misc/spic/spic.c
sys/dev/misc/tw/tw.c
sys/dev/raid/aac/aac.c
sys/dev/raid/vinum/vinum.c
sys/dev/sound/pcm/dsp.c
sys/dev/usbmisc/ugen/ugen.c
sys/dev/usbmisc/uhid/uhid.c
sys/dev/usbmisc/ums/ums.c
sys/dev/video/bktr/bktr_os.c
sys/dev/video/cxm/cxm.c
sys/emulation/linux/linux_epoll.c
sys/kern/kern_event.c
sys/kern/kern_memio.c
sys/kern/kern_udev.c
sys/kern/subr_bus.c
sys/kern/subr_log.c
sys/kern/sys_generic.c
sys/kern/sys_pipe.c
sys/kern/tty.c
sys/kern/tty_pty.c
sys/kern/tty_tty.c
sys/kern/uipc_socket.c
sys/net/bpf.c
sys/net/i4b/driver/i4b_rbch.c
sys/net/i4b/driver/i4b_tel.c
sys/net/i4b/layer4/i4b_i4bdrv.c
sys/net/tap/if_tap.c
sys/net/tun/if_tun.c
sys/platform/pc32/apm/apm.c
sys/platform/pc32/isa/asc.c
sys/platform/pc64/apm/apm.c
sys/platform/pc64/isa/asc.c
sys/vfs/devfs/devfs_vnops.c
sys/vfs/fifofs/fifo_vnops.c
sys/vfs/gnu/ext2fs/ext2_vnops.c
sys/vfs/hammer/hammer_vnops.c
sys/vfs/ufs/ufs_vnops.c

index 0db8bc9..17ed38e 100644 (file)
@@ -766,7 +766,7 @@ fw_kqfilter(struct dev_kqfilter_args *ap)
         * XXX Implement filters for mem?
         */
        if (DEV_FWMEM(dev)) {
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
@@ -785,7 +785,7 @@ fw_kqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)ir;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index e504487..ac6418d 100644 (file)
@@ -742,7 +742,7 @@ usbkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)dev;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index db820fc..e814192 100644 (file)
@@ -139,7 +139,7 @@ drm_kqfilter(struct dev_kqfilter_args *ap)
                kn->kn_fop = &drmfiltops;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index 89f778b..706f589 100644 (file)
@@ -726,7 +726,7 @@ cmx_kqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)sc;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index dd77692..a824ded 100644 (file)
@@ -141,7 +141,7 @@ hotplugkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_fop = &hotplugfiltops;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index a612c84..6e18848 100644 (file)
@@ -792,7 +792,7 @@ genkbdkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)dev;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index e65b672..27ee023 100644 (file)
@@ -659,7 +659,7 @@ msekqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)sc;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index 08332fc..8a7b335 100644 (file)
@@ -2423,7 +2423,7 @@ psmkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)sc;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index e31c2df..1086c0d 100644 (file)
@@ -607,7 +607,7 @@ snpkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)snp;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index 42ef04e..dcef981 100644 (file)
@@ -563,7 +563,7 @@ spickqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)sc;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index 5ba33db..0f622fd 100644 (file)
@@ -568,7 +568,7 @@ twkqfilter(struct dev_kqfilter_args *ap)
     kn->kn_hook = (caddr_t)sc;
     break;
   default:
-    ap->a_result = 1;
+    ap->a_result = EOPNOTSUPP;
     return (0);
   }
 
index cdafcdd..aca4e6b 100644 (file)
@@ -3108,7 +3108,7 @@ aac_kqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)sc;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index 979dc2d..7ea66e2 100644 (file)
@@ -607,7 +607,7 @@ vinumkqfilter(struct dev_kqfilter_args *ap)
         ap->a_kn->kn_hook = (caddr_t)ap->a_head.a_dev;
         ap->a_result = 0;
     } else {
-        ap->a_result = 1;
+        ap->a_result = EOPNOTSUPP;
     }
 
     return (0);
index c799e0f..54b4bc7 100644 (file)
@@ -1131,7 +1131,7 @@ dsp_kqfilter(struct dev_kqfilter_args *ap)
        struct snd_dbuf *bs;
 
        getchns(i_dev, &rdch, &wrch, SD_F_PRIO_RD | SD_F_PRIO_WR);
-       ap->a_result = 1;
+
        switch (kn->kn_filter) {
        case EVFILT_READ:
                if (rdch) {
@@ -1149,6 +1149,9 @@ dsp_kqfilter(struct dev_kqfilter_args *ap)
                        ap->a_result = 0;
                }
                break;
+       default:
+               ap->a_result = EOPNOTSUPP;
+               break;
        }
 
        if (ap->a_result == 0) {
index fcce4b0..83f33cb 100644 (file)
@@ -1547,7 +1547,7 @@ ugenkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)dev;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index f69d443..367c792 100644 (file)
@@ -730,7 +730,7 @@ uhidkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)sc;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index eda339a..92fdc7e 100644 (file)
@@ -719,7 +719,7 @@ ums_kqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)sc;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index 97e99bd..fe0ce82 100644 (file)
@@ -788,8 +788,9 @@ bktr_kqfilter(struct dev_kqfilter_args *ap)
                        kn->kn_hook = (caddr_t)bktr;
                        break;
                }
+               /* fall through */
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index 5f88d6f..ec3b8d3 100644 (file)
@@ -2965,7 +2965,7 @@ cxm_kqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)sc;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index c19ca36..9fa47c1 100644 (file)
@@ -103,16 +103,16 @@ linux_kevent_to_epoll(struct kevent *kevent, struct linux_epoll_event *event)
                 return;
         }
         switch (kevent->filter) {
-                case EVFILT_READ:
-                        if (kevent->data > 0)
-                                event->events = LINUX_EPOLLIN;
-                        event->data = kevent->ident;
-                break;
-                case EVFILT_WRITE:
-                        if (kevent->data > 0)
-                                event->events = LINUX_EPOLLOUT;
-                        event->data = kevent->ident;
-                break;
+       case EVFILT_READ:
+               if (kevent->data > 0)
+                       event->events = LINUX_EPOLLIN;
+               event->data = kevent->ident;
+               break;
+       case EVFILT_WRITE:
+               if (kevent->data > 0)
+                       event->events = LINUX_EPOLLOUT;
+               event->data = kevent->ident;
+               break;
         }
 }
 
index 0d2a895..ccbd67b 100644 (file)
@@ -171,7 +171,7 @@ kqueue_kqfilter(struct file *fp, struct knote *kn)
        get_mplock();
        if (kn->kn_filter != EVFILT_READ) {
                rel_mplock();
-               return (1);
+               return (EOPNOTSUPP);
        }
 
        kn->kn_fop = &kqread_filtops;
index f50a7a7..8aa07c2 100644 (file)
@@ -582,7 +582,7 @@ mmkqfilter(struct dev_kqfilter_args *ap)
                }
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index 661be89..3741f03 100644 (file)
@@ -574,7 +574,7 @@ udev_dev_kqfilter(struct dev_kqfilter_args *ap)
                kn->kn_fop = &udev_dev_read_filtops;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                lockmgr(&udevctx.lock, LK_RELEASE);
                return (0);
        }
index 9776f8f..3453b71 100644 (file)
@@ -315,7 +315,7 @@ devkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_fop = &dev_filtops;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                lockmgr(&devsoftc.lock, LK_RELEASE);
                return (0);
        }
index d5ab5b5..740e663 100644 (file)
@@ -198,7 +198,7 @@ logkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_fop = &logread_filtops;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index b1e8941..3f6291d 100644 (file)
@@ -1256,7 +1256,6 @@ poll_copyout(void *arg, struct kevent *kevp, int count, int *res)
                if (kevp[i].ident == pfd->fd) {
                        if (kevp[i].flags & EV_ERROR) {
                                switch(kevp[i].data) {
-                               case EPERM:
                                case EOPNOTSUPP:
                                        /*
                                         * Operation not supported.  Poll
index b6cb258..66b4a95 100644 (file)
@@ -1397,7 +1397,7 @@ pipe_kqfilter(struct file *fp, struct knote *kn)
                break;
        default:
                rel_mplock();
-               return (EPERM);
+               return (EOPNOTSUPP);
        }
        kn->kn_hook = (caddr_t)cpipe;
 
index 1979289..43e5525 100644 (file)
@@ -1217,7 +1217,7 @@ ttykqfilter(struct dev_kqfilter_args *ap)
                kn->kn_fop = &ttywrite_filtops;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index 224519a..1661659 100644 (file)
@@ -732,7 +732,7 @@ ptckqfilter(struct dev_kqfilter_args *ap)
                kn->kn_fop = &ptcwrite_filtops;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index afb140e..d3fe69e 100644 (file)
@@ -293,7 +293,7 @@ cttykqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)dev;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index fd83603..64a77d4 100644 (file)
@@ -1768,7 +1768,7 @@ sokqfilter(struct file *fp, struct knote *kn)
                ssb = &so->so_rcv;
                break;
        default:
-               return (1);
+               return (EOPNOTSUPP);
        }
 
        crit_enter();
index 9780c99..d057e39 100644 (file)
@@ -1140,7 +1140,7 @@ bpfkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)d;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index c53cf6e..651eb5b 100644 (file)
@@ -615,7 +615,7 @@ i4brbchkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)dev;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index 917acf8..7d75f30 100644 (file)
@@ -796,7 +796,7 @@ i4btelkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)dev;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index 433644f..9a28f2b 100644 (file)
@@ -788,7 +788,7 @@ i4bkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_fop = &i4bkqfiltops_write;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index 062d52e..e58d359 100644 (file)
@@ -1018,7 +1018,7 @@ tapkqfilter(struct dev_kqfilter_args *ap)
        case EVFILT_WRITE:
                /* fall through */
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                rel_mplock();
                return(0);
        }
index 62a645c..d9429ba 100644 (file)
@@ -755,8 +755,8 @@ tunkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)tp;
                break;
        default:
-               ap->a_result = 1;
                ifnet_deserialize_all(&tp->tun_if);
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index 5a49e2c..0b30682 100644 (file)
@@ -1377,7 +1377,7 @@ apmkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)sc;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index dc48b88..e2ce868 100644 (file)
@@ -897,7 +897,7 @@ asckqfilter(struct dev_kqfilter_args *ap)
         kn->kn_hook = (caddr_t)scu;
         break;
     default:
-        ap->a_result = 1;
+        ap->a_result = EOPNOTSUPP;
         return (0);
     }
 
index 6f4f4a7..902f355 100644 (file)
@@ -1377,7 +1377,7 @@ apmkqfilter(struct dev_kqfilter_args *ap)
                kn->kn_hook = (caddr_t)sc;
                break;
        default:
-               ap->a_result = 1;
+               ap->a_result = EOPNOTSUPP;
                return (0);
        }
 
index c4f58de..2c49ec2 100644 (file)
@@ -896,7 +896,7 @@ asckqfilter(struct dev_kqfilter_args *ap)
         kn->kn_hook = (caddr_t)scu;
         break;
     default:
-        ap->a_result = 1;
+        ap->a_result = EOPNOTSUPP;
         return (0);
     }
 
index 3b2799d..44db541 100644 (file)
@@ -1391,10 +1391,7 @@ devfs_specf_kqfilter(struct file *fp, struct knote *kn)
 
 done:
        rel_mplock();
-       if (error)
-               return (-1);
-
-       return (0);
+       return (error);
 }
 
 
@@ -1689,7 +1686,7 @@ devfs_spec_kqfilter(struct vop_kqfilter_args *ap)
        cdev_t dev;
 
        if ((dev = vp->v_rdev) == NULL)
-               return (1);             /* device was revoked (EBADF) */
+               return (EBADF);         /* device was revoked (EBADF) */
        node = DEVFS_NODE(vp);
 
 #if 0
@@ -1697,7 +1694,7 @@ devfs_spec_kqfilter(struct vop_kqfilter_args *ap)
                nanotime(&node->atime);
 #endif
 
-       return (!dev_dkqfilter(dev, ap->a_kn));
+       return (dev_dkqfilter(dev, ap->a_kn));
 }
 
 /*
index d9688ae..cf93c86 100644 (file)
@@ -396,7 +396,7 @@ fifo_kqfilter(struct vop_kqfilter_args *ap)
                break;
        default:
                lwkt_reltoken(&vp->v_token);
-               return (1);
+               return (EOPNOTSUPP);
        }
 
        ap->a_kn->kn_hook = (caddr_t)vp;
index 2f6dafa..81b6803 100644 (file)
@@ -1953,7 +1953,7 @@ ext2_kqfilter(struct vop_kqfilter_args *ap)
                kn->kn_fop = &ext2vnode_filtops;
                break;
        default:
-               return (1);
+               return (EOPNOTSUPP);
        }
 
        kn->kn_hook = (caddr_t)vp;
index 0289f6a..226ba7d 100644 (file)
@@ -3372,7 +3372,7 @@ hammer_vop_kqfilter(struct vop_kqfilter_args *ap)
                kn->kn_fop = &hammervnode_filtops;
                break;
        default:
-               return (1);
+               return (EOPNOTSUPP);
        }
 
        kn->kn_hook = (caddr_t)vp;
index 1ab8b36..b1f2951 100644 (file)
@@ -2145,7 +2145,7 @@ ufs_kqfilter(struct vop_kqfilter_args *ap)
                kn->kn_fop = &ufsvnode_filtops;
                break;
        default:
-               return (1);
+               return (EOPNOTSUPP);
        }
 
        kn->kn_hook = (caddr_t)vp;