in reply to imitation block device in linux

I may be a bit rusty on my kernel design, but I believe kernel code becomes involved when you use block devices. You may need to write a device driver for the kernel and learn about major and minor devices. Read "man makedev".

IIRC there is a mini-tutorial somewhere out there in the cyber fields, for writing your own linux kernel driver.


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: imitation block device in linux
by chrestomanci (Priest) on Mar 18, 2011 at 15:37 UTC

    If the OP wants to take that road then the O'Reilly book Linux Device Drivers is available. The text is under a liberal open source licence, so you can read it online for free.

    Another approach would be to create a FUSE filing system, and create an artificial block device or mountable file-system image inside.

    Having said that, I doubt that the OP really needs to write a block device.

      Yeah, I'm trying to imitate a block device, one that can be accessed by programs like dd, or even mounted with the mount command. My intention is to intercept read/write/seek operations and manage the data as it goes back and forth (logging, encryption, etc). I was hoping to stay with perl, but it looks like I might have to spend some learning curve on C?
        I'm trying to imitate a block device, one that can be accessed by programs like dd

        Have you thought of making a ramdisk... it essentially makes a little disk device in your ram memory, which you can treat exactly like a disk.

        Google for ramdisk linux for many guides.

        UPDATE: I forgot to mention a loopback filesystem, where you can mount a file with the -o loop option and it acts like a disk device also.


        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku ................... flash japh