LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 01-03-2010, 09:38 AM   #1
skysmurf
LQ Newbie
 
Registered: Nov 2007
Location: Holland
Distribution: Slackware 12.1
Posts: 15

Rep: Reputation: 0
Question How to do realpath() in kernel mode?


Hi all,

I'm writing a kernel module that hooks the open() syscall (yes I know Linus hates this, but it's for an assignment so I don't have much of a choice) and makes a note whenever an attempt is made to open() something in /tmp. However, simply checking whether the filename argument to open() starts with "/tmp/" is not enough, because of relative paths, "..", symlinks etc. So I need a more reliable way to verify that the filename argument to open() resolves to something in /tmp. In user space there's the realpath() function in stdlib, but how does one do that in kernel mode?

Thanks in advance,

Alphons
 
Old 01-03-2010, 12:45 PM   #2
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
Look into the getdents calls. They return the list of inodes and paths in a structure for your viewing pleasure. Also, this is the call that gets the directory structure when a directory is listed. It may fit your purposes or at least point you in the right direction.

Regards,

Alunduil
 
1 members found this post helpful.
Old 01-03-2010, 02:41 PM   #3
skysmurf
LQ Newbie
 
Registered: Nov 2007
Location: Holland
Distribution: Slackware 12.1
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by alunduil View Post
Look into the getdents calls.
Will do, thanks.
 
  


Reply

Tags
kernel, syscall



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
How to identify processes running in user mode and kernel mode subha109 Linux - Kernel 1 10-21-2009 11:37 AM
eth0 not working in SMP kernel mode (but works in UP mode!) jorgeluis Linux - Networking 2 11-27-2007 08:46 AM
eth0 not working in SMP kernel mode (but works in UP mode!) jorgeluis Red Hat 1 11-26-2007 12:33 PM
Kernel Panic -- Selinux Strict mode rather than targeted mode Peter_APIIT Fedora 2 07-06-2007 02:23 AM

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

All times are GMT -5. The time now is 12:32 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