How to trap a copy/move-file operation in a custom filesystem based on Fuse?
I`m implementing a custo开发者_JAVA技巧m filesystem on Ubuntu using Fuse, but I need to trap when a copy or move operation occur. Right now all I see are when some file are opened for writing or reading, but I need to see these operations in context so I can see what file are being copied or moved.
Any hints?
What you want to do is probably not easily done, considering that a "copy" or "move" program could do just what you see - open a file and write to it. That's a perfectly good way of copying a file.
Even if you can see what actual binary is doing it, that wouldn't give you enough information to know if this was a copy, a move or simply a program writing data to a file.
If you tell us why you need to do this, then maybe someone can suggest another solution, that fulfills your needs.
Copy is as Weholt said: difficult to trap because it is basically the same as creating a new file and writing to it.
Move is the same operation as a rename.
I found that using pyfilesystem to create a filesystem and mounting it using the fs.expose.fuse in pyfilesystem worked very well. Look into that. I will. Thank you.
精彩评论