Microkernel
Microkernel

Reputation: 1417

Linux - mounting a user space file system(mimicking one :-) ) as a FileSystem

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 :)

Upvotes: 1

Views: 1331

Answers (3)

Juraj
Juraj

Reputation: 870

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

Upvotes: 0

Neil Mayhew
Neil Mayhew

Reputation: 14907

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.

Upvotes: 1

Dezyderat
Dezyderat

Reputation: 76

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

Upvotes: 6

Related Questions