Open and copy a file from the kernel

Pranay Srivastava pranjas at gmail.com
Tue May 27 06:26:36 EDT 2014


On Tue, May 27, 2014 at 3:05 PM, Nada Saif <nada.saif7 at gmail.com> wrote:
> Hi Srivastava,
> Thanks for your answer.
>
> I want to make a backup of any opened file.. whenever the file is opened or
> updated , it's reflected on its backup..

Hmm, not really done this but i guess you need inotify hooks and some
sort of user space daemon that hooks those inotify events. I've not
done this but
i know it shouldn't be too hard. Just search for inotify.

What you are trying isn't kernel thing to do, however i guess you are
trying to do something sort of snapshot per change of a file. But
again
since you are not doing this at file system level I won't recommend
doing this inside kernel (opening and copying). Just hook the inotify
events
in the userspace daemon and let it worry about maintaining a separate
version for all files changed.

But if you do this won't you run out of space so soon, plus the files
you'll create will eat up the inodes which really are earlier versions
you are maintaining.
Probably you should come up with a consolidated layout of versions you
are going to save. Maybe what you can do is have diffs of file in a
particular custom format
which can then all be zipped into a version database you can maintain.

Now just think of doing all this inside kernel. See it's a bad idea
and you know it!. You can use scripts to simplify everything. The
search operations within your
database to lookup a particular version, like going from version 3 to
version 8 would require applying diffs which you can easily do in
script.

If you are not doing the above things I said, then my bad. You need to
tell some more about project then maybe I can help.

>
> Regards
>
> On May 27, 2014 11:29 AM, "Pranay Srivastava" <pranjas at gmail.com> wrote:
>>
>> On Tue, May 27, 2014 at 12:49 PM, Nada Saif <nada.saif7 at gmail.com> wrote:
>> > Hi,
>> >
>> > I want to process a copy operation from file sent from user space - this
>> > copying should be inside the kernel..
>> >
>> > I read about using filp_open , will this help me ?
>>
>> I guess you want to open the files inside kernel and then copy from
>> one to another.
>>
>> That's just not good. If you are trying to learn something like
>> passing data from user space to
>> kernel, you should probably look at sysfs.
>>
>> Very simple wrappers exist that allow you to create a dummy sysfs
>> file(s) where you can have your store and show callbacks do the magic
>> you want to learn.
>>
>>
>> >
>> > Thanks,
>> > Nada
>> >
>> > _______________________________________________
>> > Kernelnewbies mailing list
>> > Kernelnewbies at kernelnewbies.org
>> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>> >
>>
>>
>>
>> --
>>         ---P.K.S



-- 
        ---P.K.S



More information about the Kernelnewbies mailing list