[haiku-development] file modification watching

Hi,

a few weeks ago when working on the music collection I noticed that the current index server implementation is not really working and also not optimal. The problem is that I need a notification in case a file has been modified. Currently a modification query with intermediate updates is used to do the job. The resolution of the modification time is just one second. Though I get a mod notification but I have to wait one second to not miss possible later changes (I don't wait at the moment).

For example, copying a music file to the disc usually takes less then a second, when handling the first mod message the music file is almost empty and the id3 tag analyser fails. the complete file is never analysed. This problem does not appear when the file is already in the fs cache and thats why I haven't noticed it before when testing it.

A simple solution would be to wait a second before start analysing but then we still rely that the underlying fs supports queries. Monitoring other volumes would not be possible. The other solution is to watch stat changes. With a modification to the original be api, which is already in the trunk, it is possible to watch changes of all nodes. This is fine because at least bfs sends a stat changed notification when closing (freeing the cookie) and time or size has changed. The problem is that a node_ref is send out but in general I need a entry_ref to analyse a file. There is no easy way to find a entry_ref (the path) to a node_ref.

Now my question to the experts. I thought about to add a table of open nodes in the vfs. When opening a file in the vfs using file_open a node -> path pair could be stored in a hash table. When file_close is called the entry has to be removed again. When sending a stat or attr changed notifications this information could be used to add an entry_ref to the outgoing message. This could be done optional when the user adds an additional flag in watch_node.

Is file_close also called when a team exit and the user forgot to close files?

A further optimization would be to optional only send out notifications when a file is closing.

Another not directly related question, why the fs and not the vfs is responsible to send out notifications? At least for most notifications it seams possible to me that the vfs has all needed information and can send the message.

thank you,
        Clemens

Other related posts: