LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-26-2013, 09:03 PM   #1
dth4h
Member
 
Registered: Mar 2009
Posts: 51

Rep: Reputation: 10
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.
 
Old 04-26-2013, 09:18 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Make /this/path/to a symlink to /that/path or another hardlink to the same file as /that/path?
 
Old 04-26-2013, 09:25 PM   #3
dth4h
Member
 
Registered: Mar 2009
Posts: 51

Original Poster
Rep: Reputation: 10
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.
 
Old 04-27-2013, 02:14 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
bash -r
perhaps?
 
Old 04-29-2013, 03:08 PM   #5
dth4h
Member
 
Registered: Mar 2009
Posts: 51

Original Poster
Rep: Reputation: 10
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.
 
Old 04-29-2013, 03:40 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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
 
Old 05-03-2013, 04:35 PM   #7
dth4h
Member
 
Registered: Mar 2009
Posts: 51

Original Poster
Rep: Reputation: 10
Ok, well thanks for the info.
 
  


Reply

Tags
filesystem, process, transparent


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script: stdin redirection + multiple curl process issues fernandomm Programming 1 07-04-2010 08:10 AM
Question in process redirection syfung Programming 1 09-20-2008 06:56 PM
Newbie on forking child process and I/O redirection neo_in_matrix Programming 4 09-16-2005 03:05 AM
redirection the process stdout do1do Linux - Security 3 11-23-2003 11:39 PM
redirection process stdout do1do Linux - General 2 11-23-2003 09:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration