From owner-freebsd-current Fri Jan 12 14:46: 5 2001 Delivered-To: freebsd-current@freebsd.org Received: from mail.interware.hu (mail.interware.hu [195.70.32.130]) by hub.freebsd.org (Postfix) with ESMTP id 11B5437B400 for ; Fri, 12 Jan 2001 14:45:41 -0800 (PST) Received: from kairo-46.budapest.interware.hu ([195.70.50.110] helo=elischer.org) by mail.interware.hu with esmtp (Exim 3.16 #1 (Debian)) id 14HCwq-0002Rb-00; Fri, 12 Jan 2001 23:45:28 +0100 Message-ID: <3A5F16D8.2E1B471C@elischer.org> Date: Fri, 12 Jan 2001 06:38:16 -0800 From: Julian Elischer X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 5.0-CURRENT i386) X-Accept-Language: en, hu MIME-Version: 1.0 To: Andrew Gallatin Cc: freebsd-current@freebsd.org, 'Alfred Perlstein' Subject: Re: Running Linux kernel modules. References: <01C07BF3.695D3780.ggross@symark.com> <14942.32188.899333.434988@grasshopper.cs.duke.edu> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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