views:

54

answers:

3

Hi Guys,

I have a piece of C code which with a chunk of memory(static array) can mimic file operations (It has APIs similar to fopen/fclose etc). So, any code that is compiled with this mimicking FileSystem can use these APIs as a FileSystem for all their needs :)

But I was wondering, if its possible somehow to register these APIs with Linux system/mouning this File system, and hence enabling any client to use this FS by using normal FileSystem calls (without any need of statically linking it with the My_FileSystem).

While searching for a solution, I came across this idea of making my_FileSystem as a Driver!!! => Is it possible to compile my code as a device driver (with the memory chunk in the driver) and mount this File_system @ say "/mnt/MyFs", and divert FileSystem calls like USB drivers do? (If this can be done, can you please explain how its done or point me to somewhere I can read about this).

I don't want to add these as new System calls and recompile the kernel (And making life of ppl wanting to use this difficult).

This is mainly for embedded systems running Linux... But other suggestions are also welcome. :)

Thank You,

MicroKernel :)

+5  A: 

Look at FUSE (Filesystem in Userspace), especially on examples. Its quite easy...

Dezyderat
Hi, thanks for the reply. FUSE really looks interesting. But I'm mainly looking at embedded devices running Linux, so, I am not quite sure FUSE can be used there. Will give a try anyways :)Sorry for not mentioning about Embedded Systems running Linux as the main focus.Do you like to add anything else for this particular situation of Embedded systems as main focus.
Microkernel
"Embedded" embodies a wide variety of hardware these days, even "embedded systems running Linux" cover a huge spectrum. FUSE could be fine for many embedded systems (high end ARM systems such as smart phones) but completely unacceptable for others (low memory uC systems so bare-bones they lack an MMU). Perhaps you could expand on your constraints some more.
TomMD
@Microkernel : I can't quite remember when FUSE hit mainline, but I'm almost positive it was not during the days of 2.4. A lot of 'embedded' systems still use the 2.4 kernel. What we really need to know here is what version of the Linux kernel you are using.
Tim Post
+1  A: 

Take a look at tmpfs and ramfs. These already ship with Linux and do all that you're trying to do and more. I don't think either of them would be too expensive for an embedded system.

Neil Mayhew
A: 

I would consider PlasticFS, but that will work reliably only if everything uses system C library (i.e. no statically linked binaries).

Juraj