LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   UNIX file system changes (https://www.linuxquestions.org/questions/linux-general-1/unix-file-system-changes-4912/)

Micha Agovic 07-31-2001 01:17 PM

UNIX file system changes
 
Is it possible to make a program that would react on any UNIX file system modification, i.e. whenever some file is created, deleted or changed? Could it be possible to intercept a signal whenevr one of these three actions has happened?

I am talking about a real-tim C program here.

trickykid 07-31-2001 02:49 PM

I am sure it is possible, I am not a programmer, or at least C that is, just some webdesign, but I see how something like that could be possible.

But wouldn't it require the program to constantly scan the filesystem for changes??? Maybe someone else wounld know.. Probably get a quicker response in the Programming Forum.

dilberim82 07-31-2001 03:14 PM

As far as i know, a program like that does not have to check the system constantly. I dont really know how to do it, or the steps on how to do it with C, but i wrote a similar program for windoze with Java (actually we did it with my bro).

Micha Agovic 07-31-2001 03:47 PM

UNIX file system changes
 
This is my comment to the answer of "trickykid".

It is true that we could scan permanently on UNIX the file system in order to see the differences between the "old" and the "new" state. Then we can conclude what are the files created, modified and deleted. The problem is that this is a very slow method. Searching/scanning the file system costs too much (of time units).

The best solution would be to intercept the eventual signals sent by UNIX kernel whenever a file is created, deleted or modified. This would be a very fast way to get the information. The problem for me is that I do not know if such a signals exist, and if it is the case, if we can catch such a signals by our user program?!

Anyway, thank you very much for your help.

simon 07-31-2001 05:27 PM

I think you should look at interupt handling. If you watch the interupt for the hard drive(s) then you can tell when it is accessed and don't need to monitor the file system. I don't know how you could distinguish reads from writes using this method.

dilberim82 07-31-2001 05:34 PM

do users connect to the computer remotely using ftp, ssh or telnet? If thats the case (maybe) you could get the commands from the ftp, ssh, or telnet server and do whatever you want with them. I dont know if you can do that though.
And looking at the old state and the new state of the computer would decrease your computers usage. Its not a big deal with linux (i mean not as much as windows) but it is still a concern.

isajera 07-31-2001 06:07 PM

you need to check out the www.enlightenment.org website - the efsd component of the desktop shell uses a program called fam and a kernel patch called imon to keep on top of file system changes. this is probably what you're looking for.
www.whoop.org - this is the website of the guy who's writing efsd.

oss.sgi.com/projects/fam - the sgi site for fam and imon. they're both still in early development.


All times are GMT -5. The time now is 11:27 PM.