LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Process IO redirection (https://www.linuxquestions.org/questions/linux-software-2/process-io-redirection-4175459731/)

dth4h 04-26-2013 09:03 PM

Process IO redirection
 
I want to make is so that any process run in the current shell, if it tries to access (read/write) a certain filesystem path, it will get redirected to somewhere else. So for example:

Code:

$ bash
$ redirect /this/path/to /that/path
$ nano /this/path/to/textfile

So running the above (nano /this/path/to/textfile) would actually make nano open up a new file (or already existing one) at /that/path/textfile.


I have been researching this for awhile now and can't figure it out.
I am pretty sure there is a technical term for this (other than IO redirection which usually just give results for 'echo hi > file' on Google).

Any help is greatly appreciated.

catkin 04-26-2013 09:18 PM

Make /this/path/to a symlink to /that/path or another hardlink to the same file as /that/path?

dth4h 04-26-2013 09:25 PM

Yes I want basically that, but I want it to only be for the current shell. Everything else would still write to the path /this/path/to.

Habitual 04-27-2013 02:14 PM

Code:

bash -r
perhaps?

dth4h 04-29-2013 03:08 PM

How would I do this with bash -r?

Chroot looked promising, but it has to be done as... root and it makes everything else disappear to the program.

jpollard 04-29-2013 03:40 PM

In the base setup, you can't.

The current process uses the kernels context of the user environment - and that is started at the login.

File paths are strictly global. The only "process" reference is the "current working directory".

Now environment variables can be set up... but the process has to know how to use them (most don't). The most frequently used of these is PATH, LD_LIBRARY_PATH, LD_PRELOAD - which are interpreted by a runtime library (PATH), or the process loader (result of exec system call).

What you are asking for is additional complexity in the runtime library - (as in how should it identify when something is redirected and when it isn't).

Symbolic links are global, not process specific. Plan 9 has some of this - but it is still very heavy handed about it (bind mounts are part, but bind mounts are also global unless you have created/activated namespaces for a process...)
ref:
http://uwsgi-docs.readthedocs.org/en...amespaces.html

dth4h 05-03-2013 04:35 PM

Ok, well thanks for the info.


All times are GMT -5. The time now is 04:53 AM.