File system in battery backed SRAM

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
I have a system with a region of memory that is battery-backed.

I'd like to use it as a file system - the idea is to make / read only and
put files that need to be modified into the battery backed file system....

I've googled about but found nothing that would do this; just some vague
references to ramdisks.  But then I've found nothing that would let me pin
a ramdisk into a specific region in memory and keep it there over reboots.

So...  Anyone know of any way to do this?


Re: File system in battery backed SRAM
Wath about adding a hard disk, mmc or SD ?

Re: File system in battery backed SRAM

Quoted text here. Click to load it

I've developed a little device block driver to do that.
The way i do it is very simple:

Look at some block devices, and choose one to use as a skeleton.
The request function may be something like:

#include <linux/blk.h>

// ....

#define DEVICE_REQUEST do_rh_request

static void
do_rh_request( request_queue_t * q )
    mm_segment_t fs;
    u_long start, len, addr, size;

    while ( TRUE )

                minor = MINOR(CURRENT->rq_dev);

                start = CURRENT->sector << 9;
                len  = CURRENT->current_nr_sectors << 9;
                size = YOUR_MEMORY_SIZE;

                if( (start + len) > size )
                        printk( KERN_ERR DEVICE_NAME ": bad access:
block=%ld, count=%ld\n",
                        end_request( FALSE );

                fs = get_fs();
                addr = YOUR_MEMORY_BASE_ADDRESS + start;

                if( ( CURRENT->cmd == READ ) )
                        //  READ blocks
                        copy_to_user ( CURRENT->buffer, (char *)addr, len );
                        //  WRITE blocks
                        copy_from_user ( (char*)addr, CURRENT->buffer,
len );

                end_request( TRUE );

This code write or read directly to memory. Each 512 block will be saved in
the SRAM. You may improve security by reserving one sector area and save in
that point each sector before modify it.
At system startup you may check the reserved area, and if it contains a
stored record you may recover it (the system may be turned-off when writing
to a sector).

Then you may format your block device as you do for other disks, for example
with minix, and mount it.

Bye, Gabriele

Site Timeline