I'm creating a kernel module that intercept the unlink command and make a copy of the file that want to be unlinked. For now, I intercept the unlink command and im trying to print the path of the file but it doesn't work right.
I have a method that receive a char *path parameter and I use printk to show the path, but this print some rare strings like "\xe07l\xd3\xf"
asmlinkage int hacked_sys_unlink(const char *pathname)
{
printk("RM_CATCHED: unlink( \"%s\" )\n", pathname);
return original_sys_unlink(pathname);
}
When I unlink some file and use dmesg command i get this:
[ 1531.847856] RM_CATCHED: unlink( "`g\xcfYMV" )
[ 1531.848071] RM_CATCHED: unlink( "\xe07l\xd3\xf" )
[ 1534.851623] RM_CATCHED: unlink( "\xe07l\xd3\xf" )
[ 1534.852091] RM_CATCHED: unlink( "" )
[ 1541.861962] RM_CATCHED: unlink( "" )
How can I get the real path of the file like /path/to/file.txt?