views:

103

answers:

2

I have the question http://stackoverflow.com/questions/990759/how-do-you-track-files-in-smb-with-an-application open and I was woundering whether maybe there are unique id's for files so that I can track when a file/folder is moved. Is there something like this? It can be very debian specific

+1  A: 

If the files are not going to be moved, you can use a hash.

If you can have a daemon running in the background, you write a program using inotify to moniter move events.

If you can't do that, you could use the inode number (but that could change on a file move).

Zifre
+2  A: 

The answer is as always 'it depends'. What do you mean with 'unique id'? Would this id change if the contents of the file is changed, or would you consider that as the same file? In Unix, the inode together with the device defines the 'unique id', but this is retained even if the content changes.

If you want to now what touches a file, you can use inotify on the same machine to find out what happens to files (or its precursor: dnotify).

If you need to have it accross machines, then I assume samba would use inotify to get notified and convert that to SMB/CIFS events, but I'm not familiar with that.

If you want a content-based id and therefore use hashes, you need to go to userspace. For example, this is just exactly what Git (the version control system) does: it tracks the hashes of the contents to have a 'unique id'.

Rutger Nijlunsing