How to find the complete file path using struct file in linux kernel modules
The below code written in inode_permission function of hooks.c file of selinux . But I am not getting the file path , which i need to compare with /home/seed/test . Am i doing anything wrong here ?
pname = (char *)NULL;
len = PATHLEN;
buf = kmalloc(len, GFP_KERNEL);
if (buf) // && nd->dentry && nd->mnt
{
buf = memset(buf, '\0', len);
pname = dentry_path_raw(file->f_path.dentry, buf, len-1);
if(pname)
{
// just for debugging
if ((strstr(buf,"/home/seed/test")) != NULL)
{
printk(KERN_INFO "secureAdmin: %s\n",buf);
}
kfree(buf);
|