Linked Questions

7
votes
3answers
726 views

How can I make a special file that executes code when read from [duplicate]

Most files on a Linux system are normal files, i.e. they are saved on disk and reading from them just reads from a specified chunk of memory on the disk. How can I make something that behaves like a ...
7
votes
3answers
2k views

Dynamic file content generation: Satisfying a 'file open' by a 'process execution' [duplicate]

I have a read-only file, F. A program, P, that I'm not the author of, needs to read F. I want the content of F to come from another 'generator' program, G, whenever P tries to read F (taking F to ...
6
votes
1answer
587 views

Have a 'file' generate its content on demand? [duplicate]

Is there a way that I can have something which appears as a file, but when being read some code executes which fills the content of the file "on the fly"? Like FIFO/ named pipe, but without the need ...
1
vote
1answer
118 views

Creating a virtual file whose contents are determined programmatically [duplicate]

Is it possible to create a virtual file in unix, whose contents are determined programmatically when the file is accessed, a bit like the files in /proc? For example, I have a program that retrieves ...
1
vote
1answer
112 views

Persistent process substitutions? [duplicate]

Is there a way to take a process substitution like <(grep foo some/file), and save it to a "file-like entity" on disk (reminiscent of a fifo), so that, every time this thing was opened for reading ...
3
votes
2answers
82 views

File contents created when opened [duplicate]

What I want is this: Having a file called file somewhere in the filesystem with a content something like: #!/bin/whatever-interpreter-you-want echo 'line1' echo 'line2' When ANY (almost any since ...
0
votes
2answers
50 views

Run a command which returns a string when reading a file [duplicate]

I have this idea and maybe it is not feasible, but I think it worth asking. Let's say a user is running this command: cat ~/file.txt Whenever something tries to read from this file, I would like to ...
7
votes
1answer
543 views

Is there a Linux system call to create a “view” of a range of a file?

Does Linux provide a system call which can create a "view" of a limited byte range of a backing file? I'm envisioning something that for example would act on an open file descriptor and either modify ...
2
votes
3answers
775 views

is there a system-wide “extension” to /etc/services that does not get replaced on package updates?

I know how to use /etc/services but if I change it and the inetd package is later updated via apt-get to a new default one, my changes are gone (happened to me on a apt-get dist-upgrade from Debian ...
2
votes
1answer
1k views

Create a named pipe / fifo that executes a command when read

I'm looking to supply a process that only reads from a local file with content from an http URL. The process is a daemon that is hard-coded to read a specific file in it's current working directory ...
2
votes
1answer
1k views

Launch a program to display text on startup before login

So I've written a simple UI in C. Its read only and displays system information like disk space, network info, etc. I am running ubuntu server 14.04 and currently when the appliance starts up I am ...
2
votes
2answers
515 views

Recover from faking /proc/meminfo

So, without really thinking too much, I ran this script: #!/bin/bash SWAP="${1:-512}" NEW="$[SWAP*1024]"; TEMP="${NEW//?/ }"; OLD="${TEMP:1}0" sed "/^Swap\(Total\|Free\):/s,$OLD,$NEW," /proc/meminfo &...
3
votes
2answers
127 views

“Junctioned” symbolic links [duplicate]

Does Linux have the capability to use "junctioned" symbolic links? I'm not sure if this is an actual term or not, so let me explain the concept. I have a git repository containing all my ...
1
vote
1answer
99 views

Connect Symbolic Link to program or script that returns a file

I wanted to know if I can make a symlink to a file say in a Database. This is a wild guess, but is it possible to intercept the link-follow say using a C function and then let function return the ...