LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 04-16-2014, 02:31 PM   #1
prabhurajreddy
LQ Newbie
 
Registered: Mar 2014
Posts: 4

Rep: Reputation: Disabled
Post 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);
 
Old 04-17-2014, 12:04 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Why are you not checking for errors?

Also please use code tags and proper indenting.
 
Old 04-17-2014, 01:45 PM   #3
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
see if this helps

http://tuxthink.blogspot.in/2011/12/...t-working.html
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find a file path and directory path ak.lokesh Linux - Newbie 3 02-19-2009 12:37 PM
File structures registration in linux modules to the kernel - explanation needed Neuzen Linux - Kernel 0 09-23-2008 07:54 AM
Find file/dir path nc3b Programming 5 08-28-2006 04:49 AM
cannot find map file. No module symbols loaded - kernel modules not enabled. jjorloff1 Linux - Software 3 01-06-2005 11:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration