From: Arnd Bergmann <arnd@arndb.de>
To: van <van.wanless@eqware.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: File I/O from within a driver
Date: Wed, 25 May 2005 14:18:44 +0200 [thread overview]
Message-ID: <200505251418.44680.arnd@arndb.de> (raw)
In-Reply-To: <2005524221531.650853@Oz>
On Middeweken 25 Mai 2005 07:15, van wrote:
> The structure of media files is complex and I'd rather the calling application
> didn't need to have any knowledge of that structure. But how can the driver
> do the necessary read() operations?
>
> I could, for example, have the application pass an open file descriptor in to
> my driver via an ioctl() call; if I understand matters correctly, my driver
> could then call sys_read(). I've never done anything like that before, never
> expected to need to, and it doesn't feel right.
_if_ you want to read the file, use fget() and vfs_read() on the file
descriptor you get passed. It is however considered rather bad style to
do file I/O from drivers. As Brian Gerst said, better use mmap in user
space and pass the pointer via ioctl() or write().
> Can anyone suggest the *proper* way to accomplish this?
Your assumption that the driver should parse the media file structure
is probably wrong. You should rather do as much as possible in a user
space library. Pass a file name to a library call and have that
work with all the complex parts of the file format, then define an
ioctl interface for the driver on a relatively low level.
Or even better, don't use ioctl() at all but implement only read()/write()
in the driver. E.g. for MPEG acceleration, you might want to have an
interface where you write a series of macro blocks to the character
device and read back pixel data.
Arnd <><
prev parent reply other threads:[~2005-05-25 12:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-25 5:15 File I/O from within a driver van
2005-05-25 5:41 ` Brian Gerst
2005-05-25 11:56 ` John W. Linville
2005-05-25 12:18 ` Arnd Bergmann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200505251418.44680.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=van.wanless@eqware.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox