Hello I am a newbie to kernel programming. I am writing a small kernel module that is based on wrapfs template to implement a backup mechanism. This is purely for learning basis.
I am extending wrapfs so that when a write call is made wrapfs transparently makes a copy of that file in a separate directory and then write is performed on the file. But I don't want that I create a copy for every write call.
A naive approach could be I check for existence of file in that directory. But I think for each call checking this could be a severe penalty.
I could also check for first write call and then store a value for that specific file using private_data attribute. But that would not be stored on disk. So I would need to check that again.
I was also thinking of making use of modification time. I could save a modification time. If the older modification time is before that time then only a copy is created otherwise I won't do anything. I tried to use inode.i_mtime for this but it was the modified time even before write was called, also applications can modify that time.
So I was thinking of storing some value in inode on disk that indicates its backup has been created or not. Is that possible? Any other suggestions or approaches are welcome.