开发者

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

开发者 https://www.devze.com 2023-01-06 01:24 出处:网络
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 ca

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 ad开发者_运维问答d 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 :)


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


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号