How can one,in Linux, create something like a symbolic link (hereby referred to as A) so that any program reading from a will read from an original file (B), but writing to A will instead write to a different file (C), in a way that writing to A will leave B unaffected?
Asked
Active
Viewed 75 times
0
-
After C is created, shall reading anew still read B? – Kamil Maciorowski Mar 20 '23 at 04:50
-
1Please make sure there is no [XY problem](https://meta.stackexchange.com/a/66378/355310) here. [Edit] the question if there is. – Kamil Maciorowski Mar 20 '23 at 04:53
-
I very much doubt you could do this without a (virtual) file system (like _overlayfs_). – Daniel B Mar 20 '23 at 09:39
-
@KamilMaciorowski yes – 3eeeeeee512 Mar 20 '23 at 16:16
-
Why do you want to do this? – zomega Mar 31 '23 at 09:45
-
If you don't want the file to change simply don't write to it. – zomega Mar 31 '23 at 09:46
1 Answers
0
There is no easy way to do this.
It may be possible with an overlayfs, but setting this up is complicated and for a single file even more so.
It is also possible to write a kernel module that intercepts the necessary system calls to implement such a feature. As far as I know, no-one has done this yet.
You should reconsider your use-case.
Ljm Dullaart
- 2,416
- 8
- 17