Subject: Re: Understanding foo_open, foo_read, etc.
To: None <>
From: Peter Seebach <>
List: tech-kern
Date: 08/29/2006 17:14:59
In message <>, Quentin Garnier writes:
>AFAIK, but I know or remember very little about that, but FreeBSD allows
>having close() called for each call of the system call, instead of only
>the last one.  I prefer the NetBSD approach which is I think clearer in
>its intent.
>What's so complicated about calling fdalloc and returning the ressult
>of fdclone()?

Nothing particularly awful about it, it's just that I'm trying to minimize
the changes I make from an existing driver that's expecting everything to
be using cdevsw operations rather than fileops operations.  I can do it,
it's just extra work.  :)  I have about a dozen routines to deal with,
each of which is currently:

int zt_read(struct cdev *dev, struct uio *uio, int ioflag)

and needs to become:

int zt_read(struct file * fp, off_t * off, struct uio * uio, struct ucred * active_cred, int flags)

so it's a fair amount of nuisance, and makes it harder to integrate changes
back in, if the zaptel-freebsd people are even interested.  It means a lot
of code duplication, probably.  In practice, I think I can ignore the offset
and active_cred parameters, and indeed, even the flags; I just need to
use the first argument to identify a device, and then process the uio.

So it's not awful.  And at least now I understand WHY I'm doing it.