On Sun, Nov 10, 2019 at 11:37 PM Caveman Al Toraboran <toraboracave...@protonmail.com> wrote: > > i think if we have this, we can solve slotting in a simpler > way. e.g. we install libs in their own non-conflicting > locations, and then install for them such fancy sym links > with access that routes accessing processes to the right > version of the lib. >
I think the respondents so far haven't actually understood what you're asking based on your example. What follows is mainly for the purposes of fun discussion and some awareness of what is out there, but IMO none of this is really a great basis for a solution... This is certainly possible for EXECUTABLES and is in fact commonly done. busybox is probably the most prominent example of this, and sysvinit uses it as well (as do many others no doubt). However, you're asking about libraries and probably files in general, such as config files. With a library it might be possible (though probably inadvisable) to build a wrapper library that intercepts calls, figures out which ABI/API to use, and then dispatches them to the appropriate implementations. Since it runs under the calling process it would know what that process is. Or you could use the following method... For generic files such as text files an even more inadvisable approach would be to use a bazillion FIFOs and possibly fanotify to intercept read/writes and return the appropriate data. However, I think FIFOs are limited to sequential access so that is going to limit what it can be used for. I'm not sure at what point fanotify for permissions blocks but you might also be able to swap out the symlink between the call to open and the time when the file is actually opened, but that seems likely to be subject to race conditions if you have 3 processes trying to open the same file at the same time (even if fanotify gives the opportunity to relink the file in time how would it know that the process now has an open descriptor that no longer depends on the link and that it is safe to relink for the next process). -- Rich