Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Mar 2000 21:06:41 -0800
From:      Alfred Perlstein <bright@wintelcom.net>
To:        "Gary T. Corcoran" <garycor@home.com>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: How to read a file from a device driver?
Message-ID:  <20000317210640.D14789@fw.wintelcom.net>
In-Reply-To: <38D3085D.37F31443@home.com>; from garycor@home.com on Fri, Mar 17, 2000 at 11:38:53PM -0500
References:  <38D2FF48.CE3E396B@home.com> <20000317202018.C14789@fw.wintelcom.net> <38D3085D.37F31443@home.com>

next in thread | previous in thread | raw e-mail | index | archive | help
* Gary T. Corcoran <garycor@home.com> [000317 20:54] wrote:
> 
> Alfred,
> 
> > > Can someone please tell me how I can read a file from a device driver
> > > in FreeBSD?  I need to download 2 or 3 relatively-large code files to
> > > my device, choosing from amongst several different files depending on
> > > which mode I'm operating in.  Therefore compiling-in the code is not
> > > a reasonable choice.
> > >
> > > If you can either tell me how to be able to read a file from my driver,
> > > or point me to an example driver which does this, I would appreciate it.
> > >
> > > I'm running FreeBSD 3.4.
> > >
> > > (not subscribed to this list, please always CC: me on replies)
> > 
> > I hope i'm not advocating abusing an interface here, but here's what
> > comes to mind...
> > 
> > Use an ioctl in your driver to pass in a pointer to your user
> > address space which depending on the ioctl request the size of the
> > file be written to the pointer, or that the pointer is where the
> > device should copyout() or use one of the functions from STORE(9)
> > to dump into the user address space.
> 
> Sorry, but either I'm not understanding what you're suggesting, or
> I didn't explain my need clearly...  ;-)

I had an inverted sense of what you wanted to accomplish, i thought
you had several different chunks of data that needed to be downloaded
from the driver.

> 
> I'm trying to initialize a network device, and I'm trying to download
> code *into* my device from some binary system files.  There is no
> "user space" or user process, for that matter, to deal with at this point.
> I just want to (at this step) open a file(s) directly from my device
> driver, read the file(s), and download the relevant parts to my device.
> 
> Does that change your answer?  :-)

Yes, in a couple of ways:

a) you can use a userland program to copy the data in like I suggested
   above, but you'll obviously be using 'fubyte' or 'copyin' instead of
   subyte or copyout (easiest)
b) you can make the datafiles into some sort of kernel loadable module (so so)
   you can load your module via the loader or once the system is up.
c) you can look at NAMEI and the fs code to figure out how this is done,
   one subsystem that manipulates files from kernel space is the quota
   system.
d) ? :)

good luck,
-- 
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]


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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000317210640.D14789>