I have an application that occasionally stores information to a file. For a particular reason, I find it necessary to have the information stored in a database system like MySQL. So is it possible for me to safely hijack the read
and write
system calls (in Ubuntu) produced by the application and cause it to store the information to a MySQL database instead of letting the application write to the file system?
Let A
be the application.
A -> calls:read -> reads-from-file-system
A -> calls:write -> writes-to-file-system
This is how the application originally functions. Is it possible to write a program (without messing with the Kernel-mode if possible) and implement two functions mysql_wrapped_read
and mysql_wrapped_write
, which respectively substitutes the original read
and write
function in the application?
So now, the scenario becomes:
A -> calls:mysql_wrapped_read -> reads-from-mysql-database
A -> calls:mysql_wrapped_write -> writes-to-mysql-database
Can you please tell me if this is possible? If yes, how?