Subject: Re: open(2) -> device open
To: Jay Parlar <>
From: Bill Studenmund <>
List: tech-kern
Date: 06/12/2003 09:22:01
On Thu, 12 Jun 2003, Jay Parlar wrote:

> I'm currently trying to get familiar with parts of the NetBSD kernel, in
> particular, the path taken from calling open() in userland on "/dev/xyz " to
> arriving at the xyzopen() call in the device driver.
> I'm not having too much luck right now. I know enough to start with
> sys_open() and go from there, but I keep getting lost in the internals.

Ok, here are the important calls:

sys_open calls vn_open()

vn_open calls a bunch of things, then eventually calls VOP_OPEN().

VOP_OPEN is one of the vnode interface routines, and calls the file
system. For a device, this would be the file systen for /dev. For now
let's assume that's an ffs.

The vnode system uses the vnode op entries in the vnode to determine what
to call. I know that for ffs device nodes, that is the ffs_specop_entries
table. Its VOP_OPEN entry is the one paired with vop_open_desc, which is

spec_open, in miscfs/specfs/spec_vnops.c, calls either cdevsw_lookup()
or bdevsw_lookup(), does some work, then calls (*[bc]dev->d_open)(dev,
ap->a_mode, S_IFCHR, p), which is your driver's routine.

Take care,