Subject: new kqueue diffs available for review/comment.
To: None <tech-kern@netbsd.org>
From: Luke Mewburn <lukem@wasabisystems.com>
List: tech-kern
Date: 06/04/2001 00:56:18
hello again people.

based on feedback from bill sommerfeld and jason thorpe, i've updated
my kqueue diffs, test suite, and docco:
    diff:
	ftp://ftp.netbsd.org/pub/NetBSD/misc/lukem/kqueue-010604.diffs
    test suite:
	ftp://ftp.netbsd.org/pub/NetBSD/misc/lukem/kqueue-test.tar.gz
    formatted man pages:
	ftp://ftp.netbsd.org/pub/NetBSD/misc/lukem/kfilter_register.cat2
	ftp://ftp.netbsd.org/pub/NetBSD/misc/lukem/knote.cat2
	ftp://ftp.netbsd.org/pub/NetBSD/misc/lukem/kqueue.cat2


what's changed since the last diff (010521):

+ diffs for autogenerated files (vnode_if.c et al) aren't provided

+ changed the system to using uint32_t's instead of ints & shorts.
  (this will require translation in the freebsd kqueue(2) compat shim)

+ only use positive filter numbers, instead of negative and doing
  tricky/complicated binary xors to map filter number into array
  offset.
  (this will require translation in the freebsd kqueue(2) compat shim)

+ provide macros to simplify cdevsw kqfilter for tty-like devices
  which just want to use ttykqfilter()

+ cleaned up the way that filters are looked up by providing two
  internal functions to lookup by name or filter id.

+ create two ioctls which are supported on the file descriptor
  returned by kqueue(2):
	KFILTER_BYFILTER	lookup filter by filter number, return
				result in name (which is of size len)
	KFILTER_BYNAME		lookup filter by name (len ignored)

  both use the following structure to pass args in and out:
	struct kfilter_mapping {
		char	 *name;		/* name to lookup or return */
		int	  len;		/* length of name */
		uint32_t  filter;	/* filter to lookup or return */
	};

+ add two more kernel functions;
	kfilter_register(const char *name, struct filterops *ops, int *ret)
		add a new kfilter, returning new filter number in ret
		if ret != NULL.
	kfilter_unregister(const char *name)
		delete a kfilter added with kfilter_register(9) (can't
		nuke a system filter)
  these won't recycle a filter number, so doing:
	kfilter_register("foo", ....);
	kfilter_unregister("foo");
	kfilter_register("foo", ....);
  will result in a new number for "foo". the old number is remembered,
  but if a user tries to use it it will fail.
  this is to prevent any wacky confusion if a userland caller does a
  KFILTER_BYNAME lookup and then tries to do a kevent(2) using that
  filter number, and then having Bad Shit(tm) happen because the
  filter was changed behind its back.

+ added p_opaque field to struct knote's union kn_ptr

+ added lots of comments to kern_event.c (including description of how
  kn_fdlist et al works)

+ added section 9 man pages for knote(9), and the new
  kfilter_{un,}register(9) functions

+ fixed up some bad use of malloc(9) and MALLOC(9).

(probably other stuff i've forgotten)


there's still a couple of issues not resolved, but i think they either
need further/deeper thought, or can be implemented after integration,
and i don't think they should hold up the integration:
	* events aren't copied across fork(2)
	* may need more filter entry points
	* rewrite sowakeup() et al
	* provide a kqueue(2) COMPAT_FREEBSD function

any comments/suggestions/thoughts?

i'd like to get this integrated Soon.

luke.