Andrew Gallatin wrote:
>  >
> To handle the multiple open problem, I'm overloading the open and
> close system calls.  Upon open, I call the native open, then I grovel
> around in the process' open file table looking for my special file.
> When I find it, I mark fp->f_nextread with a magic number, then store
> a pointer to the per-open private data in fp->f_offset.  On close, I
> go grovelling again.  I deallocate the private data, clear the magic
> number, and call the system close function.  I've also got an
> at_exit() hook that does much the same thing.
> Obtaining the file descripter at ioctl() and mmap() time is much more
> interesting.  When I'm called from a syscall, I pull the args out of
> the process and grab the fd, index the process' file table and bingo.
> The real problem is when mmap is called out of a fault (and not
> dev_pager_alloc, which is what gets called when the mmap syscall is
> issued).  Right now I throw up my hands and return the private data
> from the first instance I find when walking the process' open file
> table.   If this becomes a problem, I'm planning on prefaulting the
> pages at dev_pager_alloc() time (when I can get an fd from the
> process) and wiring them -- its only 20k per process..
> Isn't this gross?  Is there a better way?

I think that the better way is to actually have each open have a 
different minor number.
i.e. each process opens a different copy.

The way to achieve this best is with cloning devices.
apply within phk for more info :-)

I could imagine however that you could assume that each process 
opens the device only once, and thus have a hash-table of 
private info, keyed on curproc. You should be able to store the curproc
key with the request currently being serviced so that teh interrupt routines
can also use the same key.

> Drew
> ------------------------------------------------------------------------------
> Andrew Gallatin, Sr Systems Programmer
> Duke University                         Email: [EMAIL PROTECTED]
> Department of Computer Science          Phone: (919) 660-6590
> To Unsubscribe: send mail to [EMAIL PROTECTED]
> with "unsubscribe freebsd-current" in the body of the message

      __--_|\  Julian Elischer
     /       \ [EMAIL PROTECTED]
    (   OZ    ) World tour 2000
---> X_.---._/  from Perth, presently in:  Budapest

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to