I am looking for a way to implement filesystem files/directories access layers.
So I could have this structure ex.:
/mountPointMerged/
/mountPointLayer1/a/b/c.txt
/mountPointLayer2/a/b/c.txt
/mountPointLayer3/a/b/c.txt
When accessing the file /mountPointMerged/a/b/c.txt, if the 2nd layer is mounted, it's file would be read/written only if the 3rd layer is NOT mounted, and if both 2nd and 3rd are umounted, the 1st would be accessed.
The point is, there must happen a merge. So, adding these files specifically in these layers:
/mountPointLayer1/a/b/d.txt
/mountPointLayer2/a/b/e.txt
/mountPointLayer3/a/b/f.txt
would provide this result:
ls /mountPointMerged/a/b/
c.txt
d.txt
e.txt
f.txt
Any new file created at /mountPointMerged/, would be written at the topmost mounted layer.
But other layers could be accessed directly by accessing ex.: /mountPointLayer2/a/b/c.txt and not /mountPointMerged/.
Can it be done in some way?
overlayfilesystem, it sounds like what you are looking for: kernel.org/doc/Documentation/filesystems/overlayfs.txt