1

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 file say in a stream.

Cygwin does similar intercept for symlink follow, when we require symlinks in windows right, by reading a .lnk and another associate file for the rest of the dat which is supposed to be in a symlink and then do the follow.

My real scenario: I wanted to see if I can get a symlink to follow a file to a HDFS file which I can say pull using its API.

Iceman
  • 121
  • 4
  • a symbolic link that return data looks to me as a driver. for instance `/dev/sr0` which "point" to DVD drive, and return error if no DVD. Now, testing if a file exists using an API shouldn't be that difficult. – Archemar Dec 27 '15 at 09:50
  • @Archemar thanx for the point. But, do you think fuse as meuh mentioned is the right approach - without, going to the kernel level, resolving at user-space. – Iceman Dec 27 '15 at 14:57
  • See also [Create a virtual file that is actually a command](http://unix.stackexchange.com/questions/66990/create-a-virtual-file-that-is-actually-a-command) – Gilles 'SO- stop being evil' Dec 27 '15 at 19:41

1 Answers1

4

There are at least 2 mechanisms readily available in Linux (but probably not in cygwin). There is the fuse filesystem, see man fuse, which allows you to implement a filesystem in user-space. For example, curlftpfs (see its man page) converts file accesses into curl ftp calls.

Then there is the fanotify system call, which allows you to intercept calls made to open or read a file, and substitute or manipulate the data. See man fanotify.

meuh
  • 49,672
  • 2
  • 52
  • 114