Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Jan 2001 06:38:16 -0800
From:      Julian Elischer <julian@elischer.org>
To:        Andrew Gallatin <gallatin@cs.duke.edu>
Cc:        freebsd-current@freebsd.org, 'Alfred Perlstein' <bright@wintelcom.net>
Subject:   Re: Running Linux kernel modules.
Message-ID:  <3A5F16D8.2E1B471C@elischer.org>
References:  <01C07BF3.695D3780.ggross@symark.com> <14942.32188.899333.434988@grasshopper.cs.duke.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
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  http://www.cs.duke.edu/~gallatin
> Duke University                         Email: gallatin@cs.duke.edu
> Department of Computer Science          Phone: (919) 660-6590
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-current" in the body of the message

-- 
      __--_|\  Julian Elischer
     /       \ julian@elischer.org
    (   OZ    ) World tour 2000
---> X_.---._/  from Perth, presently in:  Budapest
            v




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A5F16D8.2E1B471C>