Categorized | Linux

How do I access a disk file from a Linux block device driver?

Posted on 18 April 2010 by Abidoon

I need documentation on how to perform file IO (to a well defined disk file) from inside a Linux block device driver. Ideally, using the 2.6.(14-21) era kernels, compiled for 32-bit.

I’m trying to emulate flash memory for a flash file system, using the disk file as the actual storage. The file will be arbitrarily large (eventually in the TiB range).

Where do I look for information?

Tags | , , , , , , ,

2 Responses to “How do I access a disk file from a Linux block device driver?”

  1. bakegoodz says:

    Your question is over my head if you trying to write your own device driver. Though I had trouble following every part of your question, it sounds like what you need is to mount a a file system to a file. You can make a file that is a virtual block device with the “dd” command, and format it into whatever filesystem you want with the regular mkfs tools. Then you can mount it with a command like “mount imagefile /media/mountpoint -o loop”

  2. jplatt39 says:

    Look, it’s called Open Source because you can go to ftp://ftp.kernel.org/pub/linux/kernel/ and download the whole source code including all the block device drivers. Then you can go to linuxquestions.org, and ask your questions. And of course http://www.tldp.org/ is the Linux Documentation project with documentation on just about everything.

    There are other places to look of course. Ubuntu has forums, google has both:

    http://www.google.com/linux
    and, though it may not seem like a good source of information:
    http://www.google.com/bsd
    Try them both. You’ll be amazed.


Leave a Reply