Subject: NetBSD char device driver (how to access file pointer or inode)?
To: None <port-arm@netbsd.org>
From: Nalin Gupta <nalingupta2000@gmail.com>
List: port-arm
Date: 02/08/2007 14:23:30
Hello,

I am aware writing Linux Modules.  I am trying to read thru NetBSD
Device Driver, but confusing between  its LKM and typical device
writing styles.

I need to port one simple Linux Device Driver to NetBSD.

So far I am unable to find, how and where I can store "private context
data" for the process who "open"ed the device.  As there can be
multiple processes opening the device. (same minor number).

In Linux, for "open", char dev driver operation is like :
static int alfOpen (  struct inode *iNode,    struct file  *filePtr  )
{
...
    filePtr->private_data =   myData;       <<<<<<<<<<< How to do this
in NetBSD ?
...
}

Whereas in NetBSD (~ v 2.0) the open operation is like:
static int alfOpen(dev_t dev, int flag, int mode, struct proc *p)
{
....
}

In this "dev" just tells Major and Minor. So unsure how and where can
I can access either inode or global open file pointer.  I looked in to
"struct proc", but still clueless.

I saw some knotes, but do not know it usage.

Any help shall be appreciated.

regards,
- nalin