How to intercept an access call to a given directory..?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

How to intercept an access call to a given directory..?

#1 Post by sunburnt »

i want to be able to point access to a directory to other directories.
Like a link does, but I need it to access multiple target directories.

I`ve thought of a few ways of doing this, a kernel module`s the best.
I`ve done some C programming, but that level is beyond my abilities.

System calls can be used to intercept access to files and directories.
Again this is done with C only I believe, I`ve only seen C examples.

Is there a way of making Linux system calls using only Bash script?

I need to stop the directory access and run a script or C program.
It reads a file listing directories to search for the file being accessed.
If the file is found, it is accessed in place of the original file access.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#2 Post by amigo »

You'd need to use inotify, fam or gamin to catch the access attempts and then re-direct the paths from there.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#3 Post by sunburnt »

Thanks amigo; Looking at them, they look to be access notices or loggers.
It doesn`t look like they trap the access and allow you to do something else.
Code sample for inotify:

Code: Select all

         /* File was accessed */
         case IN_ACCESS:
         printf("ACCESS EVENT OCCURRED: File \"%s\" on WD #%i\n",
Notice the comments "was" reference and the printf output is "past event" also.

I need to stop the access and run a script that does a "path" search for the file.

This is one method for making a "Multi-Link", a link that has multiple target directories.

A hard link points to files only.
A sym. link points to both files and directories.
A multi. link points to directories only.

It acts like PATH does, except it`s for directories that are not part of the PATH.
The union file system does the same thing also. except it`s complex over kill.
In reading about Linux kernel system calls, it looks like the way to do it.
But I don`t see how to do it except in C...
I really need a new type of link to be written into the kernel. " ln -m " = ( Multi-Link ).

Post Reply