RE: VFS functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>You should cat /etc/foo >/proc/foo
>
>And then on the kernel side, you need the "write" method of the
>/proc/foo take the lines and convert them to whatever internal
>structures you need.
>
>The thing about proc file is to avoid reading files from kernel.

I guess at this point I should discuss what I intend to do and try to weed
out any design flaws.

Basically, I intend to create a module that, when loaded, allows for
file/directory replication. So if /home is meant to be replicated to /opt
then /etc can contain a config file that has a line like:
/home	   /opt

I chose to place my hooks on the VFS layer so that the implementation is FS
independant.

The flow would be - If a sys_open is issued with any sort of write mode then
the sys_open function should check if the file is meant to be replicated. If
yes, then it should also open the replica. The file descriptor of the source
and destination files should be stored in a global data structure.

Now when, the file is written to by sys_write (or sys_writev etc), the
function needs to check if the file descriptor passed to it is listed in the
data structure created by sys_open above. If yes, it writes the data written
to source to replica also.

sys_close would check if the descriptor passed to it is listed in the
replication data structure and close the replica fd as well.

A global flag should be set by the module to indicate whether sys_open,
sys_write and sys_close should deviate and check for replica file/fd.

Unloading the module should unset the global flag for replication and clear
out of the file descriptor data structure.

All functions doing the various jobs of file path comparison, data structure
updation etc would go in the module so that minimal changes are done to the
original functions. I guess there will be still be some concurrency issues
to deal with?

Does this sound like a proper and feasible design?

Thanks,

Siddhartha


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux